30#include <wx/treebook.h>
31#include <wx/treectrl.h>
32#include <wx/listctrl.h>
33#include <wx/stc/stc.h>
44 const wxString& aAuxiliaryAction ) :
45 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
46 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
47 m_auxiliaryButton( nullptr ),
48 m_resetButton( nullptr ),
49 m_cancelButton( nullptr ),
52 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
53 SetSizer( mainSizer );
56 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
58 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
59 wxBORDER_NONE | wxTAB_TRAVERSAL );
60 treebookPanel->
SetBorders(
false,
false,
false,
true );
61 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
62 treebookPanel->SetSizer( treebookSizer );
67 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
68 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
69 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
71 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
72 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
78 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
82 if( !aAuxiliaryAction.IsEmpty() )
90 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
91 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
92 sdbSizer->AddButton( sdbSizerOK );
93 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
94 sdbSizer->AddButton( sdbSizerCancel );
126 for(
size_t i = 1; i <
m_treebook->GetPageCount(); ++i )
131 m_treebook->GetTreeCtrl()->InvalidateBestSize();
133 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 );
197 if( !DIALOG_SHIM::TransferDataToWindow() )
202#if !wxCHECK_VERSION( 3, 1, 0 )
203 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
207 if( !page->TransferDataToWindow() )
215 int lastPageIndex = wxNOT_FOUND;
217 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
219 if(
m_treebook->GetPageText( i ) == lastPage )
221 if( lastParentPage.IsEmpty() )
236 lastPageIndex = std::max( 0, lastPageIndex );
250 if( !DIALOG_SHIM::TransferDataFromWindow() )
255#if !wxCHECK_VERSION( 3, 1, 0 )
256 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
260 if( !page->TransferDataFromWindow() )
280 aParent = aParent->GetParent();
290 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
299 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
301 textCtrl->SetSelection( -1, -1 );
302 textCtrl->SetFocus();
306 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
310 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
311 scintilla->GotoPos( pos );
314 scintilla->SetFocus();
318 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
321 grid->MakeCellVisible( aRow, aCol );
322 grid->SetGridCursor( aRow, aCol );
324 grid->EnableCellEditControl(
true );
325 grid->ShowCellEditControl();
338 if( panel && ( panel->GetWindowStyle() &
wxRESETTABLE ) )
340 m_resetButton->SetLabel( wxString::Format(
_(
"Reset %s to Defaults" ),
342 m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ),
343 wxHelpEvent::Origin_Unknown ) );
360 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
361 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
362 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() ) )
368 if( aEvent.GetKeyCode() == WXK_UP )
374 if(
m_treebook->GetPage( page - 1 )->GetChildren().IsEmpty() )
375 m_treebook->SetSelection( std::max( page - 2, 0 ) );
382 else if( aEvent.GetKeyCode() == WXK_DOWN )
399 size_t page =
event.GetSelection();
402 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty()
415 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
419 m_treebook->GetPage( page )->SetSize( pageSize );
423 wxSizeEvent evt( wxDefaultSize );
431 int currentPage = aEvent.GetOldSelection();
433 if( currentPage == wxNOT_FOUND )
436 wxWindow* page =
m_treebook->GetPage( currentPage );
441 if( !page->Validate() || !page->TransferDataFromWindow() )
453 if( sel == wxNOT_FOUND )
461 wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED,
ID_RESET_PANEL );
462 panel->ProcessWindowEvent( resetCommand );
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool TransferDataToWindow() override
wxButton * m_auxiliaryButton
std::vector< bool > m_macHack
bool TransferDataFromWindow() override
void finishInitialization()
void UpdateResetButton(int aPage)
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aShowReset, const wxString &aAuxiliaryAction=wxEmptyString)
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
virtual void onPageChanging(wxBookCtrlEvent &aEvent)
virtual void onCharHook(wxKeyEvent &aEvent)
virtual void onAuxiliaryAction(wxCommandEvent &aEvent)
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
virtual void onResetButton(wxCommandEvent &aEvent)
virtual void onPageChanged(wxBookCtrlEvent &aEvent)
wxBoxSizer * m_buttonsSizer
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
A modified version of the wxInfoBar class that allows us to:
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.
void SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
wxWindow * ResolvePage(size_t aPage)
This file is part of the common library.
wxFont GetControlFont(wxWindow *aWindow)
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage