Browse Source
eeschema-gal: Base refactoring before GALification of the eeschema legacy canvas.
eeschema-gal: Base refactoring before GALification of the eeschema legacy canvas.
Note: it's only the renderer that is changed from wxDC to GAL. Tools stay the same, consider this a temporary hack. This commit splits the EDA_DRAW_FRAME, EDA_DRAW_PANEL and BLOCK_SELECTOR classes into two variants, each independently compiled into a static library. - "legacy_wx" for PCBnew/Gerbview - wxDC-based legacy canvas. We have full GAL support there anyway so it makes no sense to introduce GAL rendering API to the legacy tools. - "legacy_gal" for EEschema and the rest - GAL-based legacy canvas, using legacy tools but with a GAL renderer. Such split ensures only a small part of the common library and eeschema is affected, without messing around with already GALified tools. The commit also removes some header dependencies on class_drawpanel.hpull/13/head
committed by
Jeff Young
14 changed files with 3468 additions and 603 deletions
-
27common/CMakeLists.txt
-
158common/copy_to_clipboard.cpp
-
205common/legacy_gal/block.cpp
-
1767common/legacy_gal/eda_draw_frame.cpp
-
16common/legacy_gal/other.cpp
-
0common/legacy_wx/block.cpp
-
509common/legacy_wx/eda_draw_frame.cpp
-
8common/legacy_wx/eda_draw_panel.cpp
-
47common/legacy_wx/other.cpp
-
23common/marker_base.cpp
-
79common/worksheet.cpp
-
335common/zoom.cpp
-
389include/legacy_gal/class_drawpanel.h
-
508include/legacy_wx/class_drawpanel.h
@ -1,158 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com |
|||
* 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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file copy_to_clipboard.cpp |
|||
*/ |
|||
|
|||
#include <wx/clipbrd.h>
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <common.h>
|
|||
#include <id.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <base_screen.h>
|
|||
#include <confirm.h>
|
|||
#include <draw_frame.h>
|
|||
|
|||
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ); |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event ) |
|||
{ |
|||
DrawPageOnClipboard( this ); |
|||
|
|||
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD ) |
|||
{ |
|||
if( GetScreen()->IsBlockActive() ) |
|||
m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) ); |
|||
|
|||
m_canvas->EndMouseCapture(); |
|||
} |
|||
} |
|||
|
|||
|
|||
/* copy the current page or block to the clipboard ,
|
|||
* to export drawings to other applications (word processing ...) |
|||
* This is not suitable for copy command within Eeschema or Pcbnew |
|||
*/ |
|||
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ) |
|||
{ |
|||
bool DrawBlock = false; |
|||
wxRect DrawArea; |
|||
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen(); |
|||
|
|||
if( screen->IsBlockActive() ) |
|||
{ |
|||
DrawBlock = true; |
|||
DrawArea.SetX( screen->m_BlockLocate.GetX() ); |
|||
DrawArea.SetY( screen->m_BlockLocate.GetY() ); |
|||
DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() ); |
|||
DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() ); |
|||
} |
|||
else |
|||
DrawArea.SetSize( aFrame->GetPageSizeIU() ); |
|||
|
|||
// Calculate a reasonable dc size, in pixels, and the dc scale to fit
|
|||
// the drawings into the dc size
|
|||
// scale is the ratio resolution (in PPI) / internal units
|
|||
double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
|
|||
double inch2Iu = 1000.0 * (double) screen->MilsToIuScalar(); |
|||
double scale = ppi / inch2Iu; |
|||
|
|||
wxSize dcsize = DrawArea.GetSize(); |
|||
|
|||
int maxdim = std::max( dcsize.x, dcsize.y ); |
|||
// the max size in pixels of the bitmap used to byuild the sheet copy
|
|||
const int maxbitmapsize = 3000; |
|||
|
|||
while( int( maxdim * scale ) > maxbitmapsize ) |
|||
{ |
|||
ppi = ppi / 1.5; |
|||
scale = ppi / inch2Iu; |
|||
} |
|||
|
|||
dcsize.x *= scale; |
|||
dcsize.y *= scale; |
|||
|
|||
// Set draw offset, zoom... to values needed to draw in the memory DC
|
|||
// after saving initial values:
|
|||
wxPoint tmp_startvisu = screen->m_StartVisu; |
|||
double tmpzoom = screen->GetZoom(); |
|||
wxPoint old_org = screen->m_DrawOrg; |
|||
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; |
|||
screen->m_StartVisu.x = screen->m_StartVisu.y = 0; |
|||
|
|||
screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
|
|||
|
|||
wxMemoryDC dc; |
|||
wxBitmap image( dcsize ); |
|||
dc.SelectObject( image ); |
|||
|
|||
EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox(); |
|||
GRResetPenAndBrush( &dc ); |
|||
GRForceBlackPen( false ); |
|||
screen->m_IsPrinting = true; |
|||
dc.SetUserScale( scale, scale ); |
|||
|
|||
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), |
|||
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) ); |
|||
|
|||
if( DrawBlock ) |
|||
{ |
|||
dc.SetClippingRegion( DrawArea ); |
|||
} |
|||
|
|||
dc.Clear(); |
|||
aFrame->GetCanvas()->EraseScreen( &dc ); |
|||
const LSET allLayersMask = LSET().set(); |
|||
aFrame->PrintPage( &dc, allLayersMask, false ); |
|||
screen->m_IsPrinting = false; |
|||
aFrame->GetCanvas()->SetClipBox( tmp ); |
|||
|
|||
bool success = true; |
|||
|
|||
if( wxTheClipboard->Open() ) |
|||
{ |
|||
// This data objects are held by the clipboard,
|
|||
// so do not delete them in the app.
|
|||
wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image ); |
|||
wxTheClipboard->SetData( clipbrd_data ); |
|||
wxTheClipboard->Close(); |
|||
} |
|||
else |
|||
success = false; |
|||
|
|||
// Deselect Bitmap from DC in order to delete the MemoryDC safely
|
|||
// without deleting the bitmap
|
|||
dc.SelectObject( wxNullBitmap ); |
|||
|
|||
GRForceBlackPen( false ); |
|||
|
|||
screen->m_StartVisu = tmp_startvisu; |
|||
screen->m_DrawOrg = old_org; |
|||
screen->SetZoom( tmpzoom ); |
|||
|
|||
return success; |
|||
} |
@ -0,0 +1,205 @@ |
|||
/*
|
|||
* 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) 2004-2011 KiCad Developers, see change_log.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file block_commande.cpp |
|||
* @brief Common routines for managing on block commands. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <draw_frame.h>
|
|||
#include <common.h>
|
|||
#include <macros.h>
|
|||
#include <base_struct.h>
|
|||
#include <base_screen.h>
|
|||
#include <legacy_gal/class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <block_commande.h>
|
|||
|
|||
|
|||
BLOCK_SELECTOR::BLOCK_SELECTOR() : |
|||
EDA_RECT() |
|||
{ |
|||
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
|
|||
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
|
|||
m_color = BROWN; |
|||
} |
|||
|
|||
|
|||
BLOCK_SELECTOR::~BLOCK_SELECTOR() |
|||
{ |
|||
ClearListAndDeleteItems(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) |
|||
{ |
|||
wxString msg; |
|||
|
|||
switch( m_command ) |
|||
{ |
|||
case BLOCK_IDLE: |
|||
break; |
|||
|
|||
case BLOCK_MOVE: // Move
|
|||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
|||
case BLOCK_MOVE_EXACT: |
|||
msg = _( "Block Move" ); |
|||
break; |
|||
|
|||
case BLOCK_DRAG: // Drag
|
|||
msg = _( "Block Drag" ); |
|||
break; |
|||
|
|||
case BLOCK_DRAG_ITEM: // Drag
|
|||
msg = _( "Drag item" ); |
|||
break; |
|||
|
|||
case BLOCK_DUPLICATE: // Duplicate
|
|||
msg = _( "Block Duplicate" ); |
|||
break; |
|||
|
|||
case BLOCK_DELETE: // Delete
|
|||
msg = _( "Block Delete" ); |
|||
break; |
|||
|
|||
case BLOCK_COPY: // Copy
|
|||
msg = _( "Block Copy" ); |
|||
break; |
|||
|
|||
case BLOCK_PASTE: |
|||
msg = _( "Block Paste" ); |
|||
break; |
|||
|
|||
case BLOCK_ZOOM: // Window Zoom
|
|||
msg = _( "Zoom to selection" ); |
|||
break; |
|||
|
|||
case BLOCK_ROTATE: // Rotate 90 deg
|
|||
msg = _( "Block Rotate" ); |
|||
break; |
|||
|
|||
case BLOCK_FLIP: // Flip
|
|||
msg = _( "Block Flip" ); |
|||
break; |
|||
|
|||
case BLOCK_MIRROR_X: |
|||
case BLOCK_MIRROR_Y: // mirror
|
|||
msg = _( "Block Mirror" ); |
|||
break; |
|||
|
|||
case BLOCK_ABORT: |
|||
break; |
|||
|
|||
default: |
|||
msg = wxT( "???" ); |
|||
break; |
|||
} |
|||
|
|||
frame->DisplayToolMsg( msg ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, |
|||
GR_DRAWMODE aDrawMode, COLOR4D aColor ) |
|||
{ |
|||
if( !aDC ) |
|||
return; |
|||
|
|||
int w = GetWidth(); |
|||
int h = GetHeight(); |
|||
|
|||
GRSetDrawMode( aDC, aDrawMode ); |
|||
|
|||
if( w == 0 || h == 0 ) |
|||
GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y, |
|||
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor ); |
|||
else |
|||
GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y, |
|||
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos ) |
|||
{ |
|||
m_state = STATE_BLOCK_INIT; |
|||
SetOrigin( startpos ); |
|||
SetSize( wxSize( 0, 0 ) ); |
|||
m_items.ClearItemsList(); |
|||
aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearItemsList() |
|||
{ |
|||
m_items.ClearItemsList(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearListAndDeleteItems() |
|||
{ |
|||
m_items.ClearListAndDeleteItems(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem ) |
|||
{ |
|||
m_items.PushItem( aItem ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Clear() |
|||
{ |
|||
if( m_command != BLOCK_IDLE ) |
|||
{ |
|||
m_command = BLOCK_IDLE; |
|||
m_state = STATE_NO_BLOCK; |
|||
ClearItemsList(); |
|||
} |
|||
} |
|||
|
|||
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
|
|||
if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
|
|||
{ |
|||
// Clear block outline.
|
|||
aPanel->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
aPanel->SetMouseCapture( NULL, NULL ); |
|||
screen->SetCurItem( NULL ); |
|||
|
|||
// Delete the picked wrapper if this is a picked list.
|
|||
screen->m_BlockLocate.ClearItemsList(); |
|||
} |
|||
|
|||
screen->m_BlockLocate.SetState( STATE_NO_BLOCK ); |
|||
screen->m_BlockLocate.SetCommand( BLOCK_ABORT ); |
|||
aPanel->GetParent()->HandleBlockEnd( aDC ); |
|||
|
|||
screen->m_BlockLocate.SetCommand( BLOCK_IDLE ); |
|||
aPanel->GetParent()->DisplayToolMsg( wxEmptyString ); |
|||
aPanel->SetDefaultCursor(); |
|||
} |
1767
common/legacy_gal/eda_draw_frame.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,16 @@ |
|||
#include "fctsys.h"
|
|||
#include "gr_basic.h"
|
|||
#include "base_screen.h"
|
|||
#include "common.h"
|
|||
#include "macros.h"
|
|||
#include "legacy_gal/class_drawpanel.h"
|
|||
#include "marker_base.h"
|
|||
#include "dialog_display_info_HTML_base.h"
|
|||
|
|||
|
|||
|
|||
void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, |
|||
const wxPoint& aOffset ) |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
#include "fctsys.h"
|
|||
#include "gr_basic.h"
|
|||
#include "base_screen.h"
|
|||
#include "common.h"
|
|||
#include "macros.h"
|
|||
#include "class_drawpanel.h"
|
|||
#include "marker_base.h"
|
|||
#include "dialog_display_info_HTML_base.h"
|
|||
|
|||
|
|||
static const wxPoint MarkerShapeCorners[] = |
|||
{ |
|||
wxPoint( 0, 0 ), |
|||
wxPoint( 8, 1 ), |
|||
wxPoint( 4, 3 ), |
|||
wxPoint( 13, 8 ), |
|||
wxPoint( 9, 9 ), |
|||
wxPoint( 8, 13 ), |
|||
wxPoint( 3, 4 ), |
|||
wxPoint( 1, 8 ) |
|||
}; |
|||
const unsigned CORNERS_COUNT = DIM( MarkerShapeCorners ); |
|||
|
|||
|
|||
|
|||
void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, |
|||
const wxPoint& aOffset ) |
|||
{ |
|||
wxPoint corners[CORNERS_COUNT]; |
|||
|
|||
GRSetDrawMode( aDC, aDrawMode ); |
|||
|
|||
for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ ) |
|||
{ |
|||
corners[ii] = MarkerShapeCorners[ii]; |
|||
corners[ii].x *= m_ScalingFactor; |
|||
corners[ii].y *= m_ScalingFactor; |
|||
corners[ii] += m_Pos + aOffset; |
|||
} |
|||
|
|||
GRClosedPoly( aPanel->GetClipBox(), aDC, CORNERS_COUNT, corners, |
|||
true, // = Filled
|
|||
0, // outline width
|
|||
m_Color, // outline color
|
|||
m_Color // fill collor
|
|||
); |
|||
} |
@ -1,335 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2018 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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file zoom.cpp |
|||
*/ |
|||
|
|||
/*
|
|||
* Manage zoom, grid step, and auto crop. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <id.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <view/view.h>
|
|||
#include <base_screen.h>
|
|||
#include <draw_frame.h>
|
|||
#include <kicad_device_context.h>
|
|||
#include <hotkeys_basic.h>
|
|||
#include <menus_helpers.h>
|
|||
#include <base_units.h>
|
|||
#include <tool/tool_manager.h>
|
|||
|
|||
|
|||
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) |
|||
{ |
|||
if( IsGalCanvasActive() ) |
|||
return; |
|||
|
|||
AdjustScrollBars( aCenterPoint ); |
|||
|
|||
// Move the mouse cursor to the on grid graphic cursor position
|
|||
if( aWarpPointer ) |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
|
|||
m_canvas->Refresh(); |
|||
m_canvas->Update(); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) |
|||
{ |
|||
if( IsGalCanvasActive() ) |
|||
return; |
|||
|
|||
// Account for scrollbars (see EDA_DRAW_FRAME::AdjustScrollBars that takes
|
|||
// in account scroolbars area to adjust scroll bars)
|
|||
wxSize scrollbarSize = m_canvas->GetSize() - m_canvas->GetClientSize(); |
|||
wxSize sizeAdjusted = m_canvas->GetClientSize() - scrollbarSize; |
|||
|
|||
wxPoint dPos = posBefore - sizeAdjusted / 2; |
|||
|
|||
// screen position of crosshair after zoom
|
|||
wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); |
|||
wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos ); |
|||
|
|||
AdjustScrollBars( newCenter ); |
|||
|
|||
m_canvas->Refresh(); |
|||
m_canvas->Update(); |
|||
} |
|||
|
|||
|
|||
// Factor out the calculation portion of the various BestZoom() implementations.
|
|||
//
|
|||
// Note that like it's forerunners this routine has an intentional side-effect: it
|
|||
// sets the scroll centre position. While I'm not happy about that, it's probably
|
|||
// not worth fixing as its days are numbered (GAL canvases use a different method).
|
|||
double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre ) |
|||
{ |
|||
double bestzoom = std::max( sizeX * scaleFactor / (double) m_canvas->GetClientSize().x, |
|||
sizeY * scaleFactor / (double) m_canvas->GetClientSize().y ); |
|||
|
|||
// Take scrollbars into account
|
|||
DSIZE scrollbarSize = m_canvas->GetSize() - m_canvas->GetClientSize(); |
|||
centre.x -= int( bestzoom * scrollbarSize.x / 2.0 ); |
|||
centre.y -= int( bestzoom * scrollbarSize.y / 2.0 ); |
|||
|
|||
SetScrollCenterPosition( centre ); |
|||
|
|||
return bestzoom; |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) |
|||
{ |
|||
BASE_SCREEN* screen = GetScreen(); |
|||
|
|||
if( !screen ) |
|||
return; |
|||
|
|||
// Set the best zoom and get center point.
|
|||
|
|||
// BestZoom() can compute an illegal zoom if the client window size
|
|||
// is small, say because frame is not maximized. So use the clamping form
|
|||
// of SetZoom():
|
|||
double bestzoom = BestZoom(); |
|||
screen->SetScalingFactor( bestzoom ); |
|||
|
|||
if( screen->m_FirstRedraw ) |
|||
SetCrossHairPosition( GetScrollCenterPosition() ); |
|||
|
|||
if( !IsGalCanvasActive() ) |
|||
RedrawScreen( GetScrollCenterPosition(), aWarpPointer ); |
|||
else |
|||
m_toolManager->RunAction( "common.Control.zoomFitScreen", true ); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect ) |
|||
{ |
|||
// Compute the best zoom
|
|||
Rect.Normalize(); |
|||
|
|||
wxSize size = m_canvas->GetClientSize(); |
|||
|
|||
// Use ceil to at least show the full rect
|
|||
double scalex = (double) Rect.GetSize().x / size.x; |
|||
double bestscale = (double) Rect.GetSize().y / size.y; |
|||
|
|||
bestscale = std::max( bestscale, scalex ); |
|||
|
|||
GetScreen()->SetScalingFactor( bestscale ); |
|||
RedrawScreen( Rect.Centre(), true ); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) |
|||
{ |
|||
if( m_canvas == NULL ) |
|||
return; |
|||
|
|||
int id = event.GetId(); |
|||
bool zoom_at_cursor = false; |
|||
BASE_SCREEN* screen = GetScreen(); |
|||
wxPoint center = GetScrollCenterPosition(); |
|||
|
|||
if ( id == ID_KEY_ZOOM_IN ) |
|||
{ |
|||
id = GetCanvas()->GetEnableZoomNoCenter() ? |
|||
ID_OFFCENTER_ZOOM_IN : ID_POPUP_ZOOM_IN; |
|||
} |
|||
else if ( id == ID_KEY_ZOOM_OUT ) |
|||
{ |
|||
id = GetCanvas()->GetEnableZoomNoCenter() ? |
|||
ID_OFFCENTER_ZOOM_OUT : ID_POPUP_ZOOM_OUT; |
|||
} |
|||
|
|||
switch( id ) |
|||
{ |
|||
case ID_OFFCENTER_ZOOM_IN: |
|||
center = m_canvas->ToDeviceXY( GetCrossHairPosition() ); |
|||
|
|||
if( screen->SetPreviousZoom() ) |
|||
RedrawScreen2( center ); |
|||
break; |
|||
|
|||
case ID_POPUP_ZOOM_IN: |
|||
zoom_at_cursor = true; |
|||
center = GetCrossHairPosition(); |
|||
|
|||
// fall thru
|
|||
case ID_VIEWER_ZOOM_IN: |
|||
case ID_ZOOM_IN: |
|||
if( screen->SetPreviousZoom() ) |
|||
RedrawScreen( center, zoom_at_cursor ); |
|||
break; |
|||
|
|||
case ID_OFFCENTER_ZOOM_OUT: |
|||
center = m_canvas->ToDeviceXY( GetCrossHairPosition() ); |
|||
|
|||
if( screen->SetNextZoom() ) |
|||
RedrawScreen2( center ); |
|||
break; |
|||
|
|||
case ID_POPUP_ZOOM_OUT: |
|||
zoom_at_cursor = true; |
|||
center = GetCrossHairPosition(); |
|||
|
|||
// fall thru
|
|||
case ID_VIEWER_ZOOM_OUT: |
|||
case ID_ZOOM_OUT: |
|||
if( screen->SetNextZoom() ) |
|||
RedrawScreen( center, zoom_at_cursor ); |
|||
break; |
|||
|
|||
case ID_VIEWER_ZOOM_REDRAW: |
|||
case ID_POPUP_ZOOM_REDRAW: |
|||
case ID_ZOOM_REDRAW: |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case ID_POPUP_ZOOM_CENTER: |
|||
center = GetCrossHairPosition(); |
|||
RedrawScreen( center, true ); |
|||
break; |
|||
|
|||
case ID_POPUP_ZOOM_PAGE: |
|||
case ID_VIEWER_ZOOM_PAGE: |
|||
case ID_ZOOM_PAGE: |
|||
Zoom_Automatique( false ); |
|||
break; |
|||
|
|||
case ID_POPUP_ZOOM_SELECT: |
|||
break; |
|||
|
|||
case ID_POPUP_CANCEL: |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
break; |
|||
|
|||
default: |
|||
SetPresetZoom( id - ID_POPUP_ZOOM_LEVEL_START ); |
|||
} |
|||
|
|||
UpdateStatusBar(); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::SetNextZoom() |
|||
{ |
|||
GetScreen()->SetNextZoom(); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::SetPrevZoom() |
|||
{ |
|||
GetScreen()->SetPreviousZoom(); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::SetPresetZoom( int aIndex ) |
|||
{ |
|||
BASE_SCREEN* screen = GetScreen(); |
|||
|
|||
if( aIndex >= (int) screen->m_ZoomList.size() ) |
|||
{ |
|||
wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ), |
|||
__TFILE__, __LINE__, aIndex ); |
|||
return; |
|||
} |
|||
|
|||
if( m_zoomSelectBox ) |
|||
m_zoomSelectBox->SetSelection( aIndex ); |
|||
|
|||
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) ) |
|||
RedrawScreen( GetScrollCenterPosition(), true ); |
|||
|
|||
UpdateStatusBar(); |
|||
} |
|||
|
|||
|
|||
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) |
|||
{ |
|||
int maxZoomIds; |
|||
double zoom; |
|||
wxString msg; |
|||
BASE_SCREEN* screen = m_canvas->GetScreen(); |
|||
|
|||
msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER ); |
|||
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) ); |
|||
msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN ); |
|||
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) ); |
|||
msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT ); |
|||
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) ); |
|||
msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW ); |
|||
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) ); |
|||
msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO ); |
|||
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) ); |
|||
|
|||
|
|||
wxMenu* zoom_choice = new wxMenu; |
|||
AddMenuItem( MasterMenu, zoom_choice, |
|||
ID_POPUP_ZOOM_SELECT, _( "Zoom" ), |
|||
KiBitmap( zoom_selection_xpm ) ); |
|||
|
|||
zoom = screen->GetZoom(); |
|||
maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; |
|||
maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ? |
|||
maxZoomIds : screen->m_ZoomList.size(); |
|||
|
|||
// Populate zoom submenu.
|
|||
for( int i = 0; i < maxZoomIds; i++ ) |
|||
{ |
|||
msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] ); |
|||
|
|||
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, |
|||
wxEmptyString, wxITEM_CHECK ); |
|||
if( zoom == screen->m_ZoomList[i] ) |
|||
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true ); |
|||
} |
|||
|
|||
// Create grid submenu as required.
|
|||
if( screen->GetGridCount() ) |
|||
{ |
|||
wxMenu* gridMenu = new wxMenu; |
|||
AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, |
|||
_( "Grid" ), KiBitmap( grid_select_xpm ) ); |
|||
|
|||
wxArrayString gridsList; |
|||
int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); |
|||
|
|||
for( unsigned i = 0; i < gridsList.GetCount(); i++ ) |
|||
{ |
|||
GRID_TYPE& grid = screen->GetGrid( i ); |
|||
gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK ); |
|||
|
|||
if( (int)i == icurr ) |
|||
gridMenu->Check( grid.m_CmdId, true ); |
|||
} |
|||
} |
|||
|
|||
MasterMenu->AppendSeparator(); |
|||
AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) ); |
|||
} |
@ -0,0 +1,389 @@ |
|||
#ifndef __EDA_DRAW_PANEL_H |
|||
#define __EDA_DRAW_PANEL_H |
|||
|
|||
#include <wx/wx.h> |
|||
#include <base_struct.h> |
|||
#include <gr_basic.h> |
|||
#include <eda_rect.h> |
|||
|
|||
/** |
|||
* Mouse capture callback function prototype. |
|||
*/ |
|||
|
|||
class BASE_SCREEN; |
|||
|
|||
class EDA_DRAW_PANEL; |
|||
|
|||
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 |
|||
{ |
|||
protected: |
|||
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 |
|||
|
|||
wxPoint m_CursorClickPos; ///< Used for maintaining click position |
|||
wxTimer *m_ClickTimer; |
|||
|
|||
/// The drawing area used to redraw the screen which is usually the visible area |
|||
/// of the drawing in internal units. |
|||
EDA_RECT m_ClipBox; |
|||
|
|||
bool m_abortRequest; ///< Flag used to abort long commands. |
|||
|
|||
bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center |
|||
bool m_enableMousewheelPan; ///< True to enable mousewheel panning by default. |
|||
|
|||
bool m_enableAutoPan; ///< True to enable automatic panning. |
|||
|
|||
bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true. |
|||
|
|||
bool m_ignoreMouseEvents; ///< Ignore mouse events when true. |
|||
|
|||
/* 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. |
|||
*/ |
|||
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. |
|||
|
|||
bool m_enableBlockCommands; ///< True enables block commands. |
|||
|
|||
/** |
|||
* 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; |
|||
|
|||
/// True when drawing in mirror mode. Used by the draw arc function, because arcs |
|||
/// are oriented, and in mirror mode, orientations are reversed. |
|||
bool m_PrintIsMirrored; |
|||
|
|||
/// Mouse capture move callback function. |
|||
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback; |
|||
|
|||
/// Abort mouse capture callback function. |
|||
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback; |
|||
|
|||
/// useful to avoid false start block in certain cases |
|||
/// (like switch from a sheet to another sheet |
|||
/// >= 0 (or >= n) if a block can start |
|||
int m_canStartBlock; |
|||
|
|||
int m_doubleClickInterval; |
|||
|
|||
public: |
|||
|
|||
EDA_DRAW_PANEL(){}; |
|||
virtual ~EDA_DRAW_PANEL(){}; |
|||
|
|||
/** |
|||
* Function GetDisplayOptions |
|||
* A way to pass info to draw functions. |
|||
* this is just an accessor to the GetDisplayOptions() parent frame function. |
|||
*/ |
|||
virtual void* GetDisplayOptions() { printf("Unimplemented\n"); assert(false); return nullptr; }; |
|||
|
|||
virtual BASE_SCREEN* GetScreen() = 0; |
|||
|
|||
virtual EDA_DRAW_FRAME* GetParent() const = 0; |
|||
|
|||
//virtual void OnPaint( wxPaintEvent& event ); |
|||
|
|||
virtual 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; } |
|||
|
|||
bool GetEnableMousewheelPan() const { return m_enableMousewheelPan; } |
|||
|
|||
virtual void SetEnableMousewheelPan( bool aEnable ) { m_enableMousewheelPan = aEnable; }; |
|||
|
|||
bool GetEnableZoomNoCenter() const { return m_enableZoomNoCenter; } |
|||
|
|||
virtual void SetEnableZoomNoCenter( bool aEnable ) { m_enableZoomNoCenter = aEnable; }; |
|||
|
|||
bool GetEnableAutoPan() const { return m_enableAutoPan; } |
|||
|
|||
virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; }; |
|||
|
|||
void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; } |
|||
|
|||
void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; } |
|||
|
|||
void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; } |
|||
|
|||
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; } |
|||
|
|||
bool GetPrintMirrored() const { return m_PrintIsMirrored; } |
|||
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } |
|||
|
|||
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; } |
|||
|
|||
/** |
|||
* Function DrawBackGround |
|||
* @param DC = current Device Context |
|||
* Draws (if allowed) : |
|||
* the grid |
|||
* X and Y axis |
|||
* X and Y auxiliary axis |
|||
*/ |
|||
virtual void DrawBackGround( wxDC* DC ) { printf("Unimplemented\n"); }; |
|||
|
|||
/** |
|||
* Function DrawGrid |
|||
* 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. |
|||
*/ |
|||
virtual void DrawGrid( wxDC* aDC ) { printf("Unimplemented\n"); }; |
|||
|
|||
/** |
|||
* Function DrawAuxiliaryAxis |
|||
* Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates |
|||
* for gerber and excellon files |
|||
* @param aDC = current Device Context |
|||
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..) |
|||
*/ |
|||
virtual void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { printf("Unimplemented\n");}; |
|||
|
|||
/** |
|||
* Function DrawGridAxis |
|||
* Draw on auxiliary axis, used in Pcbnew to show grid origin, when |
|||
* 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 ..) |
|||
* @param aGridOrigin = the absolute coordinate of grid origin for snap. |
|||
*/ |
|||
virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("Unimplemented\n"); }; |
|||
|
|||
/** |
|||
* Function DeviceToLogical |
|||
* converts \a aRect from device to drawing (logical) coordinates. |
|||
* <p> |
|||
* \a aRect must be in scrolled device units. |
|||
* </p> |
|||
* @param aRect The rectangle to convert. |
|||
* @param aDC The device context used for the conversion. |
|||
* @return A rectangle converted to drawing units. |
|||
*/ |
|||
virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("Unimplemented\n");assert(false); return wxRect(); }; |
|||
|
|||
/* Mouse and keys events */ |
|||
|
|||
/** |
|||
* Function OnMouseWheel |
|||
* 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> |
|||
*/ |
|||
|
|||
virtual void EraseScreen( wxDC* DC ) { printf("Unimplemented\n"); };; |
|||
|
|||
virtual void SetZoom( double mode ) { printf("Unimplemented\n"); };; |
|||
virtual double GetZoom() { printf("Unimplemented\n"); return 1.0; };; |
|||
|
|||
//virtual void SetGrid( const wxRealPoint& size ) { printf("Unimplemented\n"); };; |
|||
//virtual wxRealPoint GetGrid() { printf("Unimplemented\n"); return wxRealPoint(1.0, 1.0); };; |
|||
|
|||
|
|||
/** |
|||
* 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 visible on the screen. |
|||
*/ |
|||
virtual bool IsPointOnDisplay( const wxPoint& aPosition ) { printf("Unimplemented\n"); return false; };; |
|||
|
|||
/** |
|||
* 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 |
|||
* 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. |
|||
* </p> |
|||
* @param aDC The device context use for drawing with the correct scale and |
|||
* offsets already configured. See DoPrepareDC(). |
|||
* @param aRect The clip rectangle in device units or NULL for the entire visible area |
|||
* of the screen. |
|||
*/ |
|||
virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("Unimplemented\n"); };; |
|||
|
|||
virtual void ReDraw( wxDC* aDC, bool aEraseBackground = true ) { printf("Unimplemented\n"); };; |
|||
|
|||
/** |
|||
* 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. |
|||
*/ |
|||
virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("Unimplemented\n"); };; |
|||
|
|||
/// @copydoc wxWindow::Refresh() |
|||
//virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ); |
|||
|
|||
/** |
|||
* Function GetScreenCenterLogicalPosition |
|||
* @return The current screen center position in logical (drawing) units. |
|||
*/ |
|||
virtual wxPoint GetScreenCenterLogicalPosition() { printf("Unimplemented\n"); return wxPoint(0, 0); };; |
|||
|
|||
/** |
|||
* Function MoveCursorToCrossHair |
|||
* warps the cursor to the current cross hair position. |
|||
*/ |
|||
virtual void MoveCursorToCrossHair() { printf("Unimplemented\n"); };; |
|||
|
|||
/** |
|||
* Function ToDeviceXY |
|||
* transforms logical to device coordinates |
|||
*/ |
|||
virtual wxPoint ToDeviceXY( const wxPoint& pos ) { printf("Unimplemented\n"); return wxPoint(0, 0); };; |
|||
|
|||
/** |
|||
* Function ToLogicalXY |
|||
* transforms device to logical coordinates |
|||
*/ |
|||
virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("Unimplemented\n"); return wxPoint(0, 0); };; |
|||
|
|||
/** |
|||
* Function MoveCursor |
|||
* moves the mouse pointer to \a aPosition in logical (drawing) units. |
|||
* @param aPosition The position in logical units to move the cursor. |
|||
*/ |
|||
virtual void MoveCursor( const wxPoint& aPosition ) { printf("Unimplemented\n"); };; |
|||
|
|||
/* Cursor functions */ |
|||
/** |
|||
* 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> |
|||
* @param aDC - the device context to draw the cursor |
|||
* @param aColor - the color to draw the cursor |
|||
*/ |
|||
virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("Unimplemented\n"); };; |
|||
|
|||
// Hide the cross hair. |
|||
virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("Unimplemented\n"); };; |
|||
|
|||
// Show the cross hair. |
|||
virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("Unimplemented\n"); };; |
|||
|
|||
/** |
|||
* Function SetMouseCapture |
|||
* sets the mouse capture and end mouse capture callbacks to \a aMouseCaptureCallback |
|||
* and \a aEndMouseCaptureCallback respectively. |
|||
*/ |
|||
virtual void SetMouseCapture( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, |
|||
END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback ) |
|||
{ |
|||
m_mouseCaptureCallback = aMouseCaptureCallback; |
|||
m_endMouseCaptureCallback = aEndMouseCaptureCallback; |
|||
} |
|||
|
|||
|
|||
virtual void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback ) |
|||
{ |
|||
m_mouseCaptureCallback = aMouseCaptureCallback; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 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. |
|||
* @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. |
|||
* @param aCallEndFunc Call the abort mouse capture callback if true. |
|||
*/ |
|||
virtual void EndMouseCapture( int aId = -1, int aCursorId = -1, |
|||
const wxString& aTitle = wxEmptyString, |
|||
bool aCallEndFunc = true ) { printf("Unimplemented\n"); assert(false); };; |
|||
|
|||
inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; } |
|||
|
|||
/** |
|||
* 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. |
|||
*/ |
|||
virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("Unimplemented\n"); assert(false); };; |
|||
|
|||
/** |
|||
* Function CallEndMouseCapture |
|||
* calls the end mouse capture callback. |
|||
* |
|||
* @param aDC A point to a wxDC object to perform any drawing upon. |
|||
*/ |
|||
virtual void CallEndMouseCapture( wxDC* aDC ) { printf("Unimplemented\n"); assert(false); };; |
|||
|
|||
/** |
|||
* Function SetCurrentCursor |
|||
* Set the current cursor shape for drawpanel |
|||
*/ |
|||
virtual void SetCurrentCursor( int aCursor ) {}; |
|||
virtual void SetCurrentCursor( const wxCursor& aCursor ) {}; |
|||
|
|||
/** |
|||
* Function GetDefaultCursor |
|||
* @return the default cursor shape |
|||
*/ |
|||
//fixme-gal |
|||
virtual int GetDefaultCursor() const = 0; |
|||
|
|||
virtual void SetDefaultCursor() {}; |
|||
|
|||
/** |
|||
* Function GetCurrentCursor |
|||
* @return the current cursor shape, depending on the current selected tool |
|||
*/ |
|||
virtual int GetCurrentCursor() const = 0; |
|||
|
|||
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {} |
|||
|
|||
virtual wxWindow* GetWindow() = 0; |
|||
}; |
|||
|
|||
#endif |
@ -0,0 +1,508 @@ |
|||
/* |
|||
* 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@gmail.com> |
|||
* Copyright (C) 1992-2018 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 |
|||
*/ |
|||
|
|||
/** |
|||
* @file class_drawpanel.h: |
|||
* @brief EDA_DRAW_PANEL class definition. |
|||
*/ |
|||
|
|||
#ifndef PANEL_WXSTRUCT_H |
|||
#define PANEL_WXSTRUCT_H |
|||
|
|||
#include <base_struct.h> |
|||
#include <gr_basic.h> |
|||
#include <eda_rect.h> |
|||
|
|||
|
|||
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: |
|||
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 |
|||
|
|||
wxPoint m_CursorClickPos; ///< Used for maintaining click position |
|||
wxTimer *m_ClickTimer; |
|||
|
|||
/// The drawing area used to redraw the screen which is usually the visible area |
|||
/// of the drawing in internal units. |
|||
EDA_RECT m_ClipBox; |
|||
|
|||
bool m_abortRequest; ///< Flag used to abort long commands. |
|||
|
|||
bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center |
|||
bool m_enableMousewheelPan; ///< True to enable mousewheel panning by default. |
|||
|
|||
bool m_enableAutoPan; ///< True to enable automatic panning. |
|||
|
|||
bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true. |
|||
|
|||
bool m_ignoreMouseEvents; ///< Ignore mouse events when true. |
|||
|
|||
/* 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. |
|||
*/ |
|||
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. |
|||
|
|||
bool m_enableBlockCommands; ///< True enables block commands. |
|||
|
|||
/** |
|||
* 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; |
|||
|
|||
/// True when drawing in mirror mode. Used by the draw arc function, because arcs |
|||
/// are oriented, and in mirror mode, orientations are reversed. |
|||
bool m_PrintIsMirrored; |
|||
|
|||
/// Mouse capture move callback function. |
|||
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback; |
|||
|
|||
/// Abort mouse capture callback function. |
|||
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback; |
|||
|
|||
/// useful to avoid false start block in certain cases |
|||
/// (like switch from a sheet to another sheet |
|||
/// >= 0 (or >= n) if a block can start |
|||
int m_canStartBlock; |
|||
|
|||
int m_doubleClickInterval; |
|||
|
|||
public: |
|||
|
|||
EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size ); |
|||
~EDA_DRAW_PANEL(); |
|||
|
|||
/** |
|||
* Function GetDisplayOptions |
|||
* A way to pass info to draw functions. |
|||
* this is just an accessor to the GetDisplayOptions() parent frame function. |
|||
*/ |
|||
void* GetDisplayOptions(); |
|||
|
|||
BASE_SCREEN* GetScreen(); |
|||
|
|||
EDA_DRAW_FRAME* GetParent() const; |
|||
|
|||
void OnPaint( wxPaintEvent& event ); |
|||
|
|||
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; } |
|||
|
|||
bool GetEnableMousewheelPan() const { return m_enableMousewheelPan; } |
|||
|
|||
void SetEnableMousewheelPan( bool aEnable ); |
|||
|
|||
bool GetEnableZoomNoCenter() const { return m_enableZoomNoCenter; } |
|||
|
|||
void SetEnableZoomNoCenter( bool aEnable ); |
|||
|
|||
bool GetEnableAutoPan() const { return m_enableAutoPan; } |
|||
|
|||
void SetEnableAutoPan( bool aEnable ); |
|||
|
|||
void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; } |
|||
|
|||
void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; } |
|||
|
|||
void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; } |
|||
|
|||
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; } |
|||
|
|||
bool GetPrintMirrored() const { return m_PrintIsMirrored; } |
|||
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } |
|||
|
|||
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; } |
|||
|
|||
/** |
|||
* Function DrawBackGround |
|||
* @param DC = current Device Context |
|||
* Draws (if allowed) : |
|||
* the grid |
|||
* X and Y axis |
|||
* X and Y auxiliary axis |
|||
*/ |
|||
void DrawBackGround( wxDC* DC ); |
|||
|
|||
/** |
|||
* Function DrawGrid |
|||
* 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. |
|||
*/ |
|||
void DrawGrid( wxDC* aDC ); |
|||
|
|||
/** |
|||
* Function DrawAuxiliaryAxis |
|||
* Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates |
|||
* for gerber and excellon files |
|||
* @param aDC = current Device Context |
|||
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..) |
|||
*/ |
|||
void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ); |
|||
|
|||
/** |
|||
* Function DrawGridAxis |
|||
* Draw on auxiliary axis, used in Pcbnew to show grid origin, when |
|||
* 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 ..) |
|||
* @param aGridOrigin = the absolute coordinate of grid origin for snap. |
|||
*/ |
|||
void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ); |
|||
|
|||
void OnEraseBackground( wxEraseEvent& event ) { } |
|||
|
|||
/** |
|||
* Function OnActivate |
|||
* handles window activation events. |
|||
* <p> |
|||
* The member m_canStartBlock is initialize to avoid a block start command on activation |
|||
* (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 ); |
|||
|
|||
/** |
|||
* Function OnTimer |
|||
* handle timer events |
|||
* <p> |
|||
* The class will start a timer when a mouse-up event is handled. If a |
|||
* double-click event is not handled inside of a specified interval, |
|||
* the timer event will fire, causing the single-click event to be handled. |
|||
* Otherwise, the system will process the double-click. |
|||
*/ |
|||
void OnTimer( wxTimerEvent& event ); |
|||
|
|||
/** |
|||
* Function DoPrepareDC |
|||
* sets up the device context \a aDC for drawing. |
|||
* <p> |
|||
* 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 |
|||
* 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. |
|||
*/ |
|||
virtual void DoPrepareDC( wxDC& aDC ) override; |
|||
|
|||
/** |
|||
* Function DeviceToLogical |
|||
* converts \a aRect from device to drawing (logical) coordinates. |
|||
* <p> |
|||
* \a aRect must be in scrolled device units. |
|||
* </p> |
|||
* @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 ); |
|||
|
|||
/* Mouse and keys events */ |
|||
|
|||
/** |
|||
* Function OnMouseWheel |
|||
* 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 ); |
|||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT ) |
|||
void OnMagnify( wxMouseEvent& event ); |
|||
#endif |
|||
void OnMouseEvent( wxMouseEvent& event ); |
|||
void OnMouseEntering( wxMouseEvent& aEvent ); |
|||
void OnMouseLeaving( wxMouseEvent& event ); |
|||
void OnKeyEvent( wxKeyEvent& event ); |
|||
void OnCharHook( wxKeyEvent& event ); |
|||
|
|||
void OnPan( wxCommandEvent& event ); |
|||
|
|||
void EraseScreen( wxDC* DC ); |
|||
void OnScrollWin( wxCommandEvent& event ); |
|||
void OnScroll( wxScrollWinEvent& event ); |
|||
|
|||
void SetZoom( double mode ); |
|||
double GetZoom(); |
|||
|
|||
void SetGrid( const wxRealPoint& size ); |
|||
wxRealPoint GetGrid(); |
|||
|
|||
/** |
|||
* 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 ); |
|||
|
|||
/** |
|||
* 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 visible on the screen. |
|||
*/ |
|||
bool IsPointOnDisplay( const wxPoint& aPosition ); |
|||
|
|||
/** |
|||
* 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 |
|||
* 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. |
|||
* </p> |
|||
* @param aDC The device context use for drawing with the correct scale and |
|||
* offsets already configured. See DoPrepareDC(). |
|||
* @param aRect The clip rectangle in device units or NULL for the entire visible area |
|||
* of the screen. |
|||
*/ |
|||
void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ); |
|||
|
|||
void ReDraw( wxDC* aDC, bool aEraseBackground = true ); |
|||
|
|||
/** |
|||
* 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. |
|||
*/ |
|||
void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ); |
|||
|
|||
/// @copydoc wxWindow::Refresh() |
|||
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) override; |
|||
|
|||
/** |
|||
* Function GetScreenCenterLogicalPosition |
|||
* @return The current screen center position in logical (drawing) units. |
|||
*/ |
|||
wxPoint GetScreenCenterLogicalPosition(); |
|||
|
|||
/** |
|||
* Function MoveCursorToCrossHair |
|||
* warps the cursor to the current cross hair position. |
|||
*/ |
|||
void MoveCursorToCrossHair(); |
|||
|
|||
/** |
|||
* Function ToDeviceXY |
|||
* transforms logical to device coordinates |
|||
*/ |
|||
wxPoint ToDeviceXY( const wxPoint& pos ); |
|||
|
|||
/** |
|||
* Function ToLogicalXY |
|||
* transforms device to logical coordinates |
|||
*/ |
|||
wxPoint ToLogicalXY( const wxPoint& pos ); |
|||
|
|||
/** |
|||
* Function MoveCursor |
|||
* moves the mouse pointer to \a aPosition in logical (drawing) units. |
|||
* @param aPosition The position in logical units to move the cursor. |
|||
*/ |
|||
void MoveCursor( const wxPoint& aPosition ); |
|||
|
|||
/* Cursor functions */ |
|||
/** |
|||
* 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> |
|||
* @param aDC - the device context to draw the cursor |
|||
* @param aColor - the color to draw the cursor |
|||
*/ |
|||
void DrawCrossHair( wxDC* aDC, COLOR4D aColor = COLOR4D::WHITE ); |
|||
|
|||
// Hide the cross hair. |
|||
void CrossHairOff( wxDC* DC ); |
|||
|
|||
// 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; |
|||
} |
|||
|
|||
|
|||
void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback ) |
|||
{ |
|||
m_mouseCaptureCallback = aMouseCaptureCallback; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 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. |
|||
* @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. |
|||
* @param aCallEndFunc Call the abort mouse capture callback if true. |
|||
*/ |
|||
void EndMouseCapture( int aId = -1, int aCursorId = -1, |
|||
const wxString& aTitle = wxEmptyString, |
|||
bool aCallEndFunc = true ); |
|||
|
|||
inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; } |
|||
|
|||
/** |
|||
* 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 ); |
|||
|
|||
/** |
|||
* Function SetCurrentCursor |
|||
* Set the current cursor shape for drawpanel |
|||
*/ |
|||
void SetCurrentCursor( int aCursor ) |
|||
{ |
|||
m_currentCursor = aCursor; |
|||
SetCursor( (wxStockCursor) m_currentCursor ); |
|||
} |
|||
|
|||
/** |
|||
* Function GetDefaultCursor |
|||
* @return the default cursor shape |
|||
*/ |
|||
int GetDefaultCursor() const { return m_defaultCursor; } |
|||
|
|||
/** |
|||
* Function GetCurrentCursor |
|||
* @return the current cursor shape, depending on the current selected tool |
|||
*/ |
|||
int GetCurrentCursor() const { return m_currentCursor; } |
|||
|
|||
|
|||
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 */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue