diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0f1722b6bd..aebd48038a 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -172,12 +172,12 @@ set( COMMON_DLG_SRCS dialogs/panel_common_settings.cpp dialogs/panel_common_settings_base.cpp dialogs/panel_hotkeys_editor.cpp - dialogs/panel_hotkeys_editor_base.cpp dialogs/wx_html_report_panel.cpp dialogs/wx_html_report_panel_base.cpp ) set( COMMON_WIDGET_SRCS + widgets/button_row_panel.cpp widgets/color_swatch.cpp widgets/footprint_choice.cpp widgets/footprint_preview_widget.cpp diff --git a/common/dialogs/panel_hotkeys_editor.cpp b/common/dialogs/panel_hotkeys_editor.cpp index e747007771..48838f699c 100644 --- a/common/dialogs/panel_hotkeys_editor.cpp +++ b/common/dialogs/panel_hotkeys_editor.cpp @@ -21,24 +21,119 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include +#include + +#include +#include +#include +#include + +#include + + +static const wxSize default_dialog_size { 500, 350 }; +static const wxSize min_dialog_size { -1, 350 }; +static const int widget_margins = 5; +static const int side_margins = 10; + +/** + * Helper function to add a filter box to a panel, with some + * sensible defaults for that purpose. + * + * @param aParent The panrent widget/panel + * @param aDescriptiveText The text to show when the box is empty. + * @return A newly constructed filter box - the caller owns it + */ +static wxSearchCtrl* CreateTextFilterBox( wxWindow* aParent, const wxString& aDescriptiveText ) +{ + auto search_widget = new wxSearchCtrl( aParent, wxID_ANY ); + + search_widget->ShowSearchButton( false ); + search_widget->ShowCancelButton( true ); + + search_widget->SetDescriptiveText( aDescriptiveText); + + return search_widget; +} + PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys, const wxString& aNickname ) : - PANEL_HOTKEYS_EDITOR_BASE( aWindow ), + wxPanel( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ), m_frame( aFrame ), m_hotkeys( aHotkeys ), m_showHotkeys( aShowHotkeys ), m_nickname( aNickname ), m_hotkeyStore( aShowHotkeys ) { - m_filterSearch->SetDescriptiveText( _("Type filter text") ); + auto mainSizer = new wxBoxSizer( wxVERTICAL ); - m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, m_hotkeyStore ); - m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys ); + // Sub-sizer for setting a wider side margin + // TODO: Can this be set by the parent widget- doesn't seem to be + // this panel's responsibility? + auto bMargins = new wxBoxSizer( wxVERTICAL ); + + auto filterSearch = CreateTextFilterBox( this, _( "Type filter text" ) ); + bMargins->Add( filterSearch, 0, wxBOTTOM | wxEXPAND | wxTOP, widget_margins ); + + m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( this, m_hotkeyStore ); + bMargins->Add( m_hotkeyListCtrl, 1, wxALL | wxEXPAND, widget_margins ); + + installButtons( bMargins ); + + mainSizer->Add( bMargins, 1, wxEXPAND | wxRIGHT | wxLEFT, side_margins ); + + this->SetSizer( mainSizer ); + this->Layout(); + + // Connect Events + filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED, + &PANEL_HOTKEYS_EDITOR::OnFilterSearch, this ); +} + + +void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer ) +{ + const BUTTON_ROW_PANEL::BTN_DEF_LIST l_btn_defs = { + { + wxID_RESET, + _( "Reset Hotkeys" ), + [this]( wxCommandEvent ){ + m_hotkeyListCtrl->ResetAllHotkeys( false ); + } + }, + { + wxID_ANY, + _( "Set to Defaults" ), + [this]( wxCommandEvent ){ + m_hotkeyListCtrl->ResetAllHotkeys( true ); + } + } + }; + + const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = { + { + wxID_ANY, + _( "Import..." ), + [this]( wxCommandEvent ){ + m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname ); + } + }, + { + wxID_ANY, + _( "Export..." ), + [this]( wxCommandEvent ){ + m_frame->ExportHotkeyConfigToFile( m_hotkeys, m_nickname ); + } + }, + }; + + auto btnPanel = new BUTTON_ROW_PANEL( this, l_btn_defs, r_btn_defs ); + + aSizer->Add( btnPanel, 0, wxEXPAND | wxTOP, widget_margins ); } @@ -60,28 +155,6 @@ bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow() } -void PANEL_HOTKEYS_EDITOR::ResetClicked( wxCommandEvent& aEvent ) -{ - m_hotkeyListCtrl->ResetAllHotkeys( false ); -} - -void PANEL_HOTKEYS_EDITOR::DefaultsClicked( wxCommandEvent& aEvent ) -{ - m_hotkeyListCtrl->ResetAllHotkeys( true ); -} - - -void PANEL_HOTKEYS_EDITOR::OnExport( wxCommandEvent& aEvent ) -{ - m_frame->ExportHotkeyConfigToFile( m_hotkeys, m_nickname ); -} - - -void PANEL_HOTKEYS_EDITOR::OnImport( wxCommandEvent& aEvent ) -{ - m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname ); -} - void PANEL_HOTKEYS_EDITOR::OnFilterSearch( wxCommandEvent& aEvent ) { const auto searchStr = aEvent.GetString(); diff --git a/common/dialogs/panel_hotkeys_editor_base.cpp b/common/dialogs/panel_hotkeys_editor_base.cpp deleted file mode 100644 index 2f00fd549c..0000000000 --- a/common/dialogs/panel_hotkeys_editor_base.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 18 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "panel_hotkeys_editor_base.h" - -/////////////////////////////////////////////////////////////////////////// - -PANEL_HOTKEYS_EDITOR_BASE::PANEL_HOTKEYS_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) -{ - m_mainSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bMargins; - bMargins = new wxBoxSizer( wxVERTICAL ); - - m_filterSearch = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - #ifndef __WXMAC__ - m_filterSearch->ShowSearchButton( false ); - #endif - m_filterSearch->ShowCancelButton( true ); - bMargins->Add( m_filterSearch, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 ); - - m_panelHotkeys = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_panelHotkeys->SetMinSize( wxSize( -1,350 ) ); - - bMargins->Add( m_panelHotkeys, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 2 ); - - wxBoxSizer* b_buttonsSizer; - b_buttonsSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_resetButton = new wxButton( this, wxID_RESET, _("Reset Hotkeys"), wxDefaultPosition, wxDefaultSize, 0 ); - b_buttonsSizer->Add( m_resetButton, 0, wxEXPAND|wxTOP|wxRIGHT, 5 ); - - m_defaultButton = new wxButton( this, wxID_ANY, _("Set to Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); - b_buttonsSizer->Add( m_defaultButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - - b_buttonsSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - btnImport = new wxButton( this, wxID_ANY, _("Import..."), wxDefaultPosition, wxDefaultSize, 0 ); - b_buttonsSizer->Add( btnImport, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - btnExport = new wxButton( this, wxID_ANY, _("Export..."), wxDefaultPosition, wxDefaultSize, 0 ); - b_buttonsSizer->Add( btnExport, 0, wxTOP|wxLEFT, 5 ); - - - bMargins->Add( b_buttonsSizer, 0, wxEXPAND, 5 ); - - - m_mainSizer->Add( bMargins, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - - - this->SetSizer( m_mainSizer ); - this->Layout(); - - // Connect Events - m_filterSearch->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnFilterSearch ), NULL, this ); - m_resetButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::ResetClicked ), NULL, this ); - m_defaultButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::DefaultsClicked ), NULL, this ); - btnImport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnImport ), NULL, this ); - btnExport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnExport ), NULL, this ); -} - -PANEL_HOTKEYS_EDITOR_BASE::~PANEL_HOTKEYS_EDITOR_BASE() -{ - // Disconnect Events - m_filterSearch->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnFilterSearch ), NULL, this ); - m_resetButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::ResetClicked ), NULL, this ); - m_defaultButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::DefaultsClicked ), NULL, this ); - btnImport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnImport ), NULL, this ); - btnExport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_HOTKEYS_EDITOR_BASE::OnExport ), NULL, this ); - -} diff --git a/common/dialogs/panel_hotkeys_editor_base.fbp b/common/dialogs/panel_hotkeys_editor_base.fbp deleted file mode 100644 index f54a83ad67..0000000000 --- a/common/dialogs/panel_hotkeys_editor_base.fbp +++ /dev/null @@ -1,650 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - panel_hotkeys_editor_base - 1000 - none - - 1 - PanelHotkeysEditorBase - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - 1 - 1 - impl_virtual - - - 0 - wxID_ANY - - - PANEL_HOTKEYS_EDITOR_BASE - - 500,300 - ; forward_declare - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - m_mainSizer - wxHORIZONTAL - protected - - 10 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - - bMargins - wxVERTICAL - none - - 5 - wxBOTTOM|wxEXPAND|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - 1 - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_filterSearch - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnFilterSearch - - - - - - 2 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - -1,350 - 1 - m_panelHotkeys - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - b_buttonsSizer - wxHORIZONTAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_RESET - Reset Hotkeys - 0 - - 0 - - - 0 - - 1 - m_resetButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - ResetClicked - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Set to Defaults - 0 - - 0 - - - 0 - - 1 - m_defaultButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - DefaultsClicked - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Import... - 0 - - 0 - - - 0 - - 1 - btnImport - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnImport - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Export... - 0 - - 0 - - - 0 - - 1 - btnExport - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExport - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/common/dialogs/panel_hotkeys_editor_base.h b/common/dialogs/panel_hotkeys_editor_base.h deleted file mode 100644 index c199f8146c..0000000000 --- a/common/dialogs/panel_hotkeys_editor_base.h +++ /dev/null @@ -1,58 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 18 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __PANEL_HOTKEYS_EDITOR_BASE_H__ -#define __PANEL_HOTKEYS_EDITOR_BASE_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class PANEL_HOTKEYS_EDITOR_BASE -/////////////////////////////////////////////////////////////////////////////// -class PANEL_HOTKEYS_EDITOR_BASE : public wxPanel -{ - private: - - protected: - wxBoxSizer* m_mainSizer; - wxSearchCtrl* m_filterSearch; - wxPanel* m_panelHotkeys; - wxButton* m_resetButton; - wxButton* m_defaultButton; - wxButton* btnImport; - wxButton* btnExport; - - // Virtual event handlers, overide them in your derived class - virtual void OnFilterSearch( wxCommandEvent& event ) { event.Skip(); } - virtual void ResetClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void DefaultsClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void OnImport( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExport( wxCommandEvent& event ) { event.Skip(); } - - - public: - - PANEL_HOTKEYS_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); - ~PANEL_HOTKEYS_EDITOR_BASE(); - -}; - -#endif //__PANEL_HOTKEYS_EDITOR_BASE_H__ diff --git a/common/widgets/button_row_panel.cpp b/common/widgets/button_row_panel.cpp new file mode 100644 index 0000000000..a4ca5f508a --- /dev/null +++ b/common/widgets/button_row_panel.cpp @@ -0,0 +1,75 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#include +#include + + +BUTTON_ROW_PANEL::BUTTON_ROW_PANEL( wxWindow* aWindow, + const BTN_DEF_LIST& aLeftBtns, + const BTN_DEF_LIST& aRightBtns ): + wxPanel( aWindow, wxID_ANY ) +{ + m_sizer = new wxBoxSizer( wxHORIZONTAL ); + + addButtons( true, aLeftBtns ); + + // add the spacer + m_sizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + addButtons( false, aRightBtns ); + + this->SetSizer( m_sizer ); + this->Layout(); +} + + +void BUTTON_ROW_PANEL::addButtons( bool aLeft, const BTN_DEF_LIST& aDefs ) +{ + // The "normal" KiCad margin magic number + // TODO: Get this from somewhere + const int btn_margin = 5; + // No button expands to fill horizontally + const int btn_proportion = 0; + + for( size_t i = 0; i < aDefs.size(); ++i ) + { + const auto& def = aDefs[i]; + wxButton* btn = new wxButton( this, def.m_id, def.m_text ); + + // Buttons expand to fill the size vertically + long this_style = wxEXPAND; + + if( ( aLeft && i > 0 ) || ( !aLeft ) ) + this_style |= wxLEFT; + + if( ( aLeft ) || ( !aLeft && i < aDefs.size() - 1 ) ) + this_style |= wxRIGHT; + + m_sizer->Add( btn, btn_proportion, this_style, btn_margin ); + + btn->Bind( wxEVT_COMMAND_BUTTON_CLICKED, def.m_callback ); + } +} \ No newline at end of file diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index cb7f31def7..122bd46ad0 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -51,9 +51,6 @@ enum ID_WHKL_MENU_IDS }; - - - /** * Class WIDGET_HOTKEY_CLIENT_DATA * Stores the hotkey change data associated with each row. To change a @@ -524,15 +521,6 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkey } -void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel ) -{ - wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); - - sizer->Add( this, 1, wxALL | wxEXPAND, 0 ); - aPanel->SetSizer( sizer ); -} - - void WIDGET_HOTKEY_LIST::ApplyFilterString( const wxString& aFilterStr ) { updateShownItems( aFilterStr ); diff --git a/include/panel_hotkeys_editor.h b/include/panel_hotkeys_editor.h index fd4776c494..b4cc78302c 100644 --- a/include/panel_hotkeys_editor.h +++ b/include/panel_hotkeys_editor.h @@ -27,11 +27,16 @@ #include #include -#include "../common/dialogs/panel_hotkeys_editor_base.h" #include +#include "wx/panel.h" -class PANEL_HOTKEYS_EDITOR : public PANEL_HOTKEYS_EDITOR_BASE + +class wxPanel; +class wxSizer; + + +class PANEL_HOTKEYS_EDITOR : public wxPanel { protected: EDA_BASE_FRAME* m_frame; @@ -50,28 +55,13 @@ public: EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys, const wxString& aNickname ); - ~PANEL_HOTKEYS_EDITOR() {}; - private: /** - * Function ResetClicked - * Reinit the hotkeys to the initial state (removes all pending changes) - * - * @param aEvent is the button press event, unused + * Install the button panel (global reset/default, import/export) + * @param aSizer the dialog to install on */ - void ResetClicked( wxCommandEvent& aEvent ) override; - - /** - * Function DefaultsClicked - * Set the hotkeys to the default values (values after installation) - * - * @param aEvent is the button press event, unused - */ - void DefaultsClicked( wxCommandEvent& aEvent ) override; - - void OnExport( wxCommandEvent& aEvent ) override; - void OnImport( wxCommandEvent& aEvent ) override; + void installButtons( wxSizer* aSizer ); /** * Function OnFilterSearch @@ -79,7 +69,7 @@ private: * * @param aEvent: the search event, used to get the search query */ - void OnFilterSearch( wxCommandEvent& aEvent ) override; + void OnFilterSearch( wxCommandEvent& aEvent ); }; diff --git a/include/widgets/button_row_panel.h b/include/widgets/button_row_panel.h new file mode 100644 index 0000000000..8abfe834ab --- /dev/null +++ b/include/widgets/button_row_panel.h @@ -0,0 +1,102 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef SIMPLE_BUTTON_PANEL_H +#define SIMPLE_BUTTON_PANEL_H + +#include "wx/panel.h" + +#include +#include + + +// Forward defs for private-only classes +class wxBoxSizer; + + +/** + * A panel that contains buttons, arranged on the left and/or right sides. + */ +class BUTTON_ROW_PANEL: public wxPanel +{ +public: + + /** + * Callback function definition. A callback of this type can be registered + * to handle the button click event. + */ + using BTN_CALLBACK = std::function< void( wxCommandEvent& ) >; + + /** + * The information needed to instantiate a button on a BUTTON_ROW_PANEL. + */ + struct BTN_DEF + { + /** + * The button ID. Can be wxID_ANY, but should be unique if you + * want to work out which button this was from an event handler. + */ + wxWindowID m_id; + + /** + * The button display text. + */ + wxString m_text; + + /** + * The callback fired when the button is clicked. Can be nullptr, + * but then the button is useless. + */ + BTN_CALLBACK m_callback; + }; + + /** + * A list of BTN_DEFs, used to group buttons into the left/right groups. + */ + using BTN_DEF_LIST = std::vector; + + /** + * Construct a SIMPLE_BUTTON_PANEL with a set of buttons on each side. + * + * @param aLeftBtns: buttons on the left side, from left to right + * @param aRightBtns: buttons on the right side, from left to right + */ + BUTTON_ROW_PANEL( wxWindow* aWindow, + const BTN_DEF_LIST& aLeftBtns, + const BTN_DEF_LIST& aRightBtns ); + +private: + + /** + * Add a set of buttons to one side of the panel. + * + * @param aSizer the sizer to add them to + * @param aLeft place on the left (false for right) + * @param aDefs list of button defs, from left to right + */ + void addButtons( bool aLeft, const BTN_DEF_LIST& aDefs ); + + wxBoxSizer* m_sizer; +}; + +#endif // SIMPLE_BUTTON_PANEL_H \ No newline at end of file diff --git a/include/widgets/widget_hotkey_list.h b/include/widgets/widget_hotkey_list.h index 2e728d3c89..413ab5bb0a 100644 --- a/include/widgets/widget_hotkey_list.h +++ b/include/widgets/widget_hotkey_list.h @@ -166,14 +166,6 @@ public: */ WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore ); - /** - * 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 ApplyFilterString * Apply a filter string to the hotkey list, selecting which hotkeys