30#include <wx/treebook.h>
31#include <wx/treectrl.h>
32#include <wx/listctrl.h>
33#include <wx/stc/stc.h>
48 const wxString& aAuxiliaryAction,
const wxSize& aInitialSize ) :
49 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
50 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
51 m_auxiliaryButton( nullptr ),
52 m_resetButton( nullptr ),
53 m_openPrefsDirButton( nullptr ),
56 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
57 SetSizer( mainSizer );
60 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
62 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
63 wxBORDER_NONE | wxTAB_TRAVERSAL );
64 treebookPanel->
SetBorders(
false,
false,
false,
true );
65 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
66 treebookPanel->SetSizer( treebookSizer );
72 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
73 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
74 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
76 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
77 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
83 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
98 if( !aAuxiliaryAction.IsEmpty() )
106 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
107 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
108 sdbSizer->AddButton( sdbSizerOK );
109 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
110 sdbSizer->AddButton( sdbSizerCancel );
147 for(
size_t i = 1; i <
m_treebook->GetPageCount(); ++i )
152 m_treebook->GetTreeCtrl()->InvalidateBestSize();
154 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
175 wxString lastPage = wxEmptyString;
176 wxString lastParentPage = wxEmptyString;
180 if( selected != wxNOT_FOUND )
182 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
184 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
186 if( parent != wxNOT_FOUND )
187 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
221 if( !DIALOG_SHIM::TransferDataToWindow() )
227 int lastPageIndex = wxNOT_FOUND;
229 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
231 if(
m_treebook->GetPageText( i ) == lastPage )
233 if( lastParentPage.IsEmpty() )
248 lastPageIndex = std::max( 0, lastPageIndex );
262 if( !DIALOG_SHIM::TransferDataFromWindow() )
276 aParent = aParent->GetParent();
286 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
295 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
297 textCtrl->SetSelection( -1, -1 );
298 textCtrl->SetFocus();
302 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
306 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
307 scintilla->GotoPos( pos );
310 scintilla->SetFocus();
314 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
317 grid->MakeCellVisible( aRow, aCol );
318 grid->SetGridCursor( aRow, aCol );
320 grid->EnableCellEditControl(
true );
321 grid->ShowCellEditControl();
334 if( panel && ( panel->GetWindowStyle() &
wxRESETTABLE ) )
336 m_resetButton->SetLabel( wxString::Format(
_(
"Reset %s to Defaults" ),
338 m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ),
339 wxHelpEvent::Origin_Unknown ) );
356 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
357 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
358 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() ) )
364 if( aEvent.GetKeyCode() == WXK_UP )
370 if(
m_treebook->GetPage( page - 1 )->GetChildren().IsEmpty() )
371 m_treebook->SetSelection( std::max( page - 2, 0 ) );
378 else if( aEvent.GetKeyCode() == WXK_DOWN )
395 size_t page =
event.GetSelection();
398 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty()
409 SetMinSize( wxDefaultSize );
410 wxSize
minSize = GetBestSize();
411 minSize.IncTo( wxSize( 600, 500 ) );
412 minSize.DecTo( wxSize( 1500, 900 ) );
415 wxSize currentSize = GetSize();
416 wxSize newSize = currentSize;
419 if( newSize != currentSize )
427 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
431 m_treebook->GetPage( page )->SetSize( pageSize );
435 wxSizeEvent evt( wxDefaultSize );
443 int currentPage = aEvent.GetOldSelection();
445 if( currentPage == wxNOT_FOUND )
448 wxWindow* page =
m_treebook->GetPage( currentPage );
453 if( !page->Validate() || !page->TransferDataFromWindow() )
465 if( sel == wxNOT_FOUND )
473 wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED,
ID_RESET_PANEL );
474 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
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aShowReset, bool aShowOpenFolder, const wxString &aAuxiliaryAction=wxEmptyString, const wxSize &aInitialSize=wxDefaultSize)
wxButton * m_auxiliaryButton
std::vector< bool > m_macHack
wxButton * m_openPrefsDirButton
bool TransferDataFromWindow() override
void finishInitialization()
void UpdateResetButton(int aPage)
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 onOpenPreferencesButton(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)
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.
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.
const int minSize
Push and Shove router track width and via size dialog.
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
wxFont GetControlFont(wxWindow *aWindow)
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage