drawpanel.cpp change for wxWidgets 2.6 compatibility
This commit is contained in:
parent
b29de1ccbe
commit
aaa0acf707
|
@ -13,28 +13,28 @@
|
|||
#include "macros.h"
|
||||
#include "id.h"
|
||||
|
||||
// defines locaux
|
||||
// Local defines
|
||||
#define CURSOR_SIZE 12 // Cursor size in pixels
|
||||
|
||||
// table des evenements captes par un WinEDA_DrawPanel
|
||||
// Events used by WinEDA_DrawPanel
|
||||
BEGIN_EVENT_TABLE( WinEDA_DrawPanel, EDA_DRAW_PANEL )
|
||||
EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
|
||||
EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
|
||||
EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
|
||||
EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
|
||||
EVT_PAINT( WinEDA_DrawPanel::OnPaint )
|
||||
EVT_SIZE( WinEDA_DrawPanel::OnSize )
|
||||
EVT_ERASE_BACKGROUND( WinEDA_DrawPanel::OnEraseBackground )
|
||||
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
|
||||
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
|
||||
EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
|
||||
EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
|
||||
EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
|
||||
EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
|
||||
EVT_PAINT( WinEDA_DrawPanel::OnPaint )
|
||||
EVT_SIZE( WinEDA_DrawPanel::OnSize )
|
||||
EVT_ERASE_BACKGROUND( WinEDA_DrawPanel::OnEraseBackground )
|
||||
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
|
||||
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
|
||||
|
||||
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
|
||||
WinEDA_DrawPanel::Process_Popup_Zoom )
|
||||
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
|
||||
WinEDA_DrawPanel::Process_Popup_Zoom )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/***********************************************************/
|
||||
/* Fonctions de base de WinEDA_DrawPanel: l'ecran de trace */
|
||||
/***********************************************************/
|
||||
/************************************************************************/
|
||||
/* WinEDA_DrawPanel basic functions (WinEDA_DrawPanel is the main panel)*/
|
||||
/************************************************************************/
|
||||
|
||||
WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
|
||||
const wxPoint& pos, const wxSize& size ) :
|
||||
|
@ -90,9 +90,9 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
|
|||
GRSetDrawMode( DC, GR_XOR );
|
||||
if( g_CursorShape == 1 ) /* Trace d'un reticule */
|
||||
{
|
||||
int dx = m_ClipBox.GetWidth()* GetZoom();
|
||||
int dx = m_ClipBox.GetWidth() * GetZoom();
|
||||
|
||||
int dy = m_ClipBox.GetHeight()* GetZoom();
|
||||
int dy = m_ClipBox.GetHeight() * GetZoom();
|
||||
|
||||
GRLine( &m_ClipBox, DC, Cursor.x - dx, Cursor.y,
|
||||
Cursor.x + dx, Cursor.y, 0, color ); // axe Y
|
||||
|
@ -101,7 +101,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
|
|||
}
|
||||
else
|
||||
{
|
||||
int len = CURSOR_SIZE* GetZoom();
|
||||
int len = CURSOR_SIZE * GetZoom();
|
||||
|
||||
GRLine( &m_ClipBox, DC, Cursor.x - len, Cursor.y,
|
||||
Cursor.x + len, Cursor.y, 0, color );
|
||||
|
@ -185,8 +185,10 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
|
|||
wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos )
|
||||
/*********************************************************************/
|
||||
|
||||
/* retourne la position absolue en pixels de la position rel_pos,
|
||||
* donn<EFBFBD>e en position relative scroll<EFBFBD>e (en pixel)
|
||||
/** Function CalcAbsolutePosition
|
||||
* @return absolute position in pixels, considering the scroll amount
|
||||
* @param rel_pos = relative position (screen position) in pixel
|
||||
* ( relative position = position in the panel draw area on screen )
|
||||
*/
|
||||
{
|
||||
wxPoint pos;
|
||||
|
@ -196,11 +198,11 @@ wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos )
|
|||
#else
|
||||
int ii, jj;
|
||||
|
||||
GetViewStart( &pos.x, &pos.y );
|
||||
GetViewStart( &pos.x, &pos.y ); // pos is the origin in scroll units
|
||||
GetScrollPixelsPerUnit( &ii, &jj );
|
||||
|
||||
pos.x *= ii;
|
||||
pos.y *= jj;
|
||||
pos.y *= jj; // pos is the origin in pixel units
|
||||
|
||||
pos.x += rel_pos.x;
|
||||
pos.y += rel_pos.y;
|
||||
|
@ -213,8 +215,9 @@ wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos )
|
|||
wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
|
||||
/**********************************************************************/
|
||||
|
||||
/* Retourne la position en unites utilisateur du pointeur souris
|
||||
* ScreenPos = position pointeur en coord absolue ecran
|
||||
/** CursorRealPosition (used to calculate the cursor position in internal units)
|
||||
* @return position (in internal units)
|
||||
* @param ScreenPos = absolute position in pixels
|
||||
*/
|
||||
{
|
||||
wxPoint curpos;
|
||||
|
@ -229,9 +232,10 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
|
|||
bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
|
||||
/********************************************************/
|
||||
|
||||
/* retourne TRUE si le point de coord physique ref_pos
|
||||
* est visible sur l'ecran, c'est a dire:
|
||||
* si ref_pos est sur la partie du schema ou pcb affichee a l'ecran
|
||||
/** Funcion IsPointOnDisplay
|
||||
* @param ref_pos is the position to test in pixels, relative to the panel.
|
||||
* @return TRUE if ref_pos is a point currently visible on screen
|
||||
* FALSE if ref_pos is out of screen
|
||||
*/
|
||||
{
|
||||
wxPoint pos;
|
||||
|
@ -246,7 +250,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
|
|||
display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN );
|
||||
|
||||
// Conversion en coord physiques
|
||||
pos = CalcAbsolutePosition( display_rect.GetPosition() );
|
||||
pos = CalcAbsolutePosition( display_rect.GetPosition() );
|
||||
|
||||
pos.x *= GetZoom();
|
||||
pos.y *= GetZoom();
|
||||
|
@ -268,8 +272,9 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
|
|||
wxPoint WinEDA_DrawPanel::CursorScreenPosition()
|
||||
/********************************************************/
|
||||
|
||||
/* retourne la position sur l'ecran,en pixels, du curseur
|
||||
* Orgine = coord absolue 0,0;
|
||||
/** CursorScreenPosition
|
||||
* @return relative position in pixels of du curseur
|
||||
* ( relative position = position in the panel draw area on screen )
|
||||
*/
|
||||
{
|
||||
wxPoint curpos = GetScreen()->m_Curseur;
|
||||
|
@ -287,16 +292,20 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
|
|||
/*********************************************************/
|
||||
wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition()
|
||||
/*********************************************************/
|
||||
|
||||
/** Function GetScreenCenterRealPosition()
|
||||
* @return position (in internal units) of the current area centre showed on screen
|
||||
*/
|
||||
{
|
||||
wxSize size;
|
||||
wxPoint realpos;
|
||||
|
||||
size = GetClientSize();
|
||||
size = GetClientSize();
|
||||
|
||||
size.x /= 2;
|
||||
size.y /= 2;
|
||||
|
||||
realpos = CalcAbsolutePosition( wxPoint( size.x, size.y ) );
|
||||
realpos = CalcAbsolutePosition( wxPoint( size.x, size.y ) );
|
||||
|
||||
realpos.x *= GetZoom();
|
||||
realpos.y *= GetZoom();
|
||||
|
@ -345,6 +354,13 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
|
|||
/********************************************************/
|
||||
void WinEDA_DrawPanel::OnActivate( wxActivateEvent& event )
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* Called on window activation.
|
||||
* init the member m_CanStartBlock to avoid a block start command
|
||||
* on activation (because a left mouse buton can be pressed and no block command wanted
|
||||
* This happens when enter on a hierarchycat sheet on double click
|
||||
*/
|
||||
{
|
||||
m_CanStartBlock = -1; // Block Command can't start
|
||||
event.Skip();
|
||||
|
@ -415,6 +431,10 @@ void WinEDA_DrawPanel::OnSize( wxSizeEvent& event )
|
|||
/******************************************/
|
||||
void WinEDA_DrawPanel::SetBoundaryBox()
|
||||
/******************************************/
|
||||
|
||||
/** Function SetBoundaryBox()
|
||||
* set the m_ClipBox member to the current displayed rectangle dimensions
|
||||
*/
|
||||
{
|
||||
BASE_SCREEN* Screen = GetScreen();;
|
||||
|
||||
|
@ -486,13 +506,13 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
|
|||
PaintClipBox.y += org.y;
|
||||
|
||||
#ifdef WX_ZOOM
|
||||
m_ClipBox.m_Pos.x = PaintClipBox.x* GetZoom();
|
||||
m_ClipBox.m_Pos.x = PaintClipBox.x * GetZoom();
|
||||
|
||||
m_ClipBox.m_Pos.y = PaintClipBox.y* GetZoom();
|
||||
m_ClipBox.m_Pos.y = PaintClipBox.y * GetZoom();
|
||||
|
||||
m_ClipBox.m_Size.x = PaintClipBox.m_Size.x* GetZoom();
|
||||
m_ClipBox.m_Size.x = PaintClipBox.m_Size.x * GetZoom();
|
||||
|
||||
m_ClipBox.m_Size.y = PaintClipBox.m_Size.y* GetZoom();
|
||||
m_ClipBox.m_Size.y = PaintClipBox.m_Size.y * GetZoom();
|
||||
|
||||
PaintClipBox = m_ClipBox;
|
||||
#else
|
||||
|
@ -562,9 +582,12 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
|
|||
void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
||||
/***********************************************/
|
||||
|
||||
/* Trace les axes X et Y et la grille
|
||||
* La grille n'est affichee que si elle peut etre facilement visible
|
||||
* La grille passe toujours par le centre de l'ecran
|
||||
/** Function DrawBackGround
|
||||
* @param DC = current Device Context
|
||||
* Draws X , Y axis
|
||||
* draws the grid
|
||||
* - the grid is drawn only if the zoom level allows a good visibility
|
||||
* - the grid is always centered on the screen centre
|
||||
*/
|
||||
{
|
||||
int Color = BLUE;
|
||||
|
@ -581,7 +604,9 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
|||
|
||||
GRSetDrawMode( DC, GR_COPY );
|
||||
|
||||
/* le pas d'affichage doit etre assez grand pour avoir une grille visible */
|
||||
/* The grid must be visible. this is possible only is grid value
|
||||
* and zoom value are sufficient
|
||||
*/
|
||||
drawgrid = m_Parent->m_Draw_Grid;
|
||||
|
||||
pas_grille_affichee = screen->GetGrid();
|
||||
|
@ -593,7 +618,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
|||
ii *= 2;
|
||||
}
|
||||
if( ii < 5 )
|
||||
drawgrid = FALSE; // grille trop petite
|
||||
drawgrid = FALSE; // The gris is small
|
||||
|
||||
ii = pas_grille_affichee.y / zoom;
|
||||
if( ii < 5 )
|
||||
|
@ -602,7 +627,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
|||
ii *= 2;
|
||||
}
|
||||
if( ii < 5 )
|
||||
drawgrid = FALSE; // grille trop petite
|
||||
drawgrid = FALSE; // The gris is small
|
||||
|
||||
GetViewStart( &org.x, &org.y );
|
||||
GetScrollPixelsPerUnit( &ii, &jj );
|
||||
|
@ -618,13 +643,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
|||
org.x += screen->m_DrawOrg.x;
|
||||
org.y += screen->m_DrawOrg.y;
|
||||
|
||||
size = GetClientSize();
|
||||
size = GetClientSize();
|
||||
|
||||
size.x *= zoom;
|
||||
size.y *= zoom;
|
||||
|
||||
pasx = screen->m_UserGrid.x * m_Parent->m_InternalUnits;
|
||||
pasy = screen->m_UserGrid.y * m_Parent->m_InternalUnits;
|
||||
pasx = screen->m_UserGrid.x * m_Parent->m_InternalUnits;
|
||||
pasy = screen->m_UserGrid.y * m_Parent->m_InternalUnits;
|
||||
|
||||
if( screen->m_UserGridUnit != INCHES )
|
||||
{
|
||||
|
@ -681,9 +706,14 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
|||
/********************************************************************/
|
||||
void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode )
|
||||
/********************************************************************/
|
||||
|
||||
/** m_Draw_Auxiliary_Axis
|
||||
* Draw the Auxiliary Axis, used in pcbnew which as origin coordinates
|
||||
* for gerber and excellon files
|
||||
*/
|
||||
{
|
||||
if( m_Parent->m_Auxiliary_Axis_Position.x == 0
|
||||
&& m_Parent->m_Auxiliary_Axis_Position.y == 0 )
|
||||
&& m_Parent->m_Auxiliary_Axis_Position.y == 0 )
|
||||
return;
|
||||
|
||||
int Color = DARKRED;
|
||||
|
@ -719,8 +749,8 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
|
|||
pos.x = event.GetX();
|
||||
pos.y = event.GetY();
|
||||
|
||||
if ( ! m_Parent->OnRightClick( pos, &MasterMenu ) )
|
||||
return false;
|
||||
if( !m_Parent->OnRightClick( pos, &MasterMenu ) )
|
||||
return false;
|
||||
|
||||
AddMenuZoom( &MasterMenu );
|
||||
|
||||
|
@ -729,7 +759,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
|
|||
MouseToCursorSchema();
|
||||
m_IgnoreMouseEvents = FALSE;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -763,14 +793,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
int localrealbutt = 0, localbutt = 0, localkey = 0;
|
||||
BASE_SCREEN* screen = GetScreen();
|
||||
static WinEDA_DrawPanel* LastPanel;
|
||||
static bool IgnoreNextLeftButtonRelease = false;
|
||||
static bool IgnoreNextLeftButtonRelease = false;
|
||||
|
||||
if( event.Leaving() || event.Entering() )
|
||||
{
|
||||
m_CanStartBlock = -1;
|
||||
}
|
||||
|
||||
if( ManageCurseur == NULL ) // Pas de commande en cours
|
||||
if( ManageCurseur == NULL ) // No command in progress
|
||||
m_AutoPAN_Request = FALSE;
|
||||
|
||||
if( m_Parent->m_FrameIsActive )
|
||||
|
@ -862,17 +892,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
|
||||
g_MouseOldButtons = localrealbutt;
|
||||
|
||||
// Appel des fonctions li<6C>es au Double Click ou au Click
|
||||
// Calling Double Click and Click functions :
|
||||
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
|
||||
{
|
||||
{
|
||||
m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );
|
||||
IgnoreNextLeftButtonRelease = true;
|
||||
}
|
||||
|
||||
IgnoreNextLeftButtonRelease = true;
|
||||
}
|
||||
else if( event.LeftUp() )
|
||||
{
|
||||
if( screen->BlockLocate.m_State==STATE_NO_BLOCK && !IgnoreNextLeftButtonRelease )
|
||||
m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
|
||||
m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
|
||||
|
||||
IgnoreNextLeftButtonRelease = false;
|
||||
}
|
||||
|
@ -885,9 +914,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Appel de la fonction generale de gestion des mouvements souris
|
||||
* et commandes clavier */
|
||||
/* Calling the general function on mouse changes (and pseudo key commands) */
|
||||
m_Parent->GeneralControle( &DC, screen->m_MousePositionInPixels );
|
||||
|
||||
|
||||
|
@ -922,7 +949,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
{
|
||||
m_AutoPAN_Request = FALSE;
|
||||
m_Parent->HandleBlockPlace( &DC );
|
||||
IgnoreNextLeftButtonRelease = true;
|
||||
IgnoreNextLeftButtonRelease = true;
|
||||
}
|
||||
}
|
||||
else if( (m_CanStartBlock >= 0 )
|
||||
|
@ -941,7 +968,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
{
|
||||
// error
|
||||
m_Parent->DisplayToolMsg(
|
||||
wxT( "WinEDA_DrawPanel::OnMouseEvent() Block Error" ) );
|
||||
wxT( "WinEDA_DrawPanel::OnMouseEvent() Block Error" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -953,10 +980,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
|
||||
if( event.ButtonUp( 1 ) || event.ButtonUp( 2 ) )
|
||||
{
|
||||
/* Relachement du bouton: fin de delimitation de block.
|
||||
* La commande peut etre terminee (DELETE) ou continuer par le placement
|
||||
* du block ainsi delimite (MOVE, COPY).
|
||||
* Cependant bloc est annule si sa taille est trop petite
|
||||
/* Release the mouse button: end of block.
|
||||
* The command can finish (DELETE) or have a next command
|
||||
* (MOVE, COPY).
|
||||
* However the block command is cancelled if the block size is small
|
||||
*/
|
||||
bool BlockIsSmall =
|
||||
( ABS( screen->BlockLocate.GetWidth() / GetZoom() ) < 3)
|
||||
|
@ -985,8 +1012,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
// Arret de block sur un double click ( qui peut provoquer un move block
|
||||
// si on d<>place la souris dans ce double click
|
||||
// End of block command on a double click
|
||||
// To avoid an unwanted block move command if the move is moved while double click
|
||||
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
|
||||
{
|
||||
if( screen->BlockLocate.m_Command != BLOCK_IDLE )
|
||||
|
@ -1066,19 +1093,24 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
#if wxCHECK_VERSION(2, 8, 0)
|
||||
/* some key commands use the mouse position: refresh it */
|
||||
wxPoint mouse_pos = wxGetMousePosition(); // Get the mouse position on screen
|
||||
wxPoint win_pos = GetScreenPosition(); // get the draw area (panel)position on screen
|
||||
mouse_pos -= win_pos; // mouse_pos = is the mouse position relative to the panel
|
||||
/* some key commands use the mouse position: refresh it */
|
||||
#if wxCHECK_VERSION( 2, 8, 0 )
|
||||
wxPoint mouse_pos = wxGetMousePosition(); // Get the mouse position on screen
|
||||
wxPoint win_pos = GetScreenPosition(); // get the draw area (panel)position on screen
|
||||
mouse_pos -= win_pos; // mouse_pos = is the mouse position relative to the panel
|
||||
|
||||
/* Compute absolute m_MousePosition in pixel units (i.e. considering the current scrool) : */
|
||||
Screen->m_MousePositionInPixels = CalcAbsolutePosition( mouse_pos );
|
||||
/* Compute absolute m_MousePosition in pixel units (i.e. considering the current scrool) : */
|
||||
Screen->m_MousePositionInPixels = CalcAbsolutePosition( mouse_pos );
|
||||
|
||||
/* Compute absolute m_MousePosition in user units: */
|
||||
Screen->m_MousePosition = CursorRealPosition( Screen->m_MousePositionInPixels );
|
||||
#else
|
||||
/* Compute absolute m_MousePosition in user units: */
|
||||
Screen->m_MousePosition = CursorRealPosition( Screen->m_MousePositionInPixels );
|
||||
|
||||
#else
|
||||
|
||||
/* if wxGetMousePosition() does not exist,
|
||||
* m_Cursor should be ok, use it to calculate the cursor position on screen
|
||||
*/
|
||||
Screen->m_MousePositionInPixels = CursorScreenPosition();
|
||||
#endif
|
||||
|
||||
m_Parent->GeneralControle( &DC, Screen->m_MousePositionInPixels );
|
||||
|
|
Loading…
Reference in New Issue