31#include <wx/treebook.h>
32#include <wx/treectrl.h>
33#include <wx/listctrl.h>
34#include <wx/stc/stc.h>
49 bool aShowOpenFolder,
const wxString& aAuxiliaryAction,
50 const wxSize& aInitialSize ) :
51 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
52 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
53 m_auxiliaryButton( nullptr ),
54 m_resetButton( nullptr ),
55 m_openPrefsDirButton( nullptr ),
58 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
59 SetSizer( mainSizer );
62 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
64 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
65 wxBORDER_NONE | wxTAB_TRAVERSAL );
66 treebookPanel->
SetBorders(
false,
false,
false,
true );
67 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
68 treebookPanel->SetSizer( treebookSizer );
74 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
75 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
76 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
78 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
79 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
85 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
97 wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 5 );
101 if( !aAuxiliaryAction.IsEmpty() )
109 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
110 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
111 sdbSizer->AddButton( sdbSizerOK );
112 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
113 sdbSizer->AddButton( sdbSizerCancel );
151 for(
size_t i = 1; i <
m_treebook->GetPageCount(); ++i )
156 m_treebook->GetTreeCtrl()->InvalidateBestSize();
158 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
179 wxString lastPage = wxEmptyString;
180 wxString lastParentPage = wxEmptyString;
184 if( selected != wxNOT_FOUND )
186 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
188 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
190 if( parent != wxNOT_FOUND )
191 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
226 if( !DIALOG_SHIM::TransferDataToWindow() )
232 int lastPageIndex = wxNOT_FOUND;
234 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
236 if(
m_treebook->GetPageText( i ) == lastPage )
238 if( lastParentPage.IsEmpty() )
253 lastPageIndex = std::max( 0, lastPageIndex );
267 if( !DIALOG_SHIM::TransferDataFromWindow() )
281 aParent = aParent->GetParent();
291 SetError( aMessage, FindWindow( aPageName ), FindWindow( aCtrlId ), aRow, aCol );
300 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
302 textCtrl->SetSelection( -1, -1 );
303 textCtrl->SetFocus();
307 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
311 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
312 scintilla->GotoPos( pos );
315 scintilla->SetFocus();
319 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
322 grid->MakeCellVisible( aRow, aCol );
323 grid->SetGridCursor( aRow, aCol );
325 grid->EnableCellEditControl(
true );
326 grid->ShowCellEditControl();
339 if( panel && ( panel->GetWindowStyle() &
wxRESETTABLE ) )
342 name.Replace( wxT(
"&" ), wxT(
"&&" ) );
345 m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ),
346 wxHelpEvent::Origin_Unknown ) );
363 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
364 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
365 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() )
366 ||
dynamic_cast<wxGrid*
>( FindFocus() ) )
372 if( aEvent.GetKeyCode() == WXK_UP )
378 if(
m_treebook->GetPage( page - 1 )->GetChildren().IsEmpty() )
379 m_treebook->SetSelection( std::max( page - 2, 0 ) );
386 else if( aEvent.GetKeyCode() == WXK_DOWN )
403 size_t page =
event.GetSelection();
406 if(
m_treebook->GetCurrentPage()->GetChildren().IsEmpty()
417 SetMinSize( wxDefaultSize );
418 wxSize
minSize = GetBestSize();
419 minSize.IncTo( FromDIP( wxSize( 600, 500 ) ) );
420 minSize.DecTo( FromDIP( wxSize( 1500, 900 ) ) );
423 wxSize currentSize = GetSize();
424 wxSize newSize = currentSize;
427 if( newSize != currentSize )
435 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
439 m_treebook->GetPage( page )->SetSize( pageSize );
443 wxSizeEvent evt( wxDefaultSize );
451 int currentPage = aEvent.GetOldSelection();
453 if( currentPage == wxNOT_FOUND )
456 wxWindow* page =
m_treebook->GetPage( currentPage );
461 if( !page->Validate() || !page->TransferDataFromWindow() )
473 if( sel == wxNOT_FOUND )
481 wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED,
ID_RESET_PANEL );
482 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.