Commit cb647737 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Improve handling of tool bar command IDs.

* Make EDA_DRAW_FRAME current tool ID member variable private.
* Added global no tool selected ID to replace application specific no
  tool selected IDs.
* Change SetToolID to prevent setting the tool ID to anything less than
  the new global no tool selected ID and assert on debug builds.
* Change command and update user interface command event handlers to use
  new global no tool selected ID.
* Fixed schematic library editor add pin hot key handler.
parent c303d3f8
......@@ -77,8 +77,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
DrawPanel = NULL;
MsgPanel = NULL;
m_currentScreen = NULL;
m_ID_current_state = 0;
m_ID_last_state = 0;
m_toolId = ID_NO_TOOL_SELECTED;
m_ID_last_state = ID_NO_TOOL_SELECTED;
m_HTOOL_current_state = 0;
m_Draw_Axis = FALSE; // TRUE to draw axis.
m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet.
......@@ -434,20 +434,6 @@ void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
}
/**
* Function SetToolID
* Enables the icon of the selected tool in the vertical toolbar.
* (Or tool ID_NO_SELECT_BUTT default if no new selection)
* @param aId = new m_ID_current_state value (if aId >= 0)
* @param aCursor = the new cursor shape (0 = default cursor)
* @param aToolMsg = tool message in status bar
* if (aId >= 0)
* Updates all variables related:
* m_ID_current_state, cursor shape and message in status bar
* If (aId < 0)
* Only updates the cursor shape and message in status bar
* (does not the current m_ID_current_state value
*/
void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
{
// Keep default cursor in toolbars
......@@ -462,7 +448,10 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
if( aId < 0 )
return;
m_ID_current_state = aId;
wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
m_toolId = aId;
}
......
......@@ -1108,7 +1108,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
if( IsMouseCaptured() )
EndMouseCapture( -1, m_defaultCursor );
else
EndMouseCapture( 0, m_cursor, wxEmptyString );
EndMouseCapture( ID_NO_TOOL_SELECTED, m_cursor, wxEmptyString );
break;
}
......@@ -1206,6 +1206,7 @@ void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title
INSTALL_UNBUFFERED_DC( dc, this );
m_endMouseCaptureCallback( this, &dc );
}
m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL;
m_AutoPAN_Request = false;
......
......@@ -183,7 +183,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
}
DrawPanel->SetMouseCapture( NULL, NULL );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh();
}
......@@ -317,7 +317,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
block->m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
}
if( zoom_command )
......@@ -479,7 +479,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
block->Clear();
GetScreen()->SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
}
}
......
......@@ -183,7 +183,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh( true );
}
......@@ -269,7 +269,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
GetScreen()->SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
DrawPanel->Refresh( true );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
}
......
......@@ -10,6 +10,7 @@
#include "confirm.h"
#include "class_drawpanel.h"
#include "wxEeschemaStruct.h"
#include "id.h"
#include "general.h"
#include "protos.h"
......@@ -109,7 +110,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
if( m_component == NULL )
return;
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component );
......
......@@ -23,7 +23,6 @@ enum id_eeschema_frm
/* Schematic editor veritcal toolbar IDs */
ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_SCH_NO_TOOL,
ID_HIERARCHY_PUSH_POP_BUTT,
ID_SCH_PLACE_COMPONENT,
ID_PLACE_POWER_BUTT,
......@@ -156,7 +155,6 @@ enum id_eeschema_frm
ID_LIBEDIT_SELECT_ALIAS,
/* Library editor vertical toolbar IDs. */
ID_LIBEDIT_NO_TOOL,
ID_LIBEDIT_PIN_BUTT,
ID_LIBEDIT_BODY_LINE_BUTT,
ID_LIBEDIT_BODY_ARC_BUTT,
......
......@@ -388,8 +388,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_NEW_COMPONENT: // Add component
if( !itemInEdit )
{
// switch to m_ID_current_state = ID_COMPONENT_BUTT;
if( m_ID_current_state != ID_SCH_PLACE_COMPONENT )
if( GetToolId() != ID_SCH_PLACE_COMPONENT )
SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add Component" ) );
OnLeftClick( aDC, aPosition );
......@@ -399,8 +398,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_NEW_POWER: // Add power component
if( !itemInEdit )
{
// switch to m_ID_current_state = ID_PLACE_POWER_BUTT;
if( m_ID_current_state != ID_PLACE_POWER_BUTT )
if( GetToolId() != ID_PLACE_POWER_BUTT )
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
OnLeftClick( aDC, aPosition );
......@@ -410,8 +408,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_LABEL:
if( notBusy )
{
// switch to m_ID_current_state = ID_LABEL_BUTT;
if( m_ID_current_state != ID_LABEL_BUTT )
if( GetToolId() != ID_LABEL_BUTT )
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add Label" ) );
OnLeftClick( aDC, aPosition );
......@@ -421,8 +418,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_HLABEL:
if( notBusy )
{
// switch to m_ID_current_state = ID_HIERLABEL_BUTT;
if( m_ID_current_state != ID_HIERLABEL_BUTT )
if( GetToolId() != ID_HIERLABEL_BUTT )
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Hierarchical Label" ) );
OnLeftClick( aDC, aPosition );
......@@ -432,8 +428,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_GLABEL:
if( notBusy )
{
// switch to m_ID_current_state = ID_GLABEL_BUTT;
if( m_ID_current_state != ID_GLABEL_BUTT )
if( GetToolId() != ID_GLABEL_BUTT )
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Global Label" ) );
OnLeftClick( aDC, aPosition );
......@@ -443,8 +438,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_JUNCTION:
if( notBusy )
{
// switch to m_ID_current_state = ID_JUNCTION_BUTT;
if( m_ID_current_state != ID_JUNCTION_BUTT )
if( GetToolId() != ID_JUNCTION_BUTT )
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add Junction" ) );
OnLeftClick( aDC, aPosition );
......@@ -454,8 +448,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_WIRE_ENTRY:
if( notBusy )
{
// switch to m_ID_current_state = ID_WIRETOBUS_ENTRY_BUTT;
if( m_ID_current_state != ID_WIRETOBUS_ENTRY_BUTT )
if( GetToolId() != ID_WIRETOBUS_ENTRY_BUTT )
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Wire to Bus entry" ) );
OnLeftClick( aDC, aPosition );
......@@ -465,8 +458,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_BUS_ENTRY:
if( notBusy )
{
// switch to m_ID_current_state = ID_BUSTOBUS_ENTRY_BUTT;
if( m_ID_current_state != ID_BUSTOBUS_ENTRY_BUTT )
if( GetToolId() != ID_BUSTOBUS_ENTRY_BUTT )
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Bus to Bus entry" ) );
OnLeftClick( aDC, aPosition );
......@@ -476,8 +468,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_HIER_SHEET:
if( notBusy )
{
// switch to m_ID_current_state = ID_SHEET_SYMBOL_BUTT;
if( m_ID_current_state != ID_SHEET_SYMBOL_BUTT )
if( GetToolId() != ID_SHEET_SYMBOL_BUTT )
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add Sheet" ) );
OnLeftClick( aDC, aPosition );
......@@ -487,8 +478,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_GRAPHIC_TEXT:
if( notBusy )
{
// switch to m_ID_current_state = ID_TEXT_COMMENT_BUTT;
if( m_ID_current_state != ID_TEXT_COMMENT_BUTT )
if( GetToolId() != ID_TEXT_COMMENT_BUTT )
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Text" ) );
OnLeftClick( aDC, aPosition );
......@@ -498,8 +488,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_GRAPHIC_POLYLINE:
if( notBusy )
{
// switch to m_ID_current_state = ID_LINE_COMMENT_BUTT;
if( m_ID_current_state != ID_LINE_COMMENT_BUTT )
if( GetToolId() != ID_LINE_COMMENT_BUTT )
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Lines" ) );
OnLeftClick( aDC, aPosition );
......@@ -510,15 +499,14 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
// An item can be selected. If not a Bus, a begin command is not possible
if( notBusy )
{
// switch to m_ID_current_state = ID_WIRE_BUTT;
if( m_ID_current_state != ID_BUS_BUTT )
if( GetToolId() != ID_BUS_BUTT )
SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add Bus" ) );
OnLeftClick( aDC, aPosition );
break;
}
if( aItem && aItem->IsNew() && ( m_ID_current_state == ID_BUS_BUTT ) )
if( aItem && aItem->IsNew() && ( GetToolId() == ID_BUS_BUTT ) )
{
if( aItem->Type() == SCH_LINE_T )
{
......@@ -538,15 +526,14 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
// An item can be selected. If not a wire, a begin command is not possible
if( notBusy )
{
// switch to m_ID_current_state = ID_WIRE_BUTT;
if( m_ID_current_state != ID_WIRE_BUTT )
if( GetToolId() != ID_WIRE_BUTT )
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
OnLeftClick( aDC, aPosition );
break;
}
if( aItem && aItem->IsNew() && ( m_ID_current_state == ID_WIRE_BUTT ) )
if( aItem && aItem->IsNew() && ( GetToolId() == ID_WIRE_BUTT ) )
{
if( aItem->Type() == SCH_LINE_T )
{
......@@ -564,7 +551,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ADD_NOCONN_FLAG: // Add a no connected flag
if( notBusy )
{
if( m_ID_current_state != ID_NOCONN_BUTT )
if( GetToolId() != ID_NOCONN_BUTT )
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add \"NoNonnect\" Flags" ) );
OnLeftClick( aDC, aPosition );
......@@ -1032,12 +1019,9 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_LIBEDIT_CREATE_PIN:
{
wxCommandEvent evt;
evt.SetId( ID_LIBEDIT_PIN_BUTT );
Process_Special_Functions( evt );
SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add pin" ) );
OnLeftClick( aDC, aPosition );
break;
}
case HK_DELETE:
m_drawItem = LocateItemUsingCursor( aPosition );
......
......@@ -66,7 +66,7 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
wxString CmpName;
LIB_ALIAS* LibEntry = NULL;
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
if( GetScreen()->IsModify()
&& !IsOK( this, _( "Current part not saved.\n\nDiscard current changes?" ) ) )
......@@ -233,7 +233,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
wxFileName fn;
wxString msg;
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
if( GetScreen()->IsModify() )
{
......@@ -371,7 +371,7 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
wxArrayString ListNames;
wxString msg;
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
m_lastDrawItem = NULL;
m_drawItem = NULL;
......@@ -470,7 +470,7 @@ void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event )
lost!\n\nClear the current component from the screen?" ) ) )
return;
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
m_drawItem = NULL;
......
......@@ -27,38 +27,17 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
if( DrawEntry == NULL || DrawEntry->m_Flags == 0 )
{
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
if( DrawEntry == NULL )
{
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->GetCrossHairPosition() );
}
DrawEntry = LocateItemUsingCursor( aPosition );
if( DrawEntry )
DrawEntry->DisplayInfo( this );
else
DisplayCmpDoc();
}
switch( m_ID_current_state )
{
case 0:
case ID_LIBEDIT_NO_TOOL:
if( DrawEntry && DrawEntry->m_Flags ) // moved object
switch( GetToolId() )
{
switch( DrawEntry->Type() )
{
case LIB_PIN_T:
PlacePin( DC );
break;
default:
EndDrawGraphicItem( DC );
break;
}
}
case ID_NO_TOOL_SELECTED:
break;
case ID_LIBEDIT_PIN_BUTT:
......@@ -91,13 +70,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT:
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
if( DrawEntry == NULL )
{
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->GetCrossHairPosition() );
}
DrawEntry = LocateItemUsingCursor( aPosition );
if( DrawEntry == NULL )
{
......@@ -119,12 +92,12 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SaveCopyInUndoList( m_component );
PlaceAncre();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
default:
DisplayError( this, wxT( "LIB_EDIT_FRAME::OnLeftClick error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
}
}
......@@ -144,12 +117,8 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
if( ( m_drawItem == NULL ) || ( m_drawItem->m_Flags == 0 ) )
{ // We can locate an item
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
if( m_drawItem == NULL )
{
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->GetCrossHairPosition() );
}
m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem == NULL )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
......
......@@ -46,14 +46,12 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
// If Command in progress, put menu "cancel"
if( DrawEntry && DrawEntry->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING,
_( "Cancel" ), cancel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator();
}
else if( m_ID_current_state && m_ID_current_state != ID_LIBEDIT_NO_TOOL )
else if( GetToolId() != ID_NO_TOOL_SELECTED )
{ // If a tool is active, put menu "end tool"
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING,
_( "End Tool" ), cancel_tool_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "End Tool" ), cancel_tool_xpm );
PopMenu->AppendSeparator();
}
......
......@@ -105,7 +105,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias )
/* Right vertical toolbar. */
EVT_TOOL_RANGE( ID_LIBEDIT_NO_TOOL, ID_LIBEDIT_DELETE_ITEM_BUTT,
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnSelectTool )
/* menubar commands */
......@@ -155,7 +156,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnUpdateSelectAlias )
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal )
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_NO_TOOL, ID_LIBEDIT_DELETE_ITEM_BUTT,
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnUpdateEditingPart )
END_EVENT_TABLE()
......@@ -177,7 +179,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_drawSpecificUnit = false;
m_tempCopyComponent = NULL;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
m_ID_current_state = ID_LIBEDIT_NO_TOOL;
// Give an icon
SetIcon( wxIcon( libedit_xpm ) );
......@@ -442,14 +443,8 @@ void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( m_component != NULL );
if( m_component != NULL )
{
if( m_ID_current_state == 0 )
m_ID_current_state = ID_LIBEDIT_NO_TOOL;
if( aEvent.GetEventObject() == m_VToolBar )
aEvent.Check( m_ID_current_state == aEvent.GetId() );
}
if( m_component != NULL && aEvent.GetEventObject() == m_VToolBar )
aEvent.Check( GetToolId() == aEvent.GetId() );
}
......@@ -596,7 +591,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
{
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
m_convert = 1;
......@@ -642,7 +637,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( DrawPanel->IsMouseCaptured() )
DrawPanel->EndMouseCapture();
else
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
break;
case ID_POPUP_LIBEDIT_DELETE_ITEM:
......@@ -650,7 +645,8 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
default:
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(),
wxEmptyString );
break;
}
......@@ -874,7 +870,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->m_IgnoreMouseEvents = false;
if( m_ID_current_state == 0 )
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
}
......@@ -1032,14 +1028,15 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
if( m_ID_current_state == 0 )
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
DrawPanel->EndMouseCapture( ID_LIBEDIT_NO_TOOL, DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(),
wxEmptyString );
switch( id )
{
case ID_LIBEDIT_NO_TOOL:
case ID_NO_TOOL_SELECTED:
SetToolID( id, wxCURSOR_ARROW, wxEmptyString );
break;
......@@ -1054,7 +1051,7 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
GetEventHandler()->ProcessEvent( cmd );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_ARROW, wxEmptyString );
}
break;
......@@ -1085,13 +1082,13 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
case ID_LIBEDIT_IMPORT_BODY_BUTT:
SetToolID( id, wxCURSOR_ARROW, _( "Import" ) );
LoadOneSymbol();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_ARROW, wxEmptyString );
break;
case ID_LIBEDIT_EXPORT_BODY_BUTT:
SetToolID( id, wxCURSOR_ARROW, _( "Export" ) );
SaveOneSymbol();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_ARROW, wxEmptyString );
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT:
......
......@@ -31,9 +31,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
SCH_ITEM* item = GetScreen()->GetCurItem();
wxPoint gridPosition = GetGridPosition( aPosition );
if( ( m_ID_current_state == ID_SCH_NO_TOOL )
|| ( m_ID_current_state == 0 )
|| ( item && item->m_Flags ) )
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = false;
m_itemToRepeat = NULL;
......@@ -73,10 +71,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
}
switch( m_ID_current_state )
switch( GetToolId() )
{
case 0:
case ID_SCH_NO_TOOL:
case ID_NO_TOOL_SELECTED:
break;
case ID_HIERARCHY_PUSH_POP_BUTT:
......@@ -139,7 +136,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_BUSTOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{
item = CreateBusEntry( aDC, ( m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT ) ?
item = CreateBusEntry( aDC, ( GetToolId() == ID_WIRETOBUS_ENTRY_BUTT ) ?
WIRE_TO_BUS : BUS_TO_BUS );
GetScreen()->SetCurItem( item );
DrawPanel->m_AutoPAN_Request = true;
......@@ -209,10 +206,10 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_HIERLABEL_BUTT:
if( (item == NULL) || (item->m_Flags == 0) )
{
if(m_ID_current_state == ID_GLABEL_BUTT)
if( GetToolId() == ID_GLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) );
if(m_ID_current_state == ID_HIERLABEL_BUTT)
if( GetToolId() == ID_HIERLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_HIERLABEL ) );
DrawPanel->m_AutoPAN_Request = true;
......@@ -251,7 +248,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( (item->Type() == SCH_SHEET_T) && (item->m_Flags == 0) )
{
if( m_ID_current_state == ID_IMPORT_HLABEL_BUTT )
if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) );
else
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) item, aDC ) );
......@@ -296,9 +293,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
default:
SetToolID( ID_SCH_NO_TOOL, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick invalid tool ID <" ) +
wxString::Format( wxT( "%d> selected." ), m_ID_current_state ) );
wxString::Format( wxT( "%d> selected." ), GetToolId() ) );
}
}
......@@ -317,10 +314,9 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
EDA_ITEM* item = GetScreen()->GetCurItem();
wxPoint pos = aPosition;
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_SCH_NO_TOOL:
case 0:
case ID_NO_TOOL_SELECTED:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{
item = LocateAndShowItem( aPosition );
......
......@@ -79,7 +79,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
}
// If Command in progress: add "cancel" and "end tool" menu
if( m_ID_current_state && m_ID_current_state != ID_SCH_NO_TOOL)
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
{
......
......@@ -134,7 +134,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
default:
// Stop the current command and deselect the current tool
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
break;
}
......@@ -170,8 +170,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( m_ID_current_state == 0 )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_END_LINE:
......@@ -575,7 +574,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case wxID_COPY: // really this is a Save block for paste
......@@ -655,7 +654,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// End switch ( id ) (Command execution)
if( m_ID_current_state == 0 )
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_itemToRepeat = NULL;
}
......@@ -728,7 +727,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
else
{
// Stop the current command (if any) but keep the current tool
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
}
}
......@@ -738,11 +737,11 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
int id = aEvent.GetId();
// Stop the current command and deselect the current tool.
DrawPanel->EndMouseCapture( ID_SCH_NO_TOOL, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
switch( id )
{
case ID_SCH_NO_TOOL:
case ID_NO_TOOL_SELECTED:
SetToolID( id, DrawPanel->GetDefaultCursor(), _( "No tool selected" ) );
break;
......@@ -826,9 +825,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
{
if( m_ID_current_state == 0 )
m_ID_current_state = ID_SCH_NO_TOOL;
if( aEvent.GetEventObject() == m_VToolBar )
aEvent.Check( m_ID_current_state == aEvent.GetId() );
aEvent.Check( GetToolId() == aEvent.GetId() );
}
......@@ -104,6 +104,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
// Tools and buttons for vertical toolbar.
EVT_TOOL( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
SCH_EDIT_FRAME::OnSelectTool )
......@@ -124,6 +125,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
SCH_EDIT_FRAME::OnUpdateSelectTool )
......@@ -161,7 +163,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr;
m_dlgFindReplace = NULL;
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
m_ID_current_state = ID_SCH_NO_TOOL;
CreateScreens();
......
......@@ -131,7 +131,7 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC*
// This is normal when adding new items to the current component
ClearTempCopyComponent();
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_LIBEDIT_BODY_ARC_BUTT:
m_drawItem = new LIB_ARC( LibEntry );
......@@ -306,10 +306,10 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
if( m_component == NULL || m_drawItem == NULL )
return;
if( m_ID_current_state )
if( GetToolId() != ID_NO_TOOL_SELECTED )
SetCursor( wxCURSOR_PENCIL );
else
SetCursor( wxCURSOR_ARROW );
SetCursor( DrawPanel->GetDefaultCursor() );
if( GetTempCopyComponent() ) // used when editing an existing item
SaveCopyInUndoList( GetTempCopyComponent() );
......
......@@ -35,7 +35,7 @@ void LIB_EDIT_FRAME::ReCreateVToolbar()
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, false );
// Set up toolbar
m_VToolBar->AddTool( ID_LIBEDIT_NO_TOOL, wxEmptyString, wxBitmap( cursor_xpm ),
m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ),
_( "Deselect current tool" ), wxITEM_CHECK );
m_VToolBar->AddTool( ID_LIBEDIT_PIN_BUTT, wxEmptyString, wxBitmap( pin_xpm ),
......
......@@ -129,7 +129,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, false );
// Set up toolbar
m_VToolBar->AddTool( ID_SCH_NO_TOOL, wxEmptyString, wxBitmap( cursor_xpm ),
m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ),
wxEmptyString, wxITEM_CHECK );
m_VToolBar->AddTool( ID_HIERARCHY_PUSH_POP_BUTT, wxEmptyString,
......
......@@ -25,7 +25,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg;
if( m_ID_current_state == 0 )
if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
{
......@@ -47,13 +47,11 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
}
}
switch( m_ID_current_state )
switch( GetToolId() )
{
case 0:
case ID_GERBVIEW_NO_TOOL:
case ID_NO_TOOL_SELECTED:
break;
case ID_GERBVIEW_DELETE_ITEM_BUTT:
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
......@@ -106,8 +104,8 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->m_BlockLocate.ClearItemsList();
}
if( m_ID_current_state == 0 )
SetToolID( 0, 0, wxEmptyString );
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
else
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
......@@ -131,12 +129,12 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
ClearMsgPanel();
break;
case ID_GERBVIEW_NO_TOOL:
SetToolID( 0, 0, wxEmptyString );
case ID_NO_TOOL_SELECTED:
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( 0, 0, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
......
......@@ -83,7 +83,7 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
WinEDA_GerberFrame::Process_Special_Functions )
// Vertical toolbar:
EVT_TOOL( ID_GERBVIEW_NO_TOOL, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_NO_TOOL_SELECTED, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
......
......@@ -18,7 +18,6 @@ enum gerbview_ids
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
ID_GERBVIEW_NO_TOOL,
ID_GERBVIEW_DELETE_ITEM_BUTT,
ID_GERBVIEW_GLOBAL_DELETE,
ID_GERBVIEW_OPTIONS_SETUP,
......
......@@ -30,12 +30,13 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu
}
// If command in progress, end command.
if( m_ID_current_state )
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) );
else
PopMenu->Append( ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ) );
PopMenu->AppendSeparator();
}
else
......
......@@ -115,7 +115,7 @@ void WinEDA_GerberFrame::ReCreateVToolbar( void )
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE );
// Set up toolbar
m_VToolBar->AddTool( ID_GERBVIEW_NO_TOOL, wxEmptyString, wxBitmap( cursor_xpm ) );
m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ) );
m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_GERBVIEW_DELETE_ITEM_BUTT, wxEmptyString, wxBitmap( delete_body_xpm ),
_( "Delete items" ) );
......
......@@ -74,7 +74,7 @@ enum main_id
ID_KICAD_ABOUT,
ID_EDIT,
ID_NO_TOOL_SELECTED,
ID_SEL_BG_COLOR,
ID_COLORS_SETUP,
......
......@@ -194,6 +194,8 @@ public:
class EDA_DRAW_FRAME : public EDA_BASE_FRAME
{
int m_toolId; ///< Id of active button on the vertical toolbar.
public:
EDA_DRAW_PANEL* DrawPanel; // Draw area
WinEDA_MsgPanel* MsgPanel; // Panel used to display some
......@@ -211,8 +213,6 @@ public:
int m_CursorShape; // shape for cursor (0 = default
// cursor)
int m_ID_current_state; // Id of active button on the
// vertical toolbar
int m_ID_last_state; // Id of previous active button
// on the vertical toolbar
int m_HTOOL_current_state; // Id of active button on
......@@ -298,20 +298,20 @@ public:
/**
* Function SetToolID
* Enables the icon of the selected tool in the vertical toolbar.
* (Or tool ID_NO_SELECT_BUTT default if no new selection)
* @param aId = new m_ID_current_state value (if aId >= 0)
* @param aCursor = the new cursor shape
* @param aToolMsg = tool message in status bar
* if (aId >= 0)
* Updates all variables related:
* m_ID_current_state, cursor shape and message in status bar
* If (aId < 0)
* Only updates the cursor shape and message in status bar
* (does not the current m_ID_current_state value
* sets the tool command ID to \a aId and sets the cursor to \a aCursor. The
* command ID must be greater or equal ::ID_NO_TOOL_SELECTED. If the command
* ID is less than ::ID_NO_TOOL_SELECTED, the tool command ID is set to
* ::ID_NO_TOOL_SELECTED. On debug builds, an assertion will be raised when
* \a aId is invalid.
* @param aId New tool command ID if greater than or equal to ::ID_NO_TOOL_SELECTED.
If less than zero, the current tool command ID is retained.
* @param aCursor Sets the cursor shape if greater than or equal to zero.
* @param aToolMsg The tool message to set in the status bar.
*/
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg );
int GetToolId() const { return m_toolId; }
/* These 4 functions provide a basic way to show/hide grid
* and /get/set grid color.
* These parameters are saved in kicad config for each main frame
......
......@@ -97,7 +97,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
break;
default: // Abort a current command (if any)
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
break;
}
......
......@@ -388,8 +388,8 @@ void WinEDA_BasePcbFrame::SetToolID( int aId, int aCursor, const wxString& aTool
return;
// handle color changes for transitions in and out of ID_TRACK_BUTT
if( ( m_ID_current_state == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
|| ( m_ID_current_state != ID_TRACK_BUTT && aId== ID_TRACK_BUTT ) )
if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
|| ( GetToolId() != ID_TRACK_BUTT && aId== ID_TRACK_BUTT ) )
{
if( DisplayOpt.ContrastModeDisplay )
redraw = true;
......
......@@ -194,7 +194,7 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
GetScreen()->ClearBlockCommand();
SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh( true );
}
......@@ -276,7 +276,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
SetCurItem( NULL );
DrawPanel->SetMouseCapture( NULL, NULL );
DrawPanel->Refresh( true );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
}
......
......@@ -199,7 +199,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi
&& DisplayOpt.ContrastModeDisplay )
{
// when routing tracks
if( frame && frame->m_ID_current_state == ID_TRACK_BUTT )
if( frame && frame->GetToolId() == ID_TRACK_BUTT )
{
int routeTop = screen->m_Route_Layer_TOP;
int routeBot = screen->m_Route_Layer_BOTTOM;
......
......@@ -76,7 +76,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
// @todo: add switch here and add calls to PcbGeneralLocateAndDisplay( int aHotKeyCode )
// when searching is needed from a hotkey handler
}
else if( m_ID_current_state == 0 )
else if( GetToolId() == ID_NO_TOOL_SELECTED )
{
switch( m_HTOOL_current_state )
{
......@@ -93,7 +93,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
}
else
{
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_PCB_SHOW_1_RATSNEST_BUTT:
scanList = GENERAL_COLLECTOR::PadsOrModules;
......@@ -301,7 +301,7 @@ void WinEDA_PcbFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int a
*/
bool keep_on_grid = true;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = false;
/* Cursor is left off grid if no block in progress and no moving object */
......@@ -321,7 +321,7 @@ void WinEDA_PcbFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int a
grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGridSize().y;
if( Magnetize( m_Pcb, this, m_ID_current_state, grid, on_grid, &pos ) )
if( Magnetize( m_Pcb, this, GetToolId(), grid, on_grid, &pos ) )
{
GetScreen()->SetCrossHairPosition( pos );
}
......
......@@ -129,8 +129,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->m_BlockLocate.ClearItemsList();
}
if( m_ID_current_state == 0 )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
else
SetCursor( DrawPanel->GetDefaultCursor() );
......@@ -140,12 +140,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc );
if( m_ID_current_state != id )
if( GetToolId() != id )
{
if( m_ID_last_state != m_ID_current_state )
m_ID_last_state = m_ID_current_state;
if( m_ID_last_state != GetToolId() )
m_ID_last_state = GetToolId();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
break;
}
......@@ -230,7 +230,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
......@@ -1154,7 +1154,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
EDA_ITEM* current = GetScreen()->GetCurItem();
// See if we are drawing a segment; if so, add a via?
if( m_ID_current_state == ID_TRACK_BUTT && current != NULL )
if( GetToolId() == ID_TRACK_BUTT && current != NULL )
{
if( current->Type() == TYPE_TRACK && ( current->IsNew() ) )
{
......@@ -1195,17 +1195,17 @@ void WinEDA_PcbFrame::OnSelectTool( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
if( m_ID_current_state == id )
if( GetToolId() == id )
return;
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
// Stop the current command and deselect the current tool.
DrawPanel->EndMouseCapture( ID_PCB_NO_TOOL, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
switch( id )
{
case ID_PCB_NO_TOOL:
case ID_NO_TOOL_SELECTED:
SetToolID( id, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
......
......@@ -27,7 +27,7 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event )
if( fn != wxEmptyString )
{
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
::wxSetWorkingDirectory( ::wxPathOnly( fn ) );
LoadOnePcbFile( fn );
DrawPanel->MoveCursorToCrossHair();
......@@ -47,7 +47,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
if( id == ID_SAVE_BOARD )
DrawPanel->EndMouseCapture( -1, DrawPanel->GetDefaultCursor() );
else
DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
switch( id )
{
......
......@@ -243,7 +243,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosi
break;
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
if( m_ID_current_state != ID_TRACK_BUTT )
if( GetToolId() != ID_TRACK_BUTT )
return;
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
break;
......@@ -263,7 +263,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosi
Other_Layer_Route( NULL, aDC );
break;
}
if( m_ID_current_state != ID_TRACK_BUTT )
if( GetToolId() != ID_TRACK_BUTT )
return;
if( GetCurItem()->Type() != TYPE_TRACK )
return;
......@@ -283,13 +283,13 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosi
if( getActiveLayer() > LAYER_N_FRONT )
break;
if( m_ID_current_state != ID_TRACK_BUTT && !itemCurrentlyEdited )
if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited )
{
cmd.SetId( ID_TRACK_BUTT );
GetEventHandler()->ProcessEvent( cmd );
}
if( m_ID_current_state != ID_TRACK_BUTT )
if( GetToolId() != ID_TRACK_BUTT )
break;
if( !itemCurrentlyEdited ) // no track in progress:
......@@ -380,7 +380,7 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC )
BOARD_ITEM* item = GetCurItem();
bool ItemFree = (item == NULL) || (item->m_Flags == 0);
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_TRACK_BUTT:
if( getActiveLayer() > LAYER_N_FRONT )
......
......@@ -210,7 +210,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
}
if( id != ID_POPUP_CANCEL_CURRENT_COMMAND )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
}
......@@ -805,10 +805,13 @@ void WinEDA_ModuleEditFrame::OnVerticalToolbar( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
SetToolID( ID_MODEDIT_NO_TOOL, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
switch( id )
{
case ID_NO_TOOL_SELECTED:
break;
case ID_MODEDIT_LINE_TOOL:
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
break;
......@@ -840,7 +843,7 @@ void WinEDA_ModuleEditFrame::OnVerticalToolbar( wxCommandEvent& aEvent )
{
SetToolID( id, wxCURSOR_ARROW, _( "Pad settings" ) );
InstallPadOptionsFrame( NULL );
SetToolID( ID_MODEDIT_NO_TOOL, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
break;
......@@ -850,6 +853,6 @@ void WinEDA_ModuleEditFrame::OnVerticalToolbar( wxCommandEvent& aEvent )
default:
wxFAIL_MSG( wxT( "Unknown command id." ) );
SetToolID( ID_MODEDIT_NO_TOOL, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
}
......@@ -27,7 +27,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->CrossHairOff( DC );
if( m_ID_current_state == 0 || m_ID_current_state == ID_MODEDIT_NO_TOOL )
if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( item && item->m_Flags ) // Move item command in progress
{
......@@ -69,10 +69,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
SetCurItem( item );
}
switch( m_ID_current_state )
switch( GetToolId() )
{
case 0:
case ID_MODEDIT_NO_TOOL:
case ID_NO_TOOL_SELECTED:
break;
case ID_MODEDIT_CIRCLE_TOOL:
......@@ -82,9 +81,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
int shape = S_SEGMENT;
if( m_ID_current_state == ID_MODEDIT_CIRCLE_TOOL )
if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL )
shape = S_CIRCLE;
if( m_ID_current_state == ID_MODEDIT_ARC_TOOL )
if( GetToolId() == ID_MODEDIT_ARC_TOOL )
shape = S_ARC;
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
......@@ -141,7 +140,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
// Replace the module in position 0, to recalculate absolutes coordinates of items
module->SetPosition( wxPoint( 0, 0 ) );
SetToolID( 0, 0, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
SetCurItem( NULL );
DrawPanel->Refresh();
}
......@@ -173,8 +172,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
default:
DisplayError( this, wxT( "WinEDA_ModuleEditFrame::ProcessCommand error" ) );
SetToolID( 0, 0, wxEmptyString );
break;
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
DrawPanel->CrossHairOn( DC );
......@@ -199,7 +197,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopM
}
// End command in progress.
if( m_ID_current_state && m_ID_current_state != ID_MODEDIT_NO_TOOL )
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( item && item->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
......@@ -375,13 +373,12 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopM
PopMenu->AppendSeparator();
if( append_set_width
|| ( m_ID_current_state
&& ( ( m_ID_current_state == ID_PCB_ADD_LINE_BUTT )
|| ( m_ID_current_state == ID_PCB_CIRCLE_BUTT )
|| ( m_ID_current_state == ID_PCB_ARC_BUTT ) ) ) )
|| ( ( GetToolId() != ID_NO_TOOL_SELECTED )
&& ( ( GetToolId() == ID_PCB_ADD_LINE_BUTT )
|| ( GetToolId() == ID_PCB_CIRCLE_BUTT )
|| ( GetToolId() == ID_PCB_ARC_BUTT ) ) ) )
{
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ENTER_EDGE_WIDTH,
_("Set Width" ), width_segment_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ENTER_EDGE_WIDTH, _("Set Width" ), width_segment_xpm );
PopMenu->AppendSeparator();
}
......@@ -397,10 +394,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
BOARD_ITEM* item = GetCurItem();
wxPoint pos = GetPosition();
switch( m_ID_current_state )
switch( GetToolId() )
{
case 0:
case ID_MODEDIT_NO_TOOL:
case ID_NO_TOOL_SELECTED:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{
item = ModeditLocateAndDisplay();
......
......@@ -61,7 +61,8 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame )
EVT_TOOL( wxID_REDO, WinEDA_ModuleEditFrame::GetComponentFromRedoList )
// Vertical tool bar button click event handler.
EVT_TOOL_RANGE( ID_MODEDIT_NO_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
EVT_TOOL( ID_NO_TOOL_SELECTED, WinEDA_ModuleEditFrame::OnVerticalToolbar )
EVT_TOOL_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
WinEDA_ModuleEditFrame::OnVerticalToolbar )
// Options Toolbar
......@@ -99,7 +100,8 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame )
WinEDA_ModuleEditFrame::OnUpdateInsertModuleInBoard )
EVT_UPDATE_UI( ID_MODEDIT_UPDATE_MODULE_IN_BOARD,
WinEDA_ModuleEditFrame::OnUpdateReplaceModuleInBoard )
EVT_UPDATE_UI_RANGE( ID_MODEDIT_NO_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar )
EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar )
END_EVENT_TABLE()
......@@ -225,13 +227,10 @@ void WinEDA_ModuleEditFrame::CloseModuleEditor( wxCommandEvent& Event )
void WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
{
if( m_ID_current_state == 0 )
m_ID_current_state = ID_MODEDIT_NO_TOOL;
aEvent.Enable( GetBoard()->m_Modules != NULL );
if( aEvent.GetEventObject() == m_VToolBar )
aEvent.Check( m_ID_current_state == aEvent.GetId() );
aEvent.Check( GetToolId() == aEvent.GetId() );
}
......
......@@ -71,7 +71,7 @@ void WinEDA_PcbFrame::MuWaveCommand( wxDC* DC, const wxPoint& MousePos )
{
MODULE* module = NULL;
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_PCB_MUWAVE_TOOL_SELF_CMD:
Begin_Self( DC );
......@@ -96,7 +96,7 @@ void WinEDA_PcbFrame::MuWaveCommand( wxDC* DC, const wxPoint& MousePos )
default:
DrawPanel->SetCursor( wxCURSOR_ARROW );
DisplayError( this, wxT( "WinEDA_PcbFrame::MuWaveCommand() id error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
}
......
......@@ -20,11 +20,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false;
bool no_tool = m_ID_current_state == 0 || m_ID_current_state == ID_PCB_NO_TOOL;
bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED;
if( no_tool || ( DrawStruct && DrawStruct->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = false;
if( DrawStruct && DrawStruct->m_Flags ) // Command in progress
{
DrawPanel->m_IgnoreMouseEvents = true;
......@@ -131,11 +132,10 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
}
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_MAIN_MENUBAR:
case ID_PCB_NO_TOOL:
case 0:
case ID_NO_TOOL_SELECTED:
break;
case ID_PCB_MUWAVE_TOOL_SELF_CMD:
......@@ -187,9 +187,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_PCB_ADD_LINE_BUTT:
{
int shape = S_SEGMENT;
if( m_ID_current_state == ID_PCB_CIRCLE_BUTT )
if( GetToolId() == ID_PCB_CIRCLE_BUTT )
shape = S_CIRCLE;
if( m_ID_current_state == ID_PCB_ARC_BUTT )
if( GetToolId() == ID_PCB_ARC_BUTT )
shape = S_ARC;
if( getActiveLayer() <= LAST_COPPER_LAYER )
......@@ -373,9 +373,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
default:
DrawPanel->SetCursor( wxCURSOR_ARROW );
DisplayError( this, wxT( "WinEDA_PcbFrame::OnLeftClick() id error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
}
}
......@@ -387,10 +386,9 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
{
BOARD_ITEM* DrawStruct = GetCurItem();
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_PCB_NO_TOOL:
case 0:
case ID_NO_TOOL_SELECTED:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
......
......@@ -51,12 +51,11 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
DrawPanel->CrossHairOff( &dc );
if( m_ID_current_state && m_ID_current_state != ID_PCB_NO_TOOL )
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( item && item->m_Flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
}
else
{
......@@ -270,7 +269,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
}
/* Display context sensitive comands: */
switch( m_ID_current_state )
switch( GetToolId() )
{
case ID_PCB_ZONES_BUTT:
if( GetBoard()->m_ZoneDescriptorList.size() > 0 )
......@@ -316,13 +315,12 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
aPopMenu->AppendSeparator();
break;
case 0:
case ID_NO_TOOL_SELECTED:
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_MODULE )
{
wxMenu* commands = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( aPopMenu, commands,
ID_POPUP_PCB_AUTOPLACE_COMMANDS, _(
"Glob Move and Place" ), move_xpm );
ADD_MENUITEM_WITH_SUBMENU( aPopMenu, commands, ID_POPUP_PCB_AUTOPLACE_COMMANDS,
_( "Glob Move and Place" ), move_xpm );
ADD_MENUITEM( commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES,
_( "Unlock All Modules" ), unlocked_xpm );
ADD_MENUITEM( commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES,
......
......@@ -183,7 +183,9 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
WinEDA_PcbFrame::OnSelectOptionToolbar )
// Vertical toolbar:
EVT_TOOL_RANGE( ID_PCB_NO_TOOL, ID_PCB_PLACE_GRID_COORD_BUTT, WinEDA_PcbFrame::OnSelectTool )
EVT_TOOL( ID_NO_TOOL_SELECTED, WinEDA_PcbFrame::OnSelectTool )
EVT_TOOL_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_PLACE_GRID_COORD_BUTT,
WinEDA_PcbFrame::OnSelectTool )
EVT_TOOL_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
WinEDA_PcbFrame::ProcessMuWaveFunctions )
......@@ -217,7 +219,8 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
WinEDA_PcbFrame::OnUpdateHighContrastDisplayMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
WinEDA_PcbFrame::OnUpdateShowLayerManager )
EVT_UPDATE_UI_RANGE( ID_PCB_NO_TOOL, ID_PCB_PLACE_GRID_COORD_BUTT,
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, WinEDA_PcbFrame::OnUpdateVerticalToolbar )
EVT_UPDATE_UI_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_PLACE_GRID_COORD_BUTT,
WinEDA_PcbFrame::OnUpdateVerticalToolbar )
EVT_UPDATE_UI_RANGE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
WinEDA_PcbFrame::OnUpdateAuxilaryToolbar )
......
......@@ -19,7 +19,6 @@ enum pcbnew_ids
ID_READ_NETLIST,
// Right vertical tool bar command IDs.
ID_PCB_NO_TOOL,
ID_PCB_HIGHLIGHT_BUTT,
ID_PCB_SHOW_1_RATSNEST_BUTT,
ID_PCB_MODULE_BUTT,
......@@ -264,7 +263,6 @@ enum pcbnew_ids
ID_PCB_DISPLAY_OPTIONS_SETUP,
// Module editor right vertical tool bar commands.
ID_MODEDIT_NO_TOOL,
ID_MODEDIT_PAD_TOOL,
ID_MODEDIT_LINE_TOOL,
ID_MODEDIT_CIRCLE_TOOL,
......
......@@ -127,7 +127,7 @@ void WinEDA_ModuleEditFrame::ReCreateVToolbar()
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, false );
// Set up toolbar
m_VToolBar->AddTool( ID_MODEDIT_NO_TOOL, wxEmptyString, wxBitmap( cursor_xpm ),
m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ),
wxEmptyString, wxITEM_CHECK );
m_VToolBar->AddSeparator();
......
......@@ -384,7 +384,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, false );
// Set up toolbar
m_VToolBar->AddTool( ID_PCB_NO_TOOL, wxEmptyString, wxBitmap( cursor_xpm ),
m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ),
wxEmptyString, wxITEM_CHECK );
m_VToolBar->AddSeparator();
......
......@@ -146,9 +146,6 @@ void WinEDA_PcbFrame::OnUpdateSave( wxUpdateUIEvent& aEvent )
void WinEDA_PcbFrame::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
{
if( m_ID_current_state == 0 )
m_ID_current_state = ID_PCB_NO_TOOL;
if( aEvent.GetEventObject() == m_VToolBar )
aEvent.Check( m_ID_current_state == aEvent.GetId() );
aEvent.Check( GetToolId() == aEvent.GetId() );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment