]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/tests/test4.py
fixed bug that caused wxHtmlWindow to segfault on html tables with cell(s) with rowsp...
[wxWidgets.git] / utils / wxPython / tests / test4.py
index d41551953bee8ccd9b834a53ed189e8cb8967d3c..079c4a92159ce6f3cc1f60eed4128d640ac4c80b 100644 (file)
@@ -22,11 +22,11 @@ class TestSimpleControlsDlg(wxDialog):
     def __init__(self, parent, log):
         self.log = log
         wxDialog.__init__(self, parent, -1, "Test Simple Controls",
-                          wxPyDefaultPosition, wxSize(350, 350))
+                          wxDefaultPosition, wxSize(350, 400))
 
 
-        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
-                      'six', 'seven', 'eight']
+        sampleList = ["zero", "one", "two", "three", "four", "five",
+                      "six", "seven", "eight", "nine", "ten"]
 
         y_pos = 5
         delta = 25
@@ -40,26 +40,26 @@ class TestSimpleControlsDlg(wxDialog):
         EVT_CHECKBOX(self, 20, self.EvtCheckBox)
         y_pos = y_pos + delta
 
-        rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(80, y_pos), wxPyDefaultSize,
-                        sampleList, 3, wxRA_HORIZONTAL| wxNO_BORDER)
+        rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(80, y_pos), wxDefaultSize,
+                        sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER)
         EVT_RADIOBOX(self, 30, self.EvtRadioBox)
         width, height = rb.GetSizeTuple()
         y_pos = y_pos + height + 5
 
         wxStaticText(self, -1, "wxChoice", wxPoint(5, y_pos), wxSize(75, 20))
-        wxChoice(self, 40, wxPoint(80, y_pos), wxSize(95, 20), #wxPyDefaultSize,
+        wxChoice(self, 40, wxPoint(80, y_pos), wxSize(95, 20), #wxDefaultSize,
                  sampleList)
         EVT_CHOICE(self, 40, self.EvtChoice)
         y_pos = y_pos + delta
 
         wxStaticText(self, -1, "wxComboBox", wxPoint(5, y_pos), wxSize(75, 18))
-        wxComboBox(self, 50, "default value", wxPoint(80, y_pos), wxSize(95, 20),
+        wxComboBox(self, 50, "default value", wxPoint(80, y_pos), wxSize(95, -1),
                    sampleList, wxCB_DROPDOWN)
         EVT_COMBOBOX(self, 50, self.EvtComboBox)
         y_pos = y_pos + delta
 
         wxStaticText(self, -1, "wxListBox", wxPoint(5, y_pos), wxSize(75, 18))
-        lb = wxListBox(self, 60, wxPoint(80, y_pos), wxPyDefaultSize,
+        lb = wxListBox(self, 60, wxPoint(80, y_pos), wxSize(95, 80),
                        sampleList, wxLB_SINGLE)
         EVT_LISTBOX(self, 60, self.EvtListBox)
         EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
@@ -70,7 +70,7 @@ class TestSimpleControlsDlg(wxDialog):
 
 
         y_pos = y_pos + 15
-        wxButton(self, wxID_OK, ' OK ', wxPoint(80, y_pos), wxPyDefaultSize).SetDefault()
+        wxButton(self, wxID_OK, ' OK ', wxPoint(80, y_pos), wxDefaultSize).SetDefault()
         wxButton(self, wxID_CANCEL, ' Cancel ', wxPoint(140, y_pos))
 
 
@@ -114,12 +114,12 @@ class TestTimer(wxTimer):
 class TestLayoutConstraints(wxFrame):
     def __init__(self, parent):
         wxFrame.__init__(self, parent, -1, 'Test Layout Constraints',
-                         wxPyDefaultPosition, wxSize(500, 300))
+                         wxDefaultPosition, wxSize(500, 300))
 
         self.SetAutoLayout(true)
         EVT_BUTTON(self, 100, self.OnButton)
 
-        self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
+        self.panelA = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
                                wxSIMPLE_BORDER)
         self.panelA.SetBackgroundColour(wxBLUE)
         lc = wxLayoutConstraints()
@@ -129,7 +129,7 @@ class TestLayoutConstraints(wxFrame):
         lc.right.PercentOf(self, wxRight, 50)
         self.panelA.SetConstraints(lc)
 
-        self.panelB = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
+        self.panelB = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
                                wxSIMPLE_BORDER)
         self.panelB.SetBackgroundColour(wxRED)
         lc = wxLayoutConstraints()
@@ -139,7 +139,7 @@ class TestLayoutConstraints(wxFrame):
         lc.left.RightOf(self.panelA, 10)
         self.panelB.SetConstraints(lc)
 
-        self.panelC = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
+        self.panelC = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
                                wxSIMPLE_BORDER)
         self.panelC.SetBackgroundColour(wxWHITE)
         lc = wxLayoutConstraints()
@@ -165,7 +165,7 @@ class TestLayoutConstraints(wxFrame):
         lc.width.AsIs       ()
         b.SetConstraints(lc);
 
-        self.panelD = wxWindow(self.panelC, -1, wxPyDefaultPosition, wxPyDefaultSize,
+        self.panelD = wxWindow(self.panelC, -1, wxDefaultPosition, wxDefaultSize,
                             wxSIMPLE_BORDER)
         self.panelD.SetBackgroundColour(wxGREEN)
         wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
@@ -199,7 +199,7 @@ class TestLayoutConstraints(wxFrame):
 class TestGrid(wxFrame):
     def __init__(self, parent, log):
         wxFrame.__init__(self, parent, -1, 'Test Grid',
-                         wxPyDefaultPosition, wxSize(500, 300))
+                         wxDefaultPosition, wxSize(500, 300))
         self.log = log
 
         grid = wxGrid(self, -1)
@@ -244,16 +244,15 @@ class TestGrid(wxFrame):
 class ColoredPanel(wxWindow):
     def __init__(self, parent, color):
         wxWindow.__init__(self, parent, -1,
-                          wxPyDefaultPosition, wxPyDefaultSize, wxRAISED_BORDER)
+                          wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
         self.SetBackgroundColour(color)
 
 
 class TestNotebookWindow(wxFrame):
     def __init__(self, parent, log):
-        wxFrame.__init__(self, parent, -1, 'Test wxNotebook',
-                         wxPyDefaultPosition, wxPyDefaultSize)
+        wxFrame.__init__(self, parent, -1, 'Test wxNotebook')
 
-        nb = wxNotebook(self, -1)
+        nb = wxNotebook(self, -1, wxPoint(0,0), self.GetClientSize())
 
         win = ColoredPanel(nb, wxBLUE)
         nb.AddPage(win, "Blue")
@@ -271,6 +270,9 @@ class TestNotebookWindow(wxFrame):
         win = TestTreeCtrlPanel(nb, log)
         nb.AddPage(win, "TreeCtrl")
 
+        win = TestListCtrlPanel(nb, log)
+        nb.AddPage(win, "ListCtrl")
+
         win = ColoredPanel(nb, wxRED)
         nb.AddPage(win, "Red")
 
@@ -292,9 +294,8 @@ class TestNotebookWindow(wxFrame):
         win = ColoredPanel(nb, wxNamedColour('INDIAN RED'))
         nb.AddPage(win, "INDIAN RED")
 
-
         nb.SetSelection(0)
-        self.SetSize(wxSize(350, 300))  # force a redraw so the notebook will draw
+        self.SetSize(wxSize(350, 300))
 
 
     def OnCloseWindow(self, event):
@@ -305,7 +306,7 @@ class TestNotebookWindow(wxFrame):
 class TestSplitterWindow(wxFrame):
     def __init__(self, parent):
         wxFrame.__init__(self, parent, -1, 'Test wxSplitterWindow',
-                         wxPyDefaultPosition, wxSize(500, 300))
+                         wxDefaultPosition, wxSize(500, 300))
 
         splitter = wxSplitterWindow(self, -1)
 
@@ -338,7 +339,7 @@ class CustomStatusBar(wxStatusBar):
         # figure out how tall to make it.
         dc = wxClientDC(self)
         dc.SetFont(self.GetFont())
-        (w,h, d,e) = dc.GetTextExtent('X')
+        (w,h) = dc.GetTextExtent('X')
         h = int(h * 1.8)
         self.SetSize(wxSize(100, h))
 
@@ -374,7 +375,7 @@ class CustomStatusBar(wxStatusBar):
 class TestCustomStatusBar(wxFrame):
     def __init__(self, parent):
         wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
-                         wxPyDefaultPosition, wxSize(500, 300))
+                         wxDefaultPosition, wxSize(500, 300))
         wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
 
         self.sb = CustomStatusBar(self)
@@ -390,18 +391,20 @@ class TestCustomStatusBar(wxFrame):
 class TestToolBar(wxFrame):
     def __init__(self, parent, log):
         wxFrame.__init__(self, parent, -1, 'Test ToolBar',
-                         wxPyDefaultPosition, wxSize(500, 300))
+                         wxDefaultPosition, wxSize(500, 300))
         self.log = log
 
         wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
 
         tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
-        #tb = wxToolBar(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
+        #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")
+                        wxNullBitmap, false, -1, -1, "New", "Long help for 'New'")
         EVT_TOOL(self, 10, self.OnToolClick)
         EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
 
@@ -492,18 +495,194 @@ class TestTreeCtrlPanel(wxPanel):
 class TestTreeCtrl(wxFrame):
     def __init__(self, parent, log):
         wxFrame.__init__(self, parent, -1, 'Test TreeCtrl',
-                         wxPyDefaultPosition, wxSize(250, 300))
+                         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)
+
 #---------------------------------------------------------------------------
 #---------------------------------------------------------------------------
 #---------------------------------------------------------------------------
 
 class AppFrame(wxFrame):
     def __init__(self, parent, id, title):
-        wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
+        wxFrame.__init__(self, parent, id, title, wxDefaultPosition,
                          wxSize(420, 200))
         if wxPlatform == '__WXMSW__':
             self.icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
@@ -519,7 +698,7 @@ class AppFrame(wxFrame):
         self.mainmenu.Append(menu, '&Tests')
         self.SetMenuBar(self.mainmenu)
 
-        self.log = wxTextCtrl(self, -1, '', wxPyDefaultPosition, wxPyDefaultSize,
+        self.log = wxTextCtrl(self, -1, '', wxDefaultPosition, wxDefaultSize,
                               wxTE_MULTILINE|wxTE_READONLY)
         self.log.WriteText('Test 4:\n')
         (w, self.charHeight) = self.log.GetTextExtent('X')
@@ -609,6 +788,14 @@ class AppFrame(wxFrame):
         menu.Append(mID, 'T&ree Control')
         EVT_MENU(self, mID, self.OnTestTreeCtrl)
 
+        mID = NewId()
+        menu.Append(mID, '&List Control')
+        EVT_MENU(self, mID, self.OnTestListCtrl)
+
+        mID = NewId()
+        menu.Append(mID, 'S&ash Window and Layout Algorithm')
+        EVT_MENU(self, mID, self.OnTestSashWindow)
+
         return menu
 
 
@@ -707,7 +894,7 @@ class AppFrame(wxFrame):
 
 
     def OnTestPageSetupDlg(self, event):
-        data = wxPageSetupData()
+        data = wxPageSetupDialogData()
         data.SetMarginTopLeft(wxPoint(50,50))
         data.SetMarginBottomRight(wxPoint(50,50))
         dlg = wxPageSetupDialog(self, data)
@@ -719,7 +906,7 @@ class AppFrame(wxFrame):
         dlg.Destroy()
 
     def OnTestPrintDlg(self, event):
-        data = wxPrintData()
+        data = wxPrintDialogData()
         data.EnablePrintToFile(true)
         data.EnablePageNumbers(true)
         data.EnableSelection(true)
@@ -755,6 +942,13 @@ class AppFrame(wxFrame):
         win = TestTreeCtrl(self, self)
         win.Show(true)
 
+    def OnTestListCtrl(self, event):
+        win = TestListCtrl(self, self)
+        win.Show(true)
+
+    def OnTestSashWindow(self, event):
+        win = TestSashWindow(self, self)
+        win.Show(true)
 
 #---------------------------------------------------------------------------
 
@@ -804,6 +998,45 @@ if __name__ == '__main__':
 #----------------------------------------------------------------------------
 #
 # $Log$
+# Revision 1.17  1999/08/05 05:06:50  RD
+# Some minor tweaks
+#
+# Revision 1.16  1999/04/30 03:29:54  RD
+#
+# wxPython 2.0b9, first phase (win32)
+# Added gobs of stuff, see wxPython/README.txt for details
+#
+# Revision 1.15.2.1  1999/03/16 06:05:50  RD
+#
+# wxPython 2.0b7
+#
+# Revision 1.15  1999/03/05 07:23:42  RD
+#
+# Minor wxPython changes for wxWin 2.0
+#
+# Revision 1.14  1999/02/27 04:20:50  RD
+#
+# minor tweaks for testing
+#
+# Revision 1.13  1999/02/20 09:04:44  RD
+# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
+# window handle.  If you can get the window handle into the python code,
+# it should just work...  More news on this later.
+#
+# Added wxImageList, wxToolTip.
+#
+# Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
+# wxRegConfig class.
+#
+# As usual, some bug fixes, tweaks, etc.
+#
+# Revision 1.12  1999/01/30 07:31:33  RD
+#
+# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
+#
+# Various cleanup, tweaks, minor additions, etc. to maintain
+# compatibility with the current wxWindows.
+#
 # Revision 1.11  1999/01/29 16:17:59  HH
 # In test4's toolbar sample, changed NULL to wxNullBitmap to prevent SIGSEVS
 # with wxGTK. The sample works now.