diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index 80f15cba8e..96c52ff0a5 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -36,48 +36,6 @@ std::map g_lastPage; std::map g_lastParentPage; -PAGED_TREEBOOK::PAGED_TREEBOOK( wxWindow* parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, const wxString& name ) - : wxTreebook( parent, id, pos, size, style, name ) -{ - GetTreeCtrl()->Bind( wxEVT_TREE_SEL_CHANGING, &PAGED_TREEBOOK::OnTreeSelChanging, this ); -} - - -void PAGED_TREEBOOK::OnTreeSelChanging( wxTreeEvent& aEvent ) -{ - wxTreeItemId pageId = aEvent.GetItem(); - - for( size_t i = 0; i < m_groupEntries.size(); ++i ) - { - if( m_groupEntries[i] == pageId ) - { - aEvent.Veto(); - - wxTreeItemIdValue cookie; - wxTreeItemId firstSubPage = GetTreeCtrl()->GetFirstChild( pageId, cookie ); - - if( firstSubPage.IsOk() ) - { - GetTreeCtrl()->SelectItem( firstSubPage, true ); - } - break; - } - } -} - - -bool PAGED_TREEBOOK::AddGroupEntry( const wxString& text, int imageId ) -{ - bool add = AddPage( new wxPanel(this), text, false, imageId ); - - wxTreeItemId newId = m_treeIds.back(); - m_groupEntries.push_back(newId); - - return add; -} - - PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUseReset, const wxString& aAuxiliaryAction ) : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize, @@ -95,7 +53,7 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUse m_infoBar = new WX_INFOBAR( this ); mainSizer->Add( m_infoBar, 0, wxEXPAND, 0 ); - m_treebook = new PAGED_TREEBOOK( this, wxID_ANY ); + m_treebook = new wxTreebook( this, wxID_ANY ); mainSizer->Add( m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 ); auto line = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); @@ -355,12 +313,20 @@ void PAGED_DIALOG::OnUpdateUI( wxUpdateUIEvent& event ) return; } } + + if( m_treebook->GetCurrentPage()->GetChildren().IsEmpty() ) + { + unsigned next = m_treebook->GetSelection() + 1; + + if( next < m_treebook->GetPageCount() ) + m_treebook->SetSelection( next ); + } } void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event ) { - int page = event.GetSelection(); + size_t page = event.GetSelection(); // Enable the reset button only if the page is resettable if( m_resetButton ) diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index 502323d980..fa1a43c4fd 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -63,15 +63,15 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : * WARNING: If you change page names you MUST update calls to ShowSchematicSetupDialog(). */ - m_treebook->AddGroupEntry( _( "General" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "General" ) ); m_treebook->AddSubPage( m_formatting, _( "Formatting" ) ); m_treebook->AddSubPage( m_fieldNameTemplates, _( "Field Name Templates" ) ); - m_treebook->AddGroupEntry( _( "Electrical Rules" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Electrical Rules" ) ); m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) ); m_treebook->AddSubPage( m_pinMap, _( "Pin Conflicts Map" ) ); - m_treebook->AddGroupEntry( _( "Project" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Project" ) ); m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 14249ed71c..f1616d535f 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -218,9 +218,9 @@ COLOR4D GetInvisibleItemColor() void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { - PAGED_TREEBOOK* book = aParent->GetTreebook(); + wxTreebook* book = aParent->GetTreebook(); - book->AddGroupEntry( _( "Eeschema" ) ); + book->AddPage( new wxPanel( book ), _( "Eeschema" ) ); book->AddSubPage( new PANEL_EESCHEMA_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); book->AddSubPage( new PANEL_EESCHEMA_SETTINGS( this, book ), _( "Editing Options" ) ); book->AddSubPage( new PANEL_EESCHEMA_COLOR_SETTINGS( this, book ), _( "Colors" ) ); @@ -422,9 +422,9 @@ void SCH_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { - PAGED_TREEBOOK* book = aParent->GetTreebook(); + wxTreebook* book = aParent->GetTreebook(); - book->AddGroupEntry( _( "Symbol Editor" ) ); + book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) ); book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_LIBEDIT_SETTINGS( this, book ), _( "Editing Options" ) ); book->AddSubPage( new PANEL_LIBEDIT_COLOR_SETTINGS( this, book ), _( "Colors" ) ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 0261a03fe5..c8d3cc2a1e 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -1136,9 +1136,9 @@ void GERBVIEW_FRAME::ActivateGalCanvas() void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { - PAGED_TREEBOOK* book = aParent->GetTreebook(); + wxTreebook* book = aParent->GetTreebook(); - book->AddGroupEntry( _( "Gerbview" ) ); + book->AddPage( new wxPanel( book ), _( "Gerbview" ) ); book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) ); diff --git a/include/widgets/paged_dialog.h b/include/widgets/paged_dialog.h index 2415a089c2..4f6bdd3ca0 100644 --- a/include/widgets/paged_dialog.h +++ b/include/widgets/paged_dialog.h @@ -28,22 +28,6 @@ class WX_INFOBAR; -class PAGED_TREEBOOK : public wxTreebook -{ -public: - PAGED_TREEBOOK( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBK_DEFAULT, - const wxString& name = wxEmptyString ); - - bool AddGroupEntry( const wxString& text, int imageId = NO_IMAGE ); - -protected: - void OnTreeSelChanging( wxTreeEvent& aEvent ); - - wxVector m_groupEntries; -}; - - class PAGED_DIALOG : public DIALOG_SHIM { private: @@ -63,7 +47,7 @@ public: const wxString& aAuxiliaryAction = wxEmptyString ); ~PAGED_DIALOG() override; - PAGED_TREEBOOK* GetTreebook() { return m_treebook; } + wxTreebook* GetTreebook() { return m_treebook; } void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString ); @@ -88,7 +72,7 @@ protected: void OnUpdateUI( wxUpdateUIEvent& event ); void OnPageChange( wxBookCtrlEvent& event ); - PAGED_TREEBOOK* m_treebook; + wxTreebook* m_treebook; wxButton* m_auxiliaryButton; wxButton* m_resetButton; wxButton* m_cancelButton; diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 18efa27868..be37716af5 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -68,23 +68,23 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : * WARNING: If you change page names you MUST update calls to ShowBoardSetupDialog(). */ - m_treebook->AddGroupEntry( _( "Board Stackup" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Board Stackup" ) ); m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) ); m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) ); // Change this value if m_physicalStackup is not the page 2 of m_treebook m_physicalStackupPage = 2; // The page number (from 0) to select the m_physicalStackup panel - m_treebook->AddGroupEntry( _( "Defaults" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Defaults" ) ); m_treebook->AddSubPage( m_textAndGraphics, _( "Text & Graphics" ) ); m_treebook->AddSubPage( m_tracksAndVias, _( "Tracks & Vias" ) ); m_treebook->AddSubPage( m_maskAndPaste, _( "Solder Mask/Paste" ) ); - m_treebook->AddGroupEntry( _( "Design Rules" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Design Rules" ) ); m_treebook->AddSubPage( m_constraints, _( "Constraints" ) ); m_treebook->AddSubPage( m_rules, _( "Rules" ) ); m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) ); - m_treebook->AddGroupEntry( _( "Project" ) ); + m_treebook->AddPage( new wxPanel( this ), _( "Project" ) ); m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 9358887fb5..47d3f4432f 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -865,9 +865,9 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & ) void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { - PAGED_TREEBOOK* book = aParent->GetTreebook(); + wxTreebook* book = aParent->GetTreebook(); - book->AddGroupEntry( _( "Footprint Editor" ) ); + book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) ); book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_MODEDIT_COLOR_SETTINGS( this, book ), _( "Colors" ) ); book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 3f3b4acd4c..fbc38dafca 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -57,9 +57,9 @@ void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event ) void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) { - PAGED_TREEBOOK* book = aParent->GetTreebook(); + wxTreebook* book = aParent->GetTreebook(); - book->AddGroupEntry( _( "Pcbnew" ) ); + book->AddPage( new wxPanel( book ), _( "Pcbnew" ) ); book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) ); book->AddSubPage( new PANEL_PCBNEW_COLOR_SETTINGS( this, book ), _( "Colors" ) );