22 #include <wx/treebook.h> 23 #include <wx/treectrl.h> 25 #include <wx/statline.h> 29 #include <wx/stc/stc.h> 40 const wxString& aAuxiliaryAction ) :
41 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
42 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
45 m_errorCtrl( nullptr ),
48 m_auxiliaryButton( nullptr ),
49 m_resetButton( nullptr ),
50 m_cancelButton( nullptr )
52 auto mainSizer =
new wxBoxSizer( wxVERTICAL );
53 SetSizer( mainSizer );
56 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
59 mainSizer->Add(
m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 );
61 auto line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
63 mainSizer->Add( line, 0, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 10 );
69 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
73 if( !aAuxiliaryAction.IsEmpty() )
81 auto sdbSizer =
new wxStdDialogButtonSizer();
82 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
83 sdbSizer->AddButton( sdbSizerOK );
84 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
85 sdbSizer->AddButton( sdbSizerCancel );
91 sdbSizerOK->SetDefault();
108 m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
117 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
122 m_treebook->GetTreeCtrl()->InvalidateBestSize();
124 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
148 wxString lastPage = wxEmptyString;
149 wxString lastParentPage = wxEmptyString;
153 if( selected != wxNOT_FOUND )
155 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
157 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
159 if( parent != wxNOT_FOUND )
160 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
176 m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
189 if( !DIALOG_SHIM::TransferDataToWindow() )
194 #if !wxCHECK_VERSION( 3, 1, 0 ) 195 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
199 if( !page->TransferDataToWindow() )
207 int lastPageIndex = wxNOT_FOUND;
209 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
211 if(
m_treebook->GetPageText( i ) == lastPage )
213 if( lastParentPage.IsEmpty() )
228 m_treebook->SetSelection( (
unsigned) std::max( 0, lastPageIndex ) );
240 if( !DIALOG_SHIM::TransferDataFromWindow() )
245 #if !wxCHECK_VERSION( 3, 1, 0 ) 246 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
250 if( !page->TransferDataFromWindow() )
268 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
275 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
294 std::function<
void( wxCommandEvent& )> aHandler )
299 wxButton* button =
new wxButton(
this, wxID_ANY, aTitle );
300 button->SetToolTip( aTooltip );
301 button->Bind( wxEVT_BUTTON, aHandler );
308 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
313 if( !page->Validate() )
335 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ctrl ) )
337 textCtrl->SetSelection( -1, -1 );
338 textCtrl->SetFocus();
342 if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( ctrl ) )
347 scintilla->GotoPos( pos );
350 scintilla->SetFocus();
354 if( wxGrid* grid = dynamic_cast<wxGrid*>( ctrl ) )
360 grid->EnableCellEditControl(
true );
361 grid->ShowCellEditControl();
366 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty() )
370 if( next < m_treebook->GetPageCount() )
378 size_t page =
event.GetSelection();
383 if(
auto panel = dynamic_cast<RESETTABLE_PANEL*>(
m_treebook->GetPage( page ) ) )
401 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
405 m_treebook->GetPage( page )->SetSize( pageSize );
418 if( sel == wxNOT_FOUND )
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
std::map< wxString, wxString > g_lastPage
This file is part of the common library.
std::vector< bool > m_macHack
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
std::map< wxString, wxString > g_lastParentPage
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
void OnPageChange(wxBookCtrlEvent &event)
bool TransferDataToWindow() override
wxButton * m_auxiliaryButton
bool TransferDataFromWindow() override
void OnUpdateUI(wxUpdateUIEvent &event)
wxBoxSizer * m_buttonsSizer
virtual void ResetPanel()=0
Reset the contents of this panel.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
A modified version of the wxInfoBar class that allows us to:
virtual void OnAuxiliaryAction(wxCommandEvent &event)
void OnResetButton(wxCommandEvent &aEvent)
void OnValidate(wxCommandEvent &aEvent)
void AddAuxiliaryAction(const wxString &aTitle, const wxString &aTooltip, std::function< void(wxCommandEvent &)> aHandler)
void finishInitialization()
A wxPanel that is designed to be reset in a standard manner.
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aUseReset=false, const wxString &aAuxiliaryAction=wxEmptyString)