2007-10-31 18:56:11 +00:00
|
|
|
/*****************************************************/
|
|
|
|
/* commandframe.cpp: window handling comman buttons */
|
|
|
|
/*****************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "macros.h"
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "kicad.h"
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2010-07-11 18:24:44 +02:00
|
|
|
|
2011-04-17 15:54:17 +02:00
|
|
|
RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) :
|
2009-11-18 20:12:11 +00:00
|
|
|
wxSashLayoutWindow( parent, wxID_ANY )
|
|
|
|
{
|
|
|
|
m_Parent = parent;
|
2011-09-09 21:30:59 +02:00
|
|
|
m_MessagesBox = NULL;
|
2009-11-18 20:12:11 +00:00
|
|
|
m_ButtPanel = new wxPanel( this, wxID_ANY );
|
2011-09-09 21:30:59 +02:00
|
|
|
m_bitmapButtons_maxHeigth = 0;
|
|
|
|
m_ButtonSeparation = 10; // control of command buttons position
|
|
|
|
m_ButtonsListPosition.x = m_ButtonSeparation;
|
|
|
|
m_ButtonsListPosition.y = m_ButtonSeparation;
|
|
|
|
m_ButtonLastPosition = m_ButtonsListPosition;
|
|
|
|
|
|
|
|
// Add bitmap buttons to launch Kicad utilities:
|
2009-11-18 20:12:11 +00:00
|
|
|
CreateCommandToolbar();
|
2011-09-09 21:30:59 +02:00
|
|
|
m_ButtonsPanelHeight = m_ButtonsListPosition.y + m_bitmapButtons_maxHeigth + 10;
|
|
|
|
|
|
|
|
// Add the wxTextCtrl showaing all messages from Kicad:
|
|
|
|
m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
|
2009-11-18 20:12:11 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY );
|
2010-10-04 14:58:07 +02:00
|
|
|
}
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2011-09-09 21:30:59 +02:00
|
|
|
|
2009-11-18 20:12:11 +00:00
|
|
|
void RIGHT_KM_FRAME::OnSize( wxSizeEvent& event )
|
2007-10-31 18:56:11 +00:00
|
|
|
{
|
2009-11-18 20:12:11 +00:00
|
|
|
#define EXTRA_MARGE 4
|
2011-09-09 21:30:59 +02:00
|
|
|
wxSize wsize = GetClientSize();
|
2009-11-18 20:12:11 +00:00
|
|
|
wsize.x -= EXTRA_MARGE;
|
|
|
|
wsize.y -= m_ButtonsPanelHeight + EXTRA_MARGE;
|
|
|
|
wxPoint wpos;
|
2011-09-09 21:30:59 +02:00
|
|
|
wpos.x = EXTRA_MARGE / 2;
|
|
|
|
wpos.y = m_ButtonsPanelHeight + (EXTRA_MARGE / 2);
|
|
|
|
if( m_MessagesBox )
|
2009-11-18 20:12:11 +00:00
|
|
|
{
|
2011-09-09 21:30:59 +02:00
|
|
|
m_MessagesBox->SetSize( wsize );
|
|
|
|
m_MessagesBox->SetPosition( wpos );
|
2009-11-18 20:12:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 21:30:59 +02:00
|
|
|
wpos.y = EXTRA_MARGE / 2;
|
|
|
|
m_ButtPanel->SetPosition( wpos );
|
2009-11-18 20:12:11 +00:00
|
|
|
wsize.y -= m_ButtonsPanelHeight - EXTRA_MARGE;
|
|
|
|
m_ButtPanel->SetSize( wsize );
|
|
|
|
m_ButtPanel->Refresh();
|
|
|
|
|
|
|
|
event.Skip();
|
2007-10-31 18:56:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 20:12:11 +00:00
|
|
|
BEGIN_EVENT_TABLE( RIGHT_KM_FRAME, wxSashLayoutWindow )
|
|
|
|
EVT_SIZE( RIGHT_KM_FRAME::OnSize )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2010-11-12 10:36:43 -06:00
|
|
|
/**
|
|
|
|
* Function CreateCommandToolbar
|
2007-10-31 18:56:11 +00:00
|
|
|
* create the buttons to call eescheman cvpcb, pcbnew and gerbview
|
|
|
|
*/
|
2011-09-09 21:30:59 +02:00
|
|
|
void RIGHT_KM_FRAME::CreateCommandToolbar( void )
|
2007-10-31 18:56:11 +00:00
|
|
|
{
|
|
|
|
wxBitmapButton* btn;
|
|
|
|
|
2011-08-28 15:02:27 -05:00
|
|
|
btn = AddBitmapButton( ID_TO_EESCHEMA, KiBitmap( icon_eeschema_xpm ) );
|
2008-08-20 22:44:37 +00:00
|
|
|
btn->SetToolTip( _( "EESchema (Schematic editor)" ) );
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2011-08-28 15:02:27 -05:00
|
|
|
btn = AddBitmapButton( ID_TO_CVPCB, KiBitmap( icon_cvpcb_xpm ) );
|
2008-08-20 22:44:37 +00:00
|
|
|
btn->SetToolTip( _( "CVpcb (Components to modules)" ) );
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2011-09-08 00:58:45 -05:00
|
|
|
btn = AddBitmapButton( ID_TO_PCB, KiBitmap( icon_pcbnew_xpm ) );
|
2008-08-20 22:44:37 +00:00
|
|
|
btn->SetToolTip( _( "PCBnew (PCB editor)" ) );
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2011-08-28 15:02:27 -05:00
|
|
|
btn = AddBitmapButton( ID_TO_GERBVIEW, KiBitmap( icon_gerbview_xpm ) );
|
2008-08-20 22:44:37 +00:00
|
|
|
btn->SetToolTip( _( "GerbView (Gerber viewer)" ) );
|
2007-10-31 18:56:11 +00:00
|
|
|
|
2011-09-08 16:27:02 -04:00
|
|
|
btn = AddBitmapButton( ID_TO_BITMAP_CONVERTER, KiBitmap( icon_bitmap2component_xpm ) );
|
2011-09-09 21:30:59 +02:00
|
|
|
btn->SetToolTip( _(
|
|
|
|
"Bitmap2Component (a tool to build a logo from a bitmap)\n\
|
|
|
|
Creates a component (for Eeschema) or a footprint (for Pcbnew) that shows a B&W picture" ) );
|
2011-08-05 21:53:42 +02:00
|
|
|
|
2011-09-08 16:27:02 -04:00
|
|
|
btn = AddBitmapButton( ID_TO_PCB_CALCULATOR, KiBitmap( icon_pcbcalculator_xpm ) );
|
2011-08-05 21:53:42 +02:00
|
|
|
btn->SetToolTip( _( "Pcb calculator" ) );
|
2007-10-31 18:56:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 10:36:43 -06:00
|
|
|
/**
|
|
|
|
* Function AddBitmapButton
|
2010-07-21 11:12:25 +02:00
|
|
|
* add a Bitmap Button (fast launch button) to the buttons panel
|
|
|
|
* @param aId = the button id
|
|
|
|
* @param aBitmap = the wxBitmap used to create the button
|
2007-10-31 18:56:11 +00:00
|
|
|
*/
|
2011-09-09 21:30:59 +02:00
|
|
|
wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap )
|
2007-10-31 18:56:11 +00:00
|
|
|
{
|
2010-07-11 18:24:44 +02:00
|
|
|
wxPoint buttPos = m_ButtonLastPosition;
|
2011-09-09 21:30:59 +02:00
|
|
|
wxSize buttSize;
|
|
|
|
int btn_margin = 0; // extra margin around the bitmap.
|
|
|
|
|
2010-07-21 11:12:25 +02:00
|
|
|
buttSize.x = aBitmap.GetWidth() + btn_margin;
|
|
|
|
buttSize.y = aBitmap.GetHeight() + btn_margin;
|
2011-09-09 21:30:59 +02:00
|
|
|
|
|
|
|
if( m_bitmapButtons_maxHeigth < buttSize.y )
|
|
|
|
m_bitmapButtons_maxHeigth = buttSize.y;
|
|
|
|
|
|
|
|
wxBitmapButton* btn = new wxBitmapButton( m_ButtPanel, aId, aBitmap, buttPos, buttSize );
|
2010-07-21 11:12:25 +02:00
|
|
|
m_ButtonLastPosition.x += buttSize.x + m_ButtonSeparation;
|
|
|
|
|
|
|
|
return btn;
|
2007-10-31 18:56:11 +00:00
|
|
|
}
|