Commit 6a26a7f9 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Use logical cursor position and other minor changes.

* Remove unused member variable m_SizeVisu from base screen object.
* Move nearest grid position code into base screen object.
* Add get cursor position method to base screen object.
* Add position parameter to OnHotKey method in base draw frame and all
  derived objects.
* Pass logical position on left mouse button click and double click
  events instead of device position.
* Pass logical position to on right mouse button click instead of device
  position.
* Use logical event position parameter for locating items in EESchema
  instead of the stored position.
* Remove unused position parameter when displaying component edit dialog
  in EESchema.
* Comment out debugging macro in eeschema/template_field_names.cpp that was
  preventing debug builds using wxWidgets 2.8.x.
parent 0093f4f6
...@@ -390,6 +390,39 @@ int BASE_SCREEN::GetGridId() ...@@ -390,6 +390,39 @@ int BASE_SCREEN::GetGridId()
} }
wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize )
{
wxPoint pt;
wxRealPoint gridSize;
if( aGridSize )
gridSize = *aGridSize;
else
gridSize = GetGridSize();
wxPoint gridOrigin = m_GridOrigin;
double offset = fmod( gridOrigin.x, gridSize.x );
int x = wxRound( (aPosition.x - offset) / gridSize.x );
pt.x = wxRound( x * gridSize.x + offset );
offset = fmod( gridOrigin.y, gridSize.y );
int y = wxRound( (aPosition.y - offset) / gridSize.y );
pt.y = wxRound ( y * gridSize.y + offset );
return pt;
}
wxPoint BASE_SCREEN::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize )
{
if( aOnGrid )
return GetNearestGridPosition( m_Curseur, aGridSize );
return m_Curseur;
}
/* free the undo and the redo lists /* free the undo and the redo lists
*/ */
void BASE_SCREEN::ClearUndoRedoList() void BASE_SCREEN::ClearUndoRedoList()
......
...@@ -176,7 +176,7 @@ void EDA_DRAW_FRAME::ReCreateMenuBar() ...@@ -176,7 +176,7 @@ void EDA_DRAW_FRAME::ReCreateMenuBar()
// Virtual function // Virtual function
void EDA_DRAW_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) void EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{ {
} }
......
...@@ -778,14 +778,17 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event ) ...@@ -778,14 +778,17 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event )
wxPoint pos; wxPoint pos;
wxMenu MasterMenu; wxMenu MasterMenu;
pos = event.GetPosition(); INSTALL_UNBUFFERED_DC( dc, this );
pos = event.GetLogicalPosition( dc );
if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) if( !m_Parent->OnRightClick( pos, &MasterMenu ) )
return false; return false;
m_Parent->AddMenuZoomAndGrid( &MasterMenu ); m_Parent->AddMenuZoomAndGrid( &MasterMenu );
m_IgnoreMouseEvents = TRUE; pos = event.GetPosition();
m_IgnoreMouseEvents = true;
PopupMenu( &MasterMenu, pos ); PopupMenu( &MasterMenu, pos );
MouseToCursorSchema(); MouseToCursorSchema();
m_IgnoreMouseEvents = false; m_IgnoreMouseEvents = false;
...@@ -940,14 +943,14 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) ...@@ -940,14 +943,14 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
localrealbutt |= localbutt; /* compensation default wxGTK */ localrealbutt |= localbutt; /* compensation default wxGTK */
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );
/* Compute the cursor position in screen (device) units. */ /* Compute the cursor position in screen (device) units. */
wxPoint pos = CalcUnscrolledPosition( event.GetPosition() ); wxPoint pos = CalcUnscrolledPosition( event.GetPosition() );
/* Compute the cursor position in drawing (logical) units. */ /* Compute the cursor position in drawing (logical) units. */
screen->m_MousePosition = CursorRealPosition( pos ); screen->m_MousePosition = event.GetLogicalPosition( DC );
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );
int kbstat = 0; int kbstat = 0;
...@@ -967,7 +970,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) ...@@ -967,7 +970,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// Calling Double Click and Click functions : // Calling Double Click and Click functions :
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{ {
m_Parent->OnLeftDClick( &DC, pos ); m_Parent->OnLeftDClick( &DC, screen->m_MousePosition );
// inhibit a response to the mouse left button release, // inhibit a response to the mouse left button release,
// because we have a double click, and we do not want a new // because we have a double click, and we do not want a new
...@@ -979,7 +982,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) ...@@ -979,7 +982,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// A block command is in progress: a left up is the end of block // A block command is in progress: a left up is the end of block
// or this is the end of a double click, already seen // or this is the end of a double click, already seen
if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK && !s_IgnoreNextLeftButtonRelease ) if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK && !s_IgnoreNextLeftButtonRelease )
m_Parent->OnLeftClick( &DC, pos ); m_Parent->OnLeftClick( &DC, screen->m_MousePosition );
s_IgnoreNextLeftButtonRelease = false; s_IgnoreNextLeftButtonRelease = false;
} }
...@@ -1217,7 +1220,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) ...@@ -1217,7 +1220,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
} }
} }
/* Some key commands use the current mouse position: refresh it */ // Some key commands use the current mouse position: refresh it.
pos = wxGetMousePosition() - GetScreenPosition(); pos = wxGetMousePosition() - GetScreenPosition();
// Compute the cursor position in drawing units. Also known as logical units to wxDC. // Compute the cursor position in drawing units. Also known as logical units to wxDC.
......
...@@ -51,21 +51,9 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer ) ...@@ -51,21 +51,9 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
*/ */
void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize ) void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
{ {
wxRealPoint grid_size; wxCHECK_RET( aCoord != NULL, wxT( "Cannot pull NULL coordinate pointer on grid." ) );
if( aGridSize ) *aCoord = GetBaseScreen()->GetNearestGridPosition( *aCoord, aGridSize );
grid_size = *aGridSize;
else
grid_size = GetBaseScreen()->GetGridSize();
const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin();
double offset = fmod( grid_origin.x, grid_size.x );
int tmp = wxRound( (aCoord->x - offset) / grid_size.x );
aCoord->x = wxRound( tmp * grid_size.x + offset );
offset = fmod( grid_origin.y, grid_size.y );
tmp = wxRound( (aCoord->y - offset) / grid_size.y );
aCoord->y = wxRound ( tmp * grid_size.y + offset );
} }
......
This diff is collapsed.
...@@ -27,51 +27,46 @@ int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow; ...@@ -27,51 +27,46 @@ int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
wxSize DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = wxDefaultSize; wxSize DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = wxDefaultSize;
void InstallCmpeditFrame( SCH_EDIT_FRAME* parent, wxPoint& pos, SCH_COMPONENT* aComponent ) void InstallCmpeditFrame( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent )
{ {
if( aComponent == NULL ) // Null component not accepted if( aComponent == NULL ) // Null component not accepted
return; return;
parent->DrawPanel->m_IgnoreMouseEvents = TRUE; aParent->DrawPanel->m_IgnoreMouseEvents = TRUE;
if( aComponent->Type() != SCH_COMPONENT_T ) if( aComponent->Type() != SCH_COMPONENT_T )
{ {
DisplayError( parent, DisplayError( aParent,
wxT( "InstallCmpeditFrame() error: This item is not a component" ) ); wxT( "InstallCmpeditFrame() error: This item is not a component" ) );
return;
} }
else
{
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dialog =
new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent );
dialog->InitBuffers( aComponent ); DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dialog( aParent );
wxSize sizeNow = dialog->GetSize(); dialog.InitBuffers( aComponent );
// this relies on wxDefaultSize being -1,-1, be careful here. wxSize sizeNow = dialog.GetSize();
if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth()
|| sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() )
{
dialog->SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize );
}
// make sure the chipnameTextCtrl is wide enough to hold any // this relies on wxDefaultSize being -1,-1, be careful here.
// unusually long chip names: if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth()
EnsureTextCtrlWidth( dialog->chipnameTextCtrl ); || sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() )
{
dialog.SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize );
}
dialog->ShowModal(); // make sure the chipnameTextCtrl is wide enough to hold any
// unusually long chip names:
EnsureTextCtrlWidth( dialog.chipnameTextCtrl );
// Some of the field values are long and are not always fully visible dialog.ShowModal();
// because the window comes up too narrow.
// Remember user's manual window resizing efforts here so it comes up
// wide enough next time.
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = dialog->GetSize();
dialog->Destroy(); // Some of the field values are long and are not always fully visible because the
} // window comes up too narrow. Remember user's manual window resizing efforts here
// so it comes up wide enough next time.
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = dialog.GetSize();
parent->DrawPanel->MouseToCursorSchema(); aParent->DrawPanel->MouseToCursorSchema();
parent->DrawPanel->m_IgnoreMouseEvents = false; aParent->DrawPanel->m_IgnoreMouseEvents = false;
} }
......
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
*/ */
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP
{ {
friend void InstallCmpeditFrame( SCH_EDIT_FRAME* parent, friend void InstallCmpeditFrame( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aComponent );
wxPoint& pos,
SCH_COMPONENT* aComponent );
SCH_EDIT_FRAME* m_Parent; SCH_EDIT_FRAME* m_Parent;
SCH_COMPONENT* m_Cmp; SCH_COMPONENT* m_Cmp;
......
This diff is collapsed.
...@@ -100,9 +100,10 @@ public: ...@@ -100,9 +100,10 @@ public:
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); } SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct );
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
void LoadSettings(); void LoadSettings();
void SaveSettings(); void SaveSettings();
......
This diff is collapsed.
...@@ -48,7 +48,7 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_ ...@@ -48,7 +48,7 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_
* *
* This menu is then added to the list of zoom commands. * This menu is then added to the list of zoom commands.
*/ */
bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{ {
SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem(); SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem();
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
...@@ -66,7 +66,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) ...@@ -66,7 +66,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
// Try to locate items at cursor position. // Try to locate items at cursor position.
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
DrawStruct = SchematicGeneralLocateAndDisplay( false ); DrawStruct = LocateAndShowItem( aPosition, false );
if( DrawStruct && (DrawStruct->Type() == SCH_SHEET_T) ) if( DrawStruct && (DrawStruct->Type() == SCH_SHEET_T) )
{ {
......
...@@ -40,7 +40,7 @@ void IncrementLabelMember( wxString& name ); ...@@ -40,7 +40,7 @@ void IncrementLabelMember( wxString& name );
/****************/ /****************/
/* EDITPART.CPP */ /* EDITPART.CPP */
/****************/ /****************/
void InstallCmpeditFrame( SCH_EDIT_FRAME* parent, wxPoint& pos, SCH_COMPONENT* m_Cmp ); void InstallCmpeditFrame( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent );
void SnapLibItemPoint( int OrigX, void SnapLibItemPoint( int OrigX,
int OrigY, int OrigY,
......
...@@ -484,7 +484,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -484,7 +484,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
break; break;
InstallCmpeditFrame( this, pos, (SCH_COMPONENT*) screen->GetCurItem() ); InstallCmpeditFrame( this, (SCH_COMPONENT*) screen->GetCurItem() );
break; break;
case ID_POPUP_SCH_MIROR_X_CMP: case ID_POPUP_SCH_MIROR_X_CMP:
......
...@@ -153,8 +153,8 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName ) ...@@ -153,8 +153,8 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
{ {
if( m_Fields[i].m_Name == aFieldName.m_Name ) if( m_Fields[i].m_Name == aFieldName.m_Name )
{ {
D(printf("inserting template fieldname:'%s' at %d\n", // D(printf("inserting template fieldname:'%s' at %d\n",
aFieldName.m_Name.utf8_str(), i );) // aFieldName.m_Name.utf8_str(), i );)
m_Fields[i] = aFieldName; m_Fields[i] = aFieldName;
return i; // return the container index return i; // return the container index
......
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); } SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
void LoadSettings(); void LoadSettings();
void SaveSettings(); void SaveSettings();
......
...@@ -13,7 +13,7 @@ GERBER_DRAW_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay() ...@@ -13,7 +13,7 @@ GERBER_DRAW_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
} }
void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, wxPoint aPosition ) void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
wxPoint oldpos; wxPoint oldpos;
......
...@@ -370,7 +370,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, ...@@ -370,7 +370,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
bool Read_GERBER_File( const wxString& GERBER_FullFileName, bool Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName ); const wxString& D_Code_FullFileName );
void GeneralControle( wxDC* DC, wxPoint Mouse ); void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
/** /**
......
...@@ -57,48 +57,45 @@ class BASE_SCREEN : public EDA_ITEM ...@@ -57,48 +57,45 @@ class BASE_SCREEN : public EDA_ITEM
GRIDS m_grids; ///< List of valid grid sizes. GRIDS m_grids; ///< List of valid grid sizes.
EDA_ITEM* m_drawList; ///< Object list for the screen. EDA_ITEM* m_drawList; ///< Object list for the screen.
wxString m_fileName; ///< File used to load the screen. wxString m_fileName; ///< File used to load the screen.
char m_FlagRefreshReq; ///< Indicates that the screen should be redrawn.
char m_FlagModified; ///< Indicates current drawing has been modified.
char m_FlagSave; ///< Indicates automatic file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object
GRID_TYPE m_Grid; ///< Current grid selection.
public: public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */
wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid)
* in user units. * in user units. (coordinates from last reset position)*/
* (coordinates from last reset position)*/
// Scrollbars management: // Scrollbars management:
int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */ int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */
int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */ int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */
wxSize m_ScrollbarNumber; /* Current virtual draw area size in scroll wxSize m_ScrollbarNumber; /* Current virtual draw area size in scroll units.
* units. * m_ScrollbarNumber * m_ScrollPixelsPerUnit =
* m_ScrollbarNumber * m_ScrollPixelsPerUnit = virtual draw area size in pixels * virtual draw area size in pixels */
*/ wxPoint m_ScrollbarPos; /* Current scroll bar position in scroll units. */
wxPoint m_ScrollbarPos; /* Current scroll bar position in scroll
* units. */ wxPoint m_StartVisu; /* Coordinates in drawing units of the current
* view position (upper left corner of device)
wxPoint m_StartVisu; /* Coordinates in drawing units of the current */
* view position (upper left corner of device)
*/ bool m_Center; /* Center on screen. If TRUE (0.0) is centered
* on screen coordinates can be < 0 and
wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu * > 0 except for schematics.
* Utile pour recadrer les affichages lors de la * FALSE: when coordinates can only be >= 0
* navigation dans la hierarchie */ * Schematic */
bool m_Center; /* Center on screen. If TRUE (0.0) is centered
* on screen coordinates can be < 0 and
* > 0 except for schematics.
* FALSE: when coordinates can only be >= 0
* Schematic */
bool m_FirstRedraw; bool m_FirstRedraw;
// Undo/redo list of commands // Undo/redo list of commands
UNDO_REDO_CONTAINER m_UndoList; /* Objects list for the undo UNDO_REDO_CONTAINER m_UndoList; /* Objects list for the undo command (old data) */
* command (old data) */ UNDO_REDO_CONTAINER m_RedoList; /* Objects list for the redo command (old data) */
UNDO_REDO_CONTAINER m_RedoList; /* Objects list for the redo unsigned m_UndoRedoCountMax; // undo/Redo command Max depth
* command (old data) */
unsigned m_UndoRedoCountMax; // undo/Redo command Max depth
/* block control */ /* block control */
BLOCK_SELECTOR m_BlockLocate; /* Block description for block BLOCK_SELECTOR m_BlockLocate; /* Block description for block commands */
* commands */
/* Page description */ /* Page description */
Ki_PageDescr* m_CurrentSheetDesc; Ki_PageDescr* m_CurrentSheetDesc;
...@@ -114,23 +111,12 @@ public: ...@@ -114,23 +111,12 @@ public:
wxString m_Commentaire3; wxString m_Commentaire3;
wxString m_Commentaire4; wxString m_Commentaire4;
private:
char m_FlagRefreshReq; /* indicates that the screen should
* be redrawn */
char m_FlagModified; // indicates current drawing has
// been modified
char m_FlagSave; // Perform automatica file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object
GRID_TYPE m_Grid; ///< Current grid selection.
/* Grid and zoom values. */ /* Grid and zoom values. */
public:
wxPoint m_GridOrigin; wxPoint m_GridOrigin;
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */ wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
int m_Zoom; /* Current zoom coefficient. */ int m_Zoom; /* Current zoom coefficient. */
int m_ZoomScalar; /* Allow zooming to non-integer increments. int m_ZoomScalar; /* Allow zooming to non-integer increments. */
*/
bool m_IsPrinting; bool m_IsPrinting;
public: public:
...@@ -369,6 +355,25 @@ public: ...@@ -369,6 +355,25 @@ public:
return useMouse ? m_MousePosition : m_Curseur; return useMouse ? m_MousePosition : m_Curseur;
} }
/**
* Function GetCursorPosition
* returns the current cursor position in logical (drawing) units.
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
* @return The current cursor position.
*/
wxPoint GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize = NULL );
/**
* Function GetNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
* @param aPosition The position to check.
* @param aGridSize The grid size to locate to if provided. If NULL then the current
* grid size is used.
* @return The nearst grid position.
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL );
/** /**
* Function GetClass * Function GetClass
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
void OnColorConfig( wxCommandEvent& aEvent ); void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
PARAM_CFG_ARRAY& GetProjectFileParameters( void ); PARAM_CFG_ARRAY& GetProjectFileParameters( void );
void SaveProjectFile( wxWindow* displayframe, bool askoverwrite = true ); void SaveProjectFile( wxWindow* displayframe, bool askoverwrite = true );
...@@ -172,7 +172,8 @@ public: ...@@ -172,7 +172,8 @@ public:
void ReCreateVToolbar(); void ReCreateVToolbar();
void ReCreateOptToolbar(); void ReCreateOptToolbar();
void ReCreateMenuBar(); void ReCreateMenuBar();
void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ); void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL );
SCH_FIELD* GetCurrentField() { return m_CurrentField; } SCH_FIELD* GetCurrentField() { return m_CurrentField; }
...@@ -200,15 +201,14 @@ public: ...@@ -200,15 +201,14 @@ public:
void InstallConfigFrame( wxCommandEvent& event ); void InstallConfigFrame( wxCommandEvent& event );
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* aDC, const wxPoint& aPosition );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* aDC, const wxPoint& aPosition );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu );
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
int BestZoom(); int BestZoom();
SCH_ITEM* SchematicGeneralLocateAndDisplay( bool IncludePin = TRUE ); SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin = true );
SCH_ITEM* SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, SCH_ITEM* LocateItem( const wxPoint& aPosition, bool aIncludePin );
bool IncludePin );
/** /**
* Function FillFootprintFieldForAllInstancesofComponent * Function FillFootprintFieldForAllInstancesofComponent
......
...@@ -267,11 +267,12 @@ public: ...@@ -267,11 +267,12 @@ public:
* Function OnHotKey. * Function OnHotKey.
* ** Commands are case insensitive ** * ** Commands are case insensitive **
* Some commands are relatives to the item under the mouse cursor * Some commands are relatives to the item under the mouse cursor
* @param aDC = current device context * @param aDC = current device context
* @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys) * @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor * @param aPosition The cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
*/ */
void OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem ); void OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
/** /**
* Function OnHotkeyDeleteItem * Function OnHotkeyDeleteItem
...@@ -366,7 +367,7 @@ public: ...@@ -366,7 +367,7 @@ public:
void ReFillLayerWidget(); void ReFillLayerWidget();
void Show3D_Frame( wxCommandEvent& event ); void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse ); void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
/** /**
* Function ShowDesignRulesEditor * Function ShowDesignRulesEditor
......
...@@ -269,7 +269,8 @@ public: ...@@ -269,7 +269,8 @@ public:
void OnMenuOpen( wxMenuEvent& event ); void OnMenuOpen( wxMenuEvent& event );
void OnMouseEvent( wxMouseEvent& event ); void OnMouseEvent( wxMouseEvent& event );
virtual void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ); virtual void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL );
/** /**
* Function AddMenuZoomAndGrid (virtual) * Function AddMenuZoomAndGrid (virtual)
...@@ -373,9 +374,9 @@ public: ...@@ -373,9 +374,9 @@ public:
* called on every mouse and key event. * called on every mouse and key event.
*</p> *</p>
* @param aDC A device context. * @param aDC A device context.
* @param aPosition The cursor position in logical (drawing) units. * @param aPosition The current cursor position in logical (drawing) units.
*/ */
virtual void GeneralControle( wxDC* aDC, wxPoint aPosition ) { /* dummy */ } virtual void GeneralControle( wxDC* aDC, const wxPoint& aPosition ) { /* dummy */ }
virtual void OnSize( wxSizeEvent& event ); virtual void OnSize( wxSizeEvent& event );
void OnEraseBackground( wxEraseEvent& SizeEvent ); void OnEraseBackground( wxEraseEvent& SizeEvent );
......
...@@ -226,7 +226,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -226,7 +226,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
} }
void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, wxPoint aPosition ) void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
wxPoint oldpos; wxPoint oldpos;
...@@ -370,7 +370,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -370,7 +370,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
if( hotkey ) if( hotkey )
{ {
OnHotKey( aDC, hotkey, NULL ); OnHotKey( aDC, hotkey, aPosition );
} }
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
......
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
/** /**
* Function OnHotKey. * Function OnHotKey.
* ** Commands are case insensitive ** * ** Commands are case insensitive **
* Some commands are relatives to the item under the mouse cursor * Some commands are relatives to the item under the mouse cursor
* @param aDC = current device context * @param aDC = current device context
* @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys) * @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor * @param aPosition The current cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
*/ */
void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem ) void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
EDA_ITEM* aItem )
{ {
if( aHotkeyCode == 0 ) if( aHotkeyCode == 0 )
return; return;
......
...@@ -20,14 +20,13 @@ ...@@ -20,14 +20,13 @@
*/ */
/*****************************************************************************************/
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStruct )
{
/*****************************************************************************************/
/* Hot keys. Some commands are relative to the item under the mouse cursor /* Hot keys. Some commands are relative to the item under the mouse cursor
* Commands are case insensitive * Commands are case insensitive
*/ */
if( hotkey == 0 ) void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem )
{
if( aHotKey == 0 )
return; return;
bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE; bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE;
...@@ -37,13 +36,13 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStru ...@@ -37,13 +36,13 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey, EDA_ITEM* DrawStru
cmd.SetEventObject( this ); cmd.SetEventObject( this );
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (aHotKey >= 'a') && (aHotKey <= 'z') )
hotkey += 'A' - 'a'; aHotKey += 'A' - 'a';
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, common_Hotkey_List ); Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, module_edit_Hotkey_List ); HK_Descr = GetDescriptorFromHotkey( aHotKey, module_edit_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
return; return;
......
...@@ -40,13 +40,14 @@ public: ...@@ -40,13 +40,14 @@ public:
void ReCreateMenuBar(); void ReCreateMenuBar();
void ToolOnRightClick( wxCommandEvent& event ); void ToolOnRightClick( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event );
void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ); void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL );
bool OnHotkeyEditItem( int aIdCommand ); bool OnHotkeyEditItem( int aIdCommand );
bool OnHotkeyDeleteItem( int aIdCommand ); bool OnHotkeyDeleteItem( int aIdCommand );
bool OnHotkeyMoveItem( int aIdCommand ); bool OnHotkeyMoveItem( int aIdCommand );
bool OnHotkeyRotateItem( int aIdCommand ); bool OnHotkeyRotateItem( int aIdCommand );
void Show3D_Frame( wxCommandEvent& event ); void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse ); void GeneralControle( wxDC* aDC, const wxPoint& aPosition );
/** /**
* Function LoadModuleFromBoard * Function LoadModuleFromBoard
......
...@@ -455,7 +455,7 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event ) ...@@ -455,7 +455,7 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
} }
void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, wxPoint aPosition ) void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
wxPoint oldpos; wxPoint oldpos;
...@@ -529,7 +529,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -529,7 +529,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
if( hotkey ) if( hotkey )
{ {
OnHotKey( aDC, hotkey, NULL ); OnHotKey( aDC, hotkey, aPosition );
} }
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment