25#include <wx/treebook.h>
26#include <wx/treectrl.h>
30#include <wx/stc/stc.h>
33#include "wx/listctrl.h"
43 const wxString& aAuxiliaryAction ) :
44 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
45 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
46 m_auxiliaryButton( nullptr ),
47 m_resetButton( nullptr ),
48 m_cancelButton( nullptr ),
51 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
52 SetSizer( mainSizer );
55 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
57 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
58 wxBORDER_NONE | wxTAB_TRAVERSAL );
59 treebookPanel->
SetBorders(
false,
false,
false,
true );
60 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
61 treebookPanel->SetSizer( treebookSizer );
63 m_treebook =
new wxTreebook( treebookPanel, wxID_ANY );
66 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
67 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
68 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
70 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
71 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
77 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
81 if( !aAuxiliaryAction.IsEmpty() )
89 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
90 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
91 sdbSizer->AddButton( sdbSizerOK );
92 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
93 sdbSizer->AddButton( sdbSizerCancel );
125 for(
size_t i = 1; i <
m_treebook->GetPageCount(); ++i )
130 m_treebook->GetTreeCtrl()->InvalidateBestSize();
132 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
155 wxString lastPage = wxEmptyString;
156 wxString lastParentPage = wxEmptyString;
160 if( selected != wxNOT_FOUND )
162 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
164 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
166 if( parent != wxNOT_FOUND )
167 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
196 if( !DIALOG_SHIM::TransferDataToWindow() )
201#if !wxCHECK_VERSION( 3, 1, 0 )
202 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
206 if( !page->TransferDataToWindow() )
214 int lastPageIndex = wxNOT_FOUND;
216 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
218 if(
m_treebook->GetPageText( i ) == lastPage )
220 if( lastParentPage.IsEmpty() )
235 lastPageIndex = std::max( 0, lastPageIndex );
249 if( !DIALOG_SHIM::TransferDataFromWindow() )
254#if !wxCHECK_VERSION( 3, 1, 0 )
255 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
259 if( !page->TransferDataFromWindow() )
275 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
286 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
288 textCtrl->SetSelection( -1, -1 );
289 textCtrl->SetFocus();
293 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
297 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
298 scintilla->GotoPos( pos );
301 scintilla->SetFocus();
305 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
308 grid->MakeCellVisible( aRow, aCol );
309 grid->SetGridCursor( aRow, aCol );
311 grid->EnableCellEditControl(
true );
312 grid->ShowCellEditControl();
321 wxWindow* panel =
m_treebook->GetPage( aPage );
326 if( panel && ( panel->GetWindowStyle() &
wxRESETTABLE ) )
330 m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ),
331 wxHelpEvent::Origin_Unknown ) );
348 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
349 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
350 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() ) )
356 if( aEvent.GetKeyCode() == WXK_UP )
362 if(
m_treebook->GetPage( page - 1 )->GetChildren().IsEmpty() )
363 m_treebook->SetSelection( std::max( page - 2, 0 ) );
370 else if( aEvent.GetKeyCode() == WXK_DOWN )
387 size_t page =
event.GetSelection();
390 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty()
403 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
407 m_treebook->GetPage( page )->SetSize( pageSize );
411 wxSizeEvent evt( wxDefaultSize );
419 int currentPage = aEvent.GetOldSelection();
421 if( currentPage == wxNOT_FOUND )
424 wxWindow* page =
m_treebook->GetPage( currentPage );
429 if( !page->Validate() || !page->TransferDataFromWindow() )
441 if( sel == wxNOT_FOUND )
449 wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED,
ID_RESET_PANEL );
450 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)
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)
This file is part of the common library.
wxFont GetControlFont(wxWindow *aWindow)
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.