]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/rearrangectrl.cpp
fixed wxXmlResource::Load's detection of filenames to be done as early as possible
[wxWidgets.git] / src / common / rearrangectrl.cpp
index cda19dd67fabf4f0d21968ce4d4e52c6f43e3b0c..a77167f47b11c226540fc57a73939b08831dc943 100644 (file)
@@ -23,6 +23,8 @@
     #pragma hdrstop
 #endif
 
+#if wxUSE_REARRANGECTRL
+
 #ifndef WX_PRECOMP
     #include "wx/button.h"
     #include "wx/stattext.h"
@@ -221,27 +223,78 @@ void wxRearrangeCtrl::OnButton(wxCommandEvent& event)
 extern
 WXDLLIMPEXP_DATA_CORE(const char) wxRearrangeDialogNameStr[] = "wxRearrangeDlg";
 
-wxRearrangeDialog::wxRearrangeDialog(wxWindow *parent,
-                                     const wxString& message,
-                                     const wxString& title,
-                                     const wxArrayInt& order,
-                                     const wxArrayString& items,
-                                     const wxPoint& pos,
-                                     const wxString& name)
-                 : wxDialog(parent, wxID_ANY, title,
-                            pos, wxDefaultSize,
-                            wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,
-                            name)
+namespace
+{
+
+enum wxRearrangeDialogSizerPositions
 {
+    Pos_Label,
+    Pos_Ctrl,
+    Pos_Buttons,
+    Pos_Max
+};
+
+} // anonymous namespace
+
+bool wxRearrangeDialog::Create(wxWindow *parent,
+                               const wxString& message,
+                               const wxString& title,
+                               const wxArrayInt& order,
+                               const wxArrayString& items,
+                               const wxPoint& pos,
+                               const wxString& name)
+{
+    if ( !wxDialog::Create(parent, wxID_ANY, title,
+                           pos, wxDefaultSize,
+                           wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,
+                           name) )
+        return false;
+
     m_ctrl = new wxRearrangeCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
                                  order, items);
 
+    // notice that the items in this sizer should be inserted accordingly to
+    // wxRearrangeDialogSizerPositions order
     wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
     sizerTop->Add(new wxStaticText(this, wxID_ANY, message),
-                  wxSizerFlags().DoubleBorder());
+                  wxSizerFlags().Border());
     sizerTop->Add(m_ctrl,
                   wxSizerFlags(1).Expand().Border());
     sizerTop->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL),
                   wxSizerFlags().Expand().Border());
     SetSizerAndFit(sizerTop);
+
+    return true;
+}
+
+void wxRearrangeDialog::AddExtraControls(wxWindow *win)
+{
+    wxSizer * const sizer = GetSizer();
+    wxCHECK_RET( sizer, "the dialog must be created first" );
+
+    wxASSERT_MSG( sizer->GetChildren().GetCount() == Pos_Max,
+                  "calling AddExtraControls() twice?" );
+
+    sizer->Insert(Pos_Buttons, win, wxSizerFlags().Expand().Border());
+
+    win->MoveAfterInTabOrder(m_ctrl);
+
+    // we need to update the initial/minimal window size
+    sizer->SetSizeHints(this);
+}
+
+wxRearrangeList *wxRearrangeDialog::GetList() const
+{
+    wxCHECK_MSG( m_ctrl, NULL, "the dialog must be created first" );
+
+    return m_ctrl->GetList();
+}
+
+wxArrayInt wxRearrangeDialog::GetOrder() const
+{
+    wxCHECK_MSG( m_ctrl, wxArrayInt(), "the dialog must be created first" );
+
+    return m_ctrl->GetList()->GetCurrentOrder();
 }
+
+#endif // wxUSE_REARRANGECTRL