Add a method to facilitate Tools handling in main frame toolbars.

Fix also a bug in gerbview_frame.cpp, about a broken toolbar accessor (fortunately not used in current code)
This commit is contained in:
jean-pierre charras 2018-04-03 13:00:20 +02:00
parent c867de53b8
commit f8a3ec4974
6 changed files with 49 additions and 23 deletions

View File

@ -134,6 +134,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
{
m_drawToolBar = NULL;
m_optionsToolBar = NULL;
m_auxiliaryToolBar = NULL;
m_gridSelectBox = NULL;
m_zoomSelectBox = NULL;
m_hotkeysDescrList = NULL;
@ -306,6 +307,37 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
m_canvas->Refresh();
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{
// Checks all the toolbars and returns true if the given tool id is toggled.
return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
);
}
wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
{
// Checks all the toolbars and returns a reference to the given tool id
// (or the first tool found, but only one or 0 tool is expected, because on
// Windows, when different tools have the same ID, it creates issues)
if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
return m_mainToolBar->FindTool( aToolId );
if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
return m_optionsToolBar->FindTool( aToolId );
if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
return m_drawToolBar->FindTool( aToolId );
if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
return m_auxiliaryToolBar->FindTool( aToolId );
return nullptr;
}
void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
{

View File

@ -68,7 +68,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME )
{
m_auxiliaryToolBar = NULL;
m_colorsSettings = &g_ColorsSettings;
m_gerberLayout = NULL;
m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1

View File

@ -182,10 +182,6 @@ public:
COLORS_DESIGN_SETTINGS* m_colorsSettings;
private:
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
// list of PARAM_CFG_xxx to read/write parameters saved in config
PARAM_CFG_ARRAY m_configSettings;
@ -258,8 +254,6 @@ public:
double BestZoom() override;
void UpdateStatusBar() override;
wxAuiToolBar* GetMainToolBar() { return m_optionsToolBar; }
/**
* Function GetZoomLevelIndicator
* returns a human readable value which can be displayed as zoom

View File

@ -121,6 +121,10 @@ protected:
/// Choice box to choose the zoom value.
wxChoice* m_zoomSelectBox;
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
/// The tool bar that contains the buttons for quick access to the application draw
/// tools. It typically is located on the right side of the main window.
wxAuiToolBar* m_drawToolBar;
@ -434,20 +438,23 @@ public:
// Toolbar accessors
wxAuiToolBar* GetMainToolBar() const { return m_mainToolBar; }
wxAuiToolBar* GetOptionsToolBar() const { return m_optionsToolBar; }
wxAuiToolBar* GetDrawToolBar() const { return m_drawToolBar; }
wxAuiToolBar* GetAuxiliaryToolBar() const { return m_auxiliaryToolBar; }
/**
* Checks all the toolbars and returns true if the given tool id is toggled.
*
* This is needed because GerbView and Pcbnew put some of the same tools in
* different toolbars (for example, zoom selection is in the main bar in
* Pcbnew and in the options bar in GerbView).
* This is needed because GerbView and Pcbnew can put some of the same tools in
* different toolbars.
*/
bool GetToolToggled( int aToolId )
{
return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) );
}
bool GetToolToggled( int aToolId );
/**
* Checks all the toolbars and returns a reference to the given tool id
* or nullptr if not found
*/
wxAuiToolBarItem* GetToolbarTool( int aToolId );
/**
* Function SetToolID

View File

@ -78,10 +78,6 @@ protected:
GENERAL_COLLECTOR* m_Collector;
PCB_GENERAL_SETTINGS m_configSettings;
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
void updateGridSelectBox();
void updateZoomSelectBox();
virtual void unitsChangeRefresh() override;

View File

@ -115,8 +115,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_FastGrid1 = 0;
m_FastGrid2 = 0;
m_auxiliaryToolBar = NULL;
m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1
// when the screen shows a 1:1 image
// obviously depends on the monitor,