]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/aui/auidemo.cpp
wxArrayStringProperty::m_delimiter default value was missing. Also cleaned up relevan...
[wxWidgets.git] / samples / aui / auidemo.cpp
index b6a1f6cae50af24103ae26cbc48c1f1e9bed6c7b..78fa5692d31db779317aa6b7a98849d180c027f2 100644 (file)
@@ -152,6 +152,7 @@ private:
     void OnCustomizeToolbar(wxCommandEvent& evt);
     void OnAllowNotebookDnD(wxAuiNotebookEvent& evt);
     void OnNotebookPageClose(wxAuiNotebookEvent& evt);
+    void OnNotebookPageClosed(wxAuiNotebookEvent& evt);
     void OnExit(wxCommandEvent& evt);
     void OnAbout(wxCommandEvent& evt);
     void OnTabAlignment(wxCommandEvent &evt);
@@ -649,6 +650,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_AUI_PANE_CLOSE(MyFrame::OnPaneClose)
     EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, MyFrame::OnAllowNotebookDnD)
     EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, MyFrame::OnNotebookPageClose)
+    EVT_AUINOTEBOOK_PAGE_CLOSED(wxID_ANY, MyFrame::OnNotebookPageClosed)
 END_EVENT_TABLE()
 
 
@@ -845,6 +847,10 @@ MyFrame::MyFrame(wxWindow* parent,
     tb4->AddTool(ID_SampleItem+29, wxT("Item 8"), tb4_bmp1);
     tb4->SetToolDropDown(ID_DropDownToolbarItem, true);
     tb4->SetCustomOverflowItems(prepend_items, append_items);
+    wxChoice* choice = new wxChoice(tb4, ID_SampleItem+35);
+    choice->AppendString(wxT("One choice"));
+    choice->AppendString(wxT("Another choice"));
+    tb4->AddControl(choice);
     tb4->Realize();
 
 
@@ -1325,6 +1331,19 @@ void MyFrame::OnNotebookPageClose(wxAuiNotebookEvent& evt)
     }
 }
 
+void MyFrame::OnNotebookPageClosed(wxAuiNotebookEvent& evt)
+{
+    wxAuiNotebook* ctrl = (wxAuiNotebook*)evt.GetEventObject();
+
+    // selection should always be a valid index
+    wxASSERT_MSG( ctrl->GetSelection() < (int)ctrl->GetPageCount(),
+                  wxString::Format("Invalid selection %d, only %d pages left",
+                                   ctrl->GetSelection(),
+                                   (int)ctrl->GetPageCount()) );
+
+    evt.Skip();
+}
+
 void MyFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& evt)
 {
     // for the purpose of this test application, explicitly
@@ -1451,7 +1470,7 @@ void MyFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& evt)
 
 void MyFrame::OnTabAlignment(wxCommandEvent &evt)
 {
-   size_t i, count;
+    size_t i, count;
     wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
     for (i = 0, count = all_panes.GetCount(); i < count; ++i)
     {
@@ -1460,10 +1479,14 @@ void MyFrame::OnTabAlignment(wxCommandEvent &evt)
         {
             wxAuiNotebook* nb = (wxAuiNotebook*)pane.window;
 
+            long style = nb->GetWindowStyleFlag();
+            style &= ~(wxAUI_NB_TOP | wxAUI_NB_BOTTOM);
             if (evt.GetId() == ID_NotebookAlignTop)
-                nb->SetWindowStyleFlag(nb->GetWindowStyleFlag()^wxAUI_NB_BOTTOM|wxAUI_NB_TOP);
-           else if (evt.GetId() == ID_NotebookAlignBottom)
-               nb->SetWindowStyleFlag(nb->GetWindowStyleFlag()^wxAUI_NB_TOP|wxAUI_NB_BOTTOM);
+                style |= wxAUI_NB_TOP;
+            else if (evt.GetId() == ID_NotebookAlignBottom)
+                style |= wxAUI_NB_BOTTOM;
+            nb->SetWindowStyleFlag(style);
+
             nb->Refresh();
         }
     }