2021-02-12 22:37:39 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <kicad_manager_frame.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/kicad_manager_actions.h>
|
|
|
|
#include <widgets/bitmap_button.h>
|
|
|
|
|
|
|
|
#include "panel_kicad_launcher.h"
|
|
|
|
|
|
|
|
|
2021-02-14 18:34:08 +00:00
|
|
|
#ifdef __WXMAC__
|
2021-02-16 15:15:52 +00:00
|
|
|
constexpr int ICON_PADDING = 4;
|
2021-02-14 18:34:08 +00:00
|
|
|
constexpr int CELL_MARGINS = 0;
|
|
|
|
#else
|
|
|
|
constexpr int ICON_PADDING = 5;
|
2021-02-14 13:52:42 -05:00
|
|
|
constexpr int CELL_MARGINS = 3;
|
2021-02-14 18:34:08 +00:00
|
|
|
#endif
|
|
|
|
|
2021-02-12 22:37:39 -05:00
|
|
|
PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER( wxWindow* aParent ) :
|
|
|
|
PANEL_KICAD_LAUNCHER_BASE( aParent )
|
|
|
|
{
|
|
|
|
m_toolManager = static_cast<KICAD_MANAGER_FRAME*>( aParent )->GetToolManager();
|
|
|
|
CreateLaunchers();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
|
|
|
{
|
|
|
|
if( m_toolsSizer->GetRows() > 0 )
|
|
|
|
{
|
|
|
|
m_toolsSizer->Clear( true );
|
|
|
|
m_toolsSizer->SetRows( 0 );
|
|
|
|
}
|
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
wxFont titleFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
titleFont.SetPointSize( titleFont.GetPointSize() + 2 );
|
|
|
|
titleFont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
|
|
|
|
wxFont helpFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
helpFont.SetStyle( wxFONTSTYLE_ITALIC );
|
|
|
|
|
2021-02-12 22:37:39 -05:00
|
|
|
auto addLauncher =
|
2021-02-14 13:13:20 +00:00
|
|
|
[&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText )
|
2021-02-12 22:37:39 -05:00
|
|
|
{
|
|
|
|
BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY );
|
|
|
|
btn->SetBitmap( aBitmap );
|
2021-02-14 18:34:08 +00:00
|
|
|
btn->SetPadding( ICON_PADDING );
|
2021-02-12 22:37:39 -05:00
|
|
|
btn->SetToolTip( aAction.GetDescription() );
|
|
|
|
|
|
|
|
auto handler =
|
|
|
|
[&]( wxEvent& aEvent )
|
|
|
|
{
|
|
|
|
OPT_TOOL_EVENT evt = aAction.MakeEvent();
|
|
|
|
evt->SetHasPosition( false );
|
|
|
|
m_toolManager->ProcessEvent( *evt );
|
|
|
|
};
|
|
|
|
|
|
|
|
wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
|
|
|
|
wxStaticText* help;
|
|
|
|
|
|
|
|
label->SetToolTip( aAction.GetDescription() );
|
2021-02-14 13:13:20 +00:00
|
|
|
label->SetFont( titleFont );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
help = new wxStaticText( this, wxID_ANY, aHelpText );
|
|
|
|
help->SetFont( helpFont );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
|
|
|
btn->Bind( wxEVT_BUTTON, handler );
|
|
|
|
label->Bind( wxEVT_LEFT_UP, handler );
|
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
int row = m_toolsSizer->GetRows();
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 18:34:08 +00:00
|
|
|
m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( 2, 1 ), wxALL, CELL_MARGINS );
|
2021-02-22 16:37:43 +00:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
// Due to https://trac.wxwidgets.org/ticket/16088?cversion=0&cnum_hist=7 GTK fails to
|
|
|
|
// correctly set the BestSize of non-default-size text so we need to make sure that the
|
|
|
|
// BestSize isn't needed.
|
|
|
|
// However, another bug on OSX causes this to make the text top-aligned, so we have to
|
|
|
|
// do it only on GTK. Sigh.
|
2021-02-20 19:47:50 +00:00
|
|
|
m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ), wxALIGN_BOTTOM|wxEXPAND, 0 );
|
2021-02-22 16:37:43 +00:00
|
|
|
#else
|
|
|
|
m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ), wxALIGN_BOTTOM, 0 );
|
|
|
|
#endif
|
|
|
|
m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_TOP, 0 );
|
2021-02-12 22:37:39 -05:00
|
|
|
};
|
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::editSchematic, KiScaledBitmap( icon_eeschema_xpm, this ),
|
|
|
|
_( "Edit the project schematic" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::editSymbols, KiScaledBitmap( icon_libedit_xpm, this ),
|
|
|
|
_( "Edit global and/or project schematic symbol libraries" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::editPCB, KiScaledBitmap( icon_pcbnew_xpm, this ),
|
|
|
|
_( "Edit the project PCB design" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::editFootprints, KiScaledBitmap( icon_modedit_xpm, this ),
|
2021-02-14 16:59:04 +00:00
|
|
|
_( "Edit global and/or project PCB footprint libraries" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-14 13:13:20 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::viewGerbers, KiScaledBitmap( icon_gerbview_xpm, this ),
|
|
|
|
_( "Preview Gerber files" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::convertImage,
|
2021-02-14 13:13:20 +00:00
|
|
|
KiScaledBitmap( icon_bitmap2component_xpm, this ),
|
|
|
|
_( "Convert bitmap images to schematic symbols or PCB footprints" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::showCalculator,
|
2021-02-14 13:13:20 +00:00
|
|
|
KiScaledBitmap( icon_pcbcalculator_xpm, this ),
|
|
|
|
_( "Show tools for calculating resistance, current capacity, etc." ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
addLauncher( KICAD_MANAGER_ACTIONS::editDrawingSheet,
|
2021-02-14 13:13:20 +00:00
|
|
|
KiScaledBitmap( icon_pagelayout_editor_xpm, this ),
|
2021-02-22 16:37:43 +00:00
|
|
|
_( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
|
|
|
|
"designs" ) );
|
2021-02-12 22:37:39 -05:00
|
|
|
|
|
|
|
if( m_toolsSizer->IsColGrowable( 1 ) )
|
|
|
|
m_toolsSizer->RemoveGrowableCol( 1 );
|
|
|
|
|
|
|
|
m_toolsSizer->AddGrowableCol( 1 );
|
|
|
|
Layout();
|
|
|
|
}
|