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 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 29 of file panel_kicad_launcher.cpp.

29  :
30  PANEL_KICAD_LAUNCHER_BASE( aParent )
31 {
32  m_toolManager = static_cast<KICAD_MANAGER_FRAME*>( aParent )->GetToolManager();
34 }
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)

References CreateLaunchers(), and m_toolManager.

◆ ~PANEL_KICAD_LAUNCHER()

virtual PANEL_KICAD_LAUNCHER::~PANEL_KICAD_LAUNCHER ( )
virtualdefault

Member Function Documentation

◆ CreateLaunchers()

void PANEL_KICAD_LAUNCHER::CreateLaunchers ( )

Definition at line 37 of file panel_kicad_launcher.cpp.

38 {
39  if( m_toolsSizer->GetRows() > 0 )
40  {
41  m_toolsSizer->Clear( true );
42  m_toolsSizer->SetRows( 0 );
43  }
44 
45  wxFont titleFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
46 #ifndef __WXGTK__
47  titleFont.SetPointSize( titleFont.GetPointSize() + 2 );
48 #endif
49  titleFont.SetWeight( wxFONTWEIGHT_BOLD );
50 
51  wxFont helpFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
52  helpFont.SetStyle( wxFONTSTYLE_ITALIC );
53 
54  auto addLauncher =
55  [&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText )
56  {
57  BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY );
58  btn->SetBitmap( aBitmap );
59  btn->SetPadding( 5 );
60  btn->SetToolTip( aAction.GetDescription() );
61 
62  auto handler =
63  [&]( wxEvent& aEvent )
64  {
65  OPT_TOOL_EVENT evt = aAction.MakeEvent();
66  evt->SetHasPosition( false );
67  m_toolManager->ProcessEvent( *evt );
68  };
69 
70  wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
71  wxStaticText* help;
72 
73  label->SetToolTip( aAction.GetDescription() );
74  label->SetFont( titleFont );
75 
76  help = new wxStaticText( this, wxID_ANY, aHelpText );
77  help->SetFont( helpFont );
78 
79  btn->Bind( wxEVT_BUTTON, handler );
80 
81  // The bug fix below makes this handler active for the entire window width. Without
82  // any visual feedback that's a bit odd. Disabling for now.
83  // label->Bind( wxEVT_LEFT_UP, handler );
84 
85  int row = m_toolsSizer->GetRows();
86 
87  m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( 2, 1 ), wxBOTTOM, 12 );
88 
89  // Due to https://trac.wxwidgets.org/ticket/16088?cversion=0&cnum_hist=7 GTK fails to
90  // correctly set the BestSize of non-default-size or styled text so we need to make
91  // sure that the BestSize isn't needed by setting wxEXPAND. Unfortunately this makes
92  // wxALIGN_BOTTOM non-functional, so we have to jump through a bunch more hoops to
93  // try and align the title and help text in the middle of the icon.
94  m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ), wxTOP|wxEXPAND, 10 );
95 
96  m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_TOP|wxTOP, 1 );
97  };
98 
101  _( "Edit the project schematic" ) );
102 
105  _( "Edit global and/or project schematic symbol libraries" ) );
106 
107  addLauncher( KICAD_MANAGER_ACTIONS::editPCB,
109  _( "Edit the project PCB design" ) );
110 
113  _( "Edit global and/or project PCB footprint libraries" ) );
114 
117  _( "Preview Gerber files" ) );
118 
121  _( "Convert bitmap images to schematic symbols or PCB footprints" ) );
122 
125  _( "Show tools for calculating resistance, current capacity, etc." ) );
126 
129  _( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
130  "designs" ) );
131 
132  if( m_toolsSizer->IsColGrowable( 1 ) )
133  m_toolsSizer->RemoveGrowableCol( 1 );
134 
135  m_toolsSizer->AddGrowableCol( 1 );
136  Layout();
137 }
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
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
wxString GetDescription(bool aIncludeHotkey=true) const
Definition: tool_action.cpp:84
wxString GetLabel() const
Definition: tool_action.cpp:70
static TOOL_ACTION editPCB
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
#define _(s)
Definition: 3d_actions.cpp:33
Represent a single user action.
Definition: tool_action.h:49
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.h:123
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:262
static TOOL_ACTION editDrawingSheet
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:569

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, KiBitmap(), 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 PANEL_KICAD_LAUNCHER(), and KICAD_MANAGER_FRAME::ShowChangedLanguage().

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 38 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: