+
+#---------------------------------------------------------------------------
+
+class TestToolBar(wxFrame):
+ def __init__(self, parent, log):
+ wxFrame.__init__(self, parent, -1, 'Test ToolBar',
+ wxDefaultPosition, wxSize(500, 300))
+ self.log = log
+
+ wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
+
+ tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
+ #tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
+ # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
+ #self.SetToolBar(tb)
+
+ self.CreateStatusBar()
+
+ tb.AddTool(10, wxNoRefBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
+ wxNullBitmap, false, -1, -1, "New", "Long help for 'New'")
+ EVT_TOOL(self, 10, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
+
+ tb.AddTool(20, wxNoRefBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
+ wxNullBitmap, false, -1, -1, "Open")
+ EVT_TOOL(self, 20, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
+
+ tb.AddSeparator()
+ tb.AddTool(30, wxNoRefBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
+ wxNullBitmap, false, -1, -1, "Copy")
+ EVT_TOOL(self, 30, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
+
+ tb.AddTool(40, wxNoRefBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
+ wxNullBitmap, false, -1, -1, "Paste")
+ EVT_TOOL(self, 40, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
+
+ tb.AddSeparator()
+
+ tb.AddTool(50, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
+ wxNullBitmap, true, -1, -1, "Toggle this")
+ EVT_TOOL(self, 50, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
+
+ tb.AddTool(60, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
+ wxNoRefBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
+ true, -1, -1, "Toggle with 2 bitmaps")
+ EVT_TOOL(self, 60, self.OnToolClick)
+ EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
+
+ tb.Realize()
+
+
+ def OnCloseWindow(self, event):
+ self.Destroy()
+
+ def OnToolClick(self, event):
+ self.log.WriteText("tool %s clicked\n" % event.GetId())
+
+ def OnToolRClick(self, event):
+ self.log.WriteText("tool %s right-clicked\n" % event.GetId())
+
+
+#---------------------------------------------------------------------------
+
+class TestTreeCtrlPanel(wxPanel):
+ def __init__(self, parent, log):
+ wxPanel.__init__(self, parent, -1)
+
+ self.log = log
+ tID = 1101
+
+ self.tree = wxTreeCtrl(self, tID)
+ root = self.tree.AddRoot("The Root Item")
+ for x in range(10):
+ child = self.tree.AppendItem(root, "Item %d" % x)
+ for y in range(5):
+ last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
+
+ self.tree.Expand(root)
+ EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
+ EVT_TREE_ITEM_COLLAPSED (self, tID, self.OnItemCollapsed)
+ EVT_TREE_SEL_CHANGED (self, tID, self.OnSelChanged)
+
+
+ def OnSize(self, event):
+ w,h = self.GetClientSizeTuple()
+ self.tree.SetDimensions(0, 0, w, h)
+
+
+ def OnItemExpanded(self, event):
+ item = event.GetItem()
+ self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
+
+ def OnItemCollapsed(self, event):
+ item = event.GetItem()
+ self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
+
+ def OnSelChanged(self, event):
+ item = event.GetItem()
+ self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(item))
+
+
+
+
+class TestTreeCtrl(wxFrame):
+ def __init__(self, parent, log):
+ wxFrame.__init__(self, parent, -1, 'Test TreeCtrl',
+ wxDefaultPosition, wxSize(250, 300))
+
+ p = TestTreeCtrlPanel(self, log)
+
+
+#---------------------------------------------------------------------------
+
+class TestListCtrlPanel(wxPanel):
+ def __init__(self, parent, log):
+ wxPanel.__init__(self, parent, -1)
+
+ self.log = log
+ tID = 1101
+
+ self.il = wxImageList(16, 16)
+ idx1 = self.il.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
+
+ self.list = wxListCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
+ wxLC_REPORT|wxSUNKEN_BORDER)
+ self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
+
+ #self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
+ #wxToolTip_Enable(true)
+
+ self.list.InsertColumn(0, "Column 0")
+ self.list.InsertColumn(1, "Column 1")
+ self.list.InsertColumn(2, "One More Column (2)")
+ for x in range(50):
+ self.list.InsertImageStringItem(x, "This is item %d" % x, idx1)
+ self.list.SetStringItem(x, 1, "Col 1, item %d" % x)
+ self.list.SetStringItem(x, 2, "item %d in column 2" % x)
+
+ self.list.SetColumnWidth(0, wxLIST_AUTOSIZE)
+ self.list.SetColumnWidth(1, wxLIST_AUTOSIZE)
+ self.list.SetColumnWidth(2, wxLIST_AUTOSIZE)
+
+
+ def OnSize(self, event):
+ w,h = self.GetClientSizeTuple()
+ self.list.SetDimensions(0, 0, w, h)
+
+
+
+
+class TestListCtrl(wxFrame):
+ def __init__(self, parent, log):
+ wxFrame.__init__(self, parent, -1, 'Test ListCtrl',
+ wxDefaultPosition, wxSize(250, 300))
+
+ p = TestListCtrlPanel(self, log)
+
+
+#---------------------------------------------------------------------------
+
+class TestSashWindow(wxMDIParentFrame):
+ NEW_WINDOW = 5000
+ TOGGLE_WINDOW = 5001
+ QUIT = 5002
+ ID_WINDOW_TOP = 5100
+ ID_WINDOW_LEFT1 = 5101
+ ID_WINDOW_LEFT2 = 5102
+ ID_WINDOW_BOTTOM = 5103
+
+
+ def __init__(self, parent, log):
+ wxMDIParentFrame.__init__(self, parent, -1, 'Test Sash Window',
+ wxDefaultPosition, wxSize(250, 300))
+
+ self.log = log
+ menu = wxMenu()
+ menu.Append(self.NEW_WINDOW, "&New Window")
+ menu.Append(self.TOGGLE_WINDOW, "&Toggle window")
+ menu.Append(self.QUIT, "E&xit")
+
+ menubar = wxMenuBar()
+ menubar.Append(menu, "&File")
+
+ self.SetMenuBar(menubar)
+ self.CreateStatusBar()
+
+ EVT_MENU(self, self.NEW_WINDOW, self.OnNewWindow)
+ EVT_MENU(self, self.TOGGLE_WINDOW, self.OnToggleWindow)
+ EVT_MENU(self, self.QUIT, self.OnQuit)
+
+ EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP,
+ self.ID_WINDOW_BOTTOM, self.OnSashDrag)
+
+
+ # Create some layout windows
+ # A window like a toolbar
+ win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, wxDefaultPosition,
+ wxSize(200, 30), wxNO_BORDER|wxSW_3D)
+ win.SetDefaultSize(wxSize(1000, 30))
+ win.SetOrientation(wxLAYOUT_HORIZONTAL)
+ win.SetAlignment(wxLAYOUT_TOP)
+ win.SetBackgroundColour(wxColour(255, 0, 0))
+ win.SetSashVisible(wxSASH_BOTTOM, true)
+
+ self.topWindow = win
+
+
+ # A window like a statusbar
+ win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM,
+ wxDefaultPosition, wxSize(200, 30),
+ wxNO_BORDER|wxSW_3D)
+ win.SetDefaultSize(wxSize(1000, 30))
+ win.SetOrientation(wxLAYOUT_HORIZONTAL)
+ win.SetAlignment(wxLAYOUT_BOTTOM)
+ win.SetBackgroundColour(wxColour(0, 0, 255))
+ win.SetSashVisible(wxSASH_TOP, true)
+
+ self.bottomWindow = win
+
+
+ # A window to the left of the client window
+ win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1,
+ wxDefaultPosition, wxSize(200, 30),
+ wxNO_BORDER|wxSW_3D)
+ win.SetDefaultSize(wxSize(120, 1000))
+ win.SetOrientation(wxLAYOUT_VERTICAL)
+ win.SetAlignment(wxLAYOUT_LEFT)
+ win.SetBackgroundColour(wxColour(0, 255, 0))
+ win.SetSashVisible(wxSASH_RIGHT, TRUE)
+ win.SetExtraBorderSize(10)
+
+ textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE|wxSUNKEN_BORDER)
+ textWindow.SetValue("A help window")
+
+ self.leftWindow1 = win
+
+
+ # Another window to the left of the client window
+ win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2,
+ wxDefaultPosition, wxSize(200, 30),
+ wxNO_BORDER|wxSW_3D)
+ win.SetDefaultSize(wxSize(120, 1000))
+ win.SetOrientation(wxLAYOUT_VERTICAL)
+ win.SetAlignment(wxLAYOUT_LEFT)
+ win.SetBackgroundColour(wxColour(0, 255, 255))
+ win.SetSashVisible(wxSASH_RIGHT, TRUE)
+
+ self.leftWindow2 = win
+
+
+ def OnNewWindow(self, event):
+ pass
+
+ def OnToggleWindow(self, event):
+ pass
+
+ def OnQuit(self, event):
+ self.Close(true)
+
+ def OnSashDrag(self, event):
+ if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
+ return
+
+ eID = event.GetId()
+ if eID == self.ID_WINDOW_TOP:
+ self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
+
+ elif eID == self.ID_WINDOW_LEFT1:
+ self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
+
+
+ elif eID == self.ID_WINDOW_LEFT2:
+ self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
+
+ elif eID == self.ID_WINDOW_BOTTOM:
+ self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
+
+ wxLayoutAlgorithm().LayoutMDIFrame(self)
+
+ # Leaves bits of itself behind sometimes
+ self.GetClientWindow().Refresh()
+
+
+ def OnSize(self, event):
+ wxLayoutAlgorithm().LayoutMDIFrame(self)
+
+#---------------------------------------------------------------------------
+#---------------------------------------------------------------------------