]> git.saurik.com Git - wxWidgets.git/commitdiff
Disable wxSIZE_FORCE_EVENT and demonstrate its bug in the wxCollapsiblePane sample
authorRobert Roebling <robert@roebling.de>
Sat, 31 Jan 2009 19:15:25 +0000 (19:15 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 31 Jan 2009 19:15:25 +0000 (19:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58560 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/collpane/collpane.cpp
src/common/sizer.cpp

index dbc8cbf4a737632f67108790a8a04b499c8b1355..a48444f4fe3ed5f2e96d43d46e230faf2e65ca76 100644 (file)
@@ -56,7 +56,10 @@ enum
     PANE_SETLABEL,
     PANE_SHOWDLG,
     PANE_ABOUT = wxID_ABOUT,
-    PANE_QUIT = wxID_EXIT
+    PANE_QUIT = wxID_EXIT,
+    
+    PANE_BUTTON,
+    PANE_TEXTCTRL
 };
 
 
@@ -94,6 +97,7 @@ public:
 
 private:
     wxCollapsiblePane *m_collPane;
+    wxBoxSizer *m_paneSizer;
 
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(MyFrame)
@@ -104,10 +108,12 @@ class MyDialog : public wxDialog
 public:
     MyDialog(wxFrame *parent);
     void OnToggleStatus(wxCommandEvent& WXUNUSED(ev));
+    void OnAlignButton(wxCommandEvent& WXUNUSED(ev));
     void OnPaneChanged(wxCollapsiblePaneEvent& event);
 
 private:
     wxCollapsiblePane *m_collPane;
+    wxGridSizer *m_paneSizer;
 
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(MyDialog)
@@ -185,11 +191,13 @@ MyFrame::MyFrame()
 
     m_collPane = new wxCollapsiblePane(this, -1, wxT("test!"));
     wxWindow *win = m_collPane->GetPane();
-
-    new wxStaticText(win, -1, wxT("Static control with absolute coords"), wxPoint(10,2));
-    new wxStaticText(win, -1, wxT("Yet another one!"), wxPoint(30, 30));
-    new wxTextCtrl(win, -1, wxT("You can place anything you like inside a wxCollapsiblePane"),
-                   wxPoint(5, 60), wxSize(300, -1));
+    
+    m_paneSizer = new wxBoxSizer( wxVERTICAL );
+    m_paneSizer->Add( new wxStaticText(win, -1, wxT("Static text") ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxStaticText(win, -1, wxT("Yet another one!") ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxTextCtrl(win, PANE_TEXTCTRL, wxT("Text control"), wxDefaultPosition, wxSize(80,-1) ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxButton(win, PANE_BUTTON, wxT("Press to align right") ), 0, wxALIGN_LEFT );
+    win->SetSizer( m_paneSizer );
 }
 
 MyFrame::~MyFrame()
@@ -263,6 +271,7 @@ enum
 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
     EVT_BUTTON(PANEDLG_TOGGLESTATUS_BTN, MyDialog::OnToggleStatus)
     EVT_COLLAPSIBLEPANE_CHANGED(wxID_ANY, MyDialog::OnPaneChanged)
+    EVT_BUTTON(PANE_BUTTON, MyDialog::OnAlignButton)
 END_EVENT_TABLE()
 
 MyDialog::MyDialog(wxFrame *parent)
@@ -285,13 +294,16 @@ MyDialog::MyDialog(wxFrame *parent)
 
     // now add test controls in the collapsible pane
     wxWindow *win = m_collPane->GetPane();
-    wxSizer *paneSz = new wxGridSizer(4, 1, 5, 5);
-    paneSz->Add(new wxColourPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
-    paneSz->Add(new wxFontPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
-    paneSz->Add(new wxFilePickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
-    paneSz->Add(new wxDirPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
-    win->SetSizer(paneSz);
-    paneSz->SetSizeHints(win);
+    m_paneSizer = new wxGridSizer(4, 1, 5, 5);
+
+    m_paneSizer->Add( new wxStaticText(win, -1, wxT("Static text") ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxStaticText(win, -1, wxT("Yet another one!") ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxTextCtrl(win, PANE_TEXTCTRL, wxT("Text control"), wxDefaultPosition, wxSize(80,-1) ), 0, wxALIGN_LEFT );
+    m_paneSizer->Add( new wxButton(win, PANE_BUTTON, wxT("Press to align right") ), 0, wxALIGN_LEFT );
+    win->SetSizer( m_paneSizer );
+
+    win->SetSizer( m_paneSizer );
+    m_paneSizer->SetSizeHints(win);
 
     SetSizer(sz);
     sz->SetSizeHints(this);
@@ -302,6 +314,14 @@ void MyDialog::OnToggleStatus(wxCommandEvent& WXUNUSED(ev))
     m_collPane->Collapse(!m_collPane->IsCollapsed());
 }
 
+void MyDialog::OnAlignButton(wxCommandEvent& WXUNUSED(ev))
+{
+   wxSizerItem *item = m_paneSizer->GetItem( FindWindow(PANE_TEXTCTRL), true );
+   item->SetFlag(  wxALIGN_RIGHT );
+   
+   Layout();
+}
+
 void MyDialog::OnPaneChanged(wxCollapsiblePaneEvent &event)
 {
     wxLogDebug(wxT("The pane has just been %s by the user"),
index a13599bf3ca559163113181c0695c5d04906b2bd..6d02d5b4b9e46f15defb1fd5716b7735876017b6 100644 (file)
@@ -486,8 +486,13 @@ void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ )
             // not change the size of the window. In such a case, no
             // wxSizeEvent would normally be generated and thus the
             // control wouldn't get layed out correctly here.
+#if 0
             m_window->SetSize(pos.x, pos.y, size.x, size.y,
                               wxSIZE_ALLOW_MINUS_ONE|wxSIZE_FORCE_EVENT );
+#else
+            m_window->SetSize(pos.x, pos.y, size.x, size.y,
+                              wxSIZE_ALLOW_MINUS_ONE );
+#endif
             break;
         }
         case Item_Sizer: