31#include <wx/treebook.h>
32#include <wx/treectrl.h>
33#include <wx/listctrl.h>
34#include <wx/stc/stc.h>
49 const wxString& aAuxiliaryAction,
const wxSize& aInitialSize ) :
50 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
51 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
52 m_auxiliaryButton( nullptr ),
53 m_resetButton( nullptr ),
54 m_openPrefsDirButton( nullptr ),
57 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
58 SetSizer( mainSizer );
61 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
63 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
64 wxBORDER_NONE | wxTAB_TRAVERSAL );
65 treebookPanel->
SetBorders(
false,
false,
false,
true );
66 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
67 treebookPanel->SetSizer( treebookSizer );
73 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
74 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
75 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
77 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
78 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
84 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
99 if( !aAuxiliaryAction.IsEmpty() )
107 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
108 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
109 sdbSizer->AddButton( sdbSizerOK );
110 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
111 sdbSizer->AddButton( sdbSizerCancel );
148 for(
size_t i = 1; i <
m_treebook->GetPageCount(); ++i )
153 m_treebook->GetTreeCtrl()->InvalidateBestSize();
155 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
176 wxString lastPage = wxEmptyString;
177 wxString lastParentPage = wxEmptyString;
181 if( selected != wxNOT_FOUND )
183 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
185 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
187 if( parent != wxNOT_FOUND )
188 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
222 if( !DIALOG_SHIM::TransferDataToWindow() )
228 int lastPageIndex = wxNOT_FOUND;
230 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
232 if(
m_treebook->GetPageText( i ) == lastPage )
234 if( lastParentPage.IsEmpty() )
249 lastPageIndex = std::max( 0, lastPageIndex );
263 if( !DIALOG_SHIM::TransferDataFromWindow() )
277 aParent = aParent->GetParent();
287 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
296 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
298 textCtrl->SetSelection( -1, -1 );
299 textCtrl->SetFocus();
303 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
307 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
308 scintilla->GotoPos( pos );
311 scintilla->SetFocus();
315 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
318 grid->MakeCellVisible( aRow, aCol );
319 grid->SetGridCursor( aRow, aCol );
321 grid->EnableCellEditControl(
true );
322 grid->ShowCellEditControl();
335 if( panel && ( panel->GetWindowStyle() &
wxRESETTABLE ) )
337 m_resetButton->SetLabel( wxString::Format(
_(
"Reset %s to Defaults" ),
339 m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ),
340 wxHelpEvent::Origin_Unknown ) );
357 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
358 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
359 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() )
360 ||
dynamic_cast<wxGrid*
>( FindFocus() ) )
366 if( aEvent.GetKeyCode() == WXK_UP )
372 if(
m_treebook->GetPage( page - 1 )->GetChildren().IsEmpty() )
373 m_treebook->SetSelection( std::max( page - 2, 0 ) );
380 else if( aEvent.GetKeyCode() == WXK_DOWN )
397 size_t page =
event.GetSelection();
400 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty()
411 SetMinSize( wxDefaultSize );
412 wxSize
minSize = GetBestSize();
413 minSize.IncTo( FromDIP( wxSize( 600, 500 ) ) );
414 minSize.DecTo( FromDIP( wxSize( 1500, 900 ) ) );
417 wxSize currentSize = GetSize();
418 wxSize newSize = currentSize;
421 if( newSize != currentSize )
429 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
433 m_treebook->GetPage( page )->SetSize( pageSize );
437 wxSizeEvent evt( wxDefaultSize );
445 int currentPage = aEvent.GetOldSelection();
447 if( currentPage == wxNOT_FOUND )
450 wxWindow* page =
m_treebook->GetPage( currentPage );
455 if( !page->Validate() || !page->TransferDataFromWindow() )
467 if( sel == wxNOT_FOUND )
475 wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED,
ID_RESET_PANEL );
476 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.
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage
Functions to provide common constants and other functions to assist in making a consistent UI.