Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
aaa0acf7
Commit
aaa0acf7
authored
Dec 09, 2007
by
CHARRAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drawpanel.cpp change for wxWidgets 2.6 compatibility
parent
b29de1cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
129 deletions
+161
-129
drawpanel.cpp
share/drawpanel.cpp
+161
-129
No files found.
share/drawpanel.cpp
View file @
aaa0acf7
...
...
@@ -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_MENU_RANGE
(
ID_POPUP_ZOOM_START_RANGE
,
ID_POPUP_ZOOM_END_RANGE
,
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
)
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�e en position relative scroll�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
;
...
...
@@ -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,6 +292,10 @@ 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
;
...
...
@@ -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
);
...
...
@@ -681,6 +706,11 @@ 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
)
...
...
@@ -719,7 +749,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
pos
.
x
=
event
.
GetX
();
pos
.
y
=
event
.
GetY
();
if
(
!
m_Parent
->
OnRightClick
(
pos
,
&
MasterMenu
)
)
if
(
!
m_Parent
->
OnRightClick
(
pos
,
&
MasterMenu
)
)
return
false
;
AddMenuZoom
(
&
MasterMenu
);
...
...
@@ -770,7 +800,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
m_CanStartBlock
=
-
1
;
}
if
(
ManageCurseur
==
NULL
)
//
Pas de commande en cour
s
if
(
ManageCurseur
==
NULL
)
//
No command in progres
s
m_AutoPAN_Request
=
FALSE
;
if
(
m_Parent
->
m_FrameIsActive
)
...
...
@@ -862,13 +892,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
g_MouseOldButtons
=
localrealbutt
;
//
Appel des fonctions li�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
;
}
else
if
(
event
.
LeftUp
()
)
{
if
(
screen
->
BlockLocate
.
m_State
==
STATE_NO_BLOCK
&&
!
IgnoreNextLeftButtonRelease
)
...
...
@@ -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
);
...
...
@@ -953,10 +980,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if
(
event
.
ButtonUp
(
1
)
||
event
.
ButtonUp
(
2
)
)
{
/* Rel
achement 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
/* Rel
ease 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 blo
ck
//
si on d�place la souris dans c
e double click
//
End of block command on a double cli
ck
//
To avoid an unwanted block move command if the move is moved whil
e double click
if
(
localbutt
==
(
int
)
(
GR_M_LEFT_DOWN
|
GR_M_DCLICK
)
)
{
if
(
screen
->
BlockLocate
.
m_Command
!=
BLOCK_IDLE
)
...
...
@@ -1066,8 +1093,8 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
}
}
#if wxCHECK_VERSION(2, 8, 0)
/* 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
...
...
@@ -1077,8 +1104,13 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
/* Compute absolute m_MousePosition in user units: */
Screen
->
m_MousePosition
=
CursorRealPosition
(
Screen
->
m_MousePositionInPixels
);
#else
#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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment