From 7b8b51b2408b3360fc9d174a7e00a659b0b55d00 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 11 Feb 2011 15:48:13 -0500 Subject: [PATCH] Draw panel object refactoring and other minor code cleaning. * Rename all member variables and methods that reference the cross hair code in draw panel object from cursor to cross hair to eliminate confusion between the two concepts. * Rename cursor capture call backs in draw panel object to improve code readability. * Create helper class for turning off the cross hair while drawing. * Remove redundant block clear code. * Remove redundant mouse capture call back reset code when end capture call back is called. * Remove unused function definitions in base draw frame object. * Lots of minor coding policy and doxygen comment fixes. --- common/base_screen.cpp | 20 ++- common/block_commande.cpp | 26 ++- common/copy_to_clipboard.cpp | 2 +- common/drawframe.cpp | 40 ++--- common/drawpanel.cpp | 96 ++++++----- common/sch_item_struct.cpp | 8 +- common/zoom.cpp | 52 ++---- cvpcb/class_DisplayFootprintsFrame.cpp | 34 ++-- cvpcb/cvframe.cpp | 3 +- cvpcb/setvisu.cpp | 2 +- eeschema/block.cpp | 102 ++++++------ eeschema/block_libedit.cpp | 43 +++-- eeschema/bus-wire-junction.cpp | 40 ++--- eeschema/busentry.cpp | 19 +-- eeschema/controle.cpp | 70 ++++---- eeschema/delete.cpp | 31 ++-- .../dialog_edit_component_in_schematic.cpp | 2 +- eeschema/dialogs/dialog_edit_label.cpp | 4 +- .../dialog_edit_libentry_fields_in_lib.cpp | 2 +- eeschema/dialogs/dialog_erc.cpp | 3 +- eeschema/edit_component_in_schematic.cpp | 19 +-- eeschema/edit_label.cpp | 45 +++-- eeschema/eeredraw.cpp | 6 +- eeschema/find.cpp | 22 +-- eeschema/getpart.cpp | 48 +++--- eeschema/hierarch.cpp | 4 +- eeschema/hotkeys.cpp | 10 +- eeschema/libedit.cpp | 14 +- eeschema/libedit_onleftclick.cpp | 8 +- eeschema/libeditframe.cpp | 70 ++++---- eeschema/libfield.cpp | 2 +- eeschema/locate.cpp | 2 +- eeschema/onleftclick.cpp | 4 +- eeschema/onrightclick.cpp | 12 +- eeschema/pinedit.cpp | 50 +++--- eeschema/sch_field.cpp | 3 +- eeschema/sch_sheet.cpp | 6 +- eeschema/schedit.cpp | 76 ++++----- eeschema/schframe.cpp | 11 +- eeschema/sheet.cpp | 44 +++-- eeschema/sheetlab.cpp | 22 +-- eeschema/symbdraw.cpp | 46 +++--- eeschema/symbedit.cpp | 9 +- eeschema/viewlib_frame.cpp | 7 +- eeschema/viewlibs.cpp | 2 +- gerbview/block.cpp | 59 +++---- gerbview/controle.cpp | 22 +-- gerbview/draw_gerber_screen.cpp | 6 +- gerbview/edit.cpp | 7 +- gerbview/gerberframe.cpp | 2 +- gerbview/hotkeys.cpp | 2 +- gerbview/locate.cpp | 5 +- gerbview/options.cpp | 2 +- include/class_base_screen.h | 46 +++++- include/class_drawpanel.h | 111 ++++++++++--- include/wxstruct.h | 29 +--- pcbnew/attribut.cpp | 12 +- pcbnew/automove.cpp | 23 +-- pcbnew/autoplac.cpp | 10 +- pcbnew/autorout.cpp | 7 +- pcbnew/basepcbframe.cpp | 17 +- pcbnew/block.cpp | 66 ++++---- pcbnew/block_module_editor.cpp | 50 +++--- pcbnew/clean.cpp | 10 +- pcbnew/connect.cpp | 2 +- pcbnew/controle.cpp | 35 ++-- pcbnew/cross-probing.cpp | 19 ++- pcbnew/deltrack.cpp | 7 +- .../dialog_edit_module_for_BoardEditor.cpp | 25 ++- .../dialog_edit_module_for_Modedit.cpp | 12 +- pcbnew/dialogs/dialog_general_options.cpp | 2 +- .../dialog_graphic_item_properties.cpp | 2 +- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 2 +- pcbnew/dimension.cpp | 16 +- pcbnew/edgemod.cpp | 38 ++--- pcbnew/edit.cpp | 155 +++++++++--------- pcbnew/edit_pcb_text.cpp | 21 +-- pcbnew/edit_track_width.cpp | 9 +- pcbnew/editedge.cpp | 39 ++--- pcbnew/editmod.cpp | 4 +- pcbnew/editrack-part2.cpp | 6 +- pcbnew/editrack.cpp | 21 +-- pcbnew/edtxtmod.cpp | 30 ++-- pcbnew/event_handlers_tracks_vias_sizes.cpp | 11 +- pcbnew/files.cpp | 8 +- pcbnew/find.cpp | 4 +- pcbnew/hotkeys_board_editor.cpp | 4 +- pcbnew/hotkeys_module_editor.cpp | 2 +- pcbnew/ioascii.cpp | 4 +- pcbnew/librairi.cpp | 8 +- pcbnew/loadcmp.cpp | 24 +-- pcbnew/mirepcb.cpp | 18 +- pcbnew/modedit.cpp | 68 ++++---- pcbnew/modedit_onclick.cpp | 27 ++- pcbnew/modeditoptions.cpp | 2 +- pcbnew/moduleframe.cpp | 22 +-- pcbnew/modules.cpp | 26 +-- pcbnew/move-drag_pads.cpp | 12 +- pcbnew/move_or_drag_track.cpp | 53 +++--- pcbnew/muonde.cpp | 30 ++-- pcbnew/muwave_command.cpp | 5 +- pcbnew/onleftclick.cpp | 19 ++- pcbnew/onrightclick.cpp | 12 +- pcbnew/sel_layer.cpp | 2 +- pcbnew/solve.cpp | 6 +- pcbnew/specctra_export.cpp | 4 +- pcbnew/specctra_import.cpp | 2 +- pcbnew/tracepcb.cpp | 12 +- pcbnew/xchgmod.cpp | 6 +- pcbnew/zones_by_polygon.cpp | 62 ++++--- 110 files changed, 1218 insertions(+), 1307 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 98d502f083..b1507f3dea 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -47,15 +47,15 @@ void BASE_SCREEN::InitDatas() { if( m_Center ) { - m_Curseur.x = m_Curseur.y = 0; + m_crossHairPosition.x = m_crossHairPosition.y = 0; m_DrawOrg.x = -ReturnPageSize().x / 2; m_DrawOrg.y = -ReturnPageSize().y / 2; } else { m_DrawOrg.x = m_DrawOrg.y = 0; - m_Curseur.x = ReturnPageSize().x / 2; - m_Curseur.y = ReturnPageSize().y / 2; + m_crossHairPosition.x = ReturnPageSize().x / 2; + m_crossHairPosition.y = ReturnPageSize().y / 2; } m_O_Curseur.x = m_O_Curseur.y = 0; @@ -417,15 +417,15 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoi wxPoint BASE_SCREEN::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) { if( aOnGrid ) - return GetNearestGridPosition( m_Curseur, aGridSize ); + return GetNearestGridPosition( m_crossHairPosition, aGridSize ); - return m_Curseur; + return m_crossHairPosition; } wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const { - wxPoint pos = m_Curseur - m_DrawOrg; + wxPoint pos = m_crossHairPosition - m_DrawOrg; double scalar = GetScalingFactor(); pos.x = wxRound( (double) pos.x * scalar ); @@ -434,6 +434,14 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const return pos; } +void BASE_SCREEN::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) +{ + if( aSnapToGrid ) + m_crossHairPosition = GetNearestGridPosition( aPosition ); + else + m_crossHairPosition = aPosition; +} + /* free the undo and the redo lists */ diff --git a/common/block_commande.cpp b/common/block_commande.cpp index 13f6662baf..59d655eb47 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -124,8 +124,7 @@ void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos ) SetOrigin( startpos ); SetSize( wxSize( 0, 0 ) ); m_ItemsSelection.ClearItemsList(); - aPanel->ManageCurseur = DrawAndSizingBlockOutlines; - aPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); } @@ -164,6 +163,7 @@ void BLOCK_SELECTOR::Clear() { if( m_Command != BLOCK_IDLE ) { + m_Flags = 0; m_Command = BLOCK_IDLE; m_State = STATE_NO_BLOCK; ClearItemsList(); @@ -216,20 +216,20 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* DC, int key, const wxPoint& startpo { DisplayError( this, wxT( "No Block to paste" ), 20 ); GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; return true; } - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { Block->m_ItemsSelection.ClearItemsList(); DisplayError( this, - wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: ManageCurseur NULL" ) ); + wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) ); return true; } Block->m_State = STATE_BLOCK_MOVE; - DrawPanel->ManageCurseur( DrawPanel, DC, startpos, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, startpos, false ); break; default: @@ -265,8 +265,8 @@ void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin if( aErase ) PtBlock->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, PtBlock->m_Color ); - PtBlock->m_BlockLastCursorPosition = aPanel->GetScreen()->m_Curseur; - PtBlock->SetEnd( aPanel->GetScreen()->m_Curseur ); + PtBlock->m_BlockLastCursorPosition = aPanel->GetScreen()->GetCrossHairPosition(); + PtBlock->SetEnd( aPanel->GetScreen()->GetCrossHairPosition() ); PtBlock->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, PtBlock->m_Color ); @@ -286,12 +286,11 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC ) { BASE_SCREEN* screen = Panel->GetScreen(); - if( Panel->ManageCurseur ) /* Erase current drawing - * on screen */ + if( Panel->IsMouseCaptured() ) /* Erase current drawing on screen */ { - Panel->ManageCurseur( Panel, DC, wxDefaultPosition, false ); /* Clear block outline. */ - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + /* Clear block outline. */ + Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, false ); + Panel->SetMouseCapture( NULL, NULL ); screen->SetCurItem( NULL ); /* Delete the picked wrapper if this is a picked list. */ @@ -301,7 +300,6 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC ) screen->m_BlockLocate.m_Flags = 0; screen->m_BlockLocate.m_State = STATE_NO_BLOCK; - screen->m_BlockLocate.m_Command = BLOCK_ABORT; Panel->GetParent()->HandleBlockEnd( DC ); diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index 3e67d45f59..fe9e353451 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -33,7 +33,7 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event ) if( GetScreen()->IsBlockActive() ) DrawPanel->SetCursor( wxCursor( DrawPanel->GetDefaultCursor() ) ); - DrawPanel->UnManageCursor(); + DrawPanel->EndMouseCapture(); } } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 2319857c08..b067d1c78d 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -127,15 +127,6 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() } -/* - * Display the message in the first pane of the status bar. - */ -void EDA_DRAW_FRAME::Affiche_Message( const wxString& message ) -{ - SetStatusText( message, 0 ); -} - - void EDA_DRAW_FRAME::EraseMsgBox() { if( MsgPanel ) @@ -193,10 +184,9 @@ void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event ) * because EDA_DRAW_FRAME does not know how to print a page * This is the reason it is a virtual function */ -void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, - bool aPrintMirrorMode, void* aData ) +void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, bool aPrintMirrorMode, void* aData ) { - wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error")); + wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); } @@ -256,7 +246,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) * index returned by GetSelection(). */ m_LastGridSizeId = id - ID_POPUP_GRID_LEVEL_1000; - screen->m_Curseur = DrawPanel->GetScreenCenterLogicalPosition(); + screen->SetCrossHairPosition( DrawPanel->GetScreenCenterLogicalPosition() ); screen->SetGrid( id ); Refresh(); } @@ -292,15 +282,14 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) if( GetScreen()->GetZoom() == selectedZoom ) return; - GetScreen()->m_Curseur = DrawPanel->GetScreenCenterLogicalPosition(); GetScreen()->SetZoom( selectedZoom ); - RedrawScreen( false ); + RedrawScreen( GetScreen()->GetScrollCenterPosition(), false ); } } /* Return the current zoom level */ -int EDA_DRAW_FRAME::GetZoom(void) +int EDA_DRAW_FRAME::GetZoom( void ) { return GetScreen()->GetZoom(); } @@ -469,7 +458,7 @@ int EDA_DRAW_FRAME::ReturnBlockCommand( int key ) void EDA_DRAW_FRAME::InitBlockPasteInfos() { GetScreen()->m_BlockLocate.ClearItemsList(); - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; } @@ -484,7 +473,7 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC ) } -void EDA_DRAW_FRAME::AdjustScrollBars() +void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) { int unitsX, unitsY, posX, posY; wxSize drawingSize, clientSize; @@ -537,8 +526,9 @@ void EDA_DRAW_FRAME::AdjustScrollBars() unitsY = wxRound( (double) drawingSize.y * scalar ); // Calculate the position, place the cursor at the center of screen. - posX = screen->m_Curseur.x - screen->m_DrawOrg.x; - posY = screen->m_Curseur.y - screen->m_DrawOrg.y; + screen->SetScrollCenterPosition( aCenterPosition ); + posX = aCenterPosition.x - screen->m_DrawOrg.x; + posY = aCenterPosition.y - screen->m_DrawOrg.y; posX -= wxRound( (double) clientSize.x / 2.0 ); posY -= wxRound( (double) clientSize.y / 2.0 ); @@ -612,6 +602,7 @@ double RoundTo0( double x, double precision ) return (double) ix / precision; } + /** * Function UpdateStatusBar * Displays in the bottom of the main window a stust: @@ -639,8 +630,8 @@ void EDA_DRAW_FRAME::UpdateStatusBar() SetStatusText( Line, 1 ); /* Display absolute coordinates: */ - double dXpos = To_User_Unit( g_UserUnit, screen->m_Curseur.x, m_InternalUnits ); - double dYpos = To_User_Unit( g_UserUnit, screen->m_Curseur.y, m_InternalUnits ); + double dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x, m_InternalUnits ); + double dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y, m_InternalUnits ); /* * Converting from inches to mm can give some coordinates due to @@ -694,8 +685,8 @@ void EDA_DRAW_FRAME::UpdateStatusBar() SetStatusText( Line, 2 ); /* Display relative coordinates: */ - dx = screen->m_Curseur.x - screen->m_O_Curseur.x; - dy = screen->m_Curseur.y - screen->m_O_Curseur.y; + dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; dXpos = To_User_Unit( g_UserUnit, dx, m_InternalUnits ); dYpos = To_User_Unit( g_UserUnit, dy, m_InternalUnits ); @@ -710,6 +701,7 @@ void EDA_DRAW_FRAME::UpdateStatusBar() SetStatusText( Line, 3 ); } + /** * Load draw frame specific configuration settings. * diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 631c134c0e..28166461ce 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -32,14 +32,6 @@ #define KICAD_TRACE_COORDS wxT( "kicad_dump_coords" ) -/* Used to inhibit a response to a mouse left button release, after a - * double click (when releasing the left button at the end of the second - * click. Used in eeschema to inhibit a mouse left release command when - * switching between hierarchical sheets on a double click. - */ -static bool s_IgnoreNextLeftButtonRelease = false; - - // Events used by EDA_DRAW_PANEL BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow ) EVT_LEAVE_WINDOW( EDA_DRAW_PANEL::OnMouseLeaving ) @@ -82,8 +74,8 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, m_AutoPAN_Enable = true; m_IgnoreMouseEvents = 0; - ManageCurseur = NULL; - ForceCloseManageCurseur = NULL; + m_mouseCaptureCallback = NULL; + m_endMouseCaptureCallback = NULL; if( wxGetApp().m_EDA_Config ) wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable, true ); @@ -124,12 +116,12 @@ BASE_SCREEN* EDA_DRAW_PANEL::GetScreen() } -void EDA_DRAW_PANEL::DrawCursor( wxDC* aDC, int aColor ) +void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, int aColor ) { if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair ) return; - wxPoint Cursor = GetScreen()->m_Curseur; + wxPoint Cursor = GetScreen()->GetCrossHairPosition(); GRSetDrawMode( aDC, GR_XOR ); @@ -155,17 +147,17 @@ void EDA_DRAW_PANEL::DrawCursor( wxDC* aDC, int aColor ) } -void EDA_DRAW_PANEL::CursorOff( wxDC* DC ) +void EDA_DRAW_PANEL::CrossHairOff( wxDC* DC ) { - DrawCursor( DC ); + DrawCrossHair( DC ); --m_cursorLevel; } -void EDA_DRAW_PANEL::CursorOn( wxDC* DC ) +void EDA_DRAW_PANEL::CrossHairOn( wxDC* DC ) { ++m_cursorLevel; - DrawCursor( DC ); + DrawCrossHair( DC ); if( m_cursorLevel > 0 ) // Shouldn't happen, but just in case .. m_cursorLevel = 0; @@ -237,9 +229,9 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() } -void EDA_DRAW_PANEL::MouseToCursorSchema() +void EDA_DRAW_PANEL::MoveCursorToCrossHair() { - MoveCursor( GetScreen()->m_Curseur ); + MoveCursor( GetScreen()->GetCrossHairPosition() ); } @@ -260,7 +252,8 @@ void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition ) GetScrollPixelsPerUnit( &xPpu, &yPpu ); CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y ); - wxLogDebug( wxT( "MoveCursor() initial screen position(%d, %d) " ) \ + wxLogTrace( KICAD_TRACE_COORDS, + wxT( "MoveCursor() initial screen position(%d, %d) " ) \ wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ), screenPos.x, screenPos.y, clientRect.x, clientRect.y, clientRect.width, clientRect.height, x, y ); @@ -277,7 +270,8 @@ void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition ) Scroll( x, y ); CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y ); - wxLogDebug( wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ), + wxLogTrace( KICAD_TRACE_COORDS, + wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ), screenPos.x, screenPos.y, x, y ); } @@ -567,7 +561,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE ) return; - GetParent()->PutOnGrid( &org, &gridSize ); + org = screen->GetNearestGridPosition( org, &gridSize ); // Setting the nearest grid position can select grid points outside the clip box. // Incrementing the start point by one grid step should prevent drawing grid points @@ -730,7 +724,7 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event ) pos = event.GetPosition(); m_IgnoreMouseEvents = true; PopupMenu( &MasterMenu, pos ); - MouseToCursorSchema(); + MoveCursorToCrossHair(); m_IgnoreMouseEvents = false; return true; @@ -739,7 +733,7 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event ) void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) { - if( ManageCurseur == NULL ) // No command in progress. + if( m_mouseCaptureCallback == NULL ) // No command in progress. m_AutoPAN_Request = false; if( !m_AutoPAN_Enable || !m_AutoPAN_Request || m_IgnoreMouseEvents ) @@ -778,7 +772,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) } INSTALL_UNBUFFERED_DC( dc, this ); - GetScreen()->m_Curseur = event.GetLogicalPosition( dc ); + GetScreen()->SetCrossHairPosition( event.GetLogicalPosition( dc ) ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); @@ -810,9 +804,16 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { + /* Used to inhibit a response to a mouse left button release, after a double click + * (when releasing the left button at the end of the second click. Used in eeschema + * to inhibit a mouse left release command when switching between hierarchical sheets + * on a double click. + */ + static bool ignoreNextLeftButtonRelease = false; + static EDA_DRAW_PANEL* LastPanel = NULL; + int localrealbutt = 0, localbutt = 0, localkey = 0; BASE_SCREEN* screen = GetScreen(); - static EDA_DRAW_PANEL* LastPanel; if( !screen ) return; @@ -835,7 +836,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_CanStartBlock = -1; } - if( ManageCurseur == NULL ) // No command in progress + if( !IsMouseCaptured() ) // No mouse capture in progress. m_AutoPAN_Request = false; if( GetParent()->m_FrameIsActive ) @@ -906,16 +907,16 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) // inhibit a response to the mouse left button release, // because we have a double click, and we do not want a new // OnLeftClick command at end of this Double Click - s_IgnoreNextLeftButtonRelease = true; + ignoreNextLeftButtonRelease = true; } else if( event.LeftUp() ) { // A block command is in progress: a left up is the end of block // or this is the end of a double click, already seen - if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK && !s_IgnoreNextLeftButtonRelease ) + if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK && !ignoreNextLeftButtonRelease ) GetParent()->OnLeftClick( &DC, screen->m_MousePosition ); - s_IgnoreNextLeftButtonRelease = false; + ignoreNextLeftButtonRelease = false; } if( !event.LeftIsDown() ) @@ -925,7 +926,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) * double click opens a dialog box, and the release mouse button * is made when the dialog box is open. */ - s_IgnoreNextLeftButtonRelease = false; + ignoreNextLeftButtonRelease = false; } if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) ) @@ -969,7 +970,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) * (a filter creates a delay for the real block command start, and * we must remember this point) */ - m_CursorStartPos = screen->m_Curseur; + m_CursorStartPos = screen->GetCrossHairPosition(); } if( m_Block_Enable && !(localbutt & GR_M_DCLICK) ) @@ -985,13 +986,12 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { m_AutoPAN_Request = false; GetParent()->HandleBlockPlace( &DC ); - s_IgnoreNextLeftButtonRelease = true; + ignoreNextLeftButtonRelease = true; } } else if( ( m_CanStartBlock >= 0 ) && ( event.LeftIsDown() || event.MiddleIsDown() ) - && ManageCurseur == NULL - && ForceCloseManageCurseur == NULL ) + && !IsMouseCaptured() ) { // Mouse is dragging: if no block in progress, start a block command. if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) @@ -1041,9 +1041,9 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) if( (screen->m_BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall ) { - if( ForceCloseManageCurseur ) + if( m_endMouseCaptureCallback ) { - ForceCloseManageCurseur( this, &DC ); + m_endMouseCaptureCallback( this, &DC ); m_AutoPAN_Request = false; } @@ -1068,13 +1068,9 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) // To avoid an unwanted block move command if the mouse is moved while double clicking if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) { - if( !screen->IsBlockActive() ) + if( !screen->IsBlockActive() && IsMouseCaptured() ) { - if( ForceCloseManageCurseur ) - { - ForceCloseManageCurseur( this, &DC ); - m_AutoPAN_Request = false; - } + m_endMouseCaptureCallback( this, &DC ); } } @@ -1111,10 +1107,10 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) case WXK_ESCAPE: m_AbortRequest = true; - if( ManageCurseur && ForceCloseManageCurseur ) - UnManageCursor( -1, m_defaultCursor ); + if( IsMouseCaptured() ) + EndMouseCapture( -1, m_defaultCursor ); else - UnManageCursor( 0, m_cursor, wxEmptyString ); + EndMouseCapture( 0, m_cursor, wxEmptyString ); break; } @@ -1207,14 +1203,14 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event ) } -void EDA_DRAW_PANEL::UnManageCursor( int id, int cursor, const wxString& title ) +void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title ) { - if( ManageCurseur && ForceCloseManageCurseur ) + if( m_mouseCaptureCallback && m_endMouseCaptureCallback ) { INSTALL_UNBUFFERED_DC( dc, this ); - ForceCloseManageCurseur( this, &dc ); - ManageCurseur = NULL; - ForceCloseManageCurseur = NULL; + m_endMouseCaptureCallback( this, &dc ); + m_mouseCaptureCallback = NULL; + m_endMouseCaptureCallback = NULL; m_AutoPAN_Request = false; } diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp index 90d7a7944d..3689b8c114 100644 --- a/common/sch_item_struct.cpp +++ b/common/sch_item_struct.cpp @@ -56,7 +56,7 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) { SCH_SCREEN* screen = aFrame->GetScreen(); - if( m_Flags & IS_NEW ) + if( IsNew() ) { if( !screen->CheckIfOnDrawList( this ) ) // don't want a loop! screen->AddToDrawList( this ); @@ -68,14 +68,12 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) m_Flags = 0; screen->SetModify(); screen->SetCurItem( NULL ); - aFrame->DrawPanel->ManageCurseur = NULL; - aFrame->DrawPanel->ForceCloseManageCurseur = NULL; + aFrame->DrawPanel->SetMouseCapture( NULL, NULL ); if( aDC ) { - aFrame->DrawPanel->CursorOff( aDC ); // Erase schematic cursor + EDA_CROSS_HAIR_MANAGER( aFrame->DrawPanel, aDC ); // Erase schematic cursor Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - aFrame->DrawPanel->CursorOn( aDC ); // Display schematic cursor } } diff --git a/common/zoom.cpp b/common/zoom.cpp index 4363f132a2..042ab02bb6 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -18,15 +18,13 @@ #include "hotkeys_basic.h" -void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer ) +void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) { - - PutOnGrid( &(GetScreen()->m_Curseur) ); - AdjustScrollBars(); + AdjustScrollBars( aCenterPoint ); #if !defined(__WXMAC__) /* DrawPanel->Refresh() is not used here because the redraw is delayed and the mouse - * events (from MouseToCursorSchema ot others) during this delay create problems: the + * events (from MoveCursorToCrossHair ot others) during this delay create problems: the * mouse cursor position is false in calculations. TODO: see exactly how the mouse * creates problems when moving during refresh use Refresh() and update() do not change * problems @@ -41,29 +39,17 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer ) /* Move the mouse cursor to the on grid graphic cursor position */ if( aWarpPointer ) - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } -/** Adjust the coordinate to the nearest grid value - * @param aCoord = coordinate to adjust - * @param aGridSize = pointer to a grid value. if NULL uses the current grid size - */ -void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize ) -{ - wxCHECK_RET( aCoord != NULL, wxT( "Cannot pull NULL coordinate pointer on grid." ) ); - - *aCoord = GetScreen()->GetNearestGridPosition( *aCoord, aGridSize ); -} - - /** Redraw the screen with best zoom level and the best centering * that shows all the page or the board */ -void EDA_DRAW_FRAME::Zoom_Automatique( bool move_mouse_cursor ) +void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) { - GetScreen()->SetZoom( BestZoom() ); // Set the best zoom - RedrawScreen( move_mouse_cursor ); // Set the best centering and refresh the screen + GetScreen()->SetZoom( BestZoom() ); // Set the best zoom and get center point. + RedrawScreen( GetScreen()->GetScrollCenterPosition(), aWarpPointer ); } @@ -86,8 +72,7 @@ void EDA_DRAW_FRAME::Window_Zoom( EDA_Rect& Rect ) bestscale = MAX( bestscale, scalex ); GetScreen()->SetScalingFactor( bestscale ); - GetScreen()->m_Curseur = Rect.Centre(); - RedrawScreen( TRUE ); + RedrawScreen( Rect.Centre(), true ); } @@ -104,31 +89,29 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) int id = event.GetId(); bool zoom_at_cursor = false; BASE_SCREEN* screen = GetScreen(); + wxPoint center = screen->GetScrollCenterPosition(); switch( id ) { case ID_POPUP_ZOOM_IN: zoom_at_cursor = true; + center = screen->GetCrossHairPosition(); // fall thru - case ID_ZOOM_IN: - if( id == ID_ZOOM_IN ) - screen->m_Curseur = DrawPanel->GetScreenCenterLogicalPosition(); if( screen->SetPreviousZoom() ) - RedrawScreen( zoom_at_cursor ); + RedrawScreen( center, zoom_at_cursor ); break; case ID_POPUP_ZOOM_OUT: zoom_at_cursor = true; + center = screen->GetCrossHairPosition(); // fall thru case ID_ZOOM_OUT: - if( id == ID_ZOOM_OUT ) - screen->m_Curseur = DrawPanel->GetScreenCenterLogicalPosition(); if( screen->SetNextZoom() ) - RedrawScreen( zoom_at_cursor ); + RedrawScreen( center, zoom_at_cursor ); break; case ID_ZOOM_REDRAW: @@ -136,7 +119,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; case ID_POPUP_ZOOM_CENTER: - RedrawScreen( true ); + RedrawScreen( center, true ); break; case ID_ZOOM_PAGE: @@ -147,7 +130,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; case ID_POPUP_CANCEL: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; default: @@ -160,7 +143,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) return; } if( screen->SetZoom( screen->m_ZoomList[i] ) ) - RedrawScreen( true ); + RedrawScreen( center, true ); } UpdateStatusBar(); @@ -207,8 +190,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) screen->m_ZoomList[i] / screen->m_ZoomScalar ); else msg.Printf( wxT( "%.1f" ), - (float) screen->m_ZoomList[i] / - screen->m_ZoomScalar ); + (float) screen->m_ZoomList[i] / screen->m_ZoomScalar ); zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, wxEmptyString, wxITEM_CHECK ); diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 3fa5e87ef4..e49bc17328 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -351,7 +351,7 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id ); UpdateStatusBar(); break; @@ -399,8 +399,8 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); - PutOnGrid( &pos ); - oldpos = GetScreen()->m_Curseur; + GetScreen()->SetCrossHairPosition( pos ); + oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( g_KeyPressed ) @@ -409,14 +409,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) cmd.SetId( ID_POPUP_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); flagcurseur = 2; - pos = GetScreen()->m_Curseur; + pos = GetScreen()->GetCrossHairPosition(); break; case WXK_F2: cmd.SetId( ID_POPUP_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); flagcurseur = 2; - pos = GetScreen()->m_Curseur; + pos = GetScreen()->GetCrossHairPosition(); break; case WXK_F3: @@ -429,18 +429,18 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) cmd.SetId( ID_POPUP_ZOOM_CENTER ); GetEventHandler()->ProcessEvent( cmd ); flagcurseur = 2; - pos = GetScreen()->m_Curseur; + pos = GetScreen()->GetCrossHairPosition(); break; case WXK_HOME: cmd.SetId( ID_ZOOM_PAGE ); GetEventHandler()->ProcessEvent( cmd ); flagcurseur = 2; - pos = GetScreen()->m_Curseur; + pos = GetScreen()->GetCrossHairPosition(); break; case ' ': - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case WXK_NUMPAD8: /* cursor moved up */ @@ -468,7 +468,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) break; } - GetScreen()->m_Curseur = pos; + GetScreen()->SetCrossHairPosition( pos ); if( GetScreen()->IsRefreshReq() ) { @@ -476,20 +476,20 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) Refresh(); } - if( oldpos != GetScreen()->m_Curseur ) + if( oldpos != GetScreen()->GetCrossHairPosition() ) { if( flagcurseur != 2 ) { - pos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - GetScreen()->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); } - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, 0 ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, 0 ); } } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index c68b551ca4..46c92f99b5 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -492,8 +492,7 @@ void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event ) void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event ) { CreateScreenCmp(); - DrawFrame->AdjustScrollBars(); - DrawFrame->RedrawScreen( FALSE ); + DrawFrame->RedrawScreen( wxPoint( 0, 0 ), false ); } diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index 7d34f4eaf3..d0ef6299f8 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -100,7 +100,7 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if ( Module ) Module->DisplayInfo( this ); - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); } diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 9d86040cdd..45a7511ef8 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -88,7 +88,7 @@ void SCH_EDIT_FRAME::InitBlockPasteInfos() BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; block->m_ItemsSelection.CopyList( m_blockItems.m_ItemsSelection ); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; } @@ -102,10 +102,10 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) bool err = false; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { err = true; - DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) ); + DisplayError( this, wxT( "HandleBlockPLace() : m_mouseCaptureCallback = NULL" ) ); } if( block->GetCount() == 0 ) @@ -130,8 +130,8 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) case BLOCK_MIRROR_Y: case BLOCK_DRAG: /* Drag */ case BLOCK_MOVE: /* Move */ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector ); MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector ); @@ -140,8 +140,8 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) case BLOCK_COPY: /* Copy */ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector ); @@ -152,8 +152,9 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) break; case BLOCK_PASTE: - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + PasteListOfItems( DC ); block->ClearItemsList(); break; @@ -171,14 +172,8 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) // clear struct.m_Flags. GetScreen()->ClearDrawingState(); - - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - block->m_Flags = 0; - block->m_State = STATE_NO_BLOCK; - block->m_Command = BLOCK_IDLE; + GetScreen()->ClearBlockCommand(); GetScreen()->SetCurItem( NULL ); - GetScreen()->TestDanglingEnds( DrawPanel, DC ); if( block->GetCount() ) @@ -187,6 +182,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) block->ClearItemsList(); } + DrawPanel->SetMouseCapture( NULL, NULL ); SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); DrawPanel->Refresh(); } @@ -213,20 +209,19 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) BlockState state = block->m_State; CmdBlockType command = block->m_Command; - if( DrawPanel->ForceCloseManageCurseur ) - DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + if( DrawPanel->m_endMouseCaptureCallback ) + DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC ); block->m_State = state; block->m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur = block->GetEnd(); + DrawPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); + GetScreen()->SetCrossHairPosition( block->GetEnd() ); if( block->m_Command != BLOCK_ABORT ) - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } - if( DrawPanel->ManageCurseur != NULL ) + if( DrawPanel->IsMouseCaptured() ) { switch( block->m_Command ) { @@ -251,16 +246,15 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { nextcmd = true; GetScreen()->SelectBlockItems(); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); block->m_State = STATE_BLOCK_MOVE; } else { - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->SetMouseCapture( NULL, NULL ); } break; @@ -321,9 +315,8 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) block->m_Flags = 0; block->m_State = STATE_NO_BLOCK; block->m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->SetCurItem( NULL ); + DrawPanel->SetMouseCapture( NULL, NULL ); SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); } @@ -370,8 +363,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) break; case BLOCK_DRAG: /* move to Drag */ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); // Clear list of items to move, and rebuild it with items to drag: block->ClearItemsList(); @@ -384,16 +377,16 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) blockCmdFinished = false; GetScreen()->SelectBlockItems(); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); block->m_State = STATE_BLOCK_MOVE; } break; case BLOCK_DELETE: /* move to Delete */ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); if( block->GetCount() ) { @@ -406,8 +399,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) break; case BLOCK_SAVE: /* Save list in paste buffer*/ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); if( block->GetCount() ) { @@ -418,20 +411,21 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) break; case BLOCK_ZOOM: /* Window Zoom */ - DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC ); DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() ); Window_Zoom( GetScreen()->m_BlockLocate ); break; case BLOCK_ROTATE: - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + if( block->GetCount() ) { /* Compute the rotation center and put it on grid */ wxPoint rotationPoint = block->Centre(); - PutOnGrid( &rotationPoint ); + GetScreen()->SetCrossHairPosition( rotationPoint ); SaveCopyInUndoList( block->m_ItemsSelection, UR_ROTATED, rotationPoint ); RotateListOfItems( block->m_ItemsSelection, rotationPoint ); OnModify(); @@ -442,14 +436,14 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) break; case BLOCK_MIRROR_X: - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); if( block->GetCount() ) { /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); - PutOnGrid( &mirrorPoint ); + GetScreen()->SetCrossHairPosition( mirrorPoint ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_X, mirrorPoint ); Mirror_X_ListOfItems( block->m_ItemsSelection, mirrorPoint ); OnModify(); @@ -459,14 +453,14 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) break; case BLOCK_MIRROR_Y: - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); if( block->GetCount() ) { /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); - PutOnGrid( &mirrorPoint ); + GetScreen()->SetCrossHairPosition( mirrorPoint ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint ); MirrorListOfItems( block->m_ItemsSelection, mirrorPoint ); OnModify(); @@ -482,13 +476,9 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) if( blockCmdFinished ) { - block->ClearItemsList(); - block->m_Flags = 0; - block->m_State = STATE_NO_BLOCK; - block->m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + block->Clear(); GetScreen()->SetCurItem( NULL ); + DrawPanel->SetMouseCapture( NULL, NULL ); SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); } } @@ -517,7 +507,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx } /* Repaint new view. */ - block->m_MoveVector = screen->m_Curseur - block->m_BlockLastCursorPosition; + block->m_MoveVector = screen->GetCrossHairPosition() - block->m_BlockLastCursorPosition; block->Draw( aPanel, aDC, block->m_MoveVector, g_XorMode, block->m_Color ); for( unsigned ii = 0; ii < block->GetCount(); ii++ ) diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 2267796821..b4027fb61d 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -80,14 +80,13 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { BlockState state = GetScreen()->m_BlockLocate.m_State; CmdBlockType command = GetScreen()->m_BlockLocate.m_Command; - DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC ); GetScreen()->m_BlockLocate.m_State = state; GetScreen()->m_BlockLocate.m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur.x = GetScreen()->m_BlockLocate.GetRight(); - GetScreen()->m_Curseur.y = GetScreen()->m_BlockLocate.GetBottom(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); + GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), + GetScreen()->m_BlockLocate.GetBottom() ) ); + DrawPanel->MoveCursorToCrossHair(); } switch( GetScreen()->m_BlockLocate.m_Command ) @@ -106,12 +105,14 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) if( ItemCount ) { nextCmd = true; - if( DrawPanel->ManageCurseur != NULL ) + + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } + GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; DrawPanel->Refresh( true ); } @@ -119,7 +120,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ nextCmd = true; - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; break; @@ -174,21 +175,18 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) if( ! nextCmd ) { - if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) - if ( m_component ) - m_component->ClearSelectedItems(); + if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY && m_component ) + m_component->ClearSelectedItems(); GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->SetCurItem( NULL ); + DrawPanel->SetMouseCapture( NULL, NULL ); SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); DrawPanel->Refresh( true ); } - return nextCmd; } @@ -204,10 +202,10 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) bool err = false; wxPoint pt; - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { err = true; - DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); + DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); } GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; @@ -265,14 +263,12 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->SetCurItem( NULL ); + DrawPanel->SetMouseCapture( NULL, NULL ); DrawPanel->Refresh( true ); - SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); } @@ -309,8 +305,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& } /* Repaint new view */ - PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; - PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + PtBlock->m_MoveVector = screen->GetCrossHairPosition() - PtBlock->m_BlockLastCursorPosition; GRSetDrawMode( aDC, g_XorMode ); PtBlock->Draw( aPanel, aDC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color ); diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index ad7d88ac16..c553e7c54e 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -61,7 +61,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi } } - wxPoint endpos = aPanel->GetScreen()->m_Curseur; + wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition(); if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ ComputeBreakPoint( CurrentLine, endpos ); @@ -90,7 +90,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) { SCH_LINE* oldsegment, * newsegment, * nextsegment; - wxPoint cursorpos = GetScreen()->m_Curseur; + wxPoint cursorpos = GetScreen()->GetCrossHairPosition(); if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->m_Flags == 0) ) GetScreen()->SetCurItem( NULL ); @@ -145,8 +145,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) } GetScreen()->SetCurItem( newsegment ); - DrawPanel->ManageCurseur = DrawSegment; - DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; + DrawPanel->SetMouseCapture( DrawSegment, AbortCreateNewLine ); m_itemToRepeat = NULL; } else // A segment is in progress: terminates the current segment and add a new segment. @@ -167,7 +166,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) return; } - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); /* Creates the new segment, or terminates the command * if the end point is on a pin, junction or an other wire or bus */ @@ -179,9 +178,9 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) oldsegment->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->SetDrawItems( oldsegment ); - DrawPanel->CursorOff( DC ); // Erase schematic cursor + DrawPanel->CrossHairOff( DC ); // Erase schematic cursor oldsegment->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->CursorOn( DC ); // Display schematic cursor + DrawPanel->CrossHairOn( DC ); // Display schematic cursor /* Create a new segment, and chain it after the current new segment */ if( nextsegment ) @@ -203,7 +202,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) oldsegment->m_Flags = SELECTED; newsegment->m_Flags = IS_NEW; GetScreen()->SetCurItem( newsegment ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); /* This is the first segment: Now we know the start segment position. * Create a junction if needed. Note: a junction can be needed later, @@ -269,8 +268,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) GetScreen()->SetDrawItems( lastsegment ); } - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); GetScreen()->SetCurItem( NULL ); wxPoint end_point, alt_end_point; @@ -320,7 +318,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) GetScreen()->TestDanglingEnds( DrawPanel, DC ); /* Redraw wires and junctions which can be changed by TestDanglingEnds() */ - DrawPanel->CursorOff( DC ); // Erase schematic cursor + DrawPanel->CrossHairOff( DC ); // Erase schematic cursor EDA_ITEM* item = GetScreen()->GetDrawItems(); while( item ) @@ -339,7 +337,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) item = item->Next(); } - DrawPanel->CursorOn( DC ); // Display schematic cursor + DrawPanel->CrossHairOn( DC ); // Display schematic cursor SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE ); s_OldWiresList = NULL; @@ -412,7 +410,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) SCH_POLYLINE* polyLine = (SCH_POLYLINE*) screen->GetCurItem(); wxPoint endpos; - endpos = screen->m_Curseur; + endpos = screen->GetCrossHairPosition(); int idx = polyLine->GetCornerCount() - 1; @@ -435,7 +433,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) } screen->RemoveFromDrawList( screen->GetCurItem() ); - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; screen->SetCurItem( NULL ); } @@ -449,9 +447,9 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition, m_itemToRepeat = junction; - DrawPanel->CursorOff( aDC ); // Erase schematic cursor + DrawPanel->CrossHairOff( aDC ); // Erase schematic cursor junction->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->CursorOn( aDC ); // Display schematic cursor + DrawPanel->CrossHairOn( aDC ); // Display schematic cursor junction->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->SetDrawItems( junction ); @@ -471,9 +469,9 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( wxDC* aDC, const wxPoint& aPositio NewNoConnect = new SCH_NO_CONNECT( aPosition ); m_itemToRepeat = NewNoConnect; - DrawPanel->CursorOff( aDC ); // Erase schematic cursor + DrawPanel->CrossHairOff( aDC ); // Erase schematic cursor NewNoConnect->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->CursorOn( aDC ); // Display schematic cursor + DrawPanel->CrossHairOn( aDC ); // Display schematic cursor NewNoConnect->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->SetDrawItems( NewNoConnect ); @@ -491,8 +489,6 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC ) if( screen->GetCurItem() ) { - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; screen->RemoveFromDrawList( (SCH_ITEM*) screen->GetCurItem() ); screen->SetCurItem( NULL ); screen->ReplaceWires( s_OldWiresList ); @@ -501,7 +497,6 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC ) else { SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent(); - parent->SetRepeatItem( NULL ); } @@ -529,7 +524,8 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode { - wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos; + wxPoint pos = GetScreen()->GetCrossHairPosition() - + ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos; m_itemToRepeat->m_Flags = IS_NEW; ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp(); m_itemToRepeat->Move( pos ); diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index d88b97c9f2..ee162786ad 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -45,8 +45,6 @@ static void ExitBusEntry( EDA_DRAW_PANEL* Panel, wxDC* DC ) SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent(); parent->SetRepeatItem( NULL ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; } @@ -65,7 +63,7 @@ static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a BusEntry->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); /* Redraw at the new position. */ - BusEntry->m_Pos = screen->m_Curseur; + BusEntry->m_Pos = screen->GetCrossHairPosition(); BusEntry->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); } @@ -73,7 +71,8 @@ static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* DC, int entry_type ) { // Create and place a new bus entry at cursor position - SCH_BUS_ENTRY* BusEntry = new SCH_BUS_ENTRY( GetScreen()->m_Curseur, s_LastShape, entry_type ); + SCH_BUS_ENTRY* BusEntry = new SCH_BUS_ENTRY( GetScreen()->GetCrossHairPosition(), s_LastShape, + entry_type ); BusEntry->m_Flags = IS_NEW; BusEntry->Place( this, DC );; OnModify(); @@ -96,15 +95,15 @@ void SCH_EDIT_FRAME::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, wxDC* DC ) ItemInitialPosition = BusEntry->m_Pos; - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = BusEntry->m_Pos; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( BusEntry->m_Pos ); + DrawPanel->MoveCursorToCrossHair(); GetScreen()->SetCurItem( BusEntry ); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitBusEntry; + DrawPanel->m_mouseCaptureCallback = ShowWhileMoving; + DrawPanel->m_endMouseCaptureCallback = ExitBusEntry; - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index d7cced6b4e..8dfc5ab316 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -70,7 +70,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, bool aInc break; case SCH_COMPONENT_T: - Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem ); + Pin = GetScreen()->GetPin( GetScreen()->GetCrossHairPosition(), &LibItem ); if( Pin ) break; // Priority is probing a pin first @@ -80,7 +80,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, bool aInc break; default: - Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem ); + Pin = GetScreen()->GetPin( GetScreen()->GetCrossHairPosition(), &LibItem ); break; case LIB_PIN_T: @@ -240,8 +240,8 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) int hotkey = 0; wxPoint pos = aPosition; - PutOnGrid( &pos ); - oldpos = screen->m_Curseur; + pos = screen->GetNearestGridPosition( pos ); + oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( g_KeyPressed ) @@ -279,7 +279,7 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } // Update cursor position. - screen->m_Curseur = pos; + screen->SetCrossHairPosition( pos ); if( screen->IsRefreshReq() ) { @@ -287,17 +287,17 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) wxSafeYield(); } - if( oldpos != screen->m_Curseur ) + if( oldpos != screen->GetCrossHairPosition() ) { - pos = screen->m_Curseur; - screen->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - screen->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = screen->GetCrossHairPosition(); + screen->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + screen->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, TRUE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); } } @@ -322,8 +322,8 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) int hotkey = 0; wxPoint pos = aPosition; - PutOnGrid( &pos ); - oldpos = screen->m_Curseur; + pos = screen->GetNearestGridPosition( pos ); + oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( g_KeyPressed ) @@ -361,7 +361,7 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } // Update the cursor position. - screen->m_Curseur = pos; + screen->SetCrossHairPosition( pos ); if( screen->IsRefreshReq() ) { @@ -369,17 +369,17 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) wxSafeYield(); } - if( oldpos != screen->m_Curseur ) + if( oldpos != screen->GetCrossHairPosition() ) { - pos = screen->m_Curseur; - screen->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - screen->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = screen->GetCrossHairPosition(); + screen->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + screen->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, TRUE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); } } @@ -403,8 +403,8 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) int hotkey = 0; wxPoint pos = aPosition; - PutOnGrid( &pos ); - oldpos = screen->m_Curseur; + pos = screen->GetNearestGridPosition( pos ); + oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( g_KeyPressed ) @@ -442,7 +442,7 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } // Update cursor position. - screen->m_Curseur = pos; + screen->SetCrossHairPosition( pos ); if( screen->IsRefreshReq() ) { @@ -450,17 +450,17 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) wxSafeYield(); } - if( oldpos != screen->m_Curseur ) + if( oldpos != screen->GetCrossHairPosition() ) { - pos = screen->m_Curseur; - screen->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - screen->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = screen->GetCrossHairPosition(); + screen->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + screen->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, TRUE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); } } diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 8270ef9963..df86fe3344 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -79,7 +79,7 @@ static bool MarkConnected( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, SCH_LINE void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection ) { SCH_SCREEN* screen = GetScreen(); - wxPoint refpos = screen->m_Curseur; + wxPoint refpos = screen->GetCrossHairPosition(); SCH_ITEM* DelStruct; PICKED_ITEMS_LIST pickList; @@ -97,7 +97,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection ) DelStruct = screen->GetDrawItems(); while( DelStruct - && ( DelStruct = PickStruct( screen->m_Curseur, screen, + && ( DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, JUNCTION_T | WIRE_T | BUS_T ) ) != NULL ) { DelStruct->m_Flags = SELECTEDNODE | STRUCT_DELETED; @@ -234,7 +234,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection ) } // Delete labels attached to wires - wxPoint pos = screen->m_Curseur; + wxPoint pos = screen->GetCrossHairPosition(); for( DelStruct = screen->GetDrawItems(); DelStruct != NULL; DelStruct = DelStruct->Next() ) @@ -245,8 +245,9 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection ) if( DelStruct->Type() != SCH_LABEL_T ) continue; - GetScreen()->m_Curseur = ( (SCH_TEXT*) DelStruct )->m_Pos; - EDA_ITEM* TstStruct = PickStruct( screen->m_Curseur, GetScreen(), WIRE_T | BUS_T ); + GetScreen()->SetCrossHairPosition( ( (SCH_TEXT*) DelStruct )->m_Pos ); + EDA_ITEM* TstStruct = PickStruct( screen->GetCrossHairPosition(), GetScreen(), + WIRE_T | BUS_T ); if( TstStruct && TstStruct->m_Flags & STRUCT_DELETED ) { @@ -259,7 +260,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection ) } } - screen->m_Curseur = pos; + screen->SetCrossHairPosition( pos ); } screen->ClearDrawingState(); @@ -292,23 +293,23 @@ bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC ) SCH_SCREEN* screen = (SCH_SCREEN*) ( frame->GetScreen() ); bool item_deleted = FALSE; - DelStruct = PickStruct( screen->m_Curseur, screen, MARKER_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, MARKER_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, JUNCTION_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, JUNCTION_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, NO_CONNECT_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, NO_CONNECT_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, BUS_ENTRY_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, BUS_ENTRY_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, WIRE_T | BUS_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, WIRE_T | BUS_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, DRAW_ITEM_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, DRAW_ITEM_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, TEXT_T | LABEL_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, TEXT_T | LABEL_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, COMPONENT_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, COMPONENT_T ); if( DelStruct == NULL ) - DelStruct = PickStruct( screen->m_Curseur, screen, SHEET_T ); + DelStruct = PickStruct( screen->GetCrossHairPosition(), screen, SHEET_T ); if( DelStruct ) { diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index e8535cddc8..034b792416 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -65,7 +65,7 @@ void InstallCmpeditFrame( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent ) // so it comes up wide enough next time. DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = dialog.GetSize(); - aParent->DrawPanel->MouseToCursorSchema(); + aParent->DrawPanel->MoveCursorToCrossHair(); aParent->DrawPanel->m_IgnoreMouseEvents = false; } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 971a478a2e..9090f5f097 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -183,7 +183,7 @@ void DialogLabelEditor::OnOkClick( wxCommandEvent& aEvent ) void DialogLabelEditor::OnCancelClick( wxCommandEvent& aEvent ) { - m_Parent->DrawPanel->MouseToCursorSchema(); + m_Parent->DrawPanel->MoveCursorToCrossHair(); EndModal( wxID_CANCEL ); } @@ -236,6 +236,6 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent ) g_DefaultTextLabelSize = m_CurrentText->m_Size.x; m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); - m_Parent->DrawPanel->MouseToCursorSchema(); + m_Parent->DrawPanel->MoveCursorToCrossHair(); EndModal( wxID_OK ); } diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 2a9fb39a4b..6948bb2fb4 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -109,7 +109,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event ) if( m_component == NULL ) return; - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component ); diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 5a6b41678d..c68198f0d1 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -175,8 +175,7 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); } - sheet->LastScreen()->m_Curseur = pos; - m_Parent->RedrawScreen( true ); + m_Parent->RedrawScreen( pos, true ); } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 8dd59e9ca5..6d7be389c9 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -52,9 +52,9 @@ void SCH_EDIT_FRAME::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC ) newpos = comp->GetTransform().TransformCoordinate( newpos ) + pos; - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = newpos; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( newpos ); + DrawPanel->MoveCursorToCrossHair(); m_OldPos = aField->m_Pos; m_Multiflag = 0; @@ -69,11 +69,11 @@ void SCH_EDIT_FRAME::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC ) } } - DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; - DrawPanel->ManageCurseur = MoveCmpField; + DrawPanel->m_endMouseCaptureCallback = AbortMoveCmpField; + DrawPanel->m_mouseCaptureCallback = MoveCmpField; aField->m_Flags = IS_MOVED; - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } @@ -133,7 +133,7 @@ modified!\nYou must create a new power" ) ); newtext.Trim( true ); newtext.Trim( false ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; if ( diag != wxID_OK ) return; // cancelled by user @@ -207,7 +207,7 @@ static void MoveCmpField( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos // But here we want the relative position of the moved field // and we know the actual position. // So we are using the inverse rotation/mirror transform. - wxPoint pt( aPanel->GetScreen()->m_Curseur - pos ); + wxPoint pt( aPanel->GetScreen()->GetCrossHairPosition() - pos ); TRANSFORM itrsfm = component->GetTransform().InverseTransform(); currentField->m_Pos = pos + itrsfm.TransformCoordinate( pt ); @@ -218,9 +218,6 @@ static void MoveCmpField( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos static void AbortMoveCmpField( EDA_DRAW_PANEL* Panel, wxDC* DC ) { - Panel->ForceCloseManageCurseur = NULL; - Panel->ManageCurseur = NULL; - SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) Panel->GetParent(); SCH_FIELD* currentField = frame->GetCurrentField(); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 30e0987fe8..40922db6fd 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -62,24 +62,23 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) break; } - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = ItemInitialPosition; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( ItemInitialPosition ); + DrawPanel->MoveCursorToCrossHair(); OnModify( ); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; + DrawPanel->SetMouseCapture( ShowWhileMoving,ExitMoveTexte ); GetScreen()->SetCurItem( TextStruct ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) { if( TextStruct == NULL ) - TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->m_Curseur, + TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(), TEXT_T | LABEL_T ); if( TextStruct == NULL ) return; @@ -89,7 +88,7 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) SaveCopyInUndoList( TextStruct, UR_CHANGED ); /* Erase old text */ - DrawPanel->CursorOff( DC ); + DrawPanel->CrossHairOff( DC ); TextStruct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); int orient; @@ -111,7 +110,7 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) OnModify( ); TextStruct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } @@ -126,20 +125,20 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type ) switch( type ) { case LAYER_NOTES: - NewText = new SCH_TEXT( GetScreen()->m_Curseur ); + NewText = new SCH_TEXT( GetScreen()->GetCrossHairPosition() ); break; case LAYER_LOCLABEL: - NewText = new SCH_LABEL( GetScreen()->m_Curseur ); + NewText = new SCH_LABEL( GetScreen()->GetCrossHairPosition() ); break; case LAYER_HIERLABEL: - NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur ); + NewText = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() ); NewText->m_Shape = lastGlobalLabelShape; break; case LAYER_GLOBLABEL: - NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur ); + NewText = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() ); NewText->m_Shape = lastGlobalLabelShape; break; @@ -173,9 +172,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type ) } NewText->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; - + DrawPanel->SetMouseCapture( ShowWhileMoving, ExitMoveTexte ); GetScreen()->SetCurItem( NewText ); return NewText; @@ -201,7 +198,7 @@ static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_TEXT_T: - ( (SCH_TEXT*) TextStruct )->m_Pos = aPanel->GetScreen()->m_Curseur; + ( (SCH_TEXT*) TextStruct )->m_Pos = aPanel->GetScreen()->GetCrossHairPosition(); break; default: @@ -220,8 +217,6 @@ static void ExitMoveTexte( EDA_DRAW_PANEL* Panel, wxDC* DC ) SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent(); parent->SetRepeatItem( NULL ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; if( Struct == NULL ) /* no current item */ { @@ -323,12 +318,12 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype ) } /* now delete the old text - * If it is a text flagged IS_NEW it will be deleted by ForceCloseManageCurseur() + * If it is a text flagged IS_NEW it will be deleted by m_endMouseCaptureCallback() * If not, we must delete it. */ - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + if( DrawPanel->m_mouseCaptureCallback && DrawPanel->m_endMouseCaptureCallback ) { - DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC ); } if( (flags & IS_NEW) == 0 ) // Remove old text from current list and @@ -346,7 +341,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype ) delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL; - DrawPanel->CursorOff( DC ); // Erase schematic cursor + DrawPanel->CrossHairOff( DC ); // Erase schematic cursor /* Save the new text in undo list if the old text was not itself a "new created text" * In this case, the old text is already in undo list as a deleted item. @@ -371,5 +366,5 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype ) } newtext->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->CursorOn( DC ); // redraw schematic cursor + DrawPanel->CrossHairOn( DC ); // redraw schematic cursor } diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 8fc3e97fb2..fb69c58783 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -58,10 +58,10 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->ClrRefreshReq(); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); // Display the sheet filename, and the sheet path, for non root sheets if( GetScreen()->GetFileName() == m_DefaultSchematicFileName ) diff --git a/eeschema/find.cpp b/eeschema/find.cpp index f16b07f55a..4591098a24 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -65,9 +65,9 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) m_CurrentSheet->UpdateAllScreenReferences(); } - sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos; + sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->m_Pos ); - RedrawScreen( warpCursor ); + RedrawScreen( lastMarker->m_Pos, warpCursor ); wxString path = sheetFoundIn->Path(); wxString units = GetAbbreviatedUnitsLabel(); @@ -195,8 +195,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere delta = Component->GetTransform().TransformCoordinate( pos ); pos = delta + Component->m_Pos; - wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur; - sheet->LastScreen()->m_Curseur = pos; + wxPoint old_cursor_position = sheet->LastScreen()->GetCrossHairPosition(); + sheet->LastScreen()->SetCrossHairPosition( pos ); curpos = GetScreen()->GetCrossHairScreenPosition(); @@ -216,20 +216,20 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere #undef MARGIN if( DoCenterAndRedraw ) - RedrawScreen( mouseWarp ); + RedrawScreen( curpos, mouseWarp ); else { INSTALL_UNBUFFERED_DC( dc, DrawPanel ); - EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); - DrawPanel->CursorOff( &dc ); + EXCHG( old_cursor_position, sheet->LastScreen()->GetCrossHairPosition() ); + DrawPanel->CrossHairOff( &dc ); if( mouseWarp ) DrawPanel->MoveCursor( curpos ); - EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); + EXCHG( old_cursor_position, sheet->LastScreen()->GetCrossHairPosition() ); - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); } } @@ -339,9 +339,9 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) m_CurrentSheet->UpdateAllScreenReferences(); } - sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition; + sheetFoundIn->LastScreen()->SetCrossHairPosition( lastItemPosition ); - RedrawScreen( warpCursor ); + RedrawScreen( lastItemPosition, warpCursor ); msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable(); SetStatusText( msg ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 982a1f331b..f7dfb48be9 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -34,8 +34,7 @@ wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void ) { wxSemaphore semaphore( 0, 1 ); - /* Close the current Lib browser, if open, and open a new one, in - * "modal" mode */ + /* Close the current Lib browser, if open, and open a new one, in "modal" mode */ if( m_ViewlibFrame ) { m_ViewlibFrame->Destroy(); @@ -43,7 +42,7 @@ wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void ) } m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore ); - m_ViewlibFrame->AdjustScrollBars(); + m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) ); // Show the library viewer frame until it is closed while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event @@ -105,7 +104,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if ( dlg.ShowModal() == wxID_CANCEL ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } @@ -123,7 +122,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if( Name.IsEmpty() ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } @@ -140,7 +139,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if( Name.IsEmpty() ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } } @@ -151,7 +150,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if( GetNameOfPartToLoad( this, Library, Name ) == 0 ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } } @@ -162,7 +161,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if( Name.IsEmpty() ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } } @@ -182,13 +181,13 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, if( Entry == NULL ) { DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } } DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( Entry == NULL ) { @@ -199,12 +198,10 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, lastCommponentName = Name; AddHistoryComponentName( HistoryList, Name ); - - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + DrawPanel->SetMouseCapture( ShowWhileMoving, ExitPlaceCmp ); Component = new SCH_COMPONENT( *Entry, GetSheet(), unit, convert, - GetScreen()->m_Curseur, true ); + GetScreen()->GetCrossHairPosition(), true ); // Set the m_ChipName value, from component name in lib, for aliases // Note if Entry is found, and if Name is an alias of a component, // alias exists because its root component was found @@ -234,7 +231,7 @@ static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a Component->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); } - move_vector = screen->m_Curseur - Component->m_Pos; + move_vector = screen->GetCrossHairPosition() - Component->m_Pos; Component->Move( move_vector ); Component->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); } @@ -253,7 +250,7 @@ void SCH_EDIT_FRAME::CmpRotationMiroir( SCH_COMPONENT* DrawComponent, wxDC* DC, /* Deletes the previous component. */ if( DC ) { - DrawPanel->CursorOff( DC ); + DrawPanel->CrossHairOff( DC ); if( DrawComponent->m_Flags ) DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); @@ -272,7 +269,7 @@ void SCH_EDIT_FRAME::CmpRotationMiroir( SCH_COMPONENT* DrawComponent, wxDC* DC, DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); else DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } GetScreen()->TestDanglingEnds( DrawPanel, DC ); @@ -302,9 +299,7 @@ static void ExitPlaceCmp( EDA_DRAW_PANEL* Panel, wxDC* DC ) Component->m_Flags = 0; } - Panel->Refresh( TRUE ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->Refresh( true ); screen->SetCurItem( NULL ); } @@ -427,12 +422,11 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC ) g_ItemToUndoCopy = Component->Clone(); } - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = Component->m_Pos; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( Component->m_Pos ); + DrawPanel->MoveCursorToCrossHair(); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + DrawPanel->SetMouseCapture( ShowWhileMoving, ExitPlaceCmp ); GetScreen()->SetCurItem( Component ); OldPos = Component->m_Pos; OldTransform = Component->GetTransform(); @@ -455,10 +449,10 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC ) Component->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, FALSE ); #endif DrawPanel->m_AutoPAN_Request = TRUE; - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 3d41c58ddf..48cf14754a 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -270,7 +270,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() } else { - DrawPanel->MouseToCursorSchema(); - RedrawScreen( true ); + DrawPanel->MoveCursorToCrossHair(); + RedrawScreen( screen->GetScrollCenterPosition(), true ); } } diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 94b82779f0..c2f9f97386 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_ZOOM_IN: @@ -724,7 +724,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, { SCH_SHEET* sheet = (SCH_SHEET*) aItem; // If it's a sheet, then check if a pinsheet is under the cursor - SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->m_Curseur ); + SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->GetCrossHairPosition() ); if( slabel ) aItem = slabel; @@ -733,7 +733,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, if( aItem->Type() == SCH_JUNCTION_T ) { // If it's a junction, pick the underlying wire instead - aItem = PickStruct( GetScreen()->m_Curseur, GetScreen(), WIRE_T ); + aItem = PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(), WIRE_T ); } if( aItem == NULL ) @@ -813,7 +813,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, if( aItem == NULL ) { - aItem = PickStruct( GetScreen()->m_Curseur, GetScreen(), + aItem = PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(), COMPONENT_T | TEXT_T | LABEL_T | SHEET_T ); if( aItem == NULL ) break; @@ -928,7 +928,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_ZOOM_IN: diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 53c4cdfd42..fec9d31df0 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -66,7 +66,7 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event ) wxString CmpName; LIB_ALIAS* LibEntry = NULL; - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); if( GetScreen()->IsModify() && !IsOK( this, _( "Current part not saved.\n\nDiscard current changes?" ) ) ) @@ -216,10 +216,10 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->ClrRefreshReq(); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); DisplayLibInfos(); UpdateStatusBar(); @@ -235,7 +235,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event ) wxFileName fn; wxString msg; - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); if( GetScreen()->IsModify() ) { @@ -373,7 +373,7 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event ) wxArrayString ListNames; wxString msg; - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); m_lastDrawItem = NULL; m_drawItem = NULL; @@ -472,7 +472,7 @@ void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event ) lost!\n\nClear the current component from the screen?" ) ) ) return; - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); m_drawItem = NULL; diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index ac3b1a61e7..62320f0581 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -49,7 +49,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( DrawEntry == NULL ) { DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, - GetScreen()->m_Curseur ); + GetScreen()->GetCrossHairPosition() ); } if( DrawEntry ) @@ -103,7 +103,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( DrawEntry == NULL ) { DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, - GetScreen()->m_Curseur ); + GetScreen()->GetCrossHairPosition() ); } if( DrawEntry == NULL ) { @@ -156,7 +156,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) if( m_drawItem == NULL ) { m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, - GetScreen()->m_Curseur ); + GetScreen()->GetCrossHairPosition() ); } if( m_drawItem == NULL ) { @@ -227,6 +227,6 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) break; } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index a37b13f48b..48903593db 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -347,13 +347,13 @@ int LIB_EDIT_FRAME::BestZoom() BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert ); dx = BoundaryBox.GetWidth(); dy = BoundaryBox.GetHeight(); - GetScreen()->m_Curseur = BoundaryBox.Centre(); + GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() ); } else { dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; - GetScreen()->m_Curseur = wxPoint( 0, 0 ); + GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); } /* @@ -375,6 +375,7 @@ int LIB_EDIT_FRAME::BestZoom() { if( m_clientSize == wxSize( -1, -1 ) ) m_clientSize = DrawPanel->GetClientSize(); + size = m_clientSize; } @@ -582,7 +583,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) { - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ) m_convert = 1; @@ -625,18 +626,18 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_LIBEDIT_CANCEL_EDITING: - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - DrawPanel->UnManageCursor(); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->EndMouseCapture(); else - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); break; case ID_POPUP_LIBEDIT_DELETE_ITEM: - DrawPanel->UnManageCursor(); + DrawPanel->EndMouseCapture(); break; default: - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW, wxEmptyString ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor(), wxEmptyString ); break; } @@ -715,7 +716,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_LIBEDIT_END_CREATE_ITEM: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( m_drawItem ) { EndDrawGraphicItem( &dc ); @@ -725,7 +726,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: if( m_drawItem ) { - DrawPanel->CursorOff( &dc ); + DrawPanel->CrossHairOff( &dc ); switch( m_drawItem->Type() ) { @@ -744,7 +745,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ; } - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); } break; @@ -765,11 +766,11 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_drawItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); int oldFlags = m_drawItem->GetFlags(); m_drawItem->SetFlags( 0 ); m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); - ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCursorDrawPosition() ); + ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) ); m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform ); m_drawItem->SetFlags( oldFlags ); break; @@ -778,30 +779,31 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_DELETE_ITEM: if( m_drawItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOff( &dc ); + DrawPanel->MoveCursorToCrossHair(); + DrawPanel->CrossHairOff( &dc ); SaveCopyInUndoList( m_component ); + if( m_drawItem->Type() == LIB_PIN_T ) { DeletePin( &dc, m_component, (LIB_PIN*) m_drawItem ); } else { - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); else m_component->RemoveDrawItem( m_drawItem, DrawPanel, &dc ); } m_drawItem = NULL; OnModify( ); - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); break; case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST: if( m_drawItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( m_drawItem->Type() == LIB_PIN_T ) StartMovePin( &dc ); else @@ -813,7 +815,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_drawItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( m_drawItem->Type() == LIB_RECTANGLE_T || m_drawItem->Type() == LIB_CIRCLE_T || m_drawItem->Type() == LIB_POLYLINE_T @@ -828,7 +830,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT: if( m_drawItem == NULL && m_drawItem->Type() != LIB_TEXT_T ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( !m_drawItem->InEditMode() ) { SaveCopyInUndoList( m_component ); @@ -843,7 +845,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { if( m_drawItem == NULL || ( m_drawItem->Type() != LIB_FIELD_T ) ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( !m_drawItem->InEditMode() ) { @@ -859,13 +861,13 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: if( m_drawItem == NULL ) break; - DrawPanel->CursorOff( &dc ); + DrawPanel->CrossHairOff( &dc ); if( m_drawItem->Type() == LIB_FIELD_T ) { EditField( &dc, (LIB_FIELD*) m_drawItem ); } - DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOn( &dc ); + DrawPanel->MoveCursorToCrossHair(); + DrawPanel->CrossHairOn( &dc ); break; case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: @@ -876,7 +878,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; SaveCopyInUndoList( m_component ); GlobalSetPins( &dc, (LIB_PIN*) m_drawItem, id ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_ZOOM_BLOCK: @@ -888,34 +890,34 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_DELETE_BLOCK: DrawPanel->m_AutoPAN_Request = false; GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEnd( &dc ); break; case ID_POPUP_COPY_BLOCK: DrawPanel->m_AutoPAN_Request = false; GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_SELECT_ITEMS_BLOCK: DrawPanel->m_AutoPAN_Request = false; GetScreen()->m_BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEnd( &dc ); break; case ID_POPUP_MIRROR_Y_BLOCK: DrawPanel->m_AutoPAN_Request = false; GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_Y; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_PLACE_BLOCK: DrawPanel->m_AutoPAN_Request = false; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; @@ -1074,8 +1076,8 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) wxT( "Cannot create new part from non-existant current part." ) ); INSTALL_UNBUFFERED_DC( dc, DrawPanel ); - DrawPanel->CursorOff( &dc ); + DrawPanel->CrossHairOff( &dc ); EditField( &dc, &m_component->GetValueField() ); - DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOn( &dc ); + DrawPanel->MoveCursorToCrossHair(); + DrawPanel->CrossHairOn( &dc ); } diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 0fdf724ed7..28bff3d7cd 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -166,7 +166,7 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor() if( m_drawItem == NULL ) m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, - GetScreen()->m_Curseur ); + GetScreen()->GetCrossHairPosition() ); } return m_drawItem; diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index b73ef03dba..048a0f634a 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -47,7 +47,7 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen ) { if( !SnapPoint2( Screen->m_MousePosition, COMPONENT_T, DrawList ) ) { - if( !SnapPoint2( Screen->m_Curseur, COMPONENT_T, DrawList ) ) + if( !SnapPoint2( Screen->GetCrossHairPosition(), COMPONENT_T, DrawList ) ) break; } diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 2d78bd5df5..dc911c83a8 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -352,7 +352,7 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) case SCH_COMPONENT_T: InstallCmpeditFrame( this, (SCH_COMPONENT*) item ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case SCH_TEXT_T: @@ -364,7 +364,7 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) case SCH_FIELD_T: EditCmpFieldText( (SCH_FIELD*) item, aDC ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case SCH_MARKER_T: diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 0dc9a98b2a..b7bdc9d92b 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -71,7 +71,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) if( DrawStruct && (DrawStruct->Type() == SCH_SHEET_T) ) { SCH_SHEET* sheet = (SCH_SHEET*) DrawStruct; - SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->m_Curseur ); + SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->GetCrossHairPosition() ); if( slabel ) DrawStruct = slabel; @@ -494,7 +494,7 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAM if( !is_new ) { - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), + if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); } @@ -502,7 +502,7 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAM msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm ); - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), WIRE_T | BUS_T ) ) + if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), WIRE_T | BUS_T ) ) { ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), @@ -514,7 +514,7 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAM void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) { bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; - wxPoint pos = frame->GetScreen()->m_Curseur; + wxPoint pos = frame->GetScreen()->GetCrossHairPosition(); wxString msg; if( is_new ) @@ -532,7 +532,7 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), delete_connection_xpm ); - if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), + if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); @@ -552,7 +552,7 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) { bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; - wxPoint pos = frame->GetScreen()->m_Curseur; + wxPoint pos = frame->GetScreen()->GetCrossHairPosition(); wxString msg; if( is_new ) { diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 5d94c591e0..a8127bf751 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -123,7 +123,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) if( pin->IsNew() ) { pin->m_Flags |= IS_CANCELLED; - DrawPanel->UnManageCursor(); + DrawPanel->EndMouseCapture(); } return; } @@ -194,8 +194,6 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ) parent->RestoreComponent(); /* clear edit flags */ - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; parent->SetDrawItem( NULL ); parent->SetLastDrawItem( NULL ); Panel->Refresh( true ); @@ -216,12 +214,11 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC ) // Some tests if( (CurrentPin == NULL) || (CurrentPin->Type() != LIB_PIN_T) ) { - wxMessageBox( wxT("LIB_EDIT_FRAME::PlacePin() error") ); + wxMessageBox( wxT( "LIB_EDIT_FRAME::PlacePin() error" ) ); return; } - newpos.x = GetScreen()->m_Curseur.x; - newpos.y = -GetScreen()->m_Curseur.y; + newpos = GetScreen()->GetCrossHairPosition( true ); // Tst for an other pin in same new position: for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) @@ -235,7 +232,7 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC ) status = IsOK( this, _( "This position is already occupied by \ another pin. Continue?" ) ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = false; if( !status ) @@ -252,8 +249,7 @@ another pin. Continue?" ) ); else SaveCopyInUndoList( m_component ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->EndMouseCapture(); OnModify(); CurrentPin->SetPosition( newpos ); @@ -280,11 +276,11 @@ another pin. Continue?" ) ); Pin->m_Flags = 0; } - DrawPanel->CursorOff( DC ); + DrawPanel->CrossHairOff( DC ); bool showPinText = true; CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, &showPinText, DefaultTransform ); - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); m_drawItem = NULL; } @@ -322,15 +318,13 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC ) startPos.x = OldPos.x; startPos.y = -OldPos.y; - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = startPos; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( startPos ); + DrawPanel->MoveCursorToCrossHair(); CurrentPin->DisplayInfo( this ); - DrawPanel->ManageCurseur = DrawMovePin; - DrawPanel->ForceCloseManageCurseur = AbortPinMove; - - DrawPanel->CursorOn( DC ); + DrawPanel->SetMouseCapture( DrawMovePin, AbortPinMove ); + DrawPanel->CrossHairOn( DC ); } @@ -361,7 +355,7 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi } /* Redraw pin in new position */ - CurrentPin->SetPosition( aPanel->GetScreen()->GetCursorDrawPosition() ); + CurrentPin->SetPosition( aPanel->GetScreen()->GetCrossHairPosition( true ) ); CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), -1, g_XorMode, &showPinText, DefaultTransform ); PinPreviousPos = CurrentPin->GetPosition(); @@ -435,7 +429,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) if( g_EditPinByPinIsOn == false ) pin->m_Flags |= IS_LINKED; - pin->SetPosition( GetScreen()->GetCursorDrawPosition() ); + pin->SetPosition( GetScreen()->GetCrossHairPosition( true ) ); pin->SetLength( LastPinLength ); pin->SetOrientation( LastPinOrient ); pin->SetType( LastPinType ); @@ -451,7 +445,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetId( ID_LIBEDIT_EDIT_PIN ); GetEventHandler()->ProcessEvent( cmd ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = false; if( pin->m_Flags & IS_CANCELLED ) @@ -462,8 +456,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) else { ClearTempCopyComponent(); - DrawPanel->ManageCurseur = DrawMovePin; - DrawPanel->ForceCloseManageCurseur = AbortPinMove; + DrawPanel->SetMouseCapture( DrawMovePin, AbortPinMove ); if( DC ) pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, wxCOPY, &showPinText, @@ -607,10 +600,9 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) if( g_EditPinByPinIsOn == false ) Pin->m_Flags |= IS_LINKED; - wxPoint savepos = GetScreen()->m_Curseur; - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur.x = Pin->GetPosition().x; - GetScreen()->m_Curseur.y = -Pin->GetPosition().y; + wxPoint savepos = GetScreen()->GetCrossHairPosition(); + DrawPanel->CrossHairOff( DC ); + GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x, -Pin->GetPosition().y ) ); // Add this new pin in list, and creates pins for others parts if needed m_drawItem = Pin; @@ -618,8 +610,8 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) PlacePin( DC ); m_lastDrawItem = Pin; - GetScreen()->m_Curseur = savepos; - DrawPanel->CursorOn( DC ); + GetScreen()->SetCrossHairPosition( savepos ); + DrawPanel->CrossHairOn( DC ); Pin->DisplayInfo( this ); OnModify( ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 0b65c3d790..fd6aa315f8 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -366,8 +366,7 @@ void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) int fieldNdx; LIB_COMPONENT* Entry; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->SetMouseCapture( NULL, NULL ); SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index eea3073c17..f36507e602 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -417,9 +417,9 @@ void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) if( IsNew() ) { // fix size and position of the new sheet - // using the last values set by the ManageCurseur function - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + // using the last values set by the m_mouseCaptureCallback function + frame->DrawPanel->SetMouseCapture( NULL, NULL ); + if( !frame->EditSheet( this, DC ) ) { frame->GetScreen()->SetCurItem( NULL ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 705d996ef4..5af286c89d 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -128,13 +128,13 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_DELETE: // Stop the current command (if any) but keep the current tool - DrawPanel->UnManageCursor(); + DrawPanel->EndMouseCapture(); break; default: // Stop the current command and deselect the current tool - DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); break; } @@ -156,7 +156,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case wxID_PASTE: - HandleBlockBegin( &dc, BLOCK_PASTE, screen->m_Curseur ); + HandleBlockBegin( &dc, BLOCK_PASTE, screen->GetCrossHairPosition() ); break; case ID_HIERARCHY_PUSH_POP_BUTT: @@ -228,12 +228,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_ENTRY_SELECT_SLASH: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) screen->GetCurItem(), '/' ); break; case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) screen->GetCurItem(), '\\' ); break; @@ -243,7 +243,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_END_LINE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); EndSegment( &dc ); break; @@ -252,27 +252,27 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_ROTATE_TEXT: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ChangeTextOrient( (SCH_TEXT*) screen->GetCurItem(), &dc ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_LABEL_T ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_GLOBAL_LABEL_T ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_HIERARCHICAL_LABEL_T ); break; case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_TEXT_T ); break; @@ -282,7 +282,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_ROTATE_FIELD: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); RotateCmpField( (SCH_FIELD*) screen->GetCurItem(), &dc ); break; @@ -292,7 +292,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_DELETE_NODE: case ID_POPUP_SCH_DELETE_CONNECTION: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE ); screen->SetCurItem( NULL ); m_itemToRepeat = NULL; @@ -302,9 +302,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_BREAK_WIRE: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SCH_ITEM* oldWiresList = screen->ExtractWires( true ); - screen->BreakSegment( screen->m_Curseur ); + screen->BreakSegment( screen->GetCrossHairPosition() ); if( oldWiresList ) SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE ); @@ -343,12 +343,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_END_SHEET: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); screen->GetCurItem()->Place( this, &dc ); break; case ID_POPUP_SCH_RESIZE_SHEET: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ReSizeSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ); screen->TestDanglingEnds( DrawPanel, &dc ); break; @@ -391,7 +391,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_MOVE_PINSHEET: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMove_PinSheet( (SCH_SHEET_PIN*) screen->GetCurItem(), &dc ); break; @@ -413,7 +413,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) // fall through case ID_POPUP_SCH_MOVE_ITEM_REQUEST: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST ) { @@ -421,7 +421,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) // is to simulate a block drag command if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) { - if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->m_Curseur ) ) + if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->GetCrossHairPosition() ) ) break; // Give a non null size to the search block: @@ -434,12 +434,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_DRAG_WIRE_REQUEST: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // The easiest way to handle a drag component is to simulate a // block drag command if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) { - if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->m_Curseur ) ) + if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->GetCrossHairPosition() ) ) break; // Ensure the block selection contains the segment, or one end of @@ -500,7 +500,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) option = CMP_NORMAL; break; } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( screen->GetCurItem()->m_Flags == 0 ) SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), UR_CHANGED ); @@ -510,7 +510,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } case ID_POPUP_SCH_INIT_CMP: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_SCH_EDIT_VALUE_CMP: @@ -563,7 +563,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( screen->GetCurItem() == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ConvertPart( (SCH_COMPONENT*) screen->GetCurItem(), &dc ); break; @@ -602,7 +602,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( screen->GetCurItem() == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SelPartUnit( (SCH_COMPONENT*) screen->GetCurItem(), id + 1 - ID_POPUP_SCH_SELECT_UNIT1, &dc ); break; @@ -656,7 +656,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PLACE_BLOCK: DrawPanel->m_AutoPAN_Request = FALSE; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; @@ -665,39 +665,39 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_DELETE_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); SetSheetNumberAndCount(); break; case ID_POPUP_ROTATE_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_ROTATE, &dc ); break; case ID_POPUP_MIRROR_X_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc ); break; case ID_POPUP_MIRROR_Y_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc ); break; case ID_POPUP_COPY_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_COPY, &dc ); break; case ID_POPUP_DRAG_BLOCK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); HandleBlockEndByPopUp( BLOCK_DRAG, &dc ); break; case ID_POPUP_SCH_ADD_JUNCTION: - DrawPanel->MouseToCursorSchema(); - screen->SetCurItem( AddJunction( &dc, screen->m_Curseur, true ) ); + DrawPanel->MoveCursorToCrossHair(); + screen->SetCurItem( AddJunction( &dc, screen->GetCrossHairPosition(), true ) ); screen->TestDanglingEnds( DrawPanel, &dc ); screen->SetCurItem( NULL ); break; @@ -739,7 +739,7 @@ void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC ) if( DrawStruct == NULL ) return; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); switch( DrawStruct->Type() ) { @@ -797,11 +797,11 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) screen->ClearBlockCommand(); // Stop the current command (if any) but keep the current tool - DrawPanel->UnManageCursor(); + DrawPanel->EndMouseCapture(); } else { // Stop the current command (if any) but keep the current tool - DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); } } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 636e1913e0..4c82668504 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -398,8 +398,7 @@ int SCH_EDIT_FRAME::BestZoom() size = DrawPanel->GetClientSize(); zoom = MAX( (double) dx / (double) size.x, (double) dy / (double) size.y ); - GetScreen()->m_Curseur.x = dx / 2; - GetScreen()->m_Curseur.y = dy / 2; + GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) ); return wxRound( zoom * (double) GetScreen()->m_ZoomScalar ); } @@ -693,12 +692,12 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event ) { if( m_ViewlibFrame ) { - m_ViewlibFrame->Show( TRUE ); + m_ViewlibFrame->Show( true ); } else { m_ViewlibFrame = new LIB_VIEW_FRAME( this ); - m_ViewlibFrame->AdjustScrollBars(); + m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) ); } } @@ -707,7 +706,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) { if( m_LibeditFrame ) { - m_LibeditFrame->Show( TRUE ); + m_LibeditFrame->Show( true ); } else { @@ -715,7 +714,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) wxT( "Library Editor" ), wxPoint( -1, -1 ), wxSize( 600, 400 ) ); - m_LibeditFrame->AdjustScrollBars(); + m_LibeditFrame->AdjustScrollBars( wxPoint( 0, 0 ) ); } } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 65e5a2f34a..4b477cf602 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -210,7 +210,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) if( aSheet->m_SheetName.IsEmpty() ) aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = false; aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); @@ -219,7 +219,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) /* Move selected sheet with the cursor. - * Callback function use by ManageCurseur. + * Callback function use by m_mouseCaptureCallback. */ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) @@ -233,13 +233,13 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( sheet->m_Flags & IS_RESIZED ) { - wxSize newSize( MAX( s_PreviousSheetWidth, screen->m_Curseur.x - sheet->m_Pos.x ), - MAX( s_PreviousSheetHeight, screen->m_Curseur.y - sheet->m_Pos.y ) ); + wxSize newSize( MAX( s_PreviousSheetWidth, screen->GetCrossHairPosition().x - sheet->m_Pos.x ), + MAX( s_PreviousSheetHeight, screen->GetCrossHairPosition().y - sheet->m_Pos.y ) ); sheet->Resize( newSize ); } else /* Move Sheet */ { - moveVector = screen->m_Curseur - sheet->m_Pos; + moveVector = screen->GetCrossHairPosition() - sheet->m_Pos; sheet->Move( moveVector ); } @@ -263,12 +263,12 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) } else if( (sheet->m_Flags & (IS_RESIZED|IS_MOVED)) ) { - wxPoint curspos = screen->m_Curseur; - aPanel->GetScreen()->m_Curseur = s_OldPos; + wxPoint curspos = screen->GetCrossHairPosition(); + aPanel->GetScreen()->SetCrossHairPosition( s_OldPos ); MoveOrResizeSheet( aPanel, aDC, wxDefaultPosition, true ); sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); sheet->m_Flags = 0; - screen->m_Curseur = curspos; + screen->SetCrossHairPosition( curspos ); } else { @@ -276,8 +276,6 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) } screen->SetCurItem( NULL ); - aPanel->ManageCurseur = NULL; - aPanel->ForceCloseManageCurseur = NULL; SAFE_DELETE( g_ItemToUndoCopy ); } @@ -292,7 +290,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) m_itemToRepeat = NULL; SAFE_DELETE( g_ItemToUndoCopy ); - SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur ); + SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->GetCrossHairPosition() ); sheet->m_Flags = IS_NEW | IS_RESIZED; sheet->m_TimeStamp = GetTimeStamp(); @@ -305,10 +303,8 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) // also need to update the hierarchy, if we are adding // a sheet to a screen that already has multiple instances (!) GetScreen()->SetCurItem( sheet ); - - DrawPanel->ManageCurseur = MoveOrResizeSheet; - DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, aDC, wxDefaultPosition, false ); + DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, false ); return sheet; } @@ -341,9 +337,8 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) sheetLabel.m_Pos.y - aSheet->m_Pos.y ); } - DrawPanel->ManageCurseur = MoveOrResizeSheet; - DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, aDC, wxDefaultPosition, true ); + DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, true ); if( (aSheet->m_Flags & IS_NEW) == 0 ) // not already in edit, save a copy for undo/redo { @@ -358,16 +353,15 @@ void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC ) if( ( aSheet == NULL ) || ( aSheet->Type() != SCH_SHEET_T ) ) return; - DrawPanel->CursorOff( aDC ); - GetScreen()->m_Curseur = aSheet->m_Pos; - DrawPanel->MouseToCursorSchema(); + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( aSheet->m_Pos ); + DrawPanel->MoveCursorToCrossHair(); s_OldPos = aSheet->m_Pos; aSheet->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = MoveOrResizeSheet; - DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, aDC, wxDefaultPosition, true ); - DrawPanel->CursorOn( aDC ); + DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, true ); + DrawPanel->CrossHairOn( aDC ); if( (aSheet->m_Flags & IS_NEW) == 0 ) // not already in edit, save a copy for undo/redo { diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 7d2dc31c4d..a1ec70cd65 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -57,8 +57,6 @@ static void ExitPinSheet( EDA_DRAW_PANEL* Panel, wxDC* DC ) } Panel->GetScreen()->SetCurItem( NULL ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; } @@ -86,11 +84,10 @@ void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) m_Pos = tmp; } - ConstraintOnEdge( frame->GetScreen()->m_Curseur ); + ConstraintOnEdge( frame->GetScreen()->GetCrossHairPosition() ); Sheet->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->EndMouseCapture(); } @@ -102,9 +99,8 @@ void SCH_EDIT_FRAME::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC ) s_InitialPosition = SheetLabel->m_Pos; s_InitialEdge = SheetLabel->GetEdge(); - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -119,7 +115,7 @@ static void Move_PinSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo if( aErase ) SheetLabel->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); - SheetLabel->ConstraintOnEdge( aPanel->GetScreen()->m_Curseur ); + SheetLabel->ConstraintOnEdge( aPanel->GetScreen()->GetCrossHairPosition() ); SheetLabel->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); } @@ -189,9 +185,8 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Create_PinSheet( SCH_SHEET* Sheet, wxDC* DC ) GetScreen()->SetCurItem( NewSheetLabel ); s_CurrentTypeLabel = NewSheetLabel->m_Shape; - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); OnModify(); return NewSheetLabel; @@ -243,8 +238,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC ) s_CurrentTypeLabel = NewSheetLabel->m_Shape = HLabel->m_Shape; GetScreen()->SetCurItem( NewSheetLabel ); - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet ); Move_PinSheet( DrawPanel, DC, wxDefaultPosition, false ); return NewSheetLabel; diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index bd7afd67e5..4265c460b4 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -107,11 +107,8 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) if( item == NULL ) return; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - bool newItem = item->IsNew(); - item->EndEdit( parent->GetScreen()->GetCursorDrawPosition(), true ); + item->EndEdit( parent->GetScreen()->GetCrossHairPosition( true ), true ); if( newItem ) { @@ -127,9 +124,8 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ) { - DrawPanel->ManageCurseur = SymbolDisplayDraw; - DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; - wxPoint drawPos = GetScreen()->GetCursorDrawPosition(); + DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); + wxPoint drawPos = GetScreen()->GetCrossHairPosition( true ); // no temp copy -> the current version of component will be used for Undo // This is normal when adding new items to the current component @@ -164,7 +160,7 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DrawPanel->m_IgnoreMouseEvents = true; EditSymbolText( NULL, Text ); DrawPanel->m_IgnoreMouseEvents = false; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( Text->m_Text.IsEmpty() ) { @@ -194,16 +190,15 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* m_drawItem->SetConvert( m_convert ); // Draw initial symbol: - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } else { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->EndMouseCapture(); return NULL; } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; return m_drawItem; @@ -217,7 +212,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC ) if( m_drawItem == NULL ) return; - wxPoint pos = GetScreen()->GetCursorDrawPosition(); + wxPoint pos = GetScreen()->GetCrossHairPosition( true ); if( m_drawItem->ContinueEdit( pos ) ) { @@ -251,11 +246,11 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx { int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit(); wxString text = ((LIB_FIELD*)item)->GetFullText( unit ); - item->Draw( aPanel, aDC, Screen->GetCursorDrawPosition(), -1, g_XorMode, &text, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, &text, DefaultTransform ); } else - item->Draw( aPanel, aDC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL, DefaultTransform ); } @@ -268,10 +263,9 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC ) SetCursor( wxCURSOR_HAND ); TempCopyComponent(); - m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() ); - DrawPanel->ManageCurseur = RedrawWhileMovingCursor; - DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) ); + DrawPanel->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -282,10 +276,9 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC ) return; TempCopyComponent(); - m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCursorDrawPosition() ); - DrawPanel->ManageCurseur = SymbolDisplayDraw; - DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCrossHairPosition( true ) ); + DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -300,7 +293,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& return; item->SetEraseLastDrawItem( aErase ); - item->Draw( aPanel, aDC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL, + item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL, DefaultTransform ); } @@ -328,13 +321,12 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC ) if( m_drawItem->IsNew() ) m_component->AddDrawItem( m_drawItem ); - m_drawItem->EndEdit( GetScreen()->GetCursorDrawPosition() ); + m_drawItem->EndEdit( GetScreen()->GetCrossHairPosition( true ) ); m_drawItem = NULL; OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); DrawPanel->Refresh(); } diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 009b5cf618..bc3dfce15e 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -52,8 +52,8 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void ) if( dlg.ShowModal() == wxID_CANCEL ) return; - GetScreen()->m_Curseur = wxPoint( 0, 0 ); - DrawPanel->MouseToCursorSchema(); + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; wxFileName fn = dlg.GetPath(); @@ -229,14 +229,13 @@ void LIB_EDIT_FRAME::PlaceAncre() if( m_component == NULL ) return; - wxPoint offset( -GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y ); + wxPoint offset( -GetScreen()->GetCrossHairPosition().x, GetScreen()->GetCrossHairPosition().y ); OnModify( ); m_component->SetOffset( offset ); /* Redraw the symbol */ - GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0; - RedrawScreen( TRUE ); + RedrawScreen( wxPoint( 0 , 0 ), true ); DrawPanel->Refresh(); } diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 8f4569465c..f0cbafb918 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -301,7 +301,7 @@ void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv ) void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) { - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); UpdateStatusBar(); } @@ -313,8 +313,7 @@ int LIB_VIEW_FRAME::BestZoom() LIB_COMPONENT* component; CMP_LIBRARY* lib; - GetScreen()->m_Curseur.x = 0; - GetScreen()->m_Curseur.y = 0; + GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); bestzoom = 16; lib = CMP_LIBRARY::FindLibrary( m_libraryName ); @@ -360,7 +359,7 @@ int LIB_VIEW_FRAME::BestZoom() (double) GetScreen()->m_ZoomScalar ); bestzoom = MAX( ii, jj ) + 1; - GetScreen()->m_Curseur = BoundaryBox.Centre(); + GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() ); return bestzoom; } diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index 5972faca7d..3c423c2a4a 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -296,7 +296,7 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE ); /* Redraw the cursor */ - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); if( !tmp.IsEmpty() ) component->SetName( tmp ); diff --git a/gerbview/block.cpp b/gerbview/block.cpp index 68420b509c..37aa5f3360 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -89,11 +89,11 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) { bool err = false; - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { err = true; DisplayError( this, - wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); + wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); } GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; @@ -106,15 +106,17 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) case BLOCK_DRAG: /* Drag */ case BLOCK_MOVE: /* Move */ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + Block_Move( DC ); GetScreen()->m_BlockLocate.ClearItemsList(); break; case BLOCK_COPY: /* Copy */ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + Block_Duplicate( DC ); GetScreen()->m_BlockLocate.ClearItemsList(); break; @@ -134,13 +136,10 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) break; } + DrawPanel->SetMouseCapture( NULL, NULL ); GetScreen()->SetModify(); + GetScreen()->ClearBlockCommand(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; if( GetScreen()->m_BlockLocate.GetCount() ) { DisplayError( this, wxT( "HandleBlockPLace error: some items left" ) ); @@ -166,7 +165,7 @@ bool WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) bool nextcmd = false; bool zoom_command = false; - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) switch( GetScreen()->m_BlockLocate.m_Command ) { @@ -181,14 +180,14 @@ bool WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) case BLOCK_PRESELECT_MOVE: /* Move with preselection list */ GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; nextcmd = true; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); break; case BLOCK_DELETE: /* Delete */ GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); Block_Delete( DC ); break; @@ -211,12 +210,8 @@ bool WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) if( ! nextcmd ) { - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->m_BlockLocate.ClearItemsList(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->ClearBlockCommand(); + DrawPanel->SetMouseCapture( NULL, NULL ); DisplayToolMsg( wxEmptyString ); } @@ -253,9 +248,9 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP ) { - screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x - + screen->m_BlockLocate.m_MoveVector.x = screen->GetCrossHairPosition().x - screen->m_BlockLocate.GetRight(); - screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - + screen->m_BlockLocate.m_MoveVector.y = screen->GetCrossHairPosition().y - screen->m_BlockLocate.GetBottom(); } @@ -306,11 +301,11 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) wxPoint delta; wxPoint oldpos; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + oldpos = GetScreen()->GetCrossHairPosition(); + DrawPanel->m_mouseCaptureCallback = NULL; - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->MoveCursorToCrossHair(); GetScreen()->SetModify(); GetScreen()->m_BlockLocate.Normalize(); @@ -338,11 +333,11 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) wxPoint delta; wxPoint oldpos; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + oldpos = GetScreen()->GetCrossHairPosition(); + DrawPanel->m_mouseCaptureCallback = NULL; - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->MoveCursorToCrossHair(); GetScreen()->SetModify(); GetScreen()->m_BlockLocate.Normalize(); diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index a0ff4606a5..3fd4f4fc6a 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -20,7 +20,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) int hotkey = 0; wxPoint pos = aPosition; - PutOnGrid( &pos ); + pos = GetScreen()->GetNearestGridPosition( pos ); if( GetScreen()->IsRefreshReq() ) { @@ -37,7 +37,7 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) return; } - oldpos = GetScreen()->m_Curseur; + oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( g_KeyPressed ) @@ -71,19 +71,19 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) break; } - GetScreen()->m_Curseur = pos; + GetScreen()->SetCrossHairPosition( pos ); - if( oldpos != GetScreen()->m_Curseur ) + if( oldpos != GetScreen()->GetCrossHairPosition() ) { - pos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - GetScreen()->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, true ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true ); } } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index b6d336a27e..78b2b9aff8 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -97,10 +97,10 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) TraceWorkSheet( DC, screen, 0 ); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); // Display the filename and the layer name (found in the gerber files, if any) // relative to the active layer diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 56b4b1fbd2..9ad728ce76 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -97,7 +97,8 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_CANCEL_CURRENT_COMMAND: - DrawPanel->UnManageCursor( ); + DrawPanel->EndMouseCapture( ); + /* Should not be executed, except bug */ if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE ) { @@ -105,14 +106,16 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.ClearItemsList(); } + if( m_ID_current_state == 0 ) SetToolID( 0, 0, wxEmptyString ); else DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() ); + break; default: - DrawPanel->UnManageCursor( ); + DrawPanel->EndMouseCapture( ); break; } diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index 3a656b53cf..7875ac3a5f 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -247,7 +247,7 @@ int WinEDA_GerberFrame::BestZoom() x = (double) bbox.GetWidth() / (double) size.x; y = (double) bbox.GetHeight() / (double) size.y; - GetScreen()->m_Curseur = bbox.Centre(); + GetScreen()->SetScrollCenterPosition( bbox.Centre() ); int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ); return best_zoom; diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index f84e6b278d..8f71f9f205 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -126,7 +126,7 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) break; case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_SWITCH_UNITS: diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 597577595b..888cc2943a 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -15,12 +15,13 @@ GERBER_DRAW_ITEM* WinEDA_GerberFrame::Locate( int aTypeloc ) MsgPanel->EraseMsgBox(); wxPoint ref; bool found = false; + if( aTypeloc == CURSEUR_ON_GRILLE ) - ref = GetScreen()->m_Curseur; + ref = GetScreen()->GetCrossHairPosition(); else ref = GetScreen()->m_MousePosition; - int layer = GetScreen()->m_Active_Layer; + int layer = GetScreen()->m_Active_Layer; // Search first on active layer BOARD_ITEM* item = GetBoard()->m_Drawings; diff --git a/gerbview/options.cpp b/gerbview/options.cpp index 92288db2c6..93a9f976e6 100644 --- a/gerbview/options.cpp +++ b/gerbview/options.cpp @@ -54,7 +54,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); DisplayOpt.DisplayPolarCood = state; UpdateStatusBar(); break; diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 2087a951e6..be77d6bf2e 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -62,10 +62,18 @@ class BASE_SCREEN : public EDA_ITEM char m_FlagSave; ///< Indicates automatic file save. EDA_ITEM* m_CurrentItem; ///< Currently selected object GRID_TYPE m_Grid; ///< Current grid selection. + wxPoint m_scrollCenter; ///< Current scroll center point in logical units. + + /** + * The cross hair position in logical (drawing) units. The cross hair is not the cursor + * position. It is an addition indicator typically drawn on grid to indicate to the + * user where the current action will be performed. + */ + wxPoint m_crossHairPosition; public: wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ - wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ + wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) * in user units. (coordinates from last reset position)*/ @@ -151,14 +159,28 @@ public: virtual int GetInternalUnits( void ); /** - * Return the current cursor position in drawing coordinates. - * - * This call inverts the Y axis coordinated of m_Curseur to correct for the difference - * between the wxWidgets GDI and the Kicad drawing coordinates. - * - * @return - The cursor position in drawing coordinates. + * Function GetCrossHairPosition + * return the current cross hair position in logical (drawing) coordinates. + * @param aInvertY Inverts the Y axis position. + * @return The cross hair position in drawing coordinates. */ - wxPoint GetCursorDrawPosition() { return wxPoint( m_Curseur.x, -m_Curseur.y ); } + wxPoint GetCrossHairPosition( bool aInvertY = false ) const + { + if( aInvertY ) + return wxPoint( m_crossHairPosition.x, -m_crossHairPosition.y ); + + return wxPoint( m_crossHairPosition.x, m_crossHairPosition.y ); + } + + /** + * Function SetCrossHairPosition + * sets the screen cross hair position to \a aPosition in logical (drawing) units. + * @param aPosition The new cross hair position. + * @param aSnapToGrid Sets the cross hair position to the nearest grid position to + * \a aPosition. + * + */ + void SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid = true ); /* general Undo/Redo command control */ @@ -352,7 +374,7 @@ public: */ wxPoint RefPos( bool useMouse ) { - return useMouse ? m_MousePosition : m_Curseur; + return useMouse ? m_MousePosition : m_crossHairPosition; } /** @@ -408,6 +430,12 @@ public: void ClearBlockCommand() { m_BlockLocate.Clear(); } + wxPoint GetScrollCenterPosition() const { return m_scrollCenter; } + void SetScrollCenterPosition( const wxPoint& aCenterPosition ) + { + m_scrollCenter = aCenterPosition; + } + #if defined(DEBUG) /** diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index f884a224c0..debddbfccf 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -15,6 +15,18 @@ class BASE_SCREEN; class PCB_SCREEN; +/** + * Mouse capture callback function prototype. + */ +typedef void ( *MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC, + const wxPoint& aPosition, bool aErase ); + +/** + * End mouse capture callback function prototype. + */ +typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC ); + + class EDA_DRAW_PANEL : public wxScrolledWindow { private: @@ -53,12 +65,11 @@ public: /* Cursor management (used in editing functions) */ - /* Mouse capture move callback function prototype. */ - void (*ManageCurseur)( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ); + /* Mouse capture move callback function. */ + MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback; - /* Abort managed cursor callback function prototype. */ - void (*ForceCloseManageCurseur)( EDA_DRAW_PANEL* aPanel, wxDC* aDC ); + /* Abort mouse capture callback function. */ + END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback; public: @@ -123,10 +134,10 @@ public: void OnActivate( wxActivateEvent& event ); /** - * Fucntion DoPrepareDC + * Function DoPrepareDC * sets up the device context \a aDC for drawing. *

- * This overrides wxScrolledWindow::DoPrepareDC() for settting up the the device context + * This overrides wxScrolledWindow::DoPrepareDC() for setting up the the device context * used for drawing. The scale factor and drawing logical offset are set and the base * method is called to set the DC device origin (scroll bar position). This connects * everything together to achieve the appropriate coordinate manipulation using wxDC @@ -153,7 +164,7 @@ public: /* Mouse and keys events */ /** - * Funtion OnMouseWheel + * Function OnMouseWheel * handles mouse wheel events. *

* The mouse wheel is used to provide support for zooming and panning. This @@ -188,7 +199,7 @@ public: * Function IsPointOnDisplay * @param aPosition The position to test in logical (drawing) units. * @return true if \a aPosition is visible on the screen. - * false if \a aPosition is not visiable on the screen. + * false if \a aPosition is not visible on the screen. */ bool IsPointOnDisplay( const wxPoint& aPosition ); @@ -227,7 +238,11 @@ public: */ wxPoint GetScreenCenterLogicalPosition(); - void MouseToCursorSchema(); + /** + * Function MoveCursorToCrossHair + * warps the cursor to the current cross hair position. + */ + void MoveCursorToCrossHair(); /** * Function MoveCursor @@ -238,27 +253,40 @@ public: /* Cursor functions */ /** - * Draw the user cursor. - * - * The user cursor is not the mouse cursor although they may be at the - * same screen position. The mouse cursor is still render by the OS. - * This is a drawn cross hair that is used to snap to grid when grid snapping - * is enabled. This is required because OSX does not allow moving the - * cursor programmatically. - * + * Function DrawCrossHair + * draws the user cross hair. + *

+ * The user cross hair is not the mouse cursor although they may be at the same screen + * position. The mouse cursor is still render by the OS. This is a drawn cross hair + * that is used to snap to grid when grid snapping is enabled. This is as an indicator + * to where the next user action will take place. + *

* @param aDC - the device context to draw the cursor * @param aColor - the color to draw the cursor */ - void DrawCursor( wxDC* aDC, int aColor = WHITE ); + void DrawCrossHair( wxDC* aDC, int aColor = WHITE ); - // remove the grid cursor from the display - void CursorOff( wxDC* DC ); + // Hide the cross hair. + void CrossHairOff( wxDC* DC ); - // display the grid cursor - void CursorOn( wxDC* DC ); + // Show the cross hair. + void CrossHairOn( wxDC* DC ); /** - * Release managed cursor. + * Function SetMouseCapture + * sets the mouse capture and end mouse capture callbacks to \a aMouseCaptureCallback + * and \a aEndMouseCaptureCallback respectively. + */ + void SetMouseCapture( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, + END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback ) + { + m_mouseCaptureCallback = aMouseCaptureCallback; + m_endMouseCaptureCallback = aEndMouseCaptureCallback; + } + + /** + * Function EndMouseCapture + * ends mouse a capture. * * Check to see if the cursor is being managed for block or editing commands and release it. * @param aId The command ID to restore or -1 to keep the current command ID. @@ -267,7 +295,10 @@ public: * @param aTitle The tool message to display in the status bar or wxEmptyString to clear * the message. */ - void UnManageCursor( int aId = -1, int aCursorId = -1, const wxString& aTitle = wxEmptyString ); + void EndMouseCapture( int aId = -1, int aCursorId = -1, + const wxString& aTitle = wxEmptyString ); + + inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; } int GetDefaultCursor() const { return m_defaultCursor; } @@ -275,4 +306,34 @@ public: DECLARE_EVENT_TABLE() }; + +/** + * Class EDA_CROSS_HAIR_MANAGER + * is used to hide the cross hair and restore it when the class goes out of scope. + */ +class EDA_CROSS_HAIR_MANAGER +{ +public: + EDA_CROSS_HAIR_MANAGER( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) : + m_panel( aPanel ), + m_dc( aDC ) + { + if( aPanel && aDC ) + aPanel->CrossHairOff( aDC ); + } + + ~EDA_CROSS_HAIR_MANAGER() + { + if( m_panel && m_dc ) + m_panel->CrossHairOn( m_dc ); + } + +private: + EDA_DRAW_PANEL* m_panel; + wxDC* m_dc; + + DECLARE_NO_COPY_CLASS( EDA_CROSS_HAIR_MANAGER ) +}; + + #endif /* #ifndef PANEL_WXSTRUCT_H */ diff --git a/include/wxstruct.h b/include/wxstruct.h index 3ed5de3881..54145ab5e0 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -281,7 +281,6 @@ public: */ virtual void AddMenuZoomAndGrid( wxMenu* aMasterMenu ); - void Affiche_Message( const wxString& message ); void EraseMsgBox(); void Process_PageSettings( wxCommandEvent& event ); virtual void SetToolbars(); @@ -297,6 +296,7 @@ public: virtual void ReCreateVToolbar() = 0; virtual void ReCreateMenuBar(); virtual void ReCreateAuxiliaryToolbar(); + /** * Function SetToolID * Enables the icon of the selected tool in the vertical toolbar. @@ -392,28 +392,19 @@ public: virtual void OnSize( wxSizeEvent& event ); void OnEraseBackground( wxEraseEvent& SizeEvent ); - void SetToolbarBgColor( int color_num ); virtual void OnZoom( wxCommandEvent& event ); void OnGrid( int grid_type ); /** * Function RedrawScreen * redraws the entire screen area by updating the scroll bars and mouse pointer in - * order to have the current graphic cursor position at the center of the screen. - * @param aWarpPointer Moves the mouse cursor is to the drawing position ( which - * is usually on grid) if true. - * - * Note: Mac OS ** does not ** allow moving mouse cursor by program. + * order to have \a aCenterPoint at the center of the screen. + * @param aCenterPoint The position in logical units to center the scroll bars. + * @param aWarpPointer Moves the mouse cursor to \a aCenterPoint if true. */ - void RedrawScreen( bool aWarpPointer ); + void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ); - /** Adjust the coordinate to the nearest grid value - * @param aCoord = coordinate to adjust - * @param aGridSize = pointer to a grid value. if NULL uses the current grid size - */ - void PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize = NULL ); - - void Zoom_Automatique( bool move_mouse_cursor ); + void Zoom_Automatique( bool aWarpPointer ); /* Set the zoom level to show the area Rect */ void Window_Zoom( EDA_Rect& Rect ); @@ -438,14 +429,12 @@ public: wxString GetXYSheetReferences( BASE_SCREEN* aScreen, const wxPoint& aPosition ); void DisplayToolMsg( const wxString& msg ); - void Process_Zoom( wxCommandEvent& event ); - void Process_Grid( wxCommandEvent& event ); virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0; virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; virtual void ToolOnRightClick( wxCommandEvent& event ); - void AdjustScrollBars(); + void AdjustScrollBars( const wxPoint& aCenterPosition ); /** * Function OnActivate (virtual) @@ -544,9 +533,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, - int aPrintMask, bool aPrintMirrorMode, - void * aData = NULL); + virtual void PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); DECLARE_EVENT_TABLE() }; diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index 92e9a4db2d..1730aa607d 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -22,10 +22,10 @@ void WinEDA_PcbFrame::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On ) return; OnModify(); - DrawPanel->CursorOff( DC ); // Erase cursor shape + DrawPanel->CrossHairOff( DC ); // Erase cursor shape track->SetState( SEGM_FIXE, Flag_On ); track->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL ); - DrawPanel->CursorOn( DC ); // Display cursor shape + DrawPanel->CrossHairOn( DC ); // Display cursor shape track->DisplayInfo( this ); } @@ -39,7 +39,7 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) if( (track == NULL ) || (track->Type() == TYPE_ZONE) ) return; - DrawPanel->CursorOff( DC ); // Erase cursor shape + DrawPanel->CrossHairOff( DC ); // Erase cursor shape Track = Marque_Une_Piste( GetBoard(), track, &nb_segm, NULL, true ); Trace_Une_Piste( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL ); @@ -50,7 +50,7 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) Track = Track->Next(); } - DrawPanel->CursorOn( DC ); // Display cursor shape + DrawPanel->CrossHairOn( DC ); // Display cursor shape OnModify(); } @@ -74,7 +74,7 @@ void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) } } - DrawPanel->CursorOff( DC ); // Erase cursor shape + DrawPanel->CrossHairOff( DC ); // Erase cursor shape while( Track ) /* Flag change */ { if( (net_code >= 0 ) && (net_code != Track->GetNet()) ) @@ -86,6 +86,6 @@ void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) Track = Track->Next(); } - DrawPanel->CursorOn( DC ); // Display cursor shape + DrawPanel->CrossHairOn( DC ); // Display cursor shape OnModify(); } diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index 4e120527a5..242e2d2b95 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -90,15 +90,14 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) return; case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( DrawPanel->ManageCurseur - && DrawPanel->ForceCloseManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); } break; default: // Abort a current command (if any) - DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); break; } @@ -211,10 +210,8 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) */ if( PlaceModulesHorsPcb && edgesExists ) { - if( GetScreen()->m_Curseur.y < - (GetBoard()->m_BoundaryBox.GetBottom() + 2000) ) - GetScreen()->m_Curseur.y = GetBoard()->m_BoundaryBox.GetBottom() + - 2000; + if( GetScreen()->GetCrossHairPosition().y < (GetBoard()->m_BoundaryBox.GetBottom() + 2000) ) + GetScreen()->GetCrossHairPosition().y = GetBoard()->m_BoundaryBox.GetBottom() + 2000; } /* calculate the area needed by footprints */ @@ -232,7 +229,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 ); - start = current = GetScreen()->m_Curseur; + start = current = GetScreen()->GetCrossHairPosition(); Ymax_size = 0; for( unsigned ii = 0; ii < moduleList.size(); ii++ ) @@ -254,14 +251,10 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) Ymax_size = 0; } - GetScreen()->m_Curseur.x = - current.x + Module->m_Pos.x - Module->m_RealBoundaryBox.GetX(); - GetScreen()->m_Curseur.y = - current.y + Module->m_Pos.y - Module->m_RealBoundaryBox.GetY(); + GetScreen()->SetCrossHairPosition( current + Module->m_Pos - + Module->m_RealBoundaryBox.GetPosition() ); Ymax_size = MAX( Ymax_size, Module->m_RealBoundaryBox.GetHeight() ); - PutOnGrid( &GetScreen()->m_Curseur ); - Place_Module( Module, NULL, true ); current.x += Module->m_RealBoundaryBox.GetWidth() + pas_grille; diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 0a7406c5f8..955499208e 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -276,10 +276,10 @@ end_of_tst: break; /* Place module. */ - CurrPosition = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = PosOK; + CurrPosition = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( PosOK ); Place_Module( Module, DC ); - GetScreen()->m_Curseur = CurrPosition; + GetScreen()->SetCrossHairPosition( CurrPosition ); Module->Set_Rectangle_Encadrement(); Module->SetRectangleExinscrit(); @@ -616,7 +616,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC ) DrawModuleOutlines( DrawPanel, DC, Module ); mincout = -1.0; - Affiche_Message( wxT( "Score ??, pos ??" ) ); + SetStatusText( wxT( "Score ??, pos ??" ) ); for( ; CurrPosition.x < GetBoard()->m_BoundaryBox.GetRight() - fx; CurrPosition.x += g_GridRoutingSize ) @@ -674,7 +674,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC ) (int) mincout, (float) LastPosOK.x / 10000, (float) LastPosOK.y / 10000 ); - Affiche_Message( msg ); + SetStatusText( msg ); } } if( DisplayChevelu ) diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 42667d2e54..defaed906c 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -158,7 +158,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) return; } - Affiche_Message( _( "Place Cells" ) ); + SetStatusText( _( "Place Cells" ) ); PlaceCells( GetBoard(), -1, FORCE_PADS ); /* Construction of the track list for router. */ @@ -176,9 +176,8 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) InitWork(); /* Free memory for the list of router connections. */ Board.UnInitBoard(); stop = time( NULL ) - start; - msg.Printf( wxT( "time = %d second%s" ), stop, - ( stop == 1 ) ? wxT( "" ) : wxT( "s" ) ); - Affiche_Message( msg ); + msg.Printf( wxT( "time = %d second%s" ), stop, ( stop == 1 ) ? wxT( "" ) : wxT( "s" ) ); + SetStatusText( msg ); } diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 810072cd23..11269be011 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -112,7 +112,7 @@ int WinEDA_BasePcbFrame::BestZoom( void ) else jj = 31; bestzoom = MAX( ii, jj ) + 1; - GetScreen()->m_Curseur = m_Pcb->m_BoundaryBox.Centre(); + GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() ); return bestzoom * GetScreen()->m_ZoomScalar; } @@ -129,16 +129,15 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos ) /* There may be need to reframe the drawing. */ if( !DrawPanel->IsPointOnDisplay( aPos ) ) { - screen->m_Curseur = aPos; - RedrawScreen( true ); + RedrawScreen( aPos, true ); } else { // Put cursor on item position - DrawPanel->CursorOff( &dc ); - screen->m_Curseur = aPos; - DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOff( &dc ); + screen->SetCrossHairPosition( aPos ); + DrawPanel->MoveCursorToCrossHair(); + DrawPanel->CrossHairOn( &dc ); } } @@ -323,8 +322,8 @@ void WinEDA_BasePcbFrame::UpdateStatusBar() wxString Line; double theta, ro; - int dx = screen->m_Curseur.x - screen->m_O_Curseur.x; - int dy = screen->m_Curseur.y - screen->m_O_Curseur.y; + int dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; + int dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; if( dx==0 && dy==0 ) theta = 0.0; diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 5f1d31f4cb..8411d321d0 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -85,15 +85,15 @@ private: static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, const wxString& title ) { int nocmd; - wxPoint oldpos = parent->GetScreen()->m_Curseur; + wxPoint oldpos = parent->GetScreen()->GetCrossHairPosition(); parent->DrawPanel->m_IgnoreMouseEvents = true; DIALOG_BLOCK_OPTIONS dlg( parent, title ); nocmd = dlg.ShowModal(); - parent->GetScreen()->m_Curseur = oldpos; - parent->DrawPanel->MouseToCursorSchema(); + parent->GetScreen()->SetCrossHairPosition( oldpos ); + parent->DrawPanel->MoveCursorToCrossHair(); parent->DrawPanel->m_IgnoreMouseEvents = false; parent->DrawPanel->SetCursor( parent->DrawPanel->GetDefaultCursor() ); @@ -201,11 +201,12 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) { bool err = false; - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { err = true; - DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); + DisplayError( this, wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); } + GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; switch( GetScreen()->m_BlockLocate.m_Command ) @@ -217,15 +218,17 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) case BLOCK_DRAG: /* Drag */ case BLOCK_MOVE: /* Move */ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + Block_Move(); GetScreen()->m_BlockLocate.ClearItemsList(); break; case BLOCK_COPY: /* Copy */ - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + Block_Duplicate(); GetScreen()->m_BlockLocate.ClearItemsList(); break; @@ -240,11 +243,9 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->SetMouseCapture( NULL, NULL ); + GetScreen()->ClearBlockCommand(); + if( GetScreen()->m_BlockLocate.GetCount() ) { DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) ); @@ -274,11 +275,8 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) // If coming here after cancel block, clean up and exit if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK ) { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->m_BlockLocate.ClearItemsList(); + DrawPanel->SetMouseCapture( NULL, NULL ); + GetScreen()->ClearBlockCommand(); DisplayToolMsg( wxEmptyString ); return false; } @@ -292,7 +290,7 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) cancelCmd = true; // undraw block outline - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } else { @@ -307,7 +305,7 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) } } - if( !cancelCmd && DrawPanel->ManageCurseur ) + if( !cancelCmd && DrawPanel->IsMouseCaptured() ) { switch( GetScreen()->m_BlockLocate.m_Command ) { @@ -321,24 +319,24 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; nextcmd = true; - DrawPanel->ManageCurseur = drawMovingBlock; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback = drawMovingBlock; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); break; case BLOCK_DELETE: /* Delete */ - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; Block_Delete(); break; case BLOCK_ROTATE: /* Rotation */ - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; Block_Rotate(); break; case BLOCK_FLIP: /* Flip */ - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; Block_Flip(); break; @@ -358,7 +356,7 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) // Turn off the redraw block routine now so it is not displayed // with one corner at the new center of the screen - DrawPanel->ManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback = NULL; Window_Zoom( GetScreen()->m_BlockLocate ); break; @@ -369,12 +367,8 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) if( ! nextcmd ) { - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->m_BlockLocate.ClearItemsList(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->ClearBlockCommand(); + DrawPanel->SetMouseCapture( NULL, NULL ); DisplayToolMsg( wxEmptyString ); } @@ -583,7 +577,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP ) { - screen->m_BlockLocate.m_MoveVector = screen->m_Curseur - + screen->m_BlockLocate.m_MoveVector = screen->GetCrossHairPosition() - screen->m_BlockLocate.m_BlockLastCursorPosition; } @@ -671,7 +665,7 @@ void WinEDA_PcbFrame::Block_Rotate() wxPoint centre; // rotation cent-re for the rotation transform int rotAngle = 900; // rotation angle in 0.1 deg. - oldpos = GetScreen()->m_Curseur; + oldpos = GetScreen()->GetCrossHairPosition(); centre = GetScreen()->m_BlockLocate.Centre(); OnModify(); @@ -740,7 +734,7 @@ void WinEDA_PcbFrame::Block_Flip() PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection; itemsList->m_Status = UR_FLIPPED; - memo = GetScreen()->m_Curseur; + memo = GetScreen()->GetCrossHairPosition(); center = GetScreen()->m_BlockLocate.Centre(); diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index b68ef46a04..43374c5e92 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -103,14 +103,13 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) { BlockState state = GetScreen()->m_BlockLocate.m_State; CmdBlockType command = GetScreen()->m_BlockLocate.m_Command; - DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC ); GetScreen()->m_BlockLocate.m_State = state; GetScreen()->m_BlockLocate.m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur.x = GetScreen()->m_BlockLocate.GetRight(); - GetScreen()->m_Curseur.y = GetScreen()->m_BlockLocate.GetBottom(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); + GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), + GetScreen()->m_BlockLocate.GetBottom() ) ); + DrawPanel->MoveCursorToCrossHair(); } switch( GetScreen()->m_BlockLocate.m_Command ) @@ -127,12 +126,14 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) if( itemsCount ) { nextcmd = true; - if( DrawPanel->ManageCurseur != NULL ) + + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); } + GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; DrawPanel->Refresh( TRUE ); } @@ -140,7 +141,7 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ nextcmd = true; - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; break; @@ -189,16 +190,13 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) { ClearMarkItems( currentModule ); } - GetScreen()->m_BlockLocate.m_Flags = 0; - GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - SetCurItem( NULL ); - SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); - DrawPanel->Refresh( TRUE ); - } + GetScreen()->ClearBlockCommand(); + SetCurItem( NULL ); + DrawPanel->SetMouseCapture( NULL, NULL ); + SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); + DrawPanel->Refresh( true ); + } return nextcmd; } @@ -217,10 +215,10 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) bool err = FALSE; MODULE* currentModule = GetBoard()->m_Modules; - if( DrawPanel->ManageCurseur == NULL ) + if( !DrawPanel->IsMouseCaptured() ) { err = TRUE; - DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); + DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); } GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; @@ -272,14 +270,12 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; SetCurItem( NULL ); - DrawPanel->Refresh( TRUE ); - + DrawPanel->SetMouseCapture( NULL, NULL ); + DrawPanel->Refresh( true ); SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString ); } @@ -339,7 +335,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx } /* Repaint new view. */ - PtBlock->m_MoveVector = screen->m_Curseur - PtBlock->m_BlockLastCursorPosition; + PtBlock->m_MoveVector = screen->GetCrossHairPosition() - PtBlock->m_BlockLastCursorPosition; PtBlock->Draw( aPanel, aDC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color ); diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 938bef5567..c978140ff8 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -74,7 +74,7 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC, if( aCleanVias ) // delete redundant vias { - frame->Affiche_Message( _( "Clean vias" ) ); + frame->SetStatusText( _( "Clean vias" ) ); clean_vias( frame->GetBoard() ); } @@ -83,7 +83,7 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC, but is not on the pad or the via center */ if( aConnectToPads ) { - frame->Affiche_Message( _( "Reconnect pads" ) ); + frame->SetStatusText( _( "Reconnect pads" ) ); /* Create missing segments when a track end covers a pad, but is not on the pad center */ ConnectDanglingEndToPad( frame, DC ); @@ -98,18 +98,18 @@ void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC, /* Remove null segments and intermediate points on aligned segments */ if( aMergeSegments ) { - frame->Affiche_Message( _( "Merge track segments" ) ); + frame->SetStatusText( _( "Merge track segments" ) ); clean_segments( frame ); } /* Delete dangling tracks */ if( aDeleteUnconnectedSegm ) { - frame->Affiche_Message( _( "Delete unconnected tracks" ) ); + frame->SetStatusText( _( "Delete unconnected tracks" ) ); DeleteUnconnectedTracks( frame, DC ); } - frame->Affiche_Message( _( "Cleanup finished" ) ); + frame->SetStatusText( _( "Cleanup finished" ) ); frame->Compile_Ratsnest( DC, true ); diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index 98b92ad949..1b2e6060b7 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -370,7 +370,7 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code ) m_Pcb->GetRatsnestsCount(), m_Pcb->GetNoconnectCount(), nb_net_noconnect ); - Affiche_Message( msg ); + SetStatusText( msg ); return; } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 8a2b4df29f..9ee09a3318 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -214,7 +214,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) DrawPanel->m_AbortRequest = true; // changed in false if an item PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // DrawPanel->m_IgnoreMouseEvents = false; @@ -231,9 +231,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) wxRealPoint gridSize; wxPoint oldpos; int hotkey = 0; - wxPoint pos = aPosition; - - PutOnGrid( &pos ); + wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); // Save the board after the time out : int CurrentTime = time( NULL ); @@ -262,7 +260,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) SetTitle( GetScreen()->GetFileName() ); } - oldpos = GetScreen()->m_Curseur; + oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); @@ -298,7 +296,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) } // Put cursor in new position, according to the zoom keys (if any). - GetScreen()->m_Curseur = pos; + GetScreen()->SetCrossHairPosition( pos ); /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the * cursor is left off grid this is better to reach items to delete off grid, @@ -319,16 +317,15 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) if( keep_on_grid ) { - wxPoint on_grid = pos; + wxPoint on_grid = GetScreen()->GetNearestGridPosition( pos ); - PutOnGrid( &on_grid ); wxSize grid; 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 ) ) { - GetScreen()->m_Curseur = pos; + GetScreen()->SetCrossHairPosition( pos ); } else { @@ -339,27 +336,27 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition ) || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) ) { - GetScreen()->m_Curseur = on_grid; + GetScreen()->SetCrossHairPosition( on_grid ); } } } - if( oldpos != GetScreen()->m_Curseur ) + if( oldpos != GetScreen()->GetCrossHairPosition() ) { - pos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - GetScreen()->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, false ); #else - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, true ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 63d3ddf45c..ead09ed37e 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -41,6 +41,7 @@ void RemoteCommand( const char* cmdline ) char* text; MODULE* module = 0; WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*)wxGetApp().GetTopWindow(); + wxPoint pos; strncpy( line, cmdline, sizeof(line) - 1 ); @@ -61,9 +62,10 @@ void RemoteCommand( const char* cmdline ) else msg.Printf( _( "%s not found" ), GetChars( modName ) ); - frame->Affiche_Message( msg ); + frame->SetStatusText( msg ); + if( module ) - frame->GetScreen()->m_Curseur = module->GetPosition(); + pos = module->GetPosition(); } else if( strcmp( idcmd, "$PIN:" ) == 0 ) { @@ -80,6 +82,7 @@ void RemoteCommand( const char* cmdline ) modName = CONV_FROM_UTF8( text ); module = frame->GetBoard()->FindModuleByReference( modName ); + if( module ) pad = module->FindPadByName( pinName ); @@ -88,7 +91,7 @@ void RemoteCommand( const char* cmdline ) netcode = pad->GetNet(); // put cursor on the pad: - frame->GetScreen()->m_Curseur = pad->GetPosition(); + pos = pad->GetPosition(); } if( netcode > 0 ) /* highlight the pad net*/ @@ -106,22 +109,20 @@ void RemoteCommand( const char* cmdline ) msg.Printf( _( "%s not found" ), GetChars( modName ) ); else if( pad == NULL ) { - msg.Printf( _( "%s pin %s not found" ), - GetChars( modName ), GetChars( pinName ) ); + msg.Printf( _( "%s pin %s not found" ), GetChars( modName ), GetChars( pinName ) ); frame->SetCurItem( module ); } else { - msg.Printf( _( "%s pin %s found" ), - GetChars( modName ), GetChars( pinName ) ); + msg.Printf( _( "%s pin %s found" ), GetChars( modName ), GetChars( pinName ) ); frame->SetCurItem( pad ); } - frame->Affiche_Message( msg ); + frame->SetStatusText( msg ); } if( module ) // if found, center the module on screen, and redraw the screen. - frame->RedrawScreen( false ); + frame->RedrawScreen( pos, false ); } diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 8cf57e1257..cb62b1f4a8 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -85,8 +85,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) if( g_CurrentTrackList.GetCount() == 0 ) { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); if( g_HighLight_Status ) High_Light( DC ); @@ -96,8 +95,8 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) } else { - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); return g_CurrentTrackSegment; } diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index ab6ccb56bf..d630aa9790 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -452,20 +452,17 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) if( m_DC ) { - m_Parent->DrawPanel->CursorOff( m_DC ); + m_Parent->DrawPanel->CrossHairOff( m_DC ); m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); } // Initialize masks clearances m_CurrentModule->m_LocalClearance = - ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, - m_Parent->m_InternalUnits ); + ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, m_Parent->m_InternalUnits ); m_CurrentModule->m_LocalSolderMaskMargin = - ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, - m_Parent->m_InternalUnits ); + ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits ); m_CurrentModule->m_LocalSolderPasteMargin = - ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, - m_Parent->m_InternalUnits ); + ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits ); double dtmp = 0.0; msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); @@ -579,30 +576,30 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) if( m_DC ) { m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_OR ); - m_Parent->DrawPanel->CursorOn( m_DC ); + m_Parent->DrawPanel->CrossHairOn( m_DC ); } } void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event ) { - wxPoint tmp = m_Parent->GetScreen()->m_Curseur; + wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); - m_Parent->GetScreen()->m_Curseur = m_ReferenceCopy->m_Pos; + m_Parent->GetScreen()->SetCrossHairPosition( m_ReferenceCopy->m_Pos ); m_ReferenceCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL ); - m_Parent->GetScreen()->m_Curseur = tmp; + m_Parent->GetScreen()->SetCrossHairPosition( tmp ); m_ReferenceCtrl->SetValue( m_ReferenceCopy->m_Text ); } void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event ) { - wxPoint tmp = m_Parent->GetScreen()->m_Curseur; + wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); - m_Parent->GetScreen()->m_Curseur = m_ValueCopy->m_Pos; + m_Parent->GetScreen()->SetCrossHairPosition( m_ValueCopy->m_Pos ); m_ValueCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL ); - m_Parent->GetScreen()->m_Curseur = tmp; + m_Parent->GetScreen()->SetCrossHairPosition( tmp ); m_ValueCtrl->SetValue( m_ValueCopy->m_Text ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 3d1ccb5ad0..6b091f3e4d 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -426,10 +426,10 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) /***********************************************************************/ { - wxPoint tmp = m_Parent->GetScreen()->m_Curseur; - m_Parent->GetScreen()->m_Curseur = m_ReferenceCopy->m_Pos; + wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); + m_Parent->GetScreen()->SetCrossHairPosition( m_ReferenceCopy->m_Pos ); m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL ); - m_Parent->GetScreen()->m_Curseur = tmp; + m_Parent->GetScreen()->SetCrossHairPosition( tmp ); m_ReferenceCtrl->SetValue(m_ReferenceCopy->m_Text); } @@ -437,10 +437,10 @@ void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event) /***********************************************************/ { - wxPoint tmp = m_Parent->GetScreen()->m_Curseur; - m_Parent->GetScreen()->m_Curseur = m_ValueCopy->m_Pos; + wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); + m_Parent->GetScreen()->SetCrossHairPosition( m_ValueCopy->m_Pos ); m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL ); - m_Parent->GetScreen()->m_Curseur = tmp; + m_Parent->GetScreen()->SetCrossHairPosition( tmp); m_ValueCtrl->SetValue(m_ValueCopy->m_Text); } diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 97202accba..f33458c4fc 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -144,7 +144,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); DisplayOpt.DisplayPolarCood = state; UpdateStatusBar(); break; diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index a80e128ed3..08daea0baf 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -68,7 +68,7 @@ void WinEDA_PcbFrame::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem, wx DialogGraphicItemProperties* dialog = new DialogGraphicItemProperties( this, aItem, aDC ); dialog->ShowModal(); dialog->Destroy(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; } diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 650c8fb400..e6686b3c85 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -64,7 +64,7 @@ void WinEDA_PcbFrame::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC ) DrawPanel->m_IgnoreMouseEvents = TRUE; DIALOG_PCB_TEXT_PROPERTIES dlg( this, TextPCB, DC ); dlg.ShowModal(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; } diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 74363eaea1..1318746411 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -210,10 +210,8 @@ static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC ) } } - status_dimension = 0; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - ((WinEDA_PcbFrame*)Panel->GetParent())->SetCurItem(NULL); + status_dimension = 0; + ((WinEDA_PcbFrame*)Panel->GetParent())->SetCurItem( NULL ); } @@ -226,7 +224,7 @@ DIMENSION* WinEDA_PcbFrame::Begin_Dimension( DIMENSION* Dimension, wxDC* DC ) if( Dimension == NULL ) /* debut reel du trace */ { status_dimension = 1; - pos = GetScreen()->m_Curseur; + pos = GetScreen()->GetCrossHairPosition(); Dimension = new DIMENSION( GetBoard() ); Dimension->m_Flags = IS_NEW; @@ -267,8 +265,7 @@ DIMENSION* WinEDA_PcbFrame::Begin_Dimension( DIMENSION* Dimension, wxDC* DC ) Dimension->Draw( DrawPanel, DC, GR_XOR ); - DrawPanel->ManageCurseur = Montre_Position_New_Dimension; - DrawPanel->ForceCloseManageCurseur = Exit_EditDimension; + DrawPanel->SetMouseCapture( Montre_Position_New_Dimension, Exit_EditDimension ); return Dimension; } @@ -289,8 +286,7 @@ DIMENSION* WinEDA_PcbFrame::Begin_Dimension( DIMENSION* Dimension, wxDC* DC ) SaveCopyInUndoList( Dimension, UR_NEW ); OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); return NULL; } @@ -301,7 +297,7 @@ static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, { PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen(); DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem(); - wxPoint pos = screen->m_Curseur; + wxPoint pos = screen->GetCrossHairPosition(); if( Dimension == NULL ) return; diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 8f504208e9..2b9aa8b1db 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -38,14 +38,14 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) { if( Edge == NULL ) return; + Edge->Draw( DrawPanel, DC, GR_XOR ); Edge->m_Flags |= IS_MOVED; MoveVector.x = MoveVector.y = 0; - CursorInitialPosition = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = Move_Segment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + CursorInitialPosition = GetScreen()->GetCrossHairPosition(); + DrawPanel->SetMouseCapture( Move_Segment, Exit_EditEdge_Module ); SetCurItem( Edge ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); } @@ -63,8 +63,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge ) Edge->m_End0 -= MoveVector; Edge->m_Flags = 0; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); OnModify(); MODULE* Module = (MODULE*) Edge->GetParent(); @@ -89,7 +88,7 @@ static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos Edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); } - MoveVector = -(screen->m_Curseur - CursorInitialPosition); + MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition); Edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); @@ -115,7 +114,7 @@ static void ShowEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP Edge->Draw( aPanel, aDC, GR_XOR ); } - Edge->m_End = screen->m_Curseur; + Edge->m_End = screen->GetCrossHairPosition(); /* Update relative coordinate. */ Edge->m_End0 = Edge->m_End - Module->m_Pos; @@ -185,8 +184,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge ) /* an edge is put on a copper layer, and it is very dangerous. a *confirmation is requested */ if( !IsOK( this, - _( - "The graphic item will be on a copper layer. It is very dangerous. Are you sure?" ) ) ) + _( "The graphic item will be on a copper layer. It is very dangerous. Are you sure?" ) ) ) return; } @@ -223,13 +221,15 @@ void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* aEdge ) { wxString buffer; - buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth, GetScreen()->GetInternalUnits() ); + buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth, + GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); if( dlg.ShowModal() != wxID_OK ) return; // cancelled by user buffer = dlg.GetValue( ); - g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() ); + g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, + GetScreen()->GetInternalUnits() ); if( aEdge ) { @@ -289,8 +289,7 @@ static void Exit_EditEdge_Module( EDA_DRAW_PANEL* Panel, wxDC* DC ) Edge->Draw( Panel, DC, GR_OR ); } } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); } @@ -339,7 +338,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, Edge->SetLayer( SILKSCREEN_N_BACK ); /* Initialise the starting point of the new segment or arc */ - Edge->m_Start = GetScreen()->m_Curseur; + Edge->m_Start = GetScreen()->GetCrossHairPosition(); /* Initialise the ending point of the new segment or arc */ Edge->m_End = Edge->m_Start; @@ -351,9 +350,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, Edge->m_End0 = Edge->m_Start0; module->Set_Rectangle_Encadrement(); - - DrawPanel->ManageCurseur = ShowEdgeModule; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + DrawPanel->SetMouseCapture( ShowEdgeModule, Exit_EditEdge_Module ); } /* Segment creation in progress. * The ending coordinate are updated by the function @@ -380,7 +377,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, Edge->m_Flags = IS_NEW; Edge->m_Width = g_ModuleSegmentWidth; - Edge->m_Start = GetScreen()->m_Curseur; + Edge->m_Start = GetScreen()->GetCrossHairPosition(); Edge->m_End = Edge->m_Start; /* Update relative coordinate. */ @@ -418,6 +415,5 @@ void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge ) Module->Set_Rectangle_Encadrement(); Module->m_LastEdit_Time = time( NULL ); OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 2730cd4cb6..43c3c16189 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -39,7 +39,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) BOARD_ITEM* DrawStruct = GetCurItem(); MODULE* module; - DrawPanel->CursorOff( &dc ); + DrawPanel->CrossHairOff( &dc ); wxGetMousePosition( &pos.x, &pos.y ); @@ -118,11 +118,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( DrawPanel->ManageCurseur - && DrawPanel->ForceCloseManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); } + /* Should not be executed, just in case */ if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE ) { @@ -130,20 +130,23 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.ClearItemsList(); } + if( m_ID_current_state == 0 ) SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); else SetCursor( DrawPanel->GetDefaultCursor() ); + break; default: // Finish (abort) the command - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); if( m_ID_current_state != id ) { if( m_ID_last_state != m_ID_current_state ) m_ID_last_state = m_ID_current_state; + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); } break; @@ -296,7 +299,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_END_LINE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // EndSegment(&dc); break; @@ -305,7 +308,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( GetCurItem() == NULL ) break; Edit_Track_Width( &dc, (TRACK*) GetCurItem() ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); OnModify(); break; @@ -313,7 +316,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( GetCurItem() == NULL ) break; Edit_TrackSegm_Width( &dc, (TRACK*) GetCurItem() ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); OnModify(); break; @@ -329,16 +332,16 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) dlg.ShowModal(); } } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_END_TRACK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); End_Route( (TRACK*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem()->m_Flags & IS_DRAGGED ) { PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc ); @@ -350,12 +353,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) * switch from _/ to -\ . * If a track is in progress, it will be redrawn */ - if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor ) + if( DrawPanel->m_mouseCaptureCallback == ShowNewTrackWhenMovingCursor ) ShowNewTrackWhenMovingCursor( DrawPanel, &dc, wxDefaultPosition, false ); g_Alternate_Track_Posture = !g_Alternate_Track_Posture; - if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor ) + if( DrawPanel->m_mouseCaptureCallback == ShowNewTrackWhenMovingCursor ) ShowNewTrackWhenMovingCursor( DrawPanel, &dc, wxDefaultPosition, false ); break; @@ -364,7 +367,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( !IsMicroViaAcceptable() ) break; case ID_POPUP_PCB_PLACE_VIA: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem()->m_Flags & IS_DRAGGED ) { PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc ); @@ -384,7 +387,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_TRACKSEG: if( GetCurItem() == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) ); OnModify(); break; @@ -392,14 +395,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_TRACK: if( GetCurItem() == NULL ) break; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Delete_Track( &dc, (TRACK*) GetCurItem() ); SetCurItem( NULL ); OnModify(); break; case ID_POPUP_PCB_DELETE_TRACKNET: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Delete_net( &dc, (TRACK*) GetCurItem() ); SetCurItem( NULL ); OnModify(); @@ -433,7 +436,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_DELETE_ZONE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem() == NULL ) break; { @@ -453,20 +456,20 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_AutoPAN_Request = true; Add_Similar_Zone( &dc, (ZONE_CONTAINER*) GetCurItem() ); break; case ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_AutoPAN_Request = true; Add_Zone_Cutout( &dc, (ZONE_CONTAINER*) GetCurItem() ); break; case ID_POPUP_PCB_DELETE_ZONE_CONTAINER: case ID_POPUP_PCB_DELETE_ZONE_CUTOUT: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); { int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNet(); Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() ); @@ -483,7 +486,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_MOVE_ZONE_CORNER: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); DrawPanel->m_AutoPAN_Request = true; Start_Move_Zone_Corner( &dc, @@ -495,7 +498,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); DrawPanel->m_AutoPAN_Request = true; Start_Move_Zone_Drag_Outline_Edge( &dc, @@ -506,7 +509,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_MOVE_ZONE_OUTLINES: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); DrawPanel->m_AutoPAN_Request = true; Start_Move_Zone_Outlines( &dc, zone_cont ); @@ -515,9 +518,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_ADD_ZONE_CORNER: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); - wxPoint pos = GetScreen()->m_Curseur; + wxPoint pos = GetScreen()->GetCrossHairPosition(); /* add corner between zone_cont->m_CornerSelection * and zone_cont->m_CornerSelection+1 @@ -539,7 +542,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_PLACE_ZONE_OUTLINES: case ID_POPUP_PCB_PLACE_ZONE_CORNER: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont ); DrawPanel->m_AutoPAN_Request = false; @@ -547,7 +550,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) } case ID_POPUP_PCB_FILL_ALL_ZONES: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Fill_All_Zones(); GetBoard()->DisplayInfo( this ); break; @@ -583,7 +586,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_FILL_ZONE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Fill_Zone( (ZONE_CONTAINER*) GetCurItem() ); test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() ); GetBoard()->DisplayInfo( this ); @@ -622,8 +625,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DisplayInfoMessage( this, msg ); break; } - GetScreen()->m_Curseur = ((MODULE*) GetCurItem())->m_Pos; - DrawPanel->MouseToCursorSchema(); + GetScreen()->SetCrossHairPosition( ((MODULE*) GetCurItem())->m_Pos ); + DrawPanel->MoveCursorToCrossHair(); StartMove_Module( (MODULE*) GetCurItem(), &dc ); break; @@ -640,12 +643,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DisplayInfoMessage( this, msg ); break; } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMove_Module( module, &dc ); break; case ID_POPUP_PCB_DELETE_MODULE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // If the current Item is a pad, text module ...: Get its parent if( GetCurItem()->Type() != TYPE_MODULE ) @@ -669,7 +672,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // If the current Item is a pad, text module ...: Get its parent if( GetCurItem()->Type() != TYPE_MODULE ) @@ -692,7 +695,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // If the current Item is a pad, text module ...: Get its parent if( GetCurItem()->Type() != TYPE_MODULE ) @@ -715,7 +718,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_CHANGE_SIDE_MODULE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); // If the current Item is a pad, text module ...: Get its parent if( GetCurItem()->Type() != TYPE_MODULE ) @@ -744,7 +747,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DRAG_PAD_REQUEST: @@ -760,7 +763,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; } g_Drag_Pistes_On = true; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMovePad( (D_PAD*) GetCurItem(), &dc ); break; @@ -777,28 +780,28 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; } g_Drag_Pistes_On = false; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMovePad( (D_PAD*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_EDIT_PAD: InstallPadOptionsFrame( (D_PAD*) GetCurItem() ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED ); Import_Pad_Settings( (D_PAD*) GetCurItem(), true ); break; case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Global_Import_Pad_Settings( (D_PAD*) GetCurItem(), true ); break; case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Export_Pad_Settings( (D_PAD*) GetCurItem() ); break; @@ -806,12 +809,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED ); DeletePad( (D_PAD*) GetCurItem() ); SetCurItem( NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_EDIT_TEXTMODULE: InstallTextModOptionsFrame( (TEXTE_MODULE*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_RESET_TEXT_SIZE: @@ -819,27 +822,27 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMoveTexteModule( (TEXTE_MODULE*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_ROTATE_TEXTMODULE: RotateTextModule( (TEXTE_MODULE*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_TEXTMODULE: DeleteTextModule( (TEXTE_MODULE*) GetCurItem() ); SetCurItem( NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_SELECT_LAYER: itmp = SelectLayer( getActiveLayer(), -1, -1 ); if( itmp >= 0 ) setActiveLayer( itmp ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: @@ -850,7 +853,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) itmp = SelectLayer( getActiveLayer(), FIRST_NO_COPPER_LAYER, -1 ); if( itmp >= 0 ) setActiveLayer( itmp ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_SELECT_CU_LAYER: @@ -861,7 +864,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_LAYER_PAIR: SelectLayerPair(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_TOOLBARH_PCB_SELECT_LAYER: @@ -872,60 +875,60 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_EDIT_TEXTEPCB: InstallTextPCBOptionsFrame( (TEXTE_PCB*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_ROTATE_TEXTEPCB: Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_TEXTEPCB: Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_MOVE_MIRE_REQUEST: StartMove_Mire( (MIREPCB*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_EDIT_MIRE: InstallMireOptionsFrame( (MIREPCB*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_MIRE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Delete_Mire( (MIREPCB*) GetCurItem(), &dc ); SetCurItem( NULL ); break; case ID_POPUP_PCB_DELETE_DIMENSION: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Delete_Dimension( (DIMENSION*) GetCurItem(), &dc ); SetCurItem( NULL ); break; case ID_POPUP_PCB_EDIT_DIMENSION: Install_Edit_Dimension( (DIMENSION*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_DRAWING: Delete_Segment_Edge( (DRAWSEGMENT*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_MARKER: RemoveStruct( GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_GETINFO_MARKER: if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER_PCB ) ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_DRAWING_LAYER: @@ -933,22 +936,22 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; Delete_Drawings_All_Layer( GetCurItem()->GetLayer() ); SetCurItem( NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->Refresh(); break; case ID_POPUP_PCB_EDIT_DRAWING: InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_MOVE_DRAWING_REQUEST: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Start_Move_DrawItem( (DRAWSEGMENT*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_STOP_CURRENT_DRAWING: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) ) { End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc ); @@ -957,7 +960,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) ) { if( End_Zone( &dc ) ) @@ -967,7 +970,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( GetCurItem() && (GetCurItem()->m_Flags & IS_NEW) ) { if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline, @@ -977,29 +980,29 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id ); break; case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: case ID_POPUP_PCB_MOVE_TRACK_NODE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id ); break; case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_PCB_BREAK_TRACK: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); { TRACK* track = (TRACK*) GetScreen()->GetCurItem(); - wxPoint pos = GetScreen()->m_Curseur; + wxPoint pos = GetScreen()->GetCrossHairPosition(); track->Draw( DrawPanel, &dc, GR_XOR ); PICKED_ITEMS_LIST itemsListPicker; TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker); @@ -1058,7 +1061,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) } SetToolbars(); - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); DrawPanel->m_IgnoreMouseEvents = false; } @@ -1068,7 +1071,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, EDA_ITEM* DrawStruct, wxD if( DrawStruct == NULL ) return; - frame->DrawPanel->MouseToCursorSchema(); + frame->DrawPanel->MoveCursorToCrossHair(); switch( DrawStruct->Type() ) { diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index bcbfe7985f..d43b678eda 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -32,9 +32,6 @@ static TEXTE_PCB s_TextCopy( (BOARD_ITEM*) NULL ); /* copy of the edited text */ void Abort_Edit_Pcb_Text( EDA_DRAW_PANEL* Panel, wxDC* DC ) { - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - TEXTE_PCB* TextePcb = (TEXTE_PCB*) Panel->GetScreen()->GetCurItem(); ( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL ); @@ -61,8 +58,7 @@ void Abort_Edit_Pcb_Text( EDA_DRAW_PANEL* Panel, wxDC* DC ) */ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); if( TextePcb == NULL ) @@ -79,8 +75,7 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) } if( TextePcb->m_Flags == IS_MOVED ) // If moved only - SaveCopyInUndoList( TextePcb, UR_MOVED, - TextePcb->m_Pos - s_TextCopy.m_Pos ); + SaveCopyInUndoList( TextePcb, UR_MOVED, TextePcb->m_Pos - s_TextCopy.m_Pos ); else { // Restore initial params @@ -109,10 +104,9 @@ void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ) TextePcb->Draw( DrawPanel, DC, GR_XOR ); TextePcb->m_Flags |= IS_MOVED; TextePcb->DisplayInfo( this ); - DrawPanel->ManageCurseur = Move_Texte_Pcb; - DrawPanel->ForceCloseManageCurseur = Abort_Edit_Pcb_Text; + DrawPanel->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); SetCurItem( TextePcb ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); } @@ -128,7 +122,7 @@ static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP if( aErase ) TextePcb->Draw( aPanel, aDC, GR_XOR ); - TextePcb->m_Pos = aPanel->GetScreen()->m_Curseur; + TextePcb->m_Pos = aPanel->GetScreen()->GetCrossHairPosition(); TextePcb->Draw( aPanel, aDC, GR_XOR ); } @@ -143,8 +137,7 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) SaveCopyInUndoList( TextePcb, UR_DELETED ); TextePcb->UnLink(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); } @@ -166,7 +159,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) TextePcb->m_Mirror = true; TextePcb->m_Size = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize; - TextePcb->m_Pos = GetScreen()->m_Curseur; + TextePcb->m_Pos = GetScreen()->GetCrossHairPosition(); TextePcb->m_Thickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; InstallTextPCBOptionsFrame( TextePcb, DC ); diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index ed0ddc6cc0..5c8a39f9b6 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -126,10 +126,10 @@ void WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem ) { TRACK* oldsegm = (TRACK*) itemsListPicker.GetPickedItemLink( 0 ); wxASSERT( oldsegm ); - DrawPanel->CursorOff( aDC ); // Erase cursor shape + DrawPanel->CrossHairOff( aDC ); // Erase cursor shape oldsegm->Draw( DrawPanel, aDC, GR_XOR ); // Erase old track shape aTrackItem->Draw( DrawPanel, aDC, GR_OR ); // Display new track shape - DrawPanel->CursorOn( aDC ); // Display cursor shape + DrawPanel->CrossHairOn( aDC ); // Display cursor shape } SaveCopyInUndoList( itemsListPicker, UR_CHANGED ); } @@ -167,7 +167,8 @@ void WinEDA_PcbFrame::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) // Some segment have changed: redraw them and save in undo list if( aDC ) { - DrawPanel->CursorOff( aDC ); // Erase cursor shape + DrawPanel->CrossHairOff( aDC ); // Erase cursor shape + for( unsigned ii = 0; ii < itemsListPicker.GetCount(); ii++ ) { TRACK* segm = (TRACK*) itemsListPicker.GetPickedItemLink( ii ); @@ -176,7 +177,7 @@ void WinEDA_PcbFrame::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) segm->Draw( DrawPanel, aDC, GR_OR ); // Display new track shape } - DrawPanel->CursorOn( aDC ); // Display cursor shape + DrawPanel->CrossHairOn( aDC ); // Display cursor shape } SaveCopyInUndoList( itemsListPicker, UR_CHANGED ); diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 6c2bc900e6..f9a44b18e2 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -32,12 +32,11 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) return; drawitem->Draw( DrawPanel, DC, GR_XOR ); drawitem->m_Flags |= IS_MOVED; - s_InitialPosition = s_LastPosition = GetScreen()->m_Curseur; + s_InitialPosition = s_LastPosition = GetScreen()->GetCrossHairPosition(); drawitem->DisplayInfo( this ); - DrawPanel->ManageCurseur = Move_Segment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + DrawPanel->SetMouseCapture( Move_Segment, Exit_EditEdge ); SetCurItem( drawitem ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } @@ -51,8 +50,7 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) SaveCopyInUndoList(drawitem, UR_MOVED, s_LastPosition - s_InitialPosition); drawitem->Draw( DrawPanel, DC, GR_OR ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); OnModify(); drawitem->m_Flags = 0; @@ -76,10 +74,10 @@ static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos Segment->Draw( aPanel, aDC, GR_XOR ); wxPoint delta; - delta = aPanel->GetScreen()->m_Curseur - s_LastPosition; + delta = aPanel->GetScreen()->GetCrossHairPosition() - s_LastPosition; Segment->m_Start += delta; Segment->m_End += delta; - s_LastPosition = aPanel->GetScreen()->m_Curseur; + s_LastPosition = aPanel->GetScreen()->GetCrossHairPosition(); Segment->Draw( aPanel, aDC, GR_XOR ); DisplayOpt.DisplayDrawItems = t_fill; @@ -180,21 +178,20 @@ static void Exit_EditEdge( EDA_DRAW_PANEL* Panel, wxDC* DC ) if( Segment->m_Flags & IS_NEW ) { - Panel->ManageCurseur( Panel, DC, wxDefaultPosition, false ); + Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, false ); Segment ->DeleteStructure(); Segment = NULL; } else { - wxPoint pos = Panel->GetScreen()->m_Curseur; - Panel->GetScreen()->m_Curseur = s_InitialPosition; - Panel->ManageCurseur( Panel, DC, wxDefaultPosition, true ); - Panel->GetScreen()->m_Curseur = pos; + wxPoint pos = Panel->GetScreen()->GetCrossHairPosition(); + Panel->GetScreen()->SetCrossHairPosition( s_InitialPosition ); + Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, true ); + Panel->GetScreen()->SetCrossHairPosition( pos ); Segment->m_Flags = 0; Segment->Draw( Panel, DC, GR_OR ); } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + ( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL ); } @@ -225,9 +222,8 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, Segment->m_Width = s_large; Segment->m_Shape = shape; Segment->m_Angle = 900; - Segment->m_Start = Segment->m_End = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = Montre_Position_NewSegment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + Segment->m_Start = Segment->m_End = GetScreen()->GetCrossHairPosition(); + DrawPanel->SetMouseCapture( Montre_Position_NewSegment, Exit_EditEdge ); } else /* The ending point ccordinate Segment->m_End was updated by he function * Montre_Position_NewSegment() called on a move mouse event @@ -288,8 +284,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) SaveCopyInUndoList( Segment, UR_NEW ); } - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); } @@ -312,13 +307,13 @@ static void Montre_Position_NewSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( Segments_45_Only && ( Segment->m_Shape == S_SEGMENT ) ) { - Calcule_Coord_Extremite_45( aPanel->GetScreen()->m_Curseur, + Calcule_Coord_Extremite_45( aPanel->GetScreen()->GetCrossHairPosition(), Segment->m_Start.x, Segment->m_Start.y, &Segment->m_End.x, &Segment->m_End.y ); } else /* here the angle is arbitrary */ { - Segment->m_End = aPanel->GetScreen()->m_Curseur; + Segment->m_End = aPanel->GetScreen()->GetCrossHairPosition(); } Segment->Draw( aPanel, aDC, GR_XOR ); diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 01ff075746..bb8de1a7d5 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -66,9 +66,9 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) if( pt_mod == NULL ) return; - moveVector = pt_mod->m_Pos - GetScreen()->m_Curseur; + moveVector = pt_mod->m_Pos - GetScreen()->GetCrossHairPosition(); - pt_mod->m_Pos = GetScreen()->m_Curseur; + pt_mod->m_Pos = GetScreen()->GetCrossHairPosition(); /* Update the relative coordinates: * The coordinates are relative to the anchor point. diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 9ab7ee3cd9..d4b9e10472 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -142,7 +142,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) itmp = g_CurrentTrackList.GetCount(); Begin_Route( g_CurrentTrackSegment, DC ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); /* create the via */ SEGVIA* via = new SEGVIA( GetBoard() ); @@ -200,7 +200,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) /* DRC fault: the Via cannot be placed here ... */ delete via; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); // delete the track(s) added in Begin_Route() while( g_CurrentTrackList.GetCount() > itmp ) @@ -253,7 +253,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); } - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); via->DisplayInfo( this ); UpdateStatusBar(); diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index fcaa6dd354..060bbda7c3 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -61,8 +61,6 @@ static void Exit_Editrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) g_CurrentTrackList.DeleteAll(); } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; frame->SetCurItem( NULL ); } @@ -86,10 +84,9 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) int masquelayer = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; BOARD_ITEM* LockPoint; - wxPoint pos = GetScreen()->m_Curseur; + wxPoint pos = GetScreen()->GetCrossHairPosition(); - DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; - DrawPanel->ForceCloseManageCurseur = Exit_Editrack; + DrawPanel->SetMouseCapture( ShowNewTrackWhenMovingCursor, Exit_Editrack ); if( aTrack == NULL ) /* Starting a new track */ { @@ -193,7 +190,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) g_CurrentTrackSegment->DisplayInfoBase( this ); SetCurItem( g_CurrentTrackSegment, false ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); if( Drc_On ) { @@ -539,11 +536,11 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) High_Light( DC ); g_HighLight_NetCode = OldNetCodeSurbrillance; + if( OldEtatSurbrillance ) High_Light( DC ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); } @@ -611,7 +608,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel ) { PCB_SCREEN* screen = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetScreen(); BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard(); - wxPoint cursor = screen->m_Curseur; + wxPoint cursor = screen->GetCrossHairPosition(); wxPoint cv, vec, n; TRACK* track = g_CurrentTrackSegment; TRACK* other; @@ -734,7 +731,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo { if( g_TwoSegmentTrackBuild ) { - g_CurrentTrackSegment->m_End = screen->m_Curseur; + g_CurrentTrackSegment->m_End = screen->GetCrossHairPosition(); if( Drc_On ) PushTrack( aPanel ); @@ -748,7 +745,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Calculate of the end of the path for the permitted directions: * horizontal, vertical or 45 degrees. */ - Calcule_Coord_Extremite_45( screen->m_Curseur, + Calcule_Coord_Extremite_45( screen->GetCrossHairPosition(), g_CurrentTrackSegment->m_Start.x, g_CurrentTrackSegment->m_Start.y, &g_CurrentTrackSegment->m_End.x, @@ -757,7 +754,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo } else /* Here the angle is arbitrary */ { - g_CurrentTrackSegment->m_End = screen->m_Curseur; + g_CurrentTrackSegment->m_End = screen->GetCrossHairPosition(); } /* Redraw the new track */ diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 402d278b84..93a1f37a36 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -49,11 +49,11 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) g_ModuleTextSize.y ), true ); Text->m_Size = g_ModuleTextSize; Text->m_Thickness = g_ModuleTextWidth; - Text->m_Pos = GetScreen()->m_Curseur; + Text->m_Pos = GetScreen()->GetCrossHairPosition(); Text->SetLocalCoord(); InstallTextModOptionsFrame( Text, NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Text->m_Flags = 0; if( DC ) @@ -130,9 +130,6 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); MODULE* Module; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - if( Text == NULL ) return; @@ -175,23 +172,21 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) MoveVector.x = MoveVector.y = 0; - DrawPanel->CursorOff( DC ); + DrawPanel->CrossHairOff( DC ); TextInitialPosition = Text->m_Pos; TextInitialOrientation = Text->m_Orient; // Center cursor on initial position of text - GetScreen()->m_Curseur = TextInitialPosition; - DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOn( DC ); + GetScreen()->SetCrossHairPosition( TextInitialPosition ); + DrawPanel->MoveCursorToCrossHair(); + DrawPanel->CrossHairOn( DC ); Text->DisplayInfo( this ); SetCurItem( Text ); - DrawPanel->ManageCurseur = Show_MoveTexte_Module; - DrawPanel->ForceCloseManageCurseur = AbortMoveTextModule; - - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, TRUE ); + DrawPanel->SetMouseCapture( Show_MoveTexte_Module, AbortMoveTextModule ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, TRUE ); } @@ -217,7 +212,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) EXCHG( Text->m_Orient, TextInitialOrientation ); // Set the new position for text. - Text->m_Pos = GetScreen()->m_Curseur; + Text->m_Pos = GetScreen()->GetCrossHairPosition(); wxPoint textRelPos = Text->m_Pos - Module->m_Pos; RotatePoint( &textRelPos, -Module->m_Orient ); Text->m_Pos0 = textRelPos; @@ -230,14 +225,13 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() ); } else - Text->m_Pos = GetScreen()->m_Curseur; + Text->m_Pos = GetScreen()->GetCrossHairPosition(); } // leave it at (0,0) so we can use it Rotate when not moving. MoveVector.x = MoveVector.y = 0; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); } @@ -257,7 +251,7 @@ static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo Text->Draw( aPanel, aDC, GR_XOR, MoveVector ); } - MoveVector = TextInitialPosition - screen->m_Curseur; + MoveVector = TextInitialPosition - screen->GetCrossHairPosition(); // Draw umbilical if text moved if( MoveVector.x || MoveVector.y ) diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index d6e1fdfd36..96495e6026 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -30,12 +30,13 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) /* Note: none of these events require aborting the current command (if any) * (like move, edit or block command) * so we do not test for a current command in progress and call - * DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + * DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); */ switch( id ) { case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH: - GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = not GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth; + GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = + not GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth; AuxiliaryToolBar_Update_UI( ); break; @@ -47,7 +48,7 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_AUTO_WIDTH: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = true; AuxiliaryToolBar_Update_UI( ); break; @@ -60,7 +61,7 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_WIDTH6: case ID_POPUP_PCB_SELECT_WIDTH7: case ID_POPUP_PCB_SELECT_WIDTH8: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = false; ii = id - ID_POPUP_PCB_SELECT_WIDTH1; GetBoard()->m_TrackWidthSelector = ii; @@ -75,7 +76,7 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_VIASIZE6: case ID_POPUP_PCB_SELECT_VIASIZE7: case ID_POPUP_PCB_SELECT_VIASIZE8: // select the new current value for via size (via diameter) - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ii = id - ID_POPUP_PCB_SELECT_VIASIZE1; GetBoard()->m_ViaSizeSelector = ii; AuxiliaryToolBar_Update_UI( ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 2bcdc41c2d..76b0db6f5d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -27,12 +27,12 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) if( fn != wxEmptyString ) { - DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); ::wxSetWorkingDirectory( ::wxPathOnly( fn ) ); LoadOnePcbFile( fn ); ReCreateAuxiliaryToolbar(); SetToolbars(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } } @@ -47,9 +47,9 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event ) // If an edition is in progress, stop it. // For something else than save, get rid of current tool. if( id == ID_SAVE_BOARD ) - DrawPanel->UnManageCursor( -1, DrawPanel->GetDefaultCursor() ); + DrawPanel->EndMouseCapture( -1, DrawPanel->GetDefaultCursor() ); else - DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() ); + DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() ); switch( id ) { diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index cde5eb847d..1aafdff3fe 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -113,7 +113,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) else msg.Printf( _( "<%s> Found" ), GetChars( s_OldStringFound ) ); - m_Parent->Affiche_Message( msg ); + m_Parent->SetStatusText( msg ); m_Parent->CursorGoto( locate_pos ); @@ -121,7 +121,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) } else { - m_Parent->Affiche_Message( wxEmptyString ); + m_Parent->SetStatusText( wxEmptyString ); if( FindMarker ) msg = _( "Marker not found" ); diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index cad668ba5a..bab94af124 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -165,7 +165,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosi break; case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_SWITCH_UNITS: @@ -218,7 +218,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosi && ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) ) { // A new track is in progress: call to End_Route() - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); End_Route( (TRACK*) GetCurItem(), aDC ); } break; diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index 2765c11644..b26804bcbb 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -60,7 +60,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ if( !blockActive ) - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_SWITCH_UNITS: diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 0d546c17d1..cef2b0bf1b 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -1119,7 +1119,7 @@ int WinEDA_PcbFrame::ReadPcbFile( LINE_READER* aReader, bool Append ) board->SynchronizeNetsAndNetClasses(); m_TrackAndViasSizesList_Changed = true; - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); BestZoom(); SetToolbars(); return 1; @@ -1173,7 +1173,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile ) if( !rc ) DisplayError( this, wxT( "Unable to save PCB file" ) ); else - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); return rc; } diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index f6993edf46..d5906b7048 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -388,7 +388,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ), GetChars( oldFileName.GetFullPath() ) ); - Affiche_Message( msg ); + SetStatusText( msg ); CreateDocLibrary( oldFileName.GetFullPath() ); } @@ -583,7 +583,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, { msg = _( "Module exists\n Line: " ); msg << LineNum; - Affiche_Message( msg ); + SetStatusText( msg ); } if( !aOverwrite ) /* Do not save the given footprint: an old * one exists */ @@ -714,7 +714,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, msg = _( "Component " ); msg += Name_Cmp; msg += added ? _( " added in " ) : _( " replaced in " ); msg += aLibName; - Affiche_Message( msg ); + SetStatusText( msg ); } return 1; @@ -763,7 +763,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName ) GetBoard()->Add( Module ); /* Update parameters: position, timestamp ... */ - newpos = GetScreen()->m_Curseur; + newpos = GetScreen()->GetCrossHairPosition(); Module->SetPosition( newpos ); Module->m_LastEdit_Time = time( NULL ); diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index ad86c1e432..d0588c97ff 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -83,10 +83,12 @@ bool WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module ) GetBoard()->m_NetInfo->BuildListOfNets(); - GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0; + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); Place_Module( Module, NULL ); + if( Module->GetLayer() != LAYER_N_FRONT ) Module->Flip( Module->m_Pos ); + Rotate_Module( NULL, Module, 0, false ); GetScreen()->ClrModify(); Zoom_Automatique( TRUE ); @@ -99,7 +101,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, wxDC* DC ) { MODULE* module; - wxPoint curspos = GetScreen()->m_Curseur; + wxPoint curspos = GetScreen()->GetCrossHairPosition(); wxString ModuleName, keys; static wxArrayString HistoryList; static wxString lastCommponentName; @@ -118,7 +120,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, if( ModuleName.IsEmpty() ) /* Cancel command */ { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } @@ -132,7 +134,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, keys ); if( ModuleName.IsEmpty() ) /* Cancel command */ { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } } @@ -144,7 +146,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, wxEmptyString ); if( ModuleName.IsEmpty() ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; /* Cancel command. */ } } @@ -160,15 +162,15 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, wxEmptyString ); if( ModuleName.IsEmpty() ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; /* Cancel command. */ } else module = Get_Librairie_Module( library, ModuleName, TRUE ); } - GetScreen()->m_Curseur = curspos; - DrawPanel->MouseToCursorSchema(); + GetScreen()->SetCrossHairPosition( curspos ); + DrawPanel->MoveCursorToCrossHair(); if( module ) { @@ -263,7 +265,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( FILTER_READER reader( fileReader ); msg.Printf( _( "Scan Lib: %s" ), GetChars( tmp ) ); - Affiche_Message( msg ); + SetStatusText( msg ); /* Reading header ENTETE_LIBRAIRIE */ reader.ReadLine(); @@ -331,7 +333,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( NewModule->ReadDescr( &reader ); SetLocaleTo_Default(); // revert to the current locale GetBoard()->Add( NewModule, ADD_APPEND ); - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); return NewModule; } } @@ -429,7 +431,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow // Statusbar library loaded message msg = _( "Library " ) + fn.GetFullPath() + _( " loaded" ); - Affiche_Message( msg ); + SetStatusText( msg ); /* Read header. */ reader.ReadLine(); diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 3618f49b51..bed7a3a401 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -175,8 +175,6 @@ static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC ) BASE_SCREEN* screen = Panel->GetScreen(); MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem(); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; ( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL ); if( MirePcb == NULL ) @@ -218,7 +216,7 @@ MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC ) MirePcb->SetLayer( EDGE_N ); MirePcb->m_Width = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth; MirePcb->m_Size = MireDefaultSize; - MirePcb->m_Pos = DrawPanel->GetScreen()->m_Curseur; + MirePcb->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition(); Place_Mire( MirePcb, DC ); @@ -235,8 +233,7 @@ void WinEDA_PcbFrame::StartMove_Mire( MIREPCB* MirePcb, wxDC* DC ) s_TargetCopy = *MirePcb; MirePcb->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = ShowTargetShapeWhileMovingMouse; - DrawPanel->ForceCloseManageCurseur = AbortMoveAndEditTarget; + DrawPanel->SetMouseCapture( ShowTargetShapeWhileMovingMouse, AbortMoveAndEditTarget ); SetCurItem( MirePcb ); } @@ -247,8 +244,7 @@ void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC ) return; MirePcb->Draw( DrawPanel, DC, GR_OR ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); OnModify(); @@ -259,12 +255,9 @@ void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC ) return; } - if( MirePcb->m_Flags == IS_MOVED ) { - SaveCopyInUndoList( MirePcb, - UR_MOVED, - MirePcb->m_Pos - s_TargetCopy.m_Pos ); + SaveCopyInUndoList( MirePcb, UR_MOVED, MirePcb->m_Pos - s_TargetCopy.m_Pos ); MirePcb->m_Flags = 0; return; } @@ -275,6 +268,7 @@ void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC ) SaveCopyInUndoList( MirePcb, UR_CHANGED ); SwapData( MirePcb, &s_TargetCopy ); } + MirePcb->m_Flags = 0; } @@ -292,7 +286,7 @@ static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( aErase ) MirePcb->Draw( aPanel, aDC, GR_XOR ); - MirePcb->m_Pos = screen->m_Curseur; + MirePcb->m_Pos = screen->GetCrossHairPosition(); MirePcb->Draw( aPanel, aDC, GR_XOR ); } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index dbc1849902..9b8b5ea897 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -116,7 +116,7 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode ) PopupMenu( &itemMenu ); // m_AbortRequest = false if an // item is selected - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; @@ -203,13 +203,15 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_CANCEL_CURRENT_COMMAND: default: - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { // for all other commands: stop the move in progress - DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); } + if( id != ID_POPUP_CANCEL_CURRENT_COMMAND ) SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; } @@ -238,9 +240,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) Clear_Pcb( true ); GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); - GetScreen()->m_Curseur = wxPoint( 0, 0 ); + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); MODULE* module = Create_1_Module( wxEmptyString ); + if( module ) // i.e. if create module command not aborted { // Initialize data relative to nets and netclasses (for a new @@ -332,10 +335,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) } else // This is an insert command { - wxPoint cursor_pos = pcbframe->GetScreen()->m_Curseur; - pcbframe->GetScreen()->m_Curseur = wxPoint( 0, 0 ); + wxPoint cursor_pos = pcbframe->GetScreen()->GetCrossHairPosition(); + pcbframe->GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); pcbframe->Place_Module( newmodule, NULL ); - pcbframe->GetScreen()->m_Curseur = cursor_pos; + pcbframe->GetScreen()->SetCrossHairPosition( cursor_pos ); newmodule->m_TimeStamp = GetTimeStamp(); pcbframe->SaveCopyInUndoList( newmodule, UR_NEW ); } @@ -352,7 +355,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) break; // //this command is aborted GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); - GetScreen()->m_Curseur = wxPoint( 0, 0 ); + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); Import_Module( ); redraw = true; if( GetBoard()->m_Modules ) @@ -379,20 +382,21 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_MODEDIT_LOAD_MODULE: { wxString full_libraryfilename; + if( !m_CurrentLib.IsEmpty() ) { - wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, - ModuleFileExtension ); + wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension ); full_libraryfilename = wxGetApp().FindLibraryPath( fn ); } GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); Clear_Pcb( true ); - GetScreen()->m_Curseur = wxPoint( 0, 0 ); + GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); Load_Module_From_Library( full_libraryfilename, NULL ); redraw = true; } + if( GetBoard()->m_Modules ) GetBoard()->m_Modules->m_Flags = 0; @@ -480,13 +484,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), 900, true ); redraw = true; break; case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), -900, true ); redraw = true; break; @@ -498,7 +502,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) int ret = dialog.ShowModal(); GetScreen()->GetCurItem()->m_Flags = 0; GetScreen()->GetCurItem()->m_Flags = 0; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( ret > 0 ) DrawPanel->Refresh(); } @@ -506,7 +510,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_MOVE_PAD_REQUEST: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc ); } break; @@ -514,7 +518,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_EDIT_PAD: { InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } break; @@ -522,23 +526,23 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false ); SetCurItem( NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true ); break; case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); Global_Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() ); break; @@ -546,13 +550,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) { InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } break; case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); StartMoveTexteModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); } break; @@ -560,7 +564,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_ROTATE_TEXTMODULE: { RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } break; @@ -568,18 +572,18 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() ); SetCurItem( NULL ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_MOVE_EDGE: { Start_Move_EdgeMod( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } break; case ID_POPUP_PCB_STOP_CURRENT_DRAWING: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) ) { End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() ); @@ -596,7 +600,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) edge = (EDGE_MODULE*) GetScreen()->GetCurItem(); } Enter_Edge_Width( edge ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( edge ) DrawPanel->Refresh(); @@ -604,32 +608,32 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() ); DrawPanel->Refresh( ); break; case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Edit_Edge_Width( NULL ); DrawPanel->Refresh( ); break; case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() ); DrawPanel->Refresh( ); break; case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); Edit_Edge_Layer( NULL ); DrawPanel->Refresh( ); break; case ID_POPUP_PCB_DELETE_EDGE: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); RemoveStruct( GetScreen()->GetCurItem() ); SetCurItem( NULL ); break; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 9cc9383a81..db4faa5695 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -25,7 +25,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { BOARD_ITEM* item = GetCurItem(); - DrawPanel->CursorOff( DC ); + DrawPanel->CrossHairOff( DC ); if( m_ID_current_state == 0 ) { if( item && item->m_Flags ) // Command in progress @@ -135,13 +135,10 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), break; module->m_Flags = 0; SaveCopyInUndoList( module, UR_MODEDIT ); - Place_Ancre( module ); // set the new relatives internal - // coordinates of items - GetScreen()->m_Curseur = wxPoint( 0, 0 ); - RedrawScreen( TRUE ); + Place_Ancre( module ); // set the new relatives internal coordinates of items + RedrawScreen( wxPoint( 0, 0 ), true ); - // Replace the module in position 0, to recalculate absolutes - // coordinates of items + // Replace the module in position 0, to recalculate absolutes coordinates of items module->SetPosition( wxPoint( 0, 0 ) ); SetToolID( 0, 0, wxEmptyString ); SetCurItem( NULL ); @@ -151,7 +148,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), case ID_PCB_PLACE_GRID_COORD_BUTT: DrawPanel->DrawGridAxis( DC, GR_XOR ); - GetScreen()->m_GridOrigin = GetScreen()->m_Curseur; + GetScreen()->m_GridOrigin = GetScreen()->GetCrossHairPosition(); DrawPanel->DrawGridAxis( DC, GR_COPY ); GetScreen()->SetModify(); break; @@ -172,13 +169,12 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), break; default: - DisplayError( this, - wxT( "WinEDA_ModuleEditFrame::ProcessCommand error" ) ); + DisplayError( this, wxT( "WinEDA_ModuleEditFrame::ProcessCommand error" ) ); SetToolID( 0, 0, wxEmptyString ); break; } - DrawPanel->CursorOn( DC ); + DrawPanel->CrossHairOn( DC ); } @@ -186,8 +182,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), * Create the pull up menu * After this menu is built, the standard ZOOM menu is added */ -bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, - wxMenu* PopMenu ) +bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) { BOARD_ITEM* item = GetCurItem(); wxString msg; @@ -432,7 +427,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { case TYPE_PAD: InstallPadOptionsFrame( (D_PAD*) item ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case TYPE_MODULE: @@ -440,7 +435,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) item ); int ret = dialog.ShowModal(); GetScreen()->GetCurItem()->m_Flags = 0; - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( ret > 0 ) DrawPanel->Refresh(); } @@ -448,7 +443,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) case TYPE_TEXTE_MODULE: InstallTextModOptionsFrame( (TEXTE_MODULE*) item, DC ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; default: diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index 6a5fa0ddac..c215f9c600 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -38,7 +38,7 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: - Affiche_Message( wxEmptyString ); + SetStatusText( wxEmptyString ); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id ); UpdateStatusBar(); break; diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index ac3d12bc34..b39202f52f 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -475,8 +475,8 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio return; } - PutOnGrid( &pos ); - oldpos = GetScreen()->m_Curseur; + pos = GetScreen()->GetNearestGridPosition( aPosition ); + oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( g_KeyPressed ) @@ -510,19 +510,19 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio break; } - GetScreen()->m_Curseur = pos; + GetScreen()->SetCrossHairPosition( pos ); - if( oldpos != GetScreen()->m_Curseur ) + if( oldpos != GetScreen()->GetCrossHairPosition() ) { - pos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = oldpos; - DrawPanel->CursorOff( aDC ); - GetScreen()->m_Curseur = pos; - DrawPanel->CursorOn( aDC ); + pos = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( oldpos ); + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( pos ); + DrawPanel->CrossHairOn( aDC ); - if( DrawPanel->ManageCurseur ) + if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->ManageCurseur( DrawPanel, aDC, aPosition, true ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true ); } } diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 96eba559d1..d488ba9511 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -95,8 +95,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) } GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; - DrawPanel->ManageCurseur = Montre_Position_Empreinte; - DrawPanel->ForceCloseManageCurseur = Abort_MoveOrCopyModule; + DrawPanel->SetMouseCapture( Montre_Position_Empreinte, Abort_MoveOrCopyModule ); DrawPanel->m_AutoPAN_Request = true; // Erase the module. @@ -108,7 +107,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) module->m_Flags = tmp; } - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); } @@ -173,13 +172,14 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) module, s_ModuleInitialCopy->m_Orient, FALSE ); + if( s_ModuleInitialCopy->GetLayer() != module->GetLayer() ) pcbframe->Change_Side_Module( module, NULL ); + module->Draw( Panel, DC, GR_OR ); } + g_Drag_Pistes_On = FALSE; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; pcbframe->SetCurItem( NULL ); delete s_ModuleInitialCopy; @@ -188,6 +188,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) // Display ratsnest is allowed pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; + if( pcbframe->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) pcbframe->DrawGeneralRatsnest( DC ); @@ -246,7 +247,7 @@ void Montre_Position_Empreinte( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint } /* Redraw the module at the new position. */ - g_Offset_Module = module->m_Pos - aPanel->GetScreen()->m_Curseur; + g_Offset_Module = module->m_Pos - aPanel->GetScreen()->GetCrossHairPosition(); DrawModuleOutlines( aPanel, aDC, module ); Dessine_Segments_Dragges( aPanel, aDC ); @@ -421,7 +422,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, && DC ) trace_ratsnest_module( DC ); - newpos = GetScreen()->m_Curseur; + newpos = GetScreen()->GetCrossHairPosition(); module->SetPosition( newpos ); module->m_Flags = 0; @@ -438,6 +439,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, { pt_segm = g_DragSegmentList[ii].m_Segm; pt_segm->SetState( EDIT, OFF ); + if( DC ) pt_segm->Draw( DrawPanel, DC, GR_OR ); } @@ -446,13 +448,11 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, EraseDragList(); } - g_Drag_Pistes_On = FALSE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + g_Drag_Pistes_On = false; + DrawPanel->SetMouseCapture( NULL, NULL ); - if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) - if( !aDoNotRecreateRatsnest ) - Compile_Ratsnest( DC, true ); + if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) && !aDoNotRecreateRatsnest ) + Compile_Ratsnest( DC, true ); if( DC ) DrawPanel->Refresh(); diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index be321ba839..d2da3d5351 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -26,8 +26,6 @@ static void Exit_Move_Pad( EDA_DRAW_PANEL* Panel, wxDC* DC ) { D_PAD* pad = s_CurrentSelectedPad; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; if( pad == NULL ) return; @@ -67,7 +65,7 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo if( aErase ) pad->Draw( aPanel, aDC, GR_XOR ); - pad->m_Pos = screen->m_Curseur; + pad->m_Pos = screen->GetCrossHairPosition(); pad->Draw( aPanel, aDC, GR_XOR ); if( !g_Drag_Pistes_On ) @@ -196,7 +194,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) Import_Pad_Settings( Pad, false ); Pad->SetNetname( wxEmptyString ); - Pad->m_Pos = GetScreen()->m_Curseur; + Pad->m_Pos = GetScreen()->GetCrossHairPosition(); rX = Pad->m_Pos.x - Module->m_Pos.x; rY = Pad->m_Pos.y - Module->m_Pos.y; @@ -279,8 +277,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC ) s_CurrentSelectedPad = Pad; Pad_OldPos = Pad->m_Pos; Pad->DisplayInfo( this ); - DrawPanel->ManageCurseur = Show_Pad_Move; - DrawPanel->ForceCloseManageCurseur = Exit_Move_Pad; + DrawPanel->SetMouseCapture( Show_Pad_Move, Exit_Move_Pad ); /* Draw the pad (SKETCH mode) */ Pad->Draw( DrawPanel, DC, GR_XOR ); @@ -379,8 +376,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) EraseDragList(); OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK ); } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 1aa9ce9072..91f9a9f418 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -56,19 +56,18 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) int ii; /* Erase the current drawings */ - wxPoint oldpos = Panel->GetScreen()->m_Curseur; + wxPoint oldpos = Panel->GetScreen()->GetCrossHairPosition(); - Panel->GetScreen()->m_Curseur = PosInit; + Panel->GetScreen()->SetCrossHairPosition( PosInit ); - if( Panel->ManageCurseur ) - Panel->ManageCurseur( Panel, DC, wxDefaultPosition, true ); + if( Panel->IsMouseCaptured() ) + Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, true ); - Panel->GetScreen()->m_Curseur = oldpos; + Panel->GetScreen()->SetCrossHairPosition( oldpos ); g_HighLight_Status = false; - ( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight( - Panel, - DC, - g_HighLight_NetCode ); + ( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight( Panel, + DC, + g_HighLight_NetCode ); if( NewTrack ) { @@ -108,8 +107,6 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) NewTrack = NULL; } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; ( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL ); /* Undo move and redraw trace segments. */ @@ -158,7 +155,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo } /* set the new track coordinates */ - wxPoint Pos = screen->m_Curseur; + wxPoint Pos = screen->GetCrossHairPosition(); moveVector = Pos - s_LastPos; s_LastPos = Pos; @@ -305,7 +302,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC } /* Compute the new track segment position */ - wxPoint Pos = screen->m_Curseur; + wxPoint Pos = screen->GetCrossHairPosition(); dx = Pos.x - s_LastPos.x; dy = Pos.y - s_LastPos.y; @@ -673,7 +670,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, Old_HighLigth_NetCode = g_HighLight_NetCode; if( g_HighLight_Status ) High_Light( DC ); - PosInit = GetScreen()->m_Curseur; + PosInit = GetScreen()->GetCrossHairPosition(); if( track->Type() == TYPE_VIA ) // For a via: always drag it { @@ -690,7 +687,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, } else { - int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 ); + int diag = track->IsPointOnEnds( GetScreen()->GetCrossHairPosition(), -1 ); wxPoint pos; switch( command ) @@ -740,14 +737,13 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, } s_LastPos = PosInit; - DrawPanel->ManageCurseur = Show_MoveNode; - DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack; + DrawPanel->SetMouseCapture( Show_MoveNode, Abort_MoveTrack ); g_HighLight_NetCode = track->GetNet(); g_HighLight_Status = true; GetBoard()->DrawHighLight( DrawPanel, DC, g_HighLight_NetCode ); - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, true ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -940,10 +936,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track ); - PosInit = GetScreen()->m_Curseur; - s_LastPos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope; - DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack; + PosInit = GetScreen()->GetCrossHairPosition(); + s_LastPos = GetScreen()->GetCrossHairPosition(); + DrawPanel->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack ); g_HighLight_NetCode = track->GetNet(); g_HighLight_Status = true; @@ -964,9 +959,8 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, if( !InitialiseDragParameters() ) { - DisplayError( this, - _( "Unable to drag this segment: two collinear segments" ) ); - DrawPanel->ManageCurseur = NULL; + DisplayError( this, _( "Unable to drag this segment: two collinear segments" ) ); + DrawPanel->m_mouseCaptureCallback = NULL; Abort_MoveTrack( DrawPanel, DC ); return; } @@ -1017,10 +1011,8 @@ bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) * (only pad connection must be tested, track connection will be * tested by test_1_net_connexion() ) */ int masque_layer = g_TabOneLayerMask[Track->GetLayer()]; - Track->start = Fast_Locate_Pad_Connecte( - GetBoard(), Track->m_Start, masque_layer ); - Track->end = Fast_Locate_Pad_Connecte( - GetBoard(), Track->m_End, masque_layer ); + Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, masque_layer ); + Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, masque_layer ); } EraseDragList(); @@ -1030,8 +1022,7 @@ bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) // of picked items OnModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); if( current_net_code > 0 ) test_1_net_connexion( DC, current_net_code ); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 7deef8339d..3413eccf70 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -88,7 +88,7 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GRPoly( &aPanel->m_ClipBox, aDC, 5, poly, false, 0, YELLOW, YELLOW ); } - Mself.m_End = aPanel->GetScreen()->m_Curseur; + Mself.m_End = aPanel->GetScreen()->GetCrossHairPosition(); pt = Mself.m_End - Mself.m_Start; angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); @@ -113,9 +113,7 @@ void Exit_Self( EDA_DRAW_PANEL* Panel, wxDC* DC ) if( Self_On ) { Self_On = 0; - Panel->ManageCurseur( Panel, DC, wxDefaultPosition, 0 ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, 0 ); } } @@ -128,18 +126,17 @@ void WinEDA_PcbFrame::Begin_Self( wxDC* DC ) return; } - Mself.m_Start = GetScreen()->m_Curseur; + Mself.m_Start = GetScreen()->GetCrossHairPosition(); Mself.m_End = Mself.m_Start; Self_On = 1; /* Update the initial coordinates. */ - GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); UpdateStatusBar(); - DrawPanel->ManageCurseur = ShowBoundingBoxMicroWaveInductor; - DrawPanel->ForceCloseManageCurseur = Exit_Self; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } @@ -183,9 +180,8 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) int ll; wxString msg; - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); + DrawPanel->SetMouseCapture( NULL, NULL ); if( Self_On == 0 ) { @@ -195,7 +191,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) Self_On = 0; - Mself.m_End = GetScreen()->m_Curseur; + Mself.m_End = GetScreen()->GetCrossHairPosition(); wxPoint pt = Mself.m_End - Mself.m_Start; int min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); @@ -613,7 +609,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value ); if( dlg.ShowModal() != wxID_OK ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; // cancelled by user } @@ -629,7 +625,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) "Create microwave module" ), msg ); if( angledlg.ShowModal() != wxID_OK ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; // cancelled by user } msg = angledlg.GetValue(); @@ -645,7 +641,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) if( abort ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return NULL; } @@ -953,7 +949,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape() frame->Destroy(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); if( ok != 1 ) { diff --git a/pcbnew/muwave_command.cpp b/pcbnew/muwave_command.cpp index e38c81247e..1880b9f6be 100644 --- a/pcbnew/muwave_command.cpp +++ b/pcbnew/muwave_command.cpp @@ -33,7 +33,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event ) break; default: // End block command in progress. - DrawPanel->UnManageCursor( ); + DrawPanel->EndMouseCapture( ); break; } @@ -106,5 +106,6 @@ void WinEDA_PcbFrame::MuWaveCommand( wxDC* DC, const wxPoint& MousePos ) { StartMove_Module( module, DC ); } - DrawPanel->MouseToCursorSchema(); + + DrawPanel->MoveCursorToCrossHair(); } diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 9c83a40f0a..6d60bf67d3 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -28,7 +28,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress { DrawPanel->m_IgnoreMouseEvents = true; - DrawPanel->CursorOff( aDC ); + DrawPanel->CrossHairOff( aDC ); switch( DrawStruct->Type() ) { @@ -102,7 +102,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } DrawPanel->m_IgnoreMouseEvents = false; - DrawPanel->CursorOn( aDC ); + DrawPanel->CrossHairOn( aDC ); + if( exit ) return; } @@ -177,7 +178,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { SetCurItem( Create_Mire( aDC ) ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); } else if( DrawStruct->Type() == TYPE_MIRE ) { @@ -266,7 +267,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } if( hit_on_corner ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); DrawPanel->m_AutoPAN_Request = true; Start_Move_Zone_Corner( aDC, @@ -298,7 +299,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { SetCurItem( Create_Texte_Pcb( aDC ) ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_AutoPAN_Request = true; } else if( DrawStruct->Type() == TYPE_TEXTE ) @@ -313,7 +314,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_COMPONENT_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawStruct = Load_Module_From_Library( wxEmptyString, aDC ); SetCurItem( DrawStruct ); if( DrawStruct ) @@ -366,14 +367,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_PCB_PLACE_OFFSET_COORD_BUTT: DrawPanel->DrawAuxiliaryAxis( aDC, GR_XOR ); - m_Auxiliary_Axis_Position = GetScreen()->m_Curseur; + m_Auxiliary_Axis_Position = GetScreen()->GetCrossHairPosition(); DrawPanel->DrawAuxiliaryAxis( aDC, GR_COPY ); OnModify(); break; case ID_PCB_PLACE_GRID_COORD_BUTT: DrawPanel->DrawGridAxis( aDC, GR_XOR ); - GetScreen()->m_GridOrigin = GetScreen()->m_Curseur; + GetScreen()->m_GridOrigin = GetScreen()->GetCrossHairPosition(); DrawPanel->DrawGridAxis( aDC, GR_COPY ); break; @@ -430,7 +431,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) case TYPE_DIMENSION: case TYPE_TEXTE_MODULE: OnEditItemRequest( aDC, DrawStruct ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); break; case TYPE_DRAWSEGMENT: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 706f832218..14526e8027 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -49,7 +49,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) return true; } - DrawPanel->CursorOff( &dc ); + DrawPanel->CrossHairOff( &dc ); if( m_ID_current_state ) { @@ -78,10 +78,10 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) /* Select a proper item */ - wxPoint cursorPos = GetScreen()->m_Curseur; + wxPoint cursorPos = GetScreen()->GetCrossHairPosition(); wxPoint selectPos = m_Collector->GetRefPos(); - PutOnGrid( &selectPos ); + selectPos = GetScreen()->GetNearestGridPosition( selectPos ); /* We can reselect another item only if there are no item being edited * because ALL moving functions use GetCurItem(), therefore GetCurItem() @@ -101,7 +101,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) item = PcbGeneralLocateAndDisplay(); if( DrawPanel->m_AbortRequest ) { - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); return false; } } @@ -365,7 +365,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) break; } - DrawPanel->CursorOn( &dc ); + DrawPanel->CrossHairOn( &dc ); return true; } @@ -403,7 +403,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) * also update Netclass selection */ { - wxPoint cursorPosition = GetScreen()->m_Curseur; + wxPoint cursorPosition = GetScreen()->GetCrossHairPosition(); wxString msg; GetBoard()->SetCurrentNetClass( Track->GetNetClassName() ); diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 197c4e1701..f21725c364 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -234,7 +234,7 @@ void WinEDA_BasePcbFrame::SelectLayerPair() int result = frame->ShowModal(); frame->Destroy(); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); SetToolbars(); // if user changed colors and we are in high contrast mode, then redraw diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index fd7c26c736..80bf818eb7 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -475,7 +475,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, } /* Placing the bit to remove obstacles on 2 pads to a link. */ - pcbframe->Affiche_Message( wxT( "Gen Cells" ) ); + pcbframe->SetStatusText( wxT( "Gen Cells" ) ); Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, CURRENT_PAD, marge, WRITE_OR_CELL ); @@ -605,7 +605,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, lastmove = MoveNodes; msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d" ), OpenNodes, ClosNodes, MoveNodes ); - pcbframe->Affiche_Message( msg ); + pcbframe->SetStatusText( msg ); } _self = 0; @@ -767,7 +767,7 @@ end_of_route: msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"), OpenNodes, ClosNodes, MoveNodes ); - pcbframe->Affiche_Message( msg ); + pcbframe->SetStatusText( msg ); return result; } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 866d6e60f9..c8fc117de9 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -133,12 +133,12 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event ) if( ok ) { - Affiche_Message( wxString( _("BOARD exported OK.")) ); + SetStatusText( wxString( _( "BOARD exported OK." ) ) ); } else { errorText += '\n'; - errorText += _("Unable to export, please fix and try again."); + errorText += _( "Unable to export, please fix and try again." ); DisplayError( this, errorText ); } } diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 8547b709a1..56aa9859c5 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -125,7 +125,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event ) */ //Compile_Ratsnest( NULL, true ); - Affiche_Message( wxString( _("Session file imported and merged OK.")) ); + SetStatusText( wxString( _( "Session file imported and merged OK." ) ) ); DrawPanel->Refresh( true ); } diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 0cb2f61568..1ff6250b6e 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -64,11 +64,11 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) screen->ClrRefreshReq(); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); /* Redraw the cursor */ - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); } @@ -102,11 +102,11 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->ClrRefreshReq(); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, FALSE ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); // Redraw the cursor - DrawPanel->DrawCursor( DC ); + DrawPanel->DrawCrossHair( DC ); } diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index d64327f079..bebea9e384 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -473,14 +473,14 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, aNewModule->SetParent( GetBoard() ); GetBoard()->m_Status_Pcb = 0; - oldpos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = aOldModule->m_Pos; + oldpos = GetScreen()->GetCrossHairPosition(); + GetScreen()->SetCrossHairPosition( aOldModule->m_Pos ); /* place module without ratsnest refresh: this will be made later * when all modules are on board */ Place_Module( aNewModule, NULL, true ); - GetScreen()->m_Curseur = oldpos; + GetScreen()->SetCrossHairPosition( oldpos ); /* Flip footprint if needed */ if( aOldModule->GetLayer() != aNewModule->GetLayer() ) diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 532f890174..b976ebcd0a 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -119,13 +119,12 @@ int WinEDA_PcbFrame::Delete_LastCreatedCorner( wxDC* DC ) { zone->m_Poly->DeleteCorner( zone->GetNumCorners() - 1 ); - if( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur( DrawPanel, DC, wxDefaultPosition, false ); + if( DrawPanel->IsMouseCaptured() ) + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } else { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); zone->RemoveAllContours(); zone->m_Flags = 0; @@ -153,8 +152,6 @@ static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ) zone->RemoveAllContours(); } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; pcbframe->SetCurItem( NULL ); s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; @@ -201,8 +198,8 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con zone_container->m_Poly->InsertCorner(corner_id-1, cx, cy ); zone_container->m_Flags = IN_EDIT; - DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse; - DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines; + DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, + Abort_Zone_Move_Corner_Or_Outlines ); s_CornerInitialPosition = zone_container->GetCornerPosition( corner_id ); s_CornerIsNew = IsNewCorner; s_AddCutoutToCurrentZone = false; @@ -223,16 +220,16 @@ void WinEDA_PcbFrame::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, { zone_container->m_Flags = IS_DRAGGED; zone_container->m_CornerSelection = corner_id; - DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse; - DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines; - s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->m_Curseur; + DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, + Abort_Zone_Move_Corner_Or_Outlines ); + s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; s_PickedList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems(); - SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), zone_container->GetLayer() ); - + SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), + zone_container->GetLayer() ); } @@ -262,9 +259,9 @@ void WinEDA_PcbFrame::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_c SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), zone_container->GetLayer() ); zone_container->m_Flags = IS_MOVED; - DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse; - DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines; - s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->m_Curseur; + DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, + Abort_Zone_Move_Corner_Or_Outlines ); + s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_CornerIsNew = false; s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; @@ -283,10 +280,11 @@ void WinEDA_PcbFrame::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER */ { zone_container->m_Flags = 0; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); + if( DC ) zone_container->Draw( DrawPanel, DC, GR_OR ); + OnModify(); s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; @@ -419,8 +417,6 @@ void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) s_PickedList. ClearListAndDeleteItems(); Panel->Refresh(); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; pcbframe->SetCurItem( NULL ); zone_container->m_Flags = 0; s_AddCutoutToCurrentZone = false; @@ -441,7 +437,7 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* zone->Draw( aPanel, aDC, GR_XOR ); } - wxPoint pos = pcbframe->GetScreen()->m_Curseur; + wxPoint pos = pcbframe->GetScreen()->GetCrossHairPosition(); if( zone->m_Flags == IS_MOVED ) { @@ -531,7 +527,7 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) diag = InstallDialogNonCopperZonesEditor( zone ); g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones } - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; if( diag == ZONE_ABORT ) @@ -571,9 +567,10 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) zone->m_TimeStamp = GetTimeStamp(); g_Zone_Default_Setting.ExportSetting( *zone ); zone->m_Poly->Start( g_Zone_Default_Setting.m_CurrentZone_Layer, - GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y, - zone->GetHatchStyle() ); - zone->AppendCorner( GetScreen()->m_Curseur ); + GetScreen()->GetCrossHairPosition().x, + GetScreen()->GetCrossHairPosition().y, + zone->GetHatchStyle() ); + zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() ) { zone->m_Flags = 0; @@ -589,8 +586,8 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) } SetCurItem( zone ); - DrawPanel->ManageCurseur = Show_New_Edge_While_Move_Mouse; - DrawPanel->ForceCloseManageCurseur = Abort_Zone_Create_Outline; + DrawPanel->SetMouseCapture( Show_New_Edge_While_Move_Mouse, + Abort_Zone_Create_Outline ); } // edge in progress: else @@ -604,7 +601,7 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) ) { // Ok, we can add a new corner - zone->AppendCorner( GetScreen()->m_Curseur ); + zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); SetCurItem( zone ); // calls DisplayInfo(). } } @@ -649,7 +646,7 @@ bool WinEDA_PcbFrame::End_Zone( wxDC* DC ) { DisplayError( this, _( "DRC error: closing this area creates a drc error with an other area" ) ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); return false; } } @@ -658,8 +655,7 @@ bool WinEDA_PcbFrame::End_Zone( wxDC* DC ) zone->DrawWhileCreateOutline( DrawPanel, DC, GR_XOR ); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->SetMouseCapture( NULL, NULL ); // Undraw old drawings, because they can have important changes int layer = zone->GetLayer(); @@ -730,7 +726,7 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) aPanel->GetParent(); - wxPoint c_pos = pcbframe->GetScreen()->m_Curseur; + wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition(); ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour; if( zone == NULL ) @@ -789,7 +785,7 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container else // edit a zone on a non copper layer (technical layer) diag = InstallDialogNonCopperZonesEditor( zone_container ); - DrawPanel->MouseToCursorSchema(); + DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = FALSE; if( diag == ZONE_ABORT )