22 #include <wx/button.h> 25 #include <wx/statline.h> 26 #include <wx/treebook.h> 27 #include <wx/treectrl.h> 31 #include <wx/stc/stc.h> 42 const wxString& aAuxiliaryAction ) :
43 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
44 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
45 m_auxiliaryButton( nullptr ),
46 m_resetButton( nullptr ),
47 m_cancelButton( nullptr ),
50 m_errorCtrl( nullptr ),
54 auto mainSizer =
new wxBoxSizer( wxVERTICAL );
55 SetSizer( mainSizer );
58 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
62 mainSizer->Add(
m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 );
64 auto line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
66 mainSizer->Add( line, 0, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 10 );
72 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
76 if( !aAuxiliaryAction.IsEmpty() )
84 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
85 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
86 sdbSizer->AddButton( sdbSizerOK );
87 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
88 sdbSizer->AddButton( sdbSizerCancel );
94 sdbSizerOK->SetDefault();
115 m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
123 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
128 m_treebook->GetTreeCtrl()->InvalidateBestSize();
130 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
156 wxString lastPage = wxEmptyString;
157 wxString lastParentPage = wxEmptyString;
161 if( selected != wxNOT_FOUND )
163 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
165 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
167 if( parent != wxNOT_FOUND )
168 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
188 m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
201 if( !DIALOG_SHIM::TransferDataToWindow() )
206 #if !wxCHECK_VERSION( 3, 1, 0 ) 207 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
211 if( !page->TransferDataToWindow() )
219 int lastPageIndex = wxNOT_FOUND;
221 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
223 if(
m_treebook->GetPageText( i ) == lastPage )
225 if( lastParentPage.IsEmpty() )
240 m_treebook->SetSelection( (
unsigned) std::max( 0, lastPageIndex ) );
252 if( !DIALOG_SHIM::TransferDataFromWindow() )
257 #if !wxCHECK_VERSION( 3, 1, 0 ) 258 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
262 if( !page->TransferDataFromWindow() )
280 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
287 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
320 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ctrl ) )
322 textCtrl->SetSelection( -1, -1 );
323 textCtrl->SetFocus();
327 if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( ctrl ) )
332 scintilla->GotoPos( pos );
335 scintilla->SetFocus();
339 if( wxGrid*
grid = dynamic_cast<wxGrid*>( ctrl ) )
345 grid->EnableCellEditControl(
true );
346 grid->ShowCellEditControl();
351 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty() )
357 if( next < m_treebook->GetPageCount() )
365 size_t page =
event.GetSelection();
370 if(
auto panel = dynamic_cast<RESETTABLE_PANEL*>(
m_treebook->GetPage( page ) ) )
391 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
395 m_treebook->GetPage( page )->SetSize( pageSize );
406 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 ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
wxFont GetControlFont(wxWindow *aWindow)
void OnPageChange(wxBookCtrlEvent &event)
bool TransferDataToWindow() override
wxButton * m_auxiliaryButton
bool TransferDataFromWindow() override
void OnUpdateUI(wxUpdateUIEvent &event)
wxBoxSizer * m_buttonsSizer
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual void ResetPanel()=0
Reset the contents of this panel.
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aShowReset, const wxString &aAuxiliaryAction=wxEmptyString)
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 finishInitialization()
A wxPanel that is designed to be reset in a standard manner.