customize the rearrange dialog even more

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-31 14:39:38 +00:00
parent 5a5f305a0f
commit e9bef30205

View File

@@ -867,16 +867,37 @@ public:
DoUpdateExtraControls(GetList()->GetSelection()); DoUpdateExtraControls(GetList()->GetSelection());
AddExtraControls(panel); AddExtraControls(panel);
// another customization not directly supported by the dialog: add a
// custom button
wxWindow * const btnOk = FindWindow(wxID_OK);
wxCHECK_RET( btnOk, "no Ok button?" );
wxSizer * const sizerBtns = btnOk->GetContainingSizer();
wxCHECK_RET( sizerBtns, "no buttons sizer?" );
sizerBtns->Add(new wxButton(this, wxID_RESET, "&Reset all"),
wxSizerFlags().Border(wxLEFT));
} }
// call this instead of ShowModal() to update order and labels array in // call this instead of ShowModal() to update order and labels array in
// case the dialog was not cancelled // case the dialog was not cancelled
bool Rearrange() bool Rearrange()
{ {
if ( ShowModal() == wxID_CANCEL ) switch ( ShowModal() )
return false; {
case wxID_CANCEL:
return false;
m_order = GetOrder(); case wxID_OK:
m_order = GetOrder();
break;
case wxID_RESET:
// order already reset
break;
}
return true; return true;
} }
@@ -901,6 +922,21 @@ private:
GetList()->SetString(m_sel, m_labels[m_sel]); GetList()->SetString(m_sel, m_labels[m_sel]);
} }
void OnReset(wxCommandEvent& WXUNUSED(event))
{
// in a real program we should probably ask if the user really wants to
// do this but here we just go ahead and reset all columns labels and
// their order without confirmation
const unsigned count = m_order.size();
for ( unsigned n = 0; n < count; n++ )
{
m_order[n] = n;
m_labels[n] = m_labelsOrig[n];
}
EndModal(wxID_RESET);
}
bool CanRename() const bool CanRename() const
{ {
// only allow renaming if the user modified the currently selected item // only allow renaming if the user modified the currently selected item
@@ -940,9 +976,12 @@ private:
BEGIN_EVENT_TABLE(MyRearrangeDialog, wxRearrangeDialog) BEGIN_EVENT_TABLE(MyRearrangeDialog, wxRearrangeDialog)
EVT_LISTBOX(wxID_ANY, MyRearrangeDialog::OnSelChange) EVT_LISTBOX(wxID_ANY, MyRearrangeDialog::OnSelChange)
EVT_UPDATE_UI(wxID_APPLY, MyRearrangeDialog::OnUpdateUIRename) EVT_UPDATE_UI(wxID_APPLY, MyRearrangeDialog::OnUpdateUIRename)
EVT_BUTTON(wxID_APPLY, MyRearrangeDialog::OnRename)
EVT_TEXT_ENTER(wxID_ANY, MyRearrangeDialog::OnRename) EVT_TEXT_ENTER(wxID_ANY, MyRearrangeDialog::OnRename)
EVT_BUTTON(wxID_APPLY, MyRearrangeDialog::OnRename)
EVT_BUTTON(wxID_RESET, MyRearrangeDialog::OnReset)
END_EVENT_TABLE() END_EVENT_TABLE()
void MyFrame::Rearrange(wxCommandEvent& WXUNUSED(event)) void MyFrame::Rearrange(wxCommandEvent& WXUNUSED(event))