diff --git a/common/common.cpp b/common/common.cpp index a6e808d882..8c0b27b2e4 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -73,8 +73,6 @@ const wxString AllFilesWildcard( _( "All files (*)|*" ) ); wxString g_ProductName = wxT( "KiCad E.D.A. " ); bool g_ShowPageLimits = true; wxString g_UserLibDirBuffer; -int g_MouseOldButtons; -int g_KeyPressed; wxString g_Prj_Default_Config_FullFilename; wxString g_Prj_Config_LocalFilename; diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index df8c3da2f0..fc54883a56 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -814,7 +814,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) static bool ignoreNextLeftButtonRelease = false; static EDA_DRAW_PANEL* LastPanel = NULL; - int localrealbutt = 0, localbutt = 0, localkey = 0; + int localrealbutt = 0, localbutt = 0; BASE_SCREEN* screen = GetScreen(); if( !screen ) @@ -846,7 +846,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) else return; - if( !event.IsButton() && !event.Moving() && !event.Dragging() && !localkey ) + if( !event.IsButton() && !event.Moving() && !event.Dragging() ) { return; } @@ -888,8 +888,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) int kbstat = 0; - g_KeyPressed = localkey; - if( event.ShiftDown() ) kbstat |= GR_KB_SHIFT; @@ -899,8 +897,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) if( event.AltDown() ) kbstat |= GR_KB_ALT; - g_MouseOldButtons = localrealbutt; - // Calling Double Click and Click functions : if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) { @@ -941,7 +937,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) } /* Calling the general function on mouse changes (and pseudo key commands) */ - GetParent()->GeneralControle( &DC, event.GetLogicalPosition( DC ) ); + GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 ); /*******************************/ /* Control of block commands : */ @@ -1090,10 +1086,10 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) { - long key, localkey; + int localkey; wxPoint pos; - key = localkey = event.GetKeyCode(); + localkey = event.GetKeyCode(); switch( localkey ) { @@ -1121,7 +1117,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) localkey |= GR_KB_CTRL; if( event.AltDown() ) localkey |= GR_KB_ALT; - if( event.ShiftDown() && (key > 256) ) + if( event.ShiftDown() && (event.GetKeyCode() > 256) ) localkey |= GR_KB_SHIFT; /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z @@ -1135,8 +1131,6 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) BASE_SCREEN* Screen = GetScreen(); - g_KeyPressed = localkey; - // Some key commands use the current mouse position: refresh it. pos = wxGetMousePosition() - GetScreenPosition(); @@ -1144,7 +1138,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) ); Screen->SetMousePosition( pos ); - GetParent()->GeneralControle( &DC, pos ); + GetParent()->GeneralControl( &DC, pos, localkey ); #if 0 event.Skip(); // Allow menu shortcut processing diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index cb30ee7e3e..9dabe7c604 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -311,7 +311,7 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) } -void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; @@ -325,7 +325,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosit oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case WXK_F1: cmd.SetId( ID_POPUP_ZOOM_IN ); diff --git a/cvpcb/class_DisplayFootprintsFrame.h b/cvpcb/class_DisplayFootprintsFrame.h index dc2e398532..cf7066fc4e 100644 --- a/cvpcb/class_DisplayFootprintsFrame.h +++ b/cvpcb/class_DisplayFootprintsFrame.h @@ -48,7 +48,7 @@ public: void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); - void GeneralControle( wxDC* DC, const wxPoint& aPosition ); + void GeneralControl( wxDC* DC, const wxPoint& aPosition, int aHotKey = 0 ); void InstallOptionsDisplay( wxCommandEvent& event ); MODULE* Get_Module( const wxString& CmpName ); diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 3f38f56f3f..d52527e8c0 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -232,19 +232,18 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin } -void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; - int hotkey = 0; wxPoint pos = aPosition; pos = screen->GetNearestGridPosition( pos ); oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case 0: break; @@ -274,7 +273,6 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; default: - hotkey = g_KeyPressed; break; } @@ -295,31 +293,30 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } } - if( hotkey ) + if( aHotKey ) { if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) - OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() ); + OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else - OnHotKey( aDC, hotkey, aPosition, NULL ); + OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); /* Display cursor coordinates info */ } -void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; - int hotkey = 0; wxPoint pos = aPosition; pos = screen->GetNearestGridPosition( pos ); oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case 0: break; @@ -349,7 +346,6 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; default: - hotkey = g_KeyPressed; break; } @@ -370,31 +366,30 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } } - if( hotkey ) + if( aHotKey ) { if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) - OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() ); + OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else - OnHotKey( aDC, hotkey, aPosition, NULL ); + OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); } -void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; - int hotkey = 0; wxPoint pos = aPosition; pos = screen->GetNearestGridPosition( pos ); oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case 0: break; @@ -424,7 +419,6 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; default: - hotkey = g_KeyPressed; break; } @@ -445,12 +439,12 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } } - if( hotkey ) + if( aHotKey ) { if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) - OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() ); + OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else - OnHotKey( aDC, hotkey, aPosition, NULL ); + OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 1b6fd7c2af..fc5bc9640c 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -105,7 +105,7 @@ public: void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ); - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void LoadSettings(); void SaveSettings(); diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 4ce54df04b..2ffaba8f28 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -69,7 +69,7 @@ public: SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void LoadSettings(); void SaveSettings(); diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index b6c5800baf..4cf6a6e62b 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -8,11 +8,10 @@ #include "gerbview.h" -void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void WinEDA_GerberFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; - int hotkey = 0; wxPoint pos = aPosition; pos = GetScreen()->GetNearestGridPosition( pos ); @@ -20,7 +19,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: @@ -47,7 +46,6 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; default: - hotkey = g_KeyPressed; break; } @@ -67,9 +65,9 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } } - if( hotkey ) + if( aHotKey ) { - OnHotKey( aDC, hotkey, NULL ); + OnHotKey( aDC, aHotKey, NULL ); } UpdateStatusBar(); diff --git a/gerbview/wxGerberFrame.h b/gerbview/wxGerberFrame.h index 36173fe1a5..dac3a7ff72 100644 --- a/gerbview/wxGerberFrame.h +++ b/gerbview/wxGerberFrame.h @@ -377,8 +377,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, bool Read_GERBER_File( const wxString& GERBER_FullFileName, const wxString& D_Code_FullFileName ); - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); - + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); /** * Function Read_D_Code_File diff --git a/include/common.h b/include/common.h index 43c8835318..7c7594297e 100644 --- a/include/common.h +++ b/include/common.h @@ -156,9 +156,6 @@ extern wxString g_ProductName; /* Default user lib path can be left void, if the standard lib path is used */ extern wxString g_UserLibDirBuffer; -extern int g_MouseOldButtons; -extern int g_KeyPressed; - extern bool g_ShowPageLimits; // TRUE to display the page limits /* File name extension definitions. */ diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 2eddafb99b..64697ca25c 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -109,7 +109,7 @@ public: void Process_Config( wxCommandEvent& event ); void OnSelectTool( wxCommandEvent& aEvent ); - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); PARAM_CFG_ARRAY& GetProjectFileParameters( void ); void SaveProjectFile( wxWindow* displayframe, bool askoverwrite = true ); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 376f593cb2..0af04b2719 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -387,7 +387,7 @@ public: void ReFillLayerWidget(); void Show3D_Frame( wxCommandEvent& event ); - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); /** * Function ShowDesignRulesEditor @@ -590,7 +590,7 @@ public: /** * Function ReadPcbFile * reads a board file <file>.brd - * @param File - The file to read from. + * @param aReader The line reader object to read from. * @param Append if 0: a previously loaded board is deleted before loading * the file else all items of the board file are added to the * existing board @@ -750,10 +750,10 @@ public: /** * Function OnEditItemRequest * Install the corresponding dialog editor for the given item - * @param DC = the current device context + * @param aDC = the current device context * @param aItem = a pointer to the BOARD_ITEM to edit */ - void OnEditItemRequest( wxDC* DC, BOARD_ITEM* aItem ); + void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ); // Highlight functions: diff --git a/include/wxstruct.h b/include/wxstruct.h index 0254b4f716..684ec468a7 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -390,7 +390,7 @@ public: void OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent ); /** - * Function GeneralControle + * Function GeneralControl * performs application specific control using \a aDC at \a aPosition in logical units. *
* Override this function for application specific control. This function gets @@ -398,8 +398,9 @@ public: *
* @param aDC A device context. * @param aPosition The current cursor position in logical (drawing) units. + * @param aHotKey A key event used for appication specific control if not zero. */ - virtual void GeneralControle( wxDC* aDC, const wxPoint& aPosition ) { /* dummy */ } + virtual void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ) { } virtual void OnSize( wxSizeEvent& event ); void OnEraseBackground( wxEraseEvent& SizeEvent ); diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index c449c5177c..260d8e4cfd 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -96,9 +96,7 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const /** * Function ReadDescr * Read description from a given line in "*.brd" format. - * @param aLine The current line which contains the first line of description. - * @param aLine The FILE to read next lines (currently not used). - * @param aLineNum a point to the line count (currently not used). + * @param aReader The line reader object which contains the first line of description. * @return int - > 0 if success reading else 0. */ int TEXTE_MODULE::ReadDescr( LINE_READER* aReader ) diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index f97e7dc5fa..aa4b0c4ff5 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -226,11 +226,10 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) } -void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void WinEDA_PcbFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; - int hotkey = 0; wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); // Save the board after the time out : @@ -264,7 +263,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) gridSize = GetScreen()->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: @@ -291,7 +290,6 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; default: - hotkey = g_KeyPressed; break; } @@ -365,9 +363,9 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) #endif } - if( hotkey ) + if( aHotKey ) { - OnHotKey( aDC, hotkey, aPosition ); + OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); /* Display new cursor coordinates */ diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index fc1acb2282..3ca4059d22 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -46,7 +46,7 @@ public: bool OnHotkeyMoveItem( int aIdCommand ); bool OnHotkeyRotateItem( int aIdCommand ); void Show3D_Frame( wxCommandEvent& event ); - void GeneralControle( wxDC* aDC, const wxPoint& aPosition ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void OnVerticalToolbar( wxCommandEvent& aEvent ); void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 16b731961a..76fe588c83 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -330,18 +330,17 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event ) } -void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) +void WinEDA_ModuleEditFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; - int hotkey = 0; wxPoint pos = aPosition; pos = GetScreen()->GetNearestGridPosition( aPosition ); oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); - switch( g_KeyPressed ) + switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: @@ -368,7 +367,6 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio break; default: - hotkey = g_KeyPressed; break; } @@ -388,9 +386,9 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio } } - if( hotkey ) + if( aHotKey ) { - OnHotKey( aDC, hotkey, aPosition ); + OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 684d4590e7..6f8d689266 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -489,13 +489,6 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) } - -/** - * Function OnEditItemRequest - * Install the corresponding dialog editor for the given item - * @param aDC = the current device context - * @param aItem = a pointer to the BOARD_ITEM to edit - */ void WinEDA_PcbFrame::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) { switch( aItem->Type() )