From 4dad12794ac075678bb84fa9853996e7dc498c32 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Fri, 15 Jan 2016 20:58:39 -0500 Subject: [PATCH] Add and use WIDGET_HOTKEY_LIST::InstallOnPanel --- common/dialogs/dialog_hotkeys_editor.cpp | 8 +- common/dialogs/dialog_hotkeys_editor_base.cpp | 5 +- common/dialogs/dialog_hotkeys_editor_base.fbp | 82 ++++++- common/dialogs/dialog_hotkeys_editor_base.h | 2 + common/widgets/widget_hotkey_list.cpp | 8 + eeschema/dialogs/dialog_eeschema_options.cpp | 5 +- .../dialogs/dialog_eeschema_options_base.cpp | 19 +- .../dialogs/dialog_eeschema_options_base.fbp | 206 ++++++++++++++++-- .../dialogs/dialog_eeschema_options_base.h | 2 + include/widgets/widget_hotkey_list.h | 8 + 10 files changed, 318 insertions(+), 27 deletions(-) diff --git a/common/dialogs/dialog_hotkeys_editor.cpp b/common/dialogs/dialog_hotkeys_editor.cpp index df1ce23002..cc025ffe13 100644 --- a/common/dialogs/dialog_hotkeys_editor.cpp +++ b/common/dialogs/dialog_hotkeys_editor.cpp @@ -41,11 +41,13 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, HOTKEYS_EDITOR_DIALOG_BASE( aParent ), m_hotkeys( aHotkeys ) { - m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( this, WIDGET_HOTKEY_LIST::GenSections( aHotkeys ) ); - m_mainSizer->Insert( 1, m_hotkeyListCtrl, wxSizerFlags( 1 ).Expand().Border( wxALL, 5 ) ); - Layout(); + m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, + WIDGET_HOTKEY_LIST::GenSections( aHotkeys ) ); + m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys ); m_sdbSizerOK->SetDefault(); + + Layout(); Center(); } diff --git a/common/dialogs/dialog_hotkeys_editor_base.cpp b/common/dialogs/dialog_hotkeys_editor_base.cpp index 1293cb4b95..5373ac504a 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.cpp +++ b/common/dialogs/dialog_hotkeys_editor_base.cpp @@ -15,10 +15,13 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind m_mainSizer = new wxBoxSizer( wxVERTICAL ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("Select a row and press a new key combination to alter the binding."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1 = new wxStaticText( this, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( 400 ); m_mainSizer->Add( m_staticText1, 0, wxALL|wxEXPAND, 5 ); + m_panelHotkeys = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_mainSizer->Add( m_panelHotkeys, 1, wxEXPAND | wxALL, 5 ); + wxBoxSizer* b_buttonsSizer; b_buttonsSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/common/dialogs/dialog_hotkeys_editor_base.fbp b/common/dialogs/dialog_hotkeys_editor_base.fbp index 814b3acc7b..6a096faede 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.fbp +++ b/common/dialogs/dialog_hotkeys_editor_base.fbp @@ -125,7 +125,7 @@ 0 0 wxID_ANY - Select a row and press a new key combination to alter the binding. + Double-click to edit 0 @@ -176,6 +176,86 @@ + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelHotkeys + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALIGN_RIGHT|wxEXPAND diff --git a/common/dialogs/dialog_hotkeys_editor_base.h b/common/dialogs/dialog_hotkeys_editor_base.h index 9c58421872..a59f560d4f 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.h +++ b/common/dialogs/dialog_hotkeys_editor_base.h @@ -20,6 +20,7 @@ class DIALOG_SHIM; #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM protected: wxBoxSizer* m_mainSizer; wxStaticText* m_staticText1; + wxPanel* m_panelHotkeys; wxButton* m_resetButton; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 2d3109af87..fcfb84a6bc 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -400,6 +400,14 @@ HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys ) } +void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel ) +{ + wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); + sizer->Add( this, 1, wxALL | wxEXPAND, 0 ); + aPanel->SetSizer( sizer ); +} + + bool WIDGET_HOTKEY_LIST::TransferDataToControl() { Freeze(); diff --git a/eeschema/dialogs/dialog_eeschema_options.cpp b/eeschema/dialogs/dialog_eeschema_options.cpp index cf42ab9f42..44ee0b317a 100644 --- a/eeschema/dialogs/dialog_eeschema_options.cpp +++ b/eeschema/dialogs/dialog_eeschema_options.cpp @@ -66,9 +66,8 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) : // Embed the hotkeys list HOTKEY_SECTIONS sections = WIDGET_HOTKEY_LIST::GenSections( g_Eeschema_Hokeys_Descr ); - m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_controlsPanel, sections ); - // Insert after the "Hotkeys:" label - m_controlsSizer->Insert( 1, m_hotkeyListCtrl, wxSizerFlags( 1 ).Expand().Border( wxALL, 5 ) ); + m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, sections ); + m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys ); // Bind event for the import/export menu Bind( wxEVT_MENU, &DIALOG_EESCHEMA_OPTIONS::OnMenu, this ); diff --git a/eeschema/dialogs/dialog_eeschema_options_base.cpp b/eeschema/dialogs/dialog_eeschema_options_base.cpp index 14477efa80..58a0a1a6b0 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.cpp +++ b/eeschema/dialogs/dialog_eeschema_options_base.cpp @@ -251,9 +251,22 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_controlsSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer13; + bSizer13 = new wxBoxSizer( wxHORIZONTAL ); + m_staticText20 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Hotkeys:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText20->Wrap( -1 ); - m_controlsSizer->Add( m_staticText20, 0, wxALL, 5 ); + bSizer13->Add( m_staticText20, 1, wxALL, 5 ); + + m_staticText21 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText21->Wrap( -1 ); + bSizer13->Add( m_staticText21, 0, wxALL, 5 ); + + + m_controlsSizer->Add( bSizer13, 0, wxEXPAND, 5 ); + + m_panelHotkeys = new wxPanel( m_controlsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_controlsSizer->Add( m_panelHotkeys, 1, wxEXPAND | wxALL, 5 ); m_checkEnableZoomCenter = new wxCheckBox( m_controlsPanel, wxID_ANY, _("Cen&ter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkEnableZoomCenter->SetToolTip( _("Keep the cursor at its current location when zooming") ); @@ -280,7 +293,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_controlsPanel->SetSizer( bSizer81 ); m_controlsPanel->Layout(); bSizer81->Fit( m_controlsPanel ); - m_notebook->AddPage( m_controlsPanel, _("Co&ntrols"), false ); + m_notebook->AddPage( m_controlsPanel, _("Co&ntrols"), true ); m_panel2 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel2->SetToolTip( _("User defined field names for schematic components. ") ); @@ -346,7 +359,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_panel2->SetSizer( bSizer6 ); m_panel2->Layout(); bSizer6->Fit( m_panel2 ); - m_notebook->AddPage( m_panel2, _("Default &Fields"), true ); + m_notebook->AddPage( m_panel2, _("Default &Fields"), false ); bOptionsSizer->Add( m_notebook, 1, wxALL|wxEXPAND, 5 ); diff --git a/eeschema/dialogs/dialog_eeschema_options_base.fbp b/eeschema/dialogs/dialog_eeschema_options_base.fbp index 4e6d1131e2..f26458387c 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.fbp +++ b/eeschema/dialogs/dialog_eeschema_options_base.fbp @@ -106,7 +106,7 @@ 5 wxALL|wxEXPAND 1 - + 1 1 1 @@ -3767,11 +3767,11 @@ - + Co&ntrols - 0 - + 1 + 1 1 1 @@ -3845,7 +3845,7 @@ - + bSizer81 wxVERTICAL @@ -3868,20 +3868,197 @@ 0 - + 5 wxALL|wxEXPAND 1 - + m_controlsSizer wxVERTICAL protected - + 5 - wxALL + wxEXPAND 0 - + + + bSizer13 + wxHORIZONTAL + none + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Hotkeys: + + 0 + + + 0 + + 1 + m_staticText20 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Double-click to edit + + 0 + + + 0 + + 1 + m_staticText21 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 1 + 1 1 1 @@ -3909,7 +4086,6 @@ 0 0 wxID_ANY - Hotkeys: 0 @@ -3917,7 +4093,7 @@ 0 1 - m_staticText20 + m_panelHotkeys 1 @@ -3927,14 +4103,12 @@ Resizable 1 - 0 - - -1 + wxTAB_TRAVERSAL @@ -4320,7 +4494,7 @@ Default &Fields - 1 + 0 1 1 diff --git a/eeschema/dialogs/dialog_eeschema_options_base.h b/eeschema/dialogs/dialog_eeschema_options_base.h index c55066cc16..3274499ff6 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.h +++ b/eeschema/dialogs/dialog_eeschema_options_base.h @@ -108,6 +108,8 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM wxPanel* m_controlsPanel; wxBoxSizer* m_controlsSizer; wxStaticText* m_staticText20; + wxStaticText* m_staticText21; + wxPanel* m_panelHotkeys; wxCheckBox* m_checkEnableZoomCenter; wxCheckBox* m_checkEnableMiddleButtonPan; wxCheckBox* m_checkMiddleButtonPanLimited; diff --git a/include/widgets/widget_hotkey_list.h b/include/widgets/widget_hotkey_list.h index d851111786..0c9de1ed2c 100644 --- a/include/widgets/widget_hotkey_list.h +++ b/include/widgets/widget_hotkey_list.h @@ -150,6 +150,14 @@ public: */ static HOTKEY_SECTIONS GenSections( EDA_HOTKEY_CONFIG* aHotkeys ); + /** + * Method InstallOnPanel + * Install this WIDGET_HOTKEY_LIST onto an empty panel. This is useful + * when combining with wxFormBuilder, as an empty panel can be left as a + * placeholder in the layout. + */ + void InstallOnPanel( wxPanel* aPanel ); + /** * Method TransferDataToControl * Load the hotkey data into the control. It is safe to call this multiple times,