2011-12-22 13:28:11 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
/**
|
|
|
|
* @file class_drawpanel.h:
|
|
|
|
* @brief EDA_DRAW_PANEL class definition.
|
|
|
|
*/
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
#ifndef PANEL_WXSTRUCT_H
|
|
|
|
#define PANEL_WXSTRUCT_H
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <colors.h>
|
|
|
|
#include <base_struct.h>
|
2012-09-01 13:38:27 +00:00
|
|
|
#include <gr_basic.h>
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
class BASE_SCREEN;
|
2009-02-04 15:25:03 +00:00
|
|
|
class PCB_SCREEN;
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
/**
|
|
|
|
* Mouse capture callback function prototype.
|
|
|
|
*/
|
|
|
|
typedef void ( *MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2011-02-21 13:54:29 +00:00
|
|
|
const wxPoint& aPosition, bool aErase );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* End mouse capture callback function prototype.
|
|
|
|
*/
|
|
|
|
typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_PANEL : public wxScrolledWindow
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2009-12-21 12:05:36 +00:00
|
|
|
private:
|
2013-08-03 05:15:23 +00:00
|
|
|
int m_currentCursor; ///< Current mouse cursor shape id.
|
|
|
|
int m_defaultCursor; ///< The default mouse cursor shape id.
|
|
|
|
bool m_showCrossHair; ///< Indicate if cross hair is to be shown.
|
|
|
|
int m_cursorLevel; ///< Index for cursor redraw in XOR mode.
|
|
|
|
int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit.
|
|
|
|
int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit.
|
|
|
|
|
|
|
|
wxPoint m_CursorStartPos; ///< Used for testing the cursor movement.
|
|
|
|
wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started
|
|
|
|
wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started
|
2009-12-21 12:05:36 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
/// The drawing area used to redraw the screen which is usually the visible area
|
|
|
|
/// of the drawing in internal units.
|
2013-08-03 05:15:23 +00:00
|
|
|
EDA_RECT m_ClipBox;
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_abortRequest; ///< Flag used to abort long commands.
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center
|
|
|
|
bool m_enableMiddleButtonPan; ///< True to enable middle mouse button panning.
|
|
|
|
bool m_panScrollbarLimits; ///< has meaning only if m_enableMiddleButtonPan = true
|
|
|
|
///< true to limit panning to scrollbar current limits
|
|
|
|
///< false to used unlimited pan
|
2012-04-11 18:54:20 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_enableAutoPan; ///< True to enable automatic panning.
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true.
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_ignoreMouseEvents; ///< Ignore mouse events when true.
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2012-12-06 21:53:00 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true.
|
2012-12-06 21:53:00 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_enableBlockCommands; ///< True enables block commands.
|
2011-02-09 19:47:33 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
/**
|
|
|
|
* Count the drag events. Used to filter mouse moves before starting a
|
|
|
|
* block command. A block command can be started only if
|
|
|
|
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid
|
|
|
|
* spurious block commands.
|
|
|
|
*/
|
|
|
|
int m_minDragEventCount;
|
2012-12-06 21:53:00 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
/// True when drawing in mirror mode. Used by the draw arc function, because arcs
|
|
|
|
/// are oriented, and in mirror mode, orientations are reversed.
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_PrintIsMirrored;
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
/// Mouse capture move callback function.
|
2011-02-11 20:48:13 +00:00
|
|
|
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback;
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
/// Abort mouse capture callback function.
|
2011-02-11 20:48:13 +00:00
|
|
|
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback;
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
/// useful to avoid false start block in certain cases
|
|
|
|
/// (like switch from a sheet to an other sheet
|
|
|
|
/// >= 0 (or >= n) if a block can start
|
|
|
|
int m_canStartBlock;
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
public:
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size );
|
|
|
|
~EDA_DRAW_PANEL();
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
/**
|
|
|
|
* Function GetDisplayOptions
|
|
|
|
* A way to pass info to draw functions.
|
|
|
|
* this is just an accessor to the GetDisplayOptions() parent frame function.
|
|
|
|
*/
|
|
|
|
void* GetDisplayOptions();
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
BASE_SCREEN* GetScreen();
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
EDA_DRAW_FRAME* GetParent() const;
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
void OnPaint( wxPaintEvent& event );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
EDA_RECT* GetClipBox() { return &m_ClipBox; }
|
|
|
|
|
|
|
|
void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; }
|
|
|
|
|
|
|
|
bool GetAbortRequest() const { return m_abortRequest; }
|
|
|
|
|
|
|
|
void SetAbortRequest( bool aAbortRequest ) { m_abortRequest = aAbortRequest; }
|
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
bool GetEnableMiddleButtonPan() const { return m_enableMiddleButtonPan; }
|
|
|
|
|
|
|
|
void SetEnableMiddleButtonPan( bool aEnable ) { m_enableMiddleButtonPan = aEnable; }
|
|
|
|
|
2013-02-02 19:10:48 +00:00
|
|
|
bool GetEnableZoomNoCenter() const { return m_enableZoomNoCenter; }
|
|
|
|
|
|
|
|
void SetEnableZoomNoCenter( bool aEnable ) { m_enableZoomNoCenter = aEnable; }
|
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
bool GetMiddleButtonPanLimited() const { return m_panScrollbarLimits; }
|
|
|
|
|
|
|
|
void SetMiddleButtonPanLimited( bool aEnable ) { m_panScrollbarLimits = aEnable; }
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
bool GetEnableAutoPan() const { return m_enableAutoPan; }
|
|
|
|
|
|
|
|
void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; }
|
|
|
|
|
|
|
|
void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; }
|
|
|
|
|
|
|
|
void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; }
|
|
|
|
|
2012-12-06 21:53:00 +00:00
|
|
|
void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; }
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool GetPrintMirrored() const { return m_PrintIsMirrored; }
|
|
|
|
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
|
2011-12-29 20:11:42 +00:00
|
|
|
|
|
|
|
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
|
2011-03-09 20:09:11 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawBackGround
|
2010-01-17 14:20:29 +00:00
|
|
|
* @param DC = current Device Context
|
|
|
|
* Draws (if allowed) :
|
|
|
|
* the grid
|
|
|
|
* X and Y axis
|
|
|
|
* X and Y auxiliary axis
|
|
|
|
*/
|
2011-02-09 19:47:33 +00:00
|
|
|
void DrawBackGround( wxDC* DC );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawGrid
|
2011-02-09 19:47:33 +00:00
|
|
|
* draws a grid to \a aDC.
|
|
|
|
* @see m_ClipBox to determine the damaged area of the drawing to draw the grid.
|
|
|
|
* @see EDA_DRAW_FRAME::IsGridVisible() to determine if grid is shown.
|
|
|
|
* @see EDA_DRAW_FRAME::GetGridColor() for the color of the grid.
|
|
|
|
* @param aDC The device context to draw the grid.
|
2010-01-17 14:20:29 +00:00
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
void DrawGrid( wxDC* aDC );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawAuxiliaryAxis
|
2011-09-30 18:15:37 +00:00
|
|
|
* Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates
|
2010-01-17 14:20:29 +00:00
|
|
|
* for gerber and excellon files
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aDC = current Device Context
|
|
|
|
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
|
2010-01-17 14:20:29 +00:00
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode );
|
2010-12-28 11:24:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DrawGridAxis
|
2011-09-30 18:15:37 +00:00
|
|
|
* Draw on auxiliary axis, used in Pcbnew to show grid origin, when
|
2010-12-28 11:24:42 +00:00
|
|
|
* the grid origin is set by user, and is not (0,0)
|
|
|
|
* @param aDC = current Device Context
|
|
|
|
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
|
2013-08-03 05:15:23 +00:00
|
|
|
* @param aGridOrigin = the absolute coordinate of grid origin for snap.
|
2010-12-28 11:24:42 +00:00
|
|
|
*/
|
2013-08-03 05:15:23 +00:00
|
|
|
void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin );
|
2010-12-28 11:24:42 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
void OnEraseBackground( wxEraseEvent& event ) { }
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
/**
|
|
|
|
* Function OnActivate
|
|
|
|
* handles window activation events.
|
|
|
|
* <p>
|
2011-12-29 20:11:42 +00:00
|
|
|
* The member m_canStartBlock is initialize to avoid a block start command on activation
|
2011-02-09 19:47:33 +00:00
|
|
|
* (because a left mouse button can be pressed and no block command wanted. This happens
|
|
|
|
* when enter on a hierarchy sheet on double click.
|
|
|
|
*</p>
|
|
|
|
*/
|
|
|
|
void OnActivate( wxActivateEvent& event );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
/**
|
2011-02-11 20:48:13 +00:00
|
|
|
* Function DoPrepareDC
|
2011-02-09 19:47:33 +00:00
|
|
|
* sets up the device context \a aDC for drawing.
|
|
|
|
* <p>
|
2011-02-11 20:48:13 +00:00
|
|
|
* This overrides wxScrolledWindow::DoPrepareDC() for setting up the the device context
|
2011-02-09 19:47:33 +00:00
|
|
|
* 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
|
|
|
|
* LogicalToDeviceXXX and DeviceToLogixalXXX methods. This gets called automatically
|
|
|
|
* for a paint event. If you do any drawing outside the paint event, you must call
|
|
|
|
* DoPrepareDC manually.
|
|
|
|
* </p>
|
|
|
|
* @param aDC The device context to prepare.
|
2010-02-08 18:15:42 +00:00
|
|
|
*/
|
2011-02-09 19:47:33 +00:00
|
|
|
virtual void DoPrepareDC( wxDC& aDC );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
/**
|
|
|
|
* Function DeviceToLogical
|
|
|
|
* converts \a aRect from device to drawing (logical) coordinates.
|
|
|
|
* <p>
|
|
|
|
* \a aRect must be in scrolled device units.
|
2011-01-31 18:26:12 +00:00
|
|
|
* </p>
|
2011-01-30 22:22:38 +00:00
|
|
|
* @param aRect The rectangle to convert.
|
|
|
|
* @param aDC The device context used for the conversion.
|
|
|
|
* @return A rectangle converted to drawing units.
|
|
|
|
*/
|
|
|
|
wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC );
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
/* Mouse and keys events */
|
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
/**
|
2011-02-11 20:48:13 +00:00
|
|
|
* Function OnMouseWheel
|
2011-02-09 19:47:33 +00:00
|
|
|
* handles mouse wheel events.
|
|
|
|
* <p>
|
|
|
|
* The mouse wheel is used to provide support for zooming and panning. This
|
|
|
|
* is accomplished by converting mouse wheel events in pseudo menu command
|
|
|
|
* events and sending them to the appropriate parent window event handler.
|
|
|
|
*</p>
|
|
|
|
*/
|
|
|
|
void OnMouseWheel( wxMouseEvent& event );
|
2015-05-21 20:54:29 +00:00
|
|
|
#ifdef USE_OSX_MAGNIFY_EVENT
|
|
|
|
void OnMagnify( wxMouseEvent& event );
|
|
|
|
#endif
|
2011-02-09 19:47:33 +00:00
|
|
|
void OnMouseEvent( wxMouseEvent& event );
|
|
|
|
void OnMouseLeaving( wxMouseEvent& event );
|
|
|
|
void OnKeyEvent( wxKeyEvent& event );
|
2011-12-17 21:21:03 +00:00
|
|
|
void OnCharHook( wxKeyEvent& event );
|
2011-02-09 19:47:33 +00:00
|
|
|
|
|
|
|
void OnPan( wxCommandEvent& event );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
void EraseScreen( wxDC* DC );
|
|
|
|
void OnScrollWin( wxCommandEvent& event );
|
|
|
|
void OnScroll( wxScrollWinEvent& event );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2012-05-07 21:47:25 +00:00
|
|
|
void SetZoom( double mode );
|
|
|
|
double GetZoom();
|
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
void SetGrid( const wxRealPoint& size );
|
|
|
|
wxRealPoint GetGrid();
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
/**
|
|
|
|
* Function OnRightClick
|
|
|
|
* builds and displays a context menu on a right mouse button click.
|
|
|
|
* @return true if the context menu is shown, or false
|
|
|
|
*/
|
|
|
|
bool OnRightClick( wxMouseEvent& event );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-02-09 19:47:33 +00:00
|
|
|
/**
|
|
|
|
* Function IsPointOnDisplay
|
|
|
|
* @param aPosition The position to test in logical (drawing) units.
|
|
|
|
* @return true if \a aPosition is visible on the screen.
|
2011-02-11 20:48:13 +00:00
|
|
|
* false if \a aPosition is not visible on the screen.
|
2011-02-09 19:47:33 +00:00
|
|
|
*/
|
|
|
|
bool IsPointOnDisplay( const wxPoint& aPosition );
|
2011-01-30 22:22:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetClipBox
|
|
|
|
* sets the clip box in drawing (logical) units from \a aRect in device units.
|
|
|
|
* <p>
|
|
|
|
* If \a aRect is NULL, then the entire visible area of the screen is used as the clip
|
|
|
|
* area. The clip box is used when drawing to determine which objects are not visible
|
2011-02-08 14:48:38 +00:00
|
|
|
* and do not need to be drawn. Note that this is not the same as setting the device
|
|
|
|
* context clipping with wxDC::SetClippingRegion(). This is the rectangle used by the
|
|
|
|
* drawing functions in gr_basic.cpp used to determine if the item to draw is off screen
|
|
|
|
* and therefore not drawn.
|
2011-01-30 22:22:38 +00:00
|
|
|
* </p>
|
2011-01-31 18:26:12 +00:00
|
|
|
* @param aDC The device context use for drawing with the correct scale and
|
2011-01-30 22:22:38 +00:00
|
|
|
* offsets already configured. See DoPrepareDC().
|
|
|
|
* @param aRect The clip rectangle in device units or NULL for the entire visible area
|
|
|
|
* of the screen.
|
|
|
|
*/
|
2011-02-09 19:47:33 +00:00
|
|
|
void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL );
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void ReDraw( wxDC* aDC, bool aEraseBackground = true );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-01-30 22:22:38 +00:00
|
|
|
* Function RefreshDrawingRect
|
|
|
|
* redraws the contents of \a aRect in drawing units. \a aRect is converted to
|
|
|
|
* screen coordinates and wxWindow::RefreshRect() is called to repaint the region.
|
|
|
|
* @param aRect The rectangle to repaint.
|
|
|
|
* @param aEraseBackground Erases the background if true.
|
2009-02-02 12:12:18 +00:00
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2013-09-20 15:29:32 +00:00
|
|
|
/// @copydoc wxWindow::Refresh()
|
|
|
|
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
|
|
|
|
|
2011-01-31 18:26:12 +00:00
|
|
|
/**
|
|
|
|
* Function GetScreenCenterLogicalPosition
|
|
|
|
* @return The current screen center position in logical (drawing) units.
|
|
|
|
*/
|
2011-02-09 19:47:33 +00:00
|
|
|
wxPoint GetScreenCenterLogicalPosition();
|
2011-01-31 18:26:12 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
/**
|
|
|
|
* Function MoveCursorToCrossHair
|
|
|
|
* warps the cursor to the current cross hair position.
|
|
|
|
*/
|
|
|
|
void MoveCursorToCrossHair();
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2013-02-02 19:10:48 +00:00
|
|
|
/**
|
|
|
|
* Function ToDeviceXY
|
|
|
|
* transforms logical to device coordinates
|
|
|
|
*/
|
|
|
|
wxPoint ToDeviceXY( const wxPoint& pos );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ToLogicalXY
|
|
|
|
* transforms device to logical coordinates
|
|
|
|
*/
|
|
|
|
wxPoint ToLogicalXY( const wxPoint& pos );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function MoveCursor
|
|
|
|
* moves the mouse pointer to \a aPosition in logical (drawing) units.
|
|
|
|
* @param aPosition The position in logical units to move the cursor.
|
|
|
|
*/
|
2011-02-09 19:47:33 +00:00
|
|
|
void MoveCursor( const wxPoint& aPosition );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
/* Cursor functions */
|
2010-01-22 18:13:43 +00:00
|
|
|
/**
|
2011-02-11 20:48:13 +00:00
|
|
|
* Function DrawCrossHair
|
|
|
|
* draws the user cross hair.
|
|
|
|
* <p>
|
|
|
|
* 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.
|
|
|
|
* </p>
|
2010-01-22 18:13:43 +00:00
|
|
|
* @param aDC - the device context to draw the cursor
|
|
|
|
* @param aColor - the color to draw the cursor
|
|
|
|
*/
|
2012-09-02 12:06:47 +00:00
|
|
|
void DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor = WHITE );
|
2010-01-22 18:13:43 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
// Hide the cross hair.
|
|
|
|
void CrossHairOff( wxDC* DC );
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
// Show the cross hair.
|
|
|
|
void CrossHairOn( wxDC* DC );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
|
|
|
|
void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback )
|
|
|
|
{
|
|
|
|
m_mouseCaptureCallback = aMouseCaptureCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2011-02-11 20:48:13 +00:00
|
|
|
* Function EndMouseCapture
|
|
|
|
* ends mouse a capture.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2011-02-08 14:48:38 +00:00
|
|
|
* 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.
|
|
|
|
* @param aCursorId The wxWidgets stock cursor ID to set the cursor to or -1 to keep the
|
|
|
|
* current cursor.
|
|
|
|
* @param aTitle The tool message to display in the status bar or wxEmptyString to clear
|
|
|
|
* the message.
|
2011-11-10 15:55:05 +00:00
|
|
|
* @param aCallEndFunc Call the abort mouse capture callback if true.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2011-02-11 20:48:13 +00:00
|
|
|
void EndMouseCapture( int aId = -1, int aCursorId = -1,
|
2011-11-10 15:55:05 +00:00
|
|
|
const wxString& aTitle = wxEmptyString,
|
|
|
|
bool aCallEndFunc = true );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
/**
|
|
|
|
* Function CallMouseCapture
|
|
|
|
* calls the mouse capture callback.
|
|
|
|
*
|
|
|
|
* @param aDC A point to a wxDC object to perform any drawing upon.
|
|
|
|
* @param aPosition A referecnce to a wxPoint object containing the current cursor
|
|
|
|
* position.
|
|
|
|
* @param aErase True indicates the item being drawn should be erase before drawing
|
|
|
|
* it a \a aPosition.
|
|
|
|
*/
|
|
|
|
void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CallEndMouseCapture
|
|
|
|
* calls the end mouse capture callback.
|
|
|
|
*
|
|
|
|
* @param aDC A point to a wxDC object to perform any drawing upon.
|
|
|
|
*/
|
|
|
|
void CallEndMouseCapture( wxDC* aDC );
|
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
/**
|
|
|
|
* Function SetCurrentCursor
|
|
|
|
* Set the current cursor shape for drawpanel
|
|
|
|
*/
|
|
|
|
void SetCurrentCursor( int aCursor )
|
|
|
|
{
|
|
|
|
m_currentCursor = aCursor;
|
2012-02-26 18:49:00 +00:00
|
|
|
SetCursor( (wxStockCursor) m_currentCursor );
|
2011-03-09 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetDefaultCursor
|
|
|
|
* return the default cursor shape
|
|
|
|
*/
|
2011-02-08 14:48:38 +00:00
|
|
|
int GetDefaultCursor() const { return m_defaultCursor; }
|
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
/**
|
|
|
|
* Function GetCurrentCursor
|
|
|
|
* return the current cursor shape, depending on the current selected tool
|
|
|
|
*/
|
|
|
|
int GetCurrentCursor() const { return m_currentCursor; }
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 )
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
#endif /* #ifndef PANEL_WXSTRUCT_H */
|