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
 
KICAD_MANAGER_FRAMEm_frame
 

Detailed Description

Definition at line 28 of file panel_kicad_launcher.h.

Constructor & Destructor Documentation

◆ PANEL_KICAD_LAUNCHER()

PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER ( wxWindow *  aParent)

Definition at line 33 of file panel_kicad_launcher.cpp.

33 :
35{
36 m_frame = static_cast<KICAD_MANAGER_FRAME*>( aParent );
39
40 Bind( wxEVT_SYS_COLOUR_CHANGED,
41 wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ), this );
42}
The main KiCad project manager frame.
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)
TOOL_MANAGER * m_toolManager
void onThemeChanged(wxSysColourChangedEvent &aEvent)
KICAD_MANAGER_FRAME * m_frame
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54

References CreateLaunchers(), TOOLS_HOLDER::GetToolManager(), m_frame, 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 45 of file panel_kicad_launcher.cpp.

46{
47 m_frame->SetPcmButton( nullptr );
48
49 if( m_toolsSizer->GetRows() > 0 )
50 {
51 m_toolsSizer->Clear( true );
52 m_toolsSizer->SetRows( 0 );
53 }
54
55 wxFont titleFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
56#ifndef __WXGTK__
57 titleFont.SetPointSize( titleFont.GetPointSize() + 2 );
58#endif
59 titleFont.SetWeight( wxFONTWEIGHT_BOLD );
60
61 wxFont helpFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
62 helpFont.SetStyle( wxFONTSTYLE_ITALIC );
63
64 auto addLauncher =
65 [&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText, bool enabled = true )
66 {
67 BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY );
68 btn->SetBitmap( aBitmap );
69 btn->SetDisabledBitmap( wxBitmap( aBitmap.ConvertToImage().ConvertToGreyscale() ) );
70 btn->SetPadding( 5 );
71 btn->SetToolTip( aAction.GetDescription() );
72
73 auto handler =
74 [&]( wxEvent& aEvent )
75 {
76 // Defocus the button because leaving the large buttons
77 // focused after a click looks out of place in the launcher
78 m_frame->SetFocus();
79 // Gives a slice of time to update the button state (mandatory on GTK,
80 // useful on MSW to avoid some cosmetic issues).
81 wxSafeYield();
82
83 OPT_TOOL_EVENT evt = aAction.MakeEvent();
84 evt->SetHasPosition( false );
86 };
87
88 wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
89 wxStaticText* help;
90
91 label->SetToolTip( aAction.GetDescription() );
92 label->SetFont( titleFont );
93
94 help = new wxStaticText( this, wxID_ANY, aHelpText );
95 help->SetFont( helpFont );
96
97 btn->Bind( wxEVT_BUTTON, handler );
98
99 // The bug fix below makes this handler active for the entire window width. Without
100 // any visual feedback that's a bit odd. Disabling for now.
101 // label->Bind( wxEVT_LEFT_UP, handler );
102
103 int row = m_toolsSizer->GetRows();
104
105 m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( 2, 1 ), wxBOTTOM, 12 );
106
107 // Due to https://trac.wxwidgets.org/ticket/16088?cversion=0&cnum_hist=7 GTK fails to
108 // correctly set the BestSize of non-default-size or styled text so we need to make
109 // sure that the BestSize isn't needed by setting wxEXPAND. Unfortunately this makes
110 // wxALIGN_BOTTOM non-functional, so we have to jump through a bunch more hoops to
111 // try and align the title and help text in the middle of the icon.
112 m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ),
113 wxTOP | wxEXPAND, 10 );
114
115 m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ),
116 wxALIGN_TOP | wxTOP, 1 );
117
118 btn->Enable( enabled );
119 if( !enabled )
120 {
121 help->Disable();
122 label->Disable();
123 }
124
125 return btn;
126 };
127
129 KiScaledBitmap( BITMAPS::icon_eeschema, this, 48, true ),
130 _( "Edit the project schematic" ) );
131
133 KiScaledBitmap( BITMAPS::icon_libedit, this, 48, true ),
134 _( "Edit global and/or project schematic symbol libraries" ) );
135
137 KiScaledBitmap( BITMAPS::icon_pcbnew, this, 48, true ),
138 _( "Edit the project PCB design" ) );
139
141 KiScaledBitmap( BITMAPS::icon_modedit, this, 48, true ),
142 _( "Edit global and/or project PCB footprint libraries" ) );
143
145 KiScaledBitmap( BITMAPS::icon_gerbview, this, 48, true ),
146 _( "Preview Gerber files" ) );
147
150 _( "Convert bitmap images to schematic symbols or PCB footprints" ) );
151
154 _( "Show tools for calculating resistance, current capacity, etc." ) );
155
158 _( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
159 "designs" ) );
160
161 BITMAP_BUTTON* bb =
163 KiScaledBitmap( BITMAPS::icon_pcm, this, 48, true ),
164 _( "Manage downloadable packages from KiCad and 3rd party repositories" ),
167
168 m_frame->SetPcmButton( bb );
169
170 Layout();
171}
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:157
@ icon_pagelayout_editor
@ icon_eeschema
@ icon_bitmap2component
@ icon_libedit
@ icon_pcbcalculator
@ icon_gerbview
@ icon_modedit
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:41
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
bool Enable(bool aEnable=true) override
Enable the button.
void SetPadding(int aPadding)
Set the amount of padding present on each side of the bitmap.
void SetDisabledBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is disabled.
static TOOL_ACTION editPCB
static TOOL_ACTION editSchematic
static TOOL_ACTION convertImage
static TOOL_ACTION editDrawingSheet
static TOOL_ACTION editFootprints
static TOOL_ACTION showPluginManager
static TOOL_ACTION showCalculator
static TOOL_ACTION viewGerbers
static TOOL_ACTION editSymbols
void SetPcmButton(BITMAP_BUTTON *aButton)
Represent a single user action.
Definition: tool_action.h:68
wxString GetLabel() const
Definition: tool_action.cpp:83
wxString GetDescription(bool aIncludeHotkey=true) const
Definition: tool_action.cpp:97
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
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:244
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
#define _(s)
STATE GetPolicyState(const wxString &aKey)
Definition: gtk/policy.cpp:25
#define POLICY_KEY_PCM
Definition: policy_keys.h:29
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:557

References _, KICAD_MANAGER_ACTIONS::convertImage, KIPLATFORM::POLICY::DISABLED, KICAD_MANAGER_ACTIONS::editDrawingSheet, KICAD_MANAGER_ACTIONS::editFootprints, KICAD_MANAGER_ACTIONS::editPCB, KICAD_MANAGER_ACTIONS::editSchematic, KICAD_MANAGER_ACTIONS::editSymbols, BITMAP_BUTTON::Enable(), TOOL_ACTION::GetDescription(), TOOL_ACTION::GetLabel(), KIPLATFORM::POLICY::GetPolicyState(), help, icon_bitmap2component, icon_eeschema, icon_gerbview, icon_libedit, icon_modedit, icon_pagelayout_editor, icon_pcbcalculator, icon_pcbnew, icon_pcm, KiScaledBitmap(), m_frame, m_toolManager, PANEL_KICAD_LAUNCHER_BASE::m_toolsSizer, TOOL_ACTION::MakeEvent(), POLICY_KEY_PCM, TOOL_MANAGER::ProcessEvent(), BITMAP_BUTTON::SetBitmap(), BITMAP_BUTTON::SetDisabledBitmap(), TOOL_EVENT::SetHasPosition(), BITMAP_BUTTON::SetPadding(), KICAD_MANAGER_FRAME::SetPcmButton(), KICAD_MANAGER_ACTIONS::showCalculator, KICAD_MANAGER_ACTIONS::showPluginManager, 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 174 of file panel_kicad_launcher.cpp.

175{
178
179 aEvent.Skip();
180}
BITMAP_STORE * GetBitmapStore()
Definition: bitmap.cpp:94
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.

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

Referenced by PANEL_KICAD_LAUNCHER().

Member Data Documentation

◆ m_frame

KICAD_MANAGER_FRAME* PANEL_KICAD_LAUNCHER::m_frame
private

Definition at line 42 of file panel_kicad_launcher.h.

Referenced by CreateLaunchers(), and PANEL_KICAD_LAUNCHER().

◆ m_mainSizer

wxBoxSizer* PANEL_KICAD_LAUNCHER_BASE::m_mainSizer
protectedinherited

◆ m_toolManager

TOOL_MANAGER* PANEL_KICAD_LAUNCHER::m_toolManager
private

Definition at line 41 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: