50 bool aShowOpenFolder,
const wxString& aAuxiliaryAction,
51 const wxSize& aInitialSize ) :
52 DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
53 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
59 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
60 SetSizer( mainSizer );
63 mainSizer->Add(
m_infoBar, 0, wxEXPAND, 0 );
65 WX_PANEL* treebookPanel =
new WX_PANEL(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
66 wxBORDER_NONE | wxTAB_TRAVERSAL );
67 treebookPanel->
SetBorders(
false,
false,
false,
true );
68 wxBoxSizer* treebookSizer =
new wxBoxSizer( wxVERTICAL );
69 treebookPanel->SetSizer( treebookSizer );
75 long treeCtrlFlags =
m_treebook->GetTreeCtrl()->GetWindowStyleFlag();
76 treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE;
77 m_treebook->GetTreeCtrl()->SetWindowStyleFlag( treeCtrlFlags );
79 treebookSizer->Add(
m_treebook, 1, wxEXPAND|wxBOTTOM, 2 );
80 mainSizer->Add( treebookPanel, 1, wxEXPAND, 0 );
86 m_resetButton =
new wxButton(
this, wxID_ANY,
_(
"Reset to Defaults" ) );
98 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 );
184 wxString lastPage = wxEmptyString;
185 wxString lastParentPage = wxEmptyString;
189 if( selected != wxNOT_FOUND )
191 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
193 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
195 if( parent != wxNOT_FOUND )
196 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
223 if( !DIALOG_SHIM::TransferDataToWindow() )
229 int lastPageIndex = wxNOT_FOUND;
231 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
233 if(
m_treebook->GetPageText( i ) == lastPage )
235 if( lastParentPage.IsEmpty() )
250 lastPageIndex = std::max( 0, lastPageIndex );
295 m_infoBar->ShowMessageFor( aMessage, 10000, wxICON_WARNING );
297 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
299 textCtrl->SetSelection( -1, -1 );
300 textCtrl->SetFocus();
304 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
308 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
309 scintilla->GotoPos( pos );
312 scintilla->SetFocus();
316 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
319 grid->MakeCellVisible( aRow, aCol );
320 grid->SetGridCursor( aRow, aCol );
322 grid->EnableCellEditControl(
true );
323 grid->ShowCellEditControl();
360 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
361 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
362 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() )
363 ||
dynamic_cast<wxTreeCtrl*
>( aEvent.GetEventObject() )
364 ||
dynamic_cast<wxGrid*
>( FindFocus() ) )
370 if( aEvent.GetKeyCode() == WXK_UP )
376 wxWindow* prevPage =
m_treebook->GetPage( page - 1 );
378 if( !prevPage || prevPage->GetChildren().IsEmpty() )
379 m_treebook->SetSelection( std::max( page - 2, 0 ) );
386 else if( aEvent.GetKeyCode() == WXK_DOWN )
403 int sel =
event.GetSelection();
405 if( sel == wxNOT_FOUND )
408 size_t page =
static_cast<size_t>( sel );
413 wxWindow* currentPage =
m_treebook->GetCurrentPage();
415 if( currentPage && currentPage->GetChildren().IsEmpty()
427 SetMinSize( wxDefaultSize );
428 wxSize
minSize = GetBestSize();
429 minSize.IncTo( FromDIP( wxSize( 600, 500 ) ) );
430 minSize.DecTo( FromDIP( wxSize( 1500, 900 ) ) );
433 int displayIdx = wxDisplay::GetFromWindow(
this );
435 if( displayIdx == wxNOT_FOUND )
438 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
439 wxSize maxSize( std::max( 0, displayArea.width - FromDIP( 40 ) ),
440 std::max( 0, displayArea.height - FromDIP( 80 ) ) );
445 wxSize currentSize = GetSize();
446 wxSize newSize = currentSize;
449 if( newSize != currentSize )
457 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
461 m_treebook->GetPage( page )->SetSize( pageSize );
465 wxSizeEvent evt( wxDefaultSize );
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
virtual void onOpenPrefsDir(wxCommandEvent &aEvent)
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)
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)
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage