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 );
186 wxString lastPage = wxEmptyString;
187 wxString lastParentPage = wxEmptyString;
191 if( selected != wxNOT_FOUND )
193 lastPage =
m_treebook->GetPageText( (
unsigned) selected );
195 int parent =
m_treebook->GetPageParent( (
unsigned) selected );
197 if( parent != wxNOT_FOUND )
198 lastParentPage =
m_treebook->GetPageText( (
unsigned) parent );
227 if( !DIALOG_SHIM::TransferDataToWindow() )
233 int lastPageIndex = wxNOT_FOUND;
235 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
237 if(
m_treebook->GetPageText( i ) == lastPage )
239 if( lastParentPage.IsEmpty() )
254 lastPageIndex = std::max( 0, lastPageIndex );
319 m_infoBar->ShowMessageFor( aMessage, 10000, wxICON_WARNING );
321 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
323 textCtrl->SetSelection( -1, -1 );
324 textCtrl->SetFocus();
328 if( wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aCtrl ) )
332 int pos = scintilla->PositionFromLine( aRow - 1 ) + ( aCol - 1 );
333 scintilla->GotoPos( pos );
336 scintilla->SetFocus();
340 if( wxGrid*
grid =
dynamic_cast<wxGrid*
>( aCtrl ) )
343 grid->MakeCellVisible( aRow, aCol );
344 grid->SetGridCursor( aRow, aCol );
346 grid->EnableCellEditControl(
true );
347 grid->ShowCellEditControl();
384 if(
dynamic_cast<wxTextEntry*
>( aEvent.GetEventObject() )
385 ||
dynamic_cast<wxStyledTextCtrl*
>( aEvent.GetEventObject() )
386 ||
dynamic_cast<wxListView*
>( aEvent.GetEventObject() )
387 ||
dynamic_cast<wxTreeCtrl*
>( aEvent.GetEventObject() )
388 ||
dynamic_cast<wxGrid*
>( FindFocus() ) )
394 if( aEvent.GetKeyCode() == WXK_UP )
400 wxWindow* prevPage =
m_treebook->GetPage( page - 1 );
402 if( !prevPage || prevPage->GetChildren().IsEmpty() )
403 m_treebook->SetSelection( std::max( page - 2, 0 ) );
410 else if( aEvent.GetKeyCode() == WXK_DOWN )
431 wxTreeItemId item = tree->HitTest( aEvent.GetPosition(), flags );
437 if( item.IsOk() && ( flags & wxTREE_HITTEST_ONITEMLABEL ) && !tree->IsExpanded( item )
438 && tree->ItemHasChildren( item ) )
440 tree->Expand( item );
445 if( tree->GetSelection() == item )
452 wxWindow* current =
m_treebook->GetCurrentPage();
454 if(
m_treebook->GetSelection() == page && current && current->GetChildren().IsEmpty()
480 int sel =
event.GetSelection();
482 if( sel == wxNOT_FOUND )
485 size_t page =
static_cast<size_t>( sel );
490 wxWindow* currentPage =
m_treebook->GetCurrentPage();
492 if( currentPage && currentPage->GetChildren().IsEmpty()
506 SetMinSize( wxDefaultSize );
507 wxSize
minSize = GetBestSize();
508 minSize.IncTo( FromDIP( wxSize( 600, 500 ) ) );
509 minSize.DecTo( FromDIP( wxSize( 1500, 900 ) ) );
512 int displayIdx = wxDisplay::GetFromWindow(
this );
514 if( displayIdx == wxNOT_FOUND )
517 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
518 wxSize maxSize( std::max( 0, displayArea.width - FromDIP( 40 ) ),
519 std::max( 0, displayArea.height - FromDIP( 80 ) ) );
524 wxSize currentSize = GetSize();
525 wxSize newSize = currentSize;
528 if( newSize != currentSize )
536 wxSize pageSize =
m_treebook->GetPage( page )->GetSize();
540 m_treebook->GetPage( page )->SetSize( pageSize );
544 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)
wxTreeItemId m_clickExpandedItem
void onTreeItemActivated(wxTreeEvent &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
void onTreeLeftDown(wxMouseEvent &aEvent)
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)
wxWindow * ShowPage(const wxString &aTitle)
Select the page with the given title.
std::map< wxString, wxString > g_lastPage
std::map< wxString, wxString > g_lastParentPage