KiCad PCB EDA Suite
PANEL_KICAD_LAUNCHER Class Reference

#include <panel_kicad_launcher.h>

Inheritance diagram for PANEL_KICAD_LAUNCHER:
PANEL_KICAD_LAUNCHER_BASE

Public Member Functions

 PANEL_KICAD_LAUNCHER (wxWindow *aParent)
 
virtual ~PANEL_KICAD_LAUNCHER ()=default
 
void CreateLaunchers ()
 

Protected Attributes

wxBoxSizer * m_mainSizer
 
wxGridBagSizer * m_toolsSizer
 

Private Member Functions

void onThemeChanged (wxSysColourChangedEvent &aEvent)
 

Private Attributes

TOOL_MANAGERm_toolManager
 

Detailed Description

Definition at line 27 of file panel_kicad_launcher.h.

Constructor & Destructor Documentation

◆ PANEL_KICAD_LAUNCHER()

PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER ( wxWindow *  aParent)

Definition at line 31 of file panel_kicad_launcher.cpp.

31  :
32  PANEL_KICAD_LAUNCHER_BASE( aParent )
33 {
34  m_toolManager = static_cast<KICAD_MANAGER_FRAME*>( aParent )->GetToolManager();
36 
37  Bind( wxEVT_SYS_COLOUR_CHANGED,
38  wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ), this );
39 }
TOOL_MANAGER * m_toolManager
PANEL_KICAD_LAUNCHER_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void onThemeChanged(wxSysColourChangedEvent &aEvent)

References CreateLaunchers(), m_toolManager, and onThemeChanged().

◆ ~PANEL_KICAD_LAUNCHER()

virtual PANEL_KICAD_LAUNCHER::~PANEL_KICAD_LAUNCHER ( )
virtualdefault

Member Function Documentation

◆ CreateLaunchers()

void PANEL_KICAD_LAUNCHER::CreateLaunchers ( )

Definition at line 42 of file panel_kicad_launcher.cpp.

43 {
44  if( m_toolsSizer->GetRows() > 0 )
45  {
46  m_toolsSizer->Clear( true );
47  m_toolsSizer->SetRows( 0 );
48  }
49 
50  wxFont titleFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
51 #ifndef __WXGTK__
52  titleFont.SetPointSize( titleFont.GetPointSize() + 2 );
53 #endif
54  titleFont.SetWeight( wxFONTWEIGHT_BOLD );
55 
56  wxFont helpFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
57  helpFont.SetStyle( wxFONTSTYLE_ITALIC );
58 
59  auto addLauncher =
60  [&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText )
61  {
62  BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY );
63  btn->SetBitmap( aBitmap );
64  btn->SetPadding( 5 );
65  btn->SetToolTip( aAction.GetDescription() );
66 
67  auto handler =
68  [&]( wxEvent& aEvent )
69  {
70  // Defocus the button because leaving the large buttons
71  // focused after a click looks out of place in the launcher
72  GetParent()->SetFocus();
73 
74  OPT_TOOL_EVENT evt = aAction.MakeEvent();
75  evt->SetHasPosition( false );
76  m_toolManager->ProcessEvent( *evt );
77  };
78 
79  wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
80  wxStaticText* help;
81 
82  label->SetToolTip( aAction.GetDescription() );
83  label->SetFont( titleFont );
84 
85  help = new wxStaticText( this, wxID_ANY, aHelpText );
86  help->SetFont( helpFont );
87 
88  btn->Bind( wxEVT_BUTTON, handler );
89 
90  // The bug fix below makes this handler active for the entire window width. Without
91  // any visual feedback that's a bit odd. Disabling for now.
92  // label->Bind( wxEVT_LEFT_UP, handler );
93 
94  int row = m_toolsSizer->GetRows();
95 
96  m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( 2, 1 ), wxBOTTOM, 12 );
97 
98  // Due to https://trac.wxwidgets.org/ticket/16088?cversion=0&cnum_hist=7 GTK fails to
99  // correctly set the BestSize of non-default-size or styled text so we need to make
100  // sure that the BestSize isn't needed by setting wxEXPAND. Unfortunately this makes
101  // wxALIGN_BOTTOM non-functional, so we have to jump through a bunch more hoops to
102  // try and align the title and help text in the middle of the icon.
103  m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ),
104  wxTOP | wxEXPAND, 10 );
105 
106  m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ),
107  wxALIGN_TOP | wxTOP, 1 );
108  };
109 
111  KiScaledBitmap( BITMAPS::icon_eeschema, this, 48, true ),
112  _( "Edit the project schematic" ) );
113 
115  KiScaledBitmap( BITMAPS::icon_libedit, this, 48, true ),
116  _( "Edit global and/or project schematic symbol libraries" ) );
117 
118  addLauncher( KICAD_MANAGER_ACTIONS::editPCB,
119  KiScaledBitmap( BITMAPS::icon_pcbnew, this, 48, true ),
120  _( "Edit the project PCB design" ) );
121 
123  KiScaledBitmap( BITMAPS::icon_modedit, this, 48, true ),
124  _( "Edit global and/or project PCB footprint libraries" ) );
125 
127  KiScaledBitmap( BITMAPS::icon_gerbview, this, 48, true ),
128  _( "Preview Gerber files" ) );
129 
132  _( "Convert bitmap images to schematic symbols or PCB footprints" ) );
133 
135  KiScaledBitmap( BITMAPS::icon_pcbcalculator, this, 48, true ),
136  _( "Show tools for calculating resistance, current capacity, etc." ) );
137 
140  _( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
141  "designs" ) );
142 
143 #ifdef PCM
144  addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager,
145  KiScaledBitmap( BITMAPS::icon_pcm, this, 48, true ),
146  _( "Manage downloadable packages from KiCad and 3rd party repositories" ) );
147 #endif
148 
149  Layout();
150 }
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:39
TOOL_MANAGER * m_toolManager
static TOOL_ACTION showCalculator
static TOOL_ACTION viewGerbers
static TOOL_ACTION convertImage
static TOOL_ACTION editSchematic
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void SetPadding(int aPadding)
Set the amount of padding present on each side of the bitmap.
static TOOL_ACTION editFootprints
#define _(s)
wxString GetDescription(bool aIncludeHotkey=true) const
Definition: tool_action.cpp:97
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:148
wxString GetLabel() const
Definition: tool_action.cpp:83
static TOOL_ACTION editPCB
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
Represent a single user action.
Definition: tool_action.h:67
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
static TOOL_ACTION editSymbols
void SetHasPosition(bool aHasPosition)
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:241
static TOOL_ACTION editDrawingSheet
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:548

References _, KICAD_MANAGER_ACTIONS::convertImage, KICAD_MANAGER_ACTIONS::editDrawingSheet, KICAD_MANAGER_ACTIONS::editFootprints, KICAD_MANAGER_ACTIONS::editPCB, KICAD_MANAGER_ACTIONS::editSchematic, KICAD_MANAGER_ACTIONS::editSymbols, TOOL_ACTION::GetDescription(), TOOL_ACTION::GetLabel(), help, icon_bitmap2component, icon_eeschema, icon_gerbview, icon_libedit, icon_modedit, icon_pagelayout_editor, icon_pcbcalculator, icon_pcbnew, icon_pcm, KiScaledBitmap(), m_toolManager, PANEL_KICAD_LAUNCHER_BASE::m_toolsSizer, TOOL_ACTION::MakeEvent(), TOOL_MANAGER::ProcessEvent(), BITMAP_BUTTON::SetBitmap(), TOOL_EVENT::SetHasPosition(), BITMAP_BUTTON::SetPadding(), KICAD_MANAGER_ACTIONS::showCalculator, and KICAD_MANAGER_ACTIONS::viewGerbers.

Referenced by onThemeChanged(), PANEL_KICAD_LAUNCHER(), and KICAD_MANAGER_FRAME::ShowChangedLanguage().

◆ onThemeChanged()

void PANEL_KICAD_LAUNCHER::onThemeChanged ( wxSysColourChangedEvent &  aEvent)
private

Definition at line 153 of file panel_kicad_launcher.cpp.

154 {
156  CreateLaunchers();
157 
158  aEvent.Skip();
159 }
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
BITMAP_STORE * GetBitmapStore()
Definition: bitmap.cpp:93

References CreateLaunchers(), GetBitmapStore(), and BITMAP_STORE::ThemeChanged().

Referenced by PANEL_KICAD_LAUNCHER().

Member Data Documentation

◆ m_mainSizer

wxBoxSizer* PANEL_KICAD_LAUNCHER_BASE::m_mainSizer
protectedinherited

◆ m_toolManager

TOOL_MANAGER* PANEL_KICAD_LAUNCHER::m_toolManager
private

Definition at line 40 of file panel_kicad_launcher.h.

Referenced by CreateLaunchers(), and PANEL_KICAD_LAUNCHER().

◆ m_toolsSizer

wxGridBagSizer* PANEL_KICAD_LAUNCHER_BASE::m_toolsSizer
protectedinherited

The documentation for this class was generated from the following files: