]> git.saurik.com Git - wxWidgets.git/commitdiff
A bugfix in the wxTreeCtrl.GetItem wrapper
authorRobin Dunn <robin@alldunn.com>
Thu, 23 Dec 1999 22:43:59 +0000 (22:43 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 23 Dec 1999 22:43:59 +0000 (22:43 +0000)
Some test/demo modifications and additions

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5095 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

utils/wxPython/demo/wxTreeCtrl.py
utils/wxPython/src/controls2.i
utils/wxPython/src/msw/controls2.cpp
utils/wxPython/tests/blit.py [new file with mode: 0644]
utils/wxPython/tests/listGetItem.py [new file with mode: 0644]
utils/wxPython/tests/testDlg.py [new file with mode: 0644]

index 48b74fff4accf98baf863e31a5af231102da19ee..b3407c0fbe34539c823b350b8fe49f4371cb8189 100644 (file)
@@ -15,14 +15,15 @@ class TestTreeCtrlPanel(wxPanel):
         self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
                                wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE)
 
-        self.il = wxImageList(16, 16)
-        idx1 = self.il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
-        idx2 = self.il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP))
-        idx3 = self.il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP))
-        idx4 = self.il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP))
-        idx5 = self.il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP))
-
-        self.tree.SetImageList(self.il)
+        il = wxImageList(16, 16)
+        idx1 = il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
+        idx2 = il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP))
+        idx3 = il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP))
+        idx4 = il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP))
+        idx5 = il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP))
+
+        self.tree.SetImageList(il)
+        self.il = il
 
         self.root = self.tree.AddRoot("The Root Item")
         self.tree.SetItemImage(self.root, idx1)
index 8bae5da0dd7e1bf75fe6e6373fd3cc72bbcee10f..cacc96e9284b27b8d2e683b1b84f16a2bb6e1ac6 100644 (file)
@@ -165,6 +165,7 @@ public:
             wxListItem* info = new wxListItem;
             info->m_itemId = itemId;
             info->m_col = col;
+            info->m_mask = 0xFFFF;
             self->GetItem(*info);
             return info;
         }
index 9b7cb275af4a42bcc0e93edce4edef57709aaee5..0158195b6f50a83af0ce79c695ce90c172246113 100644 (file)
@@ -1855,6 +1855,7 @@ static wxListItem * wxListCtrl_GetItem(wxListCtrl *self,long  itemId,int  col) {
             wxListItem* info = new wxListItem;
             info->m_itemId = itemId;
             info->m_col = col;
+            info->m_mask = 0xFFFF;
             self->GetItem(*info);
             return info;
         }
diff --git a/utils/wxPython/tests/blit.py b/utils/wxPython/tests/blit.py
new file mode 100644 (file)
index 0000000..6d7b9f5
--- /dev/null
@@ -0,0 +1,54 @@
+#-------------------------------------------------
+
+from wxPython.wx import *
+
+
+class MyFrame(wxFrame):
+    def __init__(self,parent,title,id):
+        wxFrame.__init__(self,parent,title,id,
+                         wxPoint(100,100),wxSize(300,300))
+
+
+        self.SetBackgroundColour(wxWHITE)
+        self.windowx,self.windowy=self.GetClientSizeTuple()
+
+        # make a memory DC to draw into...
+        self.mask=wxMemoryDC()
+
+        self.maskbitmap=wxEmptyBitmap(self.windowx,self.windowy)
+        self.mask.SelectObject(self.maskbitmap)
+        self.mask.SetBackgroundMode(wxTRANSPARENT)
+
+        self.mask.SetDeviceOrigin(0,0)
+
+        self.mask.SetBrush(wxBrush(wxColour(150,160,0),wxSOLID))
+        self.mask.SetPen(wxPen(wxColour(1,2,3),1,wxSOLID))
+        self.mask.DrawRectangle(0,0,self.windowx,self.windowy)
+
+        img = wxImageFromBitmap(self.maskbitmap)
+        print (img.GetRed(0,0), img.GetGreen(0,0), img.GetBlue(0,0))
+
+
+    def OnPaint(self,evt):
+        """ overriding OnPaint to give handler. """
+        dc = wxPaintDC(self)
+
+        dc.Blit(0,0,self.windowx,self.windowy,self.mask,0,0,wxCOPY)
+
+#-----------------------------------------------------------
+
+if __name__ == "__main__":
+    class MyApp(wxApp):
+        def OnInit(self):
+
+            self.frame = MyFrame(NULL, -1, "Blit Test")
+            self.frame.Show(true)
+
+            self.exiting = FALSE;
+            return true
+
+    app = MyApp(0)     # Create an instance of the application
+    app.MainLoop()     # Tell it to start processing events
+
+
+
diff --git a/utils/wxPython/tests/listGetItem.py b/utils/wxPython/tests/listGetItem.py
new file mode 100644 (file)
index 0000000..1db340f
--- /dev/null
@@ -0,0 +1,61 @@
+from wxPython.wx import *
+
+LIST_ID = 101
+
+class MyFrame(wxFrame):
+    def __init__(self, parent, id, title):
+        wxFrame.__init__(self, parent, id, title,
+                         wxDefaultPosition, wxSize(400, 400))
+        self.panel = wxPanel(self, -1)
+        self.list = wxListCtrl(self.panel, LIST_ID,
+                               wxPoint(10, 10), wxSize(370, 330),
+                               wxLC_REPORT|wxSUNKEN_BORDER)
+        self.list.InsertColumn(0, "Id")
+        self.list.InsertColumn(1, "Type")
+        self.list.InsertColumn(2, "Description")
+
+        self.insertRow(self.list, 0, 'CD', 'Dark Side of the Moon')
+        self.insertRow(self.list, 1, 'DVD', 'The Matrix')
+        self.insertRow(self.list, 2, 'Book', 'Crime and Punishment')
+
+        self.list.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)
+        self.list.SetColumnWidth(1, wxLIST_AUTOSIZE)
+        self.list.SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER)
+
+        EVT_LIST_ITEM_SELECTED(self.panel, LIST_ID, self.OnListSelect)
+
+        self.panel.Layout()
+        return
+
+    def OnListSelect(self, event):
+        item = self.list.GetItem(event.m_itemIndex, 1)
+        print item.m_itemId, item.m_col, item.m_state
+        type = self.list.GetItem(event.m_itemIndex, col=1).m_text
+        desc = self.list.GetItem(event.m_itemIndex, col=2).m_text
+        print ('Row Selected: Id: %d, Type: %s, Desc: %s' %
+               (event.m_itemIndex, `type`, `desc`))
+        return
+
+    def insertRow(self, list, row, type, desc):
+        list.InsertStringItem(row, 'label' + `row`)
+        list.SetStringItem(row, 0, `row`)
+        list.SetStringItem(row, 1, type)
+        list.SetStringItem(row, 2, desc)
+        return
+
+    def OnCloseWindow(self, event):
+        self.Destroy()
+        return
+
+
+
+class MyApp(wxApp):
+    def OnInit(self):
+        frame = MyFrame(None, -1, 'ListCtrl Test')
+        frame.Show(1)
+        self.SetTopWindow(frame)
+        return 1
+
+
+app = MyApp(0)
+app.MainLoop()
diff --git a/utils/wxPython/tests/testDlg.py b/utils/wxPython/tests/testDlg.py
new file mode 100644 (file)
index 0000000..6dee265
--- /dev/null
@@ -0,0 +1,49 @@
+## import all of the wxPython GUI package
+from wxPython.wx import *
+
+
+## Create a new frame class, derived from the wxPython Frame.
+class Dialog(wxDialog):
+
+       def __init__(self, parent, title):
+               # First, call the base class' __init__ method to create the frame
+               wxDialog.__init__( self, parent, -1, title, wxDefaultPosition, wxDefaultSize )
+
+                wxButton(self, wxID_OK, "OK", (10, 10))
+                wxButton(self, wxID_CANCEL, "Cancel", (50,50))
+               self.Centre( wxBOTH )
+
+
+       # This method is called automatically when the CLOSE event is
+       # sent to this window
+       #def OnCloseWindow(self, event):
+       #       self.Destroy()
+
+       #def OnCloseMe(self, event):
+               #self.Close(true)
+
+
+def main():
+       # Every wxWindows application must have a class derived from wxApp
+       class App(wxApp):
+
+               # wxWindows calls this method to initialize the application
+               def OnInit(self):
+
+                       # Create an instance of our customized Frame class
+                       dialog = Dialog( NULL, 'test' )
+                       dialog.ShowModal()
+                        print "got here"
+                        dialog.Destroy()
+
+                       # Tell wxWindows that this is our main window
+                       # Return a success flag
+                       return true
+
+       app = App(0)     # Create an instance of the application class
+       app.MainLoop()   # Tell it to start processing events
+
+
+
+if __name__ == '__main__':
+        main()