KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
toolbars_cvpcb.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <toolbars_cvpcb.h>
23
24#include <tool/action_toolbar.h>
25#include <tool/actions.h>
26
27#include <cvpcb_id.h>
28#include <cvpcb_mainframe.h>
29#include <tools/cvpcb_actions.h>
30#include <wx/stattext.h>
31
33
34
35std::optional<TOOLBAR_CONFIGURATION> CVPCB_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
36{
38
39 // clang-format off
40 switch( aToolbar )
41 {
42 case TOOLBAR_LOC::LEFT:
43 case TOOLBAR_LOC::RIGHT:
44 case TOOLBAR_LOC::TOP_AUX:
45 return std::nullopt;
46
47 case TOOLBAR_LOC::TOP_MAIN:
49
50 config.AppendSeparator()
51 .AppendAction( ACTIONS::showFootprintLibTable );
52
53 config.AppendSeparator()
55
56 config.AppendSeparator()
57 .AppendAction( CVPCB_ACTIONS::gotoPreviousNA )
58 .AppendAction( CVPCB_ACTIONS::gotoNextNA );
59
60 config.AppendSeparator()
61 .AppendAction( ACTIONS::undo )
62 .AppendAction( ACTIONS::redo )
63 .AppendAction( CVPCB_ACTIONS::autoAssociate )
64 .AppendAction( CVPCB_ACTIONS::deleteAll );
65
66 // Add tools for footprint names filtering:
67 config.AppendSeparator()
68 .AppendSpacer( 15 )
70 break;
71 }
72
73 // clang-format on
74 return config;
75}
76
77
79{
81
82 auto footprintFilterFactory =
83 [this]( ACTION_TOOLBAR* aToolbar )
84 {
85
86 // wxGTK with GTK3 has a serious issue with bold texts: strings are incorrectly sized
87 // and truncated after the first space.
88 // so use SetLabelMarkup is a trick to fix this issue.
89 wxString msg_bold = _( "Footprint Filters:" );
90 wxStaticText* text = new wxStaticText( m_tbTopMain, wxID_ANY, msg_bold );
91 text->SetFont( m_tbTopMain->GetFont().Bold() );
92
93 #ifdef __WXGTK3__
94 text->SetLabelMarkup( "<b>" + msg_bold + "</b>" );
95 #endif
96
97 aToolbar->AddControl( text );
98
100 aToolbar->Add( CVPCB_ACTIONS::filterFPbyPin );
101 aToolbar->Add( CVPCB_ACTIONS::FilterFPbyLibrary );
102
103 aToolbar->AddScaledSeparator( this );
104
105 if( !m_tcFilterString )
106 {
107 m_tcFilterString = new wxTextCtrl( aToolbar, wxID_ANY, wxEmptyString, wxDefaultPosition,
108 wxDefaultSize, wxTE_PROCESS_ENTER );
109 }
110
111 // Min size on Mac is (a not very useful) single character
112 m_tcFilterString->SetMinSize( wxSize( 150, -1 ) );
113 m_tcFilterString->Bind( wxEVT_TEXT_ENTER, &CVPCB_MAINFRAME::onTextFilterChanged, this );
114
115 aToolbar->AddControl( m_tcFilterString );
116 };
117
119}
120
121
122ACTION_TOOLBAR_CONTROL CVPCB_ACTION_TOOLBAR_CONTROLS::footprintFilter( "control.FootprintFilters", _( "Footprint filters" ),
123 _( "Footprint filtering controls" ) );
static TOOL_ACTION showFootprintLibTable
Definition: actions.h:234
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION redo
Definition: actions.h:69
Class to hold basic information about controls that can be added to the toolbars.
Define the structure of a toolbar with buttons that invoke ACTIONs.
static TOOL_ACTION deleteAll
Definition: cvpcb_actions.h:63
static TOOL_ACTION gotoPreviousNA
Navigate the component tree.
Definition: cvpcb_actions.h:52
static TOOL_ACTION gotoNextNA
Definition: cvpcb_actions.h:53
static TOOL_ACTION FilterFPbyLibrary
Definition: cvpcb_actions.h:69
static TOOL_ACTION filterFPbyPin
Definition: cvpcb_actions.h:68
static TOOL_ACTION autoAssociate
Footprint Association actions.
Definition: cvpcb_actions.h:61
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
Definition: cvpcb_actions.h:67
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
Definition: cvpcb_actions.h:56
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
Definition: cvpcb_actions.h:49
static ACTION_TOOLBAR_CONTROL footprintFilter
void onTextFilterChanged(wxCommandEvent &event)
void configureToolbars() override
wxTextCtrl * m_tcFilterString
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
virtual void configureToolbars()
ACTION_TOOLBAR * m_tbTopMain
#define _(s)