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 );
} }
......
...@@ -23,55 +23,60 @@ ...@@ -23,55 +23,60 @@
/** /**
* Function SchematicGeneralLocateAndDisplay * Function LocateAndShowItem
* Overlaid function * search the schematic at \a aPosition in logical (drawing) units for any item.
* Find the schematic item at cursor position * <p>
* the priority order is: * The search is first performed at \a aPosition which may be off grid. If no item is
* - marker * found at \a aPosition, the search is repeated for the nearest grid position to \a
* - noconnect * aPosition.
* - junction
* - wire/bus/entry
* - label
* - pin
* - component
* @return an EDA_ITEM pointer on the item or NULL if no item found
* @param IncludePin = true to search for pins, false to ignore them
* *
* For some items, characteristics are displayed on the screen. * The search order is as follows:
* <ul>
* <li>Marker</li>
* <li>No Connect</li>
* <li>Junction</li>
* <li>Wire, bus, or entry</li>
* <li>Label</li>
* <li>Pin</li>
* <li>Component</li>
* </ul></p>
* @param aPosition The wxPoint on the schematic to search.
* @param aIncludePin = true to search for pins, false to ignore them
* @return A SCH_ITEM pointer on the item or NULL if no item found
*/ */
SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin ) SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* item;
wxString msg; wxString msg;
wxPoint mouse_position = GetScreen()->m_MousePosition;
LIB_PIN* Pin = NULL; LIB_PIN* Pin = NULL;
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* LibItem = NULL;
wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition );
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin ); item = LocateItem( aPosition, aIncludePin );
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) ) if( !item && aPosition != gridPosition )
{ item = LocateItem( gridPosition, aIncludePin );
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
}
if( !DrawStruct ) if( !item )
return NULL; return NULL;
/* Cross probing to pcbnew if a pin or a component is found */ /* Cross probing to pcbnew if a pin or a component is found */
switch( DrawStruct->Type() ) switch( item->Type() )
{ {
case SCH_FIELD_T: case SCH_FIELD_T:
case LIB_FIELD_T: case LIB_FIELD_T:
LibItem = (SCH_COMPONENT*) DrawStruct->GetParent(); LibItem = (SCH_COMPONENT*) item->GetParent();
SendMessageToPCBNEW( DrawStruct, LibItem ); SendMessageToPCBNEW( item, LibItem );
break; break;
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem ); Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem );
if( Pin ) if( Pin )
break; // Priority is probing a pin first break; // Priority is probing a pin first
LibItem = (SCH_COMPONENT*) DrawStruct;
SendMessageToPCBNEW( DrawStruct, LibItem ); LibItem = (SCH_COMPONENT*) item;
SendMessageToPCBNEW( item, LibItem );
break; break;
default: default:
...@@ -79,85 +84,71 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin ) ...@@ -79,85 +84,71 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
break; break;
case LIB_PIN_T: case LIB_PIN_T:
Pin = (LIB_PIN*) DrawStruct; Pin = (LIB_PIN*) item;
break; break;
} }
if( Pin ) if( Pin )
{ {
/* Force display pin information (the previous display could be a // Force display pin information (the previous display could be a component info)
* component info) */
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
if( LibItem ) if( LibItem )
AppendMsgPanel( LibItem->GetRef( GetSheet() ), AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN ); LibItem->GetField( VALUE )->m_Text, DARKCYAN );
// Cross probing:2 - pin found, and send a locate pin command to // Cross probing:2 - pin found, and send a locate pin command to pcbnew (highlight net)
// pcbnew (highlight net)
SendMessageToPCBNEW( Pin, LibItem ); SendMessageToPCBNEW( Pin, LibItem );
} }
return DrawStruct;
return item;
} }
/** /**
* Function SchematicGeneralLocateAndDisplay * Function LocateItem
* Overlaid function * searches for an item at \a aPosition.
* Find the schematic item at a given position * @param aPosition The wxPoint location where to search.
* the priority order is: * @param aIncludePin True to search for pins, false to ignore them.
* - marker * @return The SCH_ITEM pointer of the item or NULL if no item found.
* - noconnect
* - junction
* - wire/bus/entry
* - label
* - pin
* - component
* @return an EDA_ITEM pointer on the item or NULL if no item found
* @param refpoint = the wxPoint location where to search
* @param IncludePin = true to search for pins, false to ignore them
*
* For some items, characteristics are displayed on the screen.
*/ */
SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin )
bool IncludePin )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* item;
LIB_PIN* Pin; LIB_PIN* Pin;
SCH_COMPONENT* LibItem; SCH_COMPONENT* LibItem;
wxString Text; wxString Text;
wxString msg; wxString msg;
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKER_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), MARKER_T );
if( DrawStruct ) if( item )
{ {
DrawStruct->DisplayInfo( this ); item->DisplayInfo( this );
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NO_CONNECT_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_CONNECT_T );
if( DrawStruct ) if( item )
{ {
ClearMsgPanel(); ClearMsgPanel();
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTION_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), JUNCTION_T );
if( DrawStruct ) if( item )
{ {
ClearMsgPanel(); ClearMsgPanel();
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), WIRE_T | BUS_T | BUS_ENTRY_T );
WIRE_T | BUS_T | BUS_ENTRY_T );
if( DrawStruct ) // We have found a wire: Search for a connected pin at the same location if( item ) // We have found a wire: Search for a connected pin at the same location
{ {
Pin = GetScreen()->GetPin( refpoint, &LibItem ); Pin = GetScreen()->GetPin( aPosition, &LibItem );
if( Pin ) if( Pin )
{ {
...@@ -170,30 +161,30 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo ...@@ -170,30 +161,30 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
else else
ClearMsgPanel(); ClearMsgPanel();
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), FIELD_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), FIELD_T );
if( DrawStruct ) if( item )
{ {
SCH_FIELD* Field = (SCH_FIELD*) DrawStruct; SCH_FIELD* Field = (SCH_FIELD*) item;
LibItem = (SCH_COMPONENT*) Field->GetParent(); LibItem = (SCH_COMPONENT*) Field->GetParent();
LibItem->DisplayInfo( this ); LibItem->DisplayInfo( this );
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LABEL_T | TEXT_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), LABEL_T | TEXT_T );
if( DrawStruct ) if( item )
{ {
ClearMsgPanel(); ClearMsgPanel();
return DrawStruct; return item;
} }
/* search for a pin */ /* search for a pin */
Pin = GetScreen()->GetPin( refpoint, &LibItem ); Pin = GetScreen()->GetPin( aPosition, &LibItem );
if( Pin ) if( Pin )
{ {
...@@ -202,41 +193,39 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo ...@@ -202,41 +193,39 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
if( LibItem ) if( LibItem )
AppendMsgPanel( LibItem->GetRef( GetSheet() ), AppendMsgPanel( LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text, DARKCYAN ); LibItem->GetField( VALUE )->m_Text, DARKCYAN );
if( IncludePin ) if( aIncludePin )
return LibItem; return LibItem;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), COMPONENT_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), COMPONENT_T );
if( DrawStruct ) if( item )
{ {
DrawStruct = LocateSmallestComponent( GetScreen() ); item = LocateSmallestComponent( GetScreen() );
LibItem = (SCH_COMPONENT*) DrawStruct; LibItem = (SCH_COMPONENT*) item;
LibItem->DisplayInfo( this ); LibItem->DisplayInfo( this );
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SHEET_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), SHEET_T );
if( DrawStruct ) if( item )
{ {
( (SCH_SHEET*) DrawStruct )->DisplayInfo( this ); ( (SCH_SHEET*) item )->DisplayInfo( this );
return DrawStruct; return item;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NO_FILTER_T ); item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_FILTER_T );
if( DrawStruct ) if( item )
{ return item;
return DrawStruct;
}
ClearMsgPanel(); ClearMsgPanel();
return NULL; return NULL;
} }
void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
...@@ -308,9 +297,9 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -308,9 +297,9 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
if( hotkey ) if( hotkey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( aDC, hotkey, screen->GetCurItem() ); OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, hotkey, NULL ); OnHotKey( aDC, hotkey, aPosition, NULL );
} }
UpdateStatusBar(); /* Display cursor coordinates info */ UpdateStatusBar(); /* Display cursor coordinates info */
...@@ -318,7 +307,7 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -318,7 +307,7 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
} }
void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
...@@ -390,16 +379,16 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -390,16 +379,16 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
if( hotkey ) if( hotkey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( aDC, hotkey, screen->GetCurItem() ); OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, hotkey, NULL ); OnHotKey( aDC, hotkey, aPosition, NULL );
} }
UpdateStatusBar(); UpdateStatusBar();
} }
void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
...@@ -471,9 +460,9 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition ) ...@@ -471,9 +460,9 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
if( hotkey ) if( hotkey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( aDC, hotkey, screen->GetCurItem() ); OnHotKey( aDC, hotkey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, hotkey, NULL ); OnHotKey( aDC, hotkey, aPosition, NULL );
} }
UpdateStatusBar(); UpdateStatusBar();
......
...@@ -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 );
wxSize sizeNow = dialog.GetSize();
// this relies on wxDefaultSize being -1,-1, be careful here. // this relies on wxDefaultSize being -1,-1, be careful here.
if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth() if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth()
|| sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() ) || sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() )
{ {
dialog->SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize ); dialog.SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize );
} }
// make sure the chipnameTextCtrl is wide enough to hold any // make sure the chipnameTextCtrl is wide enough to hold any
// unusually long chip names: // unusually long chip names:
EnsureTextCtrlWidth( dialog->chipnameTextCtrl ); EnsureTextCtrlWidth( dialog.chipnameTextCtrl );
dialog->ShowModal();
// 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;
......
...@@ -257,7 +257,7 @@ struct Ki_HotkeyInfoSectionDescriptor s_Viewlib_Hokeys_Descr[] = ...@@ -257,7 +257,7 @@ struct Ki_HotkeyInfoSectionDescriptor s_Viewlib_Hokeys_Descr[] =
* 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
*/ */
void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{ {
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
...@@ -271,20 +271,20 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -271,20 +271,20 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
bool notBusy = (!itemInEdit) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK); bool notBusy = (!itemInEdit) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK);
bool RefreshToolBar = FALSE; bool RefreshToolBar = FALSE;
if( hotkey == 0 ) if( aHotKey == 0 )
return; return;
wxPoint MousePos = GetScreen()->m_MousePosition;
/* Convert lower to upper case (the usual toupper function has problem /* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */ * with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (aHotKey >= 'a') && (aHotKey <= 'z') )
hotkey += 'A' - 'a'; aHotKey += 'A' - 'a';
// Search command from key : // Search command from key :
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List ); Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotKey, s_Common_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, s_Schematic_Hotkey_List ); HK_Descr = GetDescriptorFromHotkey( aHotKey, s_Schematic_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
return; return;
...@@ -337,22 +337,22 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -337,22 +337,22 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break; break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp( BLOCK_DRAG, DC ); HandleBlockEndByPopUp( BLOCK_DRAG, aDC );
break; break;
case HK_DELETE: case HK_DELETE:
if( notBusy) if( notBusy)
{ {
RefreshToolBar = LocateAndDeleteItem( this, DC ); RefreshToolBar = LocateAndDeleteItem( this, aDC );
OnModify(); OnModify();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds( DrawPanel, DC ); GetScreen()->TestDanglingEnds( DrawPanel, aDC );
} }
break; break;
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( notBusy && m_itemToRepeat && ( m_itemToRepeat->m_Flags == 0 ) ) if( notBusy && m_itemToRepeat && ( m_itemToRepeat->m_Flags == 0 ) )
RepeatDrawItem( DC ); RepeatDrawItem( aDC );
break; break;
case HK_FIND_ITEM: case HK_FIND_ITEM:
...@@ -392,7 +392,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -392,7 +392,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_COMPONENT_BUTT; // switch to m_ID_current_state = ID_COMPONENT_BUTT;
if( m_ID_current_state != ID_COMPONENT_BUTT ) if( m_ID_current_state != ID_COMPONENT_BUTT )
SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _( "Add Component" ) ); SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _( "Add Component" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -402,7 +403,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -402,7 +403,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_PLACE_POWER_BUTT; // switch to m_ID_current_state = ID_PLACE_POWER_BUTT;
if( m_ID_current_state != ID_PLACE_POWER_BUTT ) if( m_ID_current_state != ID_PLACE_POWER_BUTT )
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) ); SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -412,7 +414,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -412,7 +414,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_LABEL_BUTT; // switch to m_ID_current_state = ID_LABEL_BUTT;
if( m_ID_current_state != ID_LABEL_BUTT ) if( m_ID_current_state != ID_LABEL_BUTT )
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add Label" ) ); SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add Label" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -422,7 +425,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -422,7 +425,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_HIERLABEL_BUTT; // switch to m_ID_current_state = ID_HIERLABEL_BUTT;
if( m_ID_current_state != ID_HIERLABEL_BUTT ) if( m_ID_current_state != ID_HIERLABEL_BUTT )
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Hierarchical Label" ) ); SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Hierarchical Label" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -432,7 +436,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -432,7 +436,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_GLABEL_BUTT; // switch to m_ID_current_state = ID_GLABEL_BUTT;
if( m_ID_current_state != ID_GLABEL_BUTT ) if( m_ID_current_state != ID_GLABEL_BUTT )
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Global Label" ) ); SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Global Label" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -442,7 +447,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -442,7 +447,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_JUNCTION_BUTT; // switch to m_ID_current_state = ID_JUNCTION_BUTT;
if( m_ID_current_state != ID_JUNCTION_BUTT ) if( m_ID_current_state != ID_JUNCTION_BUTT )
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add Junction" ) ); SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add Junction" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -452,7 +458,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -452,7 +458,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_WIRETOBUS_ENTRY_BUTT; // switch to m_ID_current_state = ID_WIRETOBUS_ENTRY_BUTT;
if( m_ID_current_state != ID_WIRETOBUS_ENTRY_BUTT ) if( m_ID_current_state != ID_WIRETOBUS_ENTRY_BUTT )
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Wire to Bus entry" ) ); SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Wire to Bus entry" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -462,7 +469,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -462,7 +469,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_BUSTOBUS_ENTRY_BUTT; // switch to m_ID_current_state = ID_BUSTOBUS_ENTRY_BUTT;
if( m_ID_current_state != ID_BUSTOBUS_ENTRY_BUTT ) if( m_ID_current_state != ID_BUSTOBUS_ENTRY_BUTT )
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Bus to Bus entry" ) ); SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Bus to Bus entry" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -472,7 +480,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -472,7 +480,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_SHEET_SYMBOL_BUTT; // switch to m_ID_current_state = ID_SHEET_SYMBOL_BUTT;
if( m_ID_current_state != ID_SHEET_SYMBOL_BUTT ) if( m_ID_current_state != ID_SHEET_SYMBOL_BUTT )
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add Sheet" ) ); SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add Sheet" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -482,7 +491,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -482,7 +491,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_TEXT_COMMENT_BUTT; // switch to m_ID_current_state = ID_TEXT_COMMENT_BUTT;
if( m_ID_current_state != ID_TEXT_COMMENT_BUTT ) if( m_ID_current_state != ID_TEXT_COMMENT_BUTT )
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Text" ) ); SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Text" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -492,7 +502,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -492,7 +502,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_LINE_COMMENT_BUTT; // switch to m_ID_current_state = ID_LINE_COMMENT_BUTT;
if( m_ID_current_state != ID_LINE_COMMENT_BUTT ) if( m_ID_current_state != ID_LINE_COMMENT_BUTT )
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Lines" ) ); SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Lines" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
...@@ -503,22 +514,25 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -503,22 +514,25 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_WIRE_BUTT; // switch to m_ID_current_state = ID_WIRE_BUTT;
if( m_ID_current_state != ID_BUS_BUTT ) if( m_ID_current_state != ID_BUS_BUTT )
SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add Bus" ) ); SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add Bus" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
break; break;
} }
if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_BUS_BUTT ) )
if( aItem && aItem->IsNew() && ( m_ID_current_state == ID_BUS_BUTT ) )
{ {
if( DrawStruct->Type() == SCH_LINE_T ) if( aItem->Type() == SCH_LINE_T )
{ {
SCH_LINE* segment = (SCH_LINE*) DrawStruct; SCH_LINE* segment = (SCH_LINE*) aItem;
if( segment->GetLayer() != LAYER_BUS ) if( segment->GetLayer() != LAYER_BUS )
break; break;
// Bus in progress: // Bus in progress:
OnLeftClick( DC, MousePos ); OnLeftClick( aDC, aPosition );
} }
} }
break; break;
case HK_BEGIN_WIRE: case HK_BEGIN_WIRE:
...@@ -528,18 +542,22 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -528,18 +542,22 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
// switch to m_ID_current_state = ID_WIRE_BUTT; // switch to m_ID_current_state = ID_WIRE_BUTT;
if( m_ID_current_state != ID_WIRE_BUTT ) if( m_ID_current_state != ID_WIRE_BUTT )
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) ); SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
break; break;
} }
if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_WIRE_BUTT ) )
if( aItem && aItem->IsNew() && ( m_ID_current_state == ID_WIRE_BUTT ) )
{ {
if( DrawStruct->Type() == SCH_LINE_T ) if( aItem->Type() == SCH_LINE_T )
{ {
SCH_LINE* segment = (SCH_LINE*) DrawStruct; SCH_LINE* segment = (SCH_LINE*) aItem;
if( segment->GetLayer() != LAYER_WIRE ) if( segment->GetLayer() != LAYER_WIRE )
break; break;
// Wire in progress: // Wire in progress:
OnLeftClick( DC, MousePos ); OnLeftClick( aDC, aPosition );
} }
} }
break; break;
...@@ -549,34 +567,36 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -549,34 +567,36 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
{ {
if( m_ID_current_state != ID_NOCONN_BUTT ) if( m_ID_current_state != ID_NOCONN_BUTT )
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add \"NoNonnect\" Flags" ) ); SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add \"NoNonnect\" Flags" ) );
OnLeftClick( DC, MousePos );
OnLeftClick( aDC, aPosition );
} }
break; break;
case HK_ROTATE: // Component or other schematic item rotation case HK_ROTATE: // Component or other schematic item rotation
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK)//allows bloc operation on hotkey if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK)//allows bloc operation on hotkey
{ {
HandleBlockEndByPopUp(BLOCK_ROTATE, DC ); HandleBlockEndByPopUp(BLOCK_ROTATE, aDC );
break; break;
} }
if( DrawStruct == NULL )
if( aItem == NULL )
{ {
// Find the schematic object to rotate under the cursor // Find the schematic object to rotate under the cursor
DrawStruct = SchematicGeneralLocateAndDisplay( false ); aItem = LocateAndShowItem( aPosition, false );
if( DrawStruct == NULL ) if( aItem == NULL )
break; break;
if( DrawStruct->Type() == SCH_COMPONENT_T ) if( aItem->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() ); aItem = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL ) if( aItem == NULL )
break; break;
} }
if( DrawStruct ) if( aItem )
{ {
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct ); GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
// Create the events for rotating a component or other schematic item // Create the events for rotating a component or other schematic item
wxCommandEvent eventRotateComponent( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventRotateComponent( wxEVT_COMMAND_TOOL_CLICKED,
...@@ -586,11 +606,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -586,11 +606,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
wxCommandEvent eventRotateField( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventRotateField( wxEVT_COMMAND_TOOL_CLICKED,
ID_POPUP_SCH_ROTATE_FIELD ); ID_POPUP_SCH_ROTATE_FIELD );
switch( DrawStruct->Type() ) switch( aItem->Type() )
{ {
case SCH_SHEET_T: //TODO allow sheet rotate on hotkey case SCH_SHEET_T: //TODO allow sheet rotate on hotkey
//wxPostEvent( this, eventRotateSheet ); //wxPostEvent( this, eventRotateSheet );
break; break;
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
wxPostEvent( this, eventRotateComponent ); wxPostEvent( this, eventRotateComponent );
break; break;
...@@ -615,54 +636,63 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -615,54 +636,63 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK ) if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )
{ {
HandleBlockEndByPopUp(BLOCK_MIRROR_Y, DC ); HandleBlockEndByPopUp(BLOCK_MIRROR_Y, aDC );
break; break;
} }
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem == NULL )
if( DrawStruct ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem )
{ {
if( DrawStruct->m_Flags == 0 ) if( aItem->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) aItem, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIRROR_Y );
CmpRotationMiroir( (SCH_COMPONENT*) aItem, aDC, CMP_MIRROR_Y );
} }
break; break;
case HK_MIRROR_X_COMPONENT: // Mirror X (Component) case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK ) //allows bloc operation on hotkey if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK ) //allows bloc operation on hotkey
{ {
HandleBlockEndByPopUp(BLOCK_MIRROR_X, DC ); HandleBlockEndByPopUp(BLOCK_MIRROR_X, aDC );
break; break;
} }
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem == NULL )
if( DrawStruct ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem )
{ {
if( DrawStruct->m_Flags == 0 ) if( aItem->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) aItem, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIRROR_X );
CmpRotationMiroir( (SCH_COMPONENT*) aItem, aDC, CMP_MIRROR_X );
} }
break; break;
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component) case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
if( DrawStruct == NULL ) if( aItem == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); aItem = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
if( aItem )
{ {
if( DrawStruct->m_Flags == 0 ) if( aItem->m_Flags == 0 )
{ {
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) aItem, UR_CHANGED );
RefreshToolBar = TRUE; RefreshToolBar = TRUE;
} }
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_NORMAL );
GetScreen()->TestDanglingEnds( DrawPanel, DC ); CmpRotationMiroir( (SCH_COMPONENT*) aItem, aDC, CMP_NORMAL );
GetScreen()->TestDanglingEnds( DrawPanel, aDC );
} }
break; break;
case HK_DRAG: // Start drag case HK_DRAG: // Start drag
...@@ -671,51 +701,56 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -671,51 +701,56 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( itemInEdit ) if( itemInEdit )
break; break;
if( DrawStruct == NULL ) if( aItem == NULL )
{ {
// For a drag or copy command, try to find first a component: // For a drag or copy command, try to find first a component:
if( DrawStruct == NULL && HK_Descr->m_Idcommand != HK_MOVE_COMPONENT_OR_ITEM ) if( aItem == NULL && HK_Descr->m_Idcommand != HK_MOVE_COMPONENT_OR_ITEM )
DrawStruct = LocateSmallestComponent( GetScreen() ); aItem = LocateSmallestComponent( GetScreen() );
// If no component, find the schematic object to move/drag or copy under the cursor // If no component, find the schematic object to move/drag or copy under the cursor
if( DrawStruct == NULL ) if( aItem == NULL )
DrawStruct = SchematicGeneralLocateAndDisplay( false ); aItem = LocateAndShowItem( aPosition, false );
if( DrawStruct == NULL ) if( aItem == NULL )
break; break;
if( DrawStruct->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem->Type() == SCH_COMPONENT_T )
if( DrawStruct == NULL ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem == NULL )
break; break;
if( DrawStruct->Type() == SCH_SHEET_T )
if( aItem->Type() == SCH_SHEET_T )
{ {
SCH_SHEET* sheet = (SCH_SHEET*) DrawStruct; SCH_SHEET* sheet = (SCH_SHEET*) aItem;
// If it's a sheet, then check if a pinsheet is under the cursor // If it's a sheet, then check if a pinsheet is under the cursor
SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->m_Curseur ); SCH_SHEET_PIN* slabel = sheet->GetLabel( GetScreen()->m_Curseur );
if( slabel ) if( slabel )
DrawStruct = slabel; aItem = slabel;
} }
if( DrawStruct->Type() == SCH_JUNCTION_T )
if( aItem->Type() == SCH_JUNCTION_T )
{ {
// If it's a junction, pick the underlying wire instead // If it's a junction, pick the underlying wire instead
DrawStruct = PickStruct( GetScreen()->m_Curseur, GetScreen(), WIRE_T ); aItem = PickStruct( GetScreen()->m_Curseur, GetScreen(), WIRE_T );
} }
if( DrawStruct == NULL )
if( aItem == NULL )
break; break;
} }
if( HK_Descr->m_Idcommand == HK_COPY_COMPONENT_OR_LABEL ) if( HK_Descr->m_Idcommand == HK_COPY_COMPONENT_OR_LABEL )
{ {
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct ); GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent ); wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event ); wxPostEvent( this, event );
break; break;
} }
if( DrawStruct && (DrawStruct->m_Flags == 0) ) if( aItem && (aItem->m_Flags == 0) )
{ {
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct ); GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
// Create the events for moving a component or other schematic item // Create the events for moving a component or other schematic item
wxCommandEvent eventMoveOrDragComponent( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventMoveOrDragComponent( wxEVT_COMMAND_TOOL_CLICKED,
...@@ -727,7 +762,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -727,7 +762,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
wxCommandEvent eventDragWire( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventDragWire( wxEVT_COMMAND_TOOL_CLICKED,
ID_POPUP_SCH_DRAG_WIRE_REQUEST ); ID_POPUP_SCH_DRAG_WIRE_REQUEST );
switch( DrawStruct->Type() ) switch( aItem->Type() )
{ {
// select the correct event for moving an schematic object // select the correct event for moving an schematic object
// and add it to the event queue // and add it to the event queue
...@@ -755,7 +790,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -755,7 +790,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break; break;
case SCH_LINE_T: case SCH_LINE_T:
if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE ) if( ( (SCH_ITEM*) aItem )->GetLayer() == LAYER_WIRE )
{ {
if( HK_Descr->m_Idcommand == HK_DRAG ) if( HK_Descr->m_Idcommand == HK_DRAG )
wxPostEvent( this, eventDragWire ); wxPostEvent( this, eventDragWire );
...@@ -775,31 +810,34 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -775,31 +810,34 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
if( itemInEdit ) if( itemInEdit )
break; break;
if( DrawStruct == NULL )
if( aItem == NULL )
{ {
DrawStruct = PickStruct( GetScreen()->m_Curseur, GetScreen(), aItem = PickStruct( GetScreen()->m_Curseur, GetScreen(),
COMPONENT_T | TEXT_T | LABEL_T | SHEET_T ); COMPONENT_T | TEXT_T | LABEL_T | SHEET_T );
if( DrawStruct == NULL ) if( aItem == NULL )
break; break;
if( DrawStruct->Type() == SCH_COMPONENT_T )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem->Type() == SCH_COMPONENT_T )
if( DrawStruct == NULL ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem == NULL )
break; break;
} }
if( DrawStruct ) if( aItem )
{ {
wxCommandEvent eventEditPinsheet( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent eventEditPinsheet( wxEVT_COMMAND_TOOL_CLICKED,
ID_POPUP_SCH_EDIT_SHEET ); ID_POPUP_SCH_EDIT_SHEET );
switch( DrawStruct->Type() ) switch( aItem->Type() )
{ {
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
InstallCmpeditFrame( this, MousePos, (SCH_COMPONENT*) DrawStruct ); InstallCmpeditFrame( this, (SCH_COMPONENT*) aItem );
break; break;
case SCH_SHEET_T: case SCH_SHEET_T:
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct ); GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
wxPostEvent( this, eventEditPinsheet ); wxPostEvent( this, eventEditPinsheet );
break; break;
...@@ -807,7 +845,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -807,7 +845,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) DrawStruct ); EditSchematicText( (SCH_TEXT*) aItem );
break; break;
default: default:
...@@ -819,22 +857,26 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -819,22 +857,26 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case HK_EDIT_COMPONENT_VALUE: case HK_EDIT_COMPONENT_VALUE:
if( itemInEdit ) if( itemInEdit )
break; break;
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem == NULL )
if( DrawStruct ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem )
{ {
EditComponentValue( (SCH_COMPONENT*) DrawStruct, DC ); EditComponentValue( (SCH_COMPONENT*) aItem, aDC );
} }
break; break;
case HK_EDIT_COMPONENT_FOOTPRINT: case HK_EDIT_COMPONENT_FOOTPRINT:
if( itemInEdit ) if( itemInEdit )
break; break;
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); if( aItem == NULL )
if( DrawStruct ) aItem = LocateSmallestComponent( GetScreen() );
if( aItem )
{ {
EditComponentFootprint( (SCH_COMPONENT*) DrawStruct, DC ); EditComponentFootprint( (SCH_COMPONENT*) aItem, aDC );
} }
break; break;
} }
...@@ -849,26 +891,28 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -849,26 +891,28 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
* under the mouse cursor * under the mouse cursor
* Commands are case insensitive * Commands are case insensitive
*/ */
void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{ {
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
wxCommandEvent toolCmd( wxEVT_COMMAND_TOOL_CLICKED ); wxCommandEvent toolCmd( wxEVT_COMMAND_TOOL_CLICKED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
wxPoint MousePos = GetScreen()->m_MousePosition; bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->m_Flags;
bool itemInEdit = GetScreen()->GetCurItem()&& GetScreen()->GetCurItem()->m_Flags;
if( hotkey == 0 ) if( aHotKey == 0 )
return; return;
/* Convert lower to upper case (the usual toupper function has problem /* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */ * 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, s_Common_Hotkey_List );
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotKey, s_Common_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, s_LibEdit_Hotkey_List ); HK_Descr = GetDescriptorFromHotkey( aHotKey, s_LibEdit_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
return; return;
...@@ -931,7 +975,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -931,7 +975,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0) if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
&& ( m_lastDrawItem->Type() == LIB_PIN_T ) ) && ( m_lastDrawItem->Type() == LIB_PIN_T ) )
RepeatPinItem( DC, (LIB_PIN*) m_lastDrawItem ); RepeatPinItem( aDC, (LIB_PIN*) m_lastDrawItem );
break; break;
case HK_EDIT: case HK_EDIT:
...@@ -1002,7 +1046,6 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -1002,7 +1046,6 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break; break;
} }
case HK_DELETE: case HK_DELETE:
m_drawItem = LocateItemUsingCursor(); m_drawItem = LocateItemUsingCursor();
......
...@@ -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();
......
...@@ -26,21 +26,18 @@ static wxArrayString s_CmpNameList; ...@@ -26,21 +26,18 @@ static wxArrayString s_CmpNameList;
static wxArrayString s_PowerNameList; static wxArrayString s_PowerNameList;
/* Process the command triggers by the left button of the mouse when a tool void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
* is already selected.
*/
void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
SCH_ITEM* DrawStruct = GetScreen()->GetCurItem(); SCH_ITEM* item = GetScreen()->GetCurItem();
if( ( m_ID_current_state == 0 ) || ( DrawStruct && DrawStruct->m_Flags ) ) if( ( m_ID_current_state == 0 ) || ( item && item->m_Flags ) )
{ {
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
if( DrawStruct && DrawStruct->m_Flags ) if( item && item->m_Flags )
{ {
switch( DrawStruct->Type() ) switch( item->Type() )
{ {
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
...@@ -52,7 +49,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -52,7 +49,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
case SCH_FIELD_T: case SCH_FIELD_T:
DrawStruct->Place( this, DC ); item->Place( this, aDC );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -60,7 +57,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -60,7 +57,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case SCH_SCREEN_T: case SCH_SCREEN_T:
DisplayError( this, wxT( "OnLeftClick err: unexpected type for Place" ) ); DisplayError( this, wxT( "OnLeftClick err: unexpected type for Place" ) );
DrawStruct->m_Flags = 0; item->m_Flags = 0;
break; break;
case SCH_LINE_T: // May already be drawing segment. case SCH_LINE_T: // May already be drawing segment.
...@@ -70,16 +67,16 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -70,16 +67,16 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "SCH_EDIT_FRAME::OnLeftClick err: m_Flags != 0, itmetype %d" ), msg.Printf( wxT( "SCH_EDIT_FRAME::OnLeftClick err: m_Flags != 0, itmetype %d" ),
DrawStruct->Type()); item->Type());
DisplayError( this, msg ); DisplayError( this, msg );
DrawStruct->m_Flags = 0; item->m_Flags = 0;
break; break;
} }
} }
} }
else else
{ {
DrawStruct = SchematicGeneralLocateAndDisplay( true ); item = LocateAndShowItem( aPosition );
} }
} }
...@@ -92,114 +89,115 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -92,114 +89,115 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_HIERARCHY_PUSH_POP_BUTT: case ID_HIERARCHY_PUSH_POP_BUTT:
if( DrawStruct && DrawStruct->m_Flags ) if( item && item->m_Flags )
break; break;
DrawStruct = SchematicGeneralLocateAndDisplay();
if( DrawStruct && ( DrawStruct->Type() == SCH_SHEET_T ) ) item = LocateAndShowItem( aPosition );
{
InstallNextScreen( (SCH_SHEET*) DrawStruct ); if( item && ( item->Type() == SCH_SHEET_T ) )
} InstallNextScreen( (SCH_SHEET*) item );
else else
InstallPreviousSheet(); InstallPreviousSheet();
break; break;
case ID_NOCONN_BUTT: case ID_NOCONN_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
m_itemToRepeat = CreateNewNoConnectStruct( DC ); m_itemToRepeat = CreateNewNoConnectStruct( aDC );
GetScreen()->SetCurItem( m_itemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
} }
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_JUNCTION_BUTT: case ID_JUNCTION_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
m_itemToRepeat = CreateNewJunctionStruct( DC, GetScreen()->m_Curseur, TRUE ); m_itemToRepeat = CreateNewJunctionStruct( aDC, GetScreen()->m_Curseur, TRUE );
GetScreen()->SetCurItem( m_itemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
} }
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_WIRETOBUS_ENTRY_BUTT: case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT: case ID_BUSTOBUS_ENTRY_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
DrawStruct = CreateBusEntry( DC, item = CreateBusEntry( aDC, ( m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT ) ?
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS ); WIRE_TO_BUS : BUS_TO_BUS );
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( item );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( true );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
} }
break; break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT: case ID_SCHEMATIC_DELETE_ITEM_BUTT:
LocateAndDeleteItem( this, DC ); LocateAndDeleteItem( this, aDC );
OnModify( ); OnModify();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_WIRE_BUTT: case ID_WIRE_BUTT:
BeginSegment( DC, LAYER_WIRE ); BeginSegment( aDC, LAYER_WIRE );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
break; break;
case ID_BUS_BUTT: case ID_BUS_BUTT:
BeginSegment( DC, LAYER_BUS ); BeginSegment( aDC, LAYER_BUS );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
break; break;
case ID_LINE_COMMENT_BUTT: case ID_LINE_COMMENT_BUTT:
BeginSegment( DC, LAYER_NOTES ); BeginSegment( aDC, LAYER_NOTES );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
break; break;
case ID_TEXT_COMMENT_BUTT: case ID_TEXT_COMMENT_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
GetScreen()->SetCurItem( CreateNewText( DC, LAYER_NOTES ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
} }
break; break;
case ID_LABEL_BUTT: case ID_LABEL_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
GetScreen()->SetCurItem( CreateNewText( DC, LAYER_LOCLABEL ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -208,17 +206,19 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -208,17 +206,19 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_GLABEL_BUTT: case ID_GLABEL_BUTT:
case ID_HIERLABEL_BUTT: case ID_HIERLABEL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (item == NULL) || (item->m_Flags == 0) )
{ {
if(m_ID_current_state == ID_GLABEL_BUTT) if(m_ID_current_state == ID_GLABEL_BUTT)
GetScreen()->SetCurItem( CreateNewText( DC, LAYER_GLOBLABEL ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) );
if(m_ID_current_state == ID_HIERLABEL_BUTT) if(m_ID_current_state == ID_HIERLABEL_BUTT)
GetScreen()->SetCurItem( CreateNewText( DC, LAYER_HIERLABEL ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_HIERLABEL ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -226,14 +226,14 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -226,14 +226,14 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_SHEET_SYMBOL_BUTT: case ID_SHEET_SYMBOL_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
GetScreen()->SetCurItem( CreateSheet( DC ) ); GetScreen()->SetCurItem( CreateSheet( aDC ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -242,37 +242,36 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -242,37 +242,36 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_IMPORT_HLABEL_BUTT: case ID_IMPORT_HLABEL_BUTT:
case ID_SHEET_LABEL_BUTT: case ID_SHEET_LABEL_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
DrawStruct = SchematicGeneralLocateAndDisplay(); item = LocateAndShowItem( aPosition );
if( DrawStruct == NULL ) if( item == NULL )
break; break;
if( (DrawStruct->Type() == SCH_SHEET_T) if( (item->Type() == SCH_SHEET_T) && (item->m_Flags == 0) )
&& (DrawStruct->m_Flags == 0) )
{ {
if( m_ID_current_state == ID_IMPORT_HLABEL_BUTT ) if( m_ID_current_state == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) DrawStruct, DC ) ); GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) );
else else
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) DrawStruct, DC ) ); GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) item, aDC ) );
} }
else if( (DrawStruct->Type() == SCH_SHEET_LABEL_T) && (DrawStruct->m_Flags != 0) ) else if( (item->Type() == SCH_SHEET_LABEL_T) && (item->m_Flags != 0) )
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
} }
break; break;
case ID_COMPONENT_BUTT: case ID_COMPONENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (item == NULL) || (item->m_Flags == 0) )
{ {
GetScreen()->SetCurItem( Load_Component( DC, wxEmptyString, s_CmpNameList, TRUE ) ); GetScreen()->SetCurItem( Load_Component( aDC, wxEmptyString, s_CmpNameList, TRUE ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -280,14 +279,15 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -280,14 +279,15 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PLACE_POWER_BUTT: case ID_PLACE_POWER_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
GetScreen()->SetCurItem( Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) ); GetScreen()->SetCurItem( Load_Component( aDC, wxT( "power" ),
s_PowerNameList, FALSE ) );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
{ {
DrawStruct->Place( this, DC ); item->Place( this, aDC );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -315,31 +315,31 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -315,31 +315,31 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
* Id a create command is in progress: * Id a create command is in progress:
* validate and finish the command * validate and finish the command
*/ */
void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
{ {
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem(); EDA_ITEM* item = GetScreen()->GetCurItem();
wxPoint pos = GetPosition(); wxPoint pos = aPosition;
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
case 0: case 0:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->m_Flags == 0 ) )
{ {
DrawStruct = SchematicGeneralLocateAndDisplay(); item = LocateAndShowItem( aPosition );
} }
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags != 0 ) ) if( ( item == NULL ) || ( item->m_Flags != 0 ) )
break; break;
switch( DrawStruct->Type() ) switch( item->Type() )
{ {
case SCH_SHEET_T: case SCH_SHEET_T:
InstallNextScreen( (SCH_SHEET*) DrawStruct ); InstallNextScreen( (SCH_SHEET*) item );
break; break;
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
InstallCmpeditFrame( this, pos, (SCH_COMPONENT*) DrawStruct ); InstallCmpeditFrame( this, (SCH_COMPONENT*) item );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -347,16 +347,16 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -347,16 +347,16 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) DrawStruct ); EditSchematicText( (SCH_TEXT*) item );
break; break;
case SCH_FIELD_T: case SCH_FIELD_T:
EditCmpFieldText( (SCH_FIELD*) DrawStruct, DC ); EditCmpFieldText( (SCH_FIELD*) item, aDC );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
case SCH_MARKER_T: case SCH_MARKER_T:
( (SCH_MARKER*) DrawStruct )->DisplayMarkerInfo( this ); ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
break; break;
default: default:
...@@ -368,8 +368,9 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -368,8 +368,9 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case ID_BUS_BUTT: case ID_BUS_BUTT:
case ID_WIRE_BUTT: case ID_WIRE_BUTT:
case ID_LINE_COMMENT_BUTT: case ID_LINE_COMMENT_BUTT:
if( DrawStruct && ( DrawStruct->m_Flags & IS_NEW ) ) if( item && ( item->m_Flags & IS_NEW ) )
EndSegment( DC ); EndSegment( aDC );
break; break;
} }
} }
...@@ -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,31 +57,31 @@ class BASE_SCREEN : public EDA_ITEM ...@@ -57,31 +57,31 @@ 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 wxPoint m_StartVisu; /* Coordinates in drawing units of the current
* view position (upper left corner of device) * view position (upper left corner of device)
*/ */
wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu
* Utile pour recadrer les affichages lors de la
* navigation dans la hierarchie */
bool m_Center; /* Center on screen. If TRUE (0.0) is centered bool m_Center; /* Center on screen. If TRUE (0.0) is centered
* on screen coordinates can be < 0 and * on screen coordinates can be < 0 and
* > 0 except for schematics. * > 0 except for schematics.
...@@ -90,15 +90,12 @@ public: ...@@ -90,15 +90,12 @@ public:
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
* command (old data) */
unsigned m_UndoRedoCountMax; // undo/Redo command Max depth 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
......
...@@ -269,9 +269,10 @@ public: ...@@ -269,9 +269,10 @@ public:
* 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 aPosition The cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor * @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() )
......
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
* 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 aPosition The current cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor * @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() )
......
...@@ -14,12 +14,9 @@ ...@@ -14,12 +14,9 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
/********************************************************************/
void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************/
/* Handle the left buttom mouse click, when a tool is active /* Handle the left buttom mouse click, when a tool is active
*/ */
void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{ {
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false; bool exit = false;
...@@ -31,7 +28,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -31,7 +28,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress
{ {
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( aDC );
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
...@@ -39,10 +36,10 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -39,10 +36,10 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( (DrawStruct->m_Flags & IS_NEW) ) if( (DrawStruct->m_Flags & IS_NEW) )
{ {
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( DC ); Begin_Zone( aDC );
} }
else else
End_Move_Zone_Corner_Or_Outlines( DC, (ZONE_CONTAINER*) DrawStruct ); End_Move_Zone_Corner_Or_Outlines( aDC, (ZONE_CONTAINER*) DrawStruct );
exit = true; exit = true;
break; break;
...@@ -50,40 +47,40 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -50,40 +47,40 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_VIA: case TYPE_VIA:
if( DrawStruct->m_Flags & IS_DRAGGED ) if( DrawStruct->m_Flags & IS_DRAGGED )
{ {
PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, DC ); PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, aDC );
exit = true; exit = true;
} }
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC ); Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC ); PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_PAD: case TYPE_PAD:
PlacePad( (D_PAD*) DrawStruct, DC ); PlacePad( (D_PAD*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_MODULE: case TYPE_MODULE:
Place_Module( (MODULE*) DrawStruct, DC ); Place_Module( (MODULE*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_MIRE: case TYPE_MIRE:
Place_Mire( (MIREPCB*) DrawStruct, DC ); Place_Mire( (MIREPCB*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
{ {
Place_DrawItem( (DRAWSEGMENT*) DrawStruct, DC ); Place_DrawItem( (DRAWSEGMENT*) DrawStruct, aDC );
exit = true; exit = true;
} }
break; break;
...@@ -105,7 +102,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -105,7 +102,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( aDC );
if( exit ) if( exit )
return; return;
} }
...@@ -151,12 +148,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -151,12 +148,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_PCB_MUWAVE_TOOL_STUB_CMD: case ID_PCB_MUWAVE_TOOL_STUB_CMD:
case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
MuWaveCommand( DC, MousePos ); MuWaveCommand( aDC, aPosition );
break; break;
case ID_PCB_HIGHLIGHT_BUTT: case ID_PCB_HIGHLIGHT_BUTT:
{ {
int netcode = Select_High_Light( DC ); int netcode = Select_High_Light( aDC );
if( netcode < 0 ) if( netcode < 0 )
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
else else
...@@ -170,7 +167,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -170,7 +167,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_PCB_SHOW_1_RATSNEST_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT:
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
Show_1_Ratsnest( DrawStruct, DC ); Show_1_Ratsnest( DrawStruct, aDC );
if( DrawStruct ) if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct ); SendMessageToEESCHEMA( DrawStruct );
...@@ -179,12 +176,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -179,12 +176,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_PCB_MIRE_BUTT: case ID_PCB_MIRE_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
SetCurItem( Create_Mire( DC ) ); SetCurItem( Create_Mire( aDC ) );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
else if( DrawStruct->Type() == TYPE_MIRE ) else if( DrawStruct->Type() == TYPE_MIRE )
{ {
Place_Mire( (MIREPCB*) DrawStruct, DC ); Place_Mire( (MIREPCB*) DrawStruct, aDC );
} }
else else
DisplayError( this, wxT( "Internal err: Struct not TYPE_MIRE" ) ); DisplayError( this, wxT( "Internal err: Struct not TYPE_MIRE" ) );
...@@ -207,7 +204,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -207,7 +204,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
DrawStruct = Begin_DrawSegment( NULL, shape, DC ); DrawStruct = Begin_DrawSegment( NULL, shape, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
...@@ -215,7 +212,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -215,7 +212,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
&& (DrawStruct->Type() == TYPE_DRAWSEGMENT) && (DrawStruct->Type() == TYPE_DRAWSEGMENT)
&& (DrawStruct->m_Flags & IS_NEW) ) && (DrawStruct->m_Flags & IS_NEW) )
{ {
DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC ); DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
...@@ -231,14 +228,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -231,14 +228,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
DrawStruct = Begin_Route( NULL, DC ); DrawStruct = Begin_Route( NULL, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
if( DrawStruct ) if( DrawStruct )
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) else if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{ {
TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC ); TRACK* track = Begin_Route( (TRACK*) DrawStruct, aDC );
// SetCurItem() must not write to the msg panel // SetCurItem() must not write to the msg panel
// because a track info is displayed while moving the mouse cursor // because a track info is displayed while moving the mouse cursor
if( track ) // A new segment was created if( track ) // A new segment was created
...@@ -272,12 +269,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -272,12 +269,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Corner( DC, Start_Move_Zone_Corner( aDC,
zone_cont, zone_cont,
zone_cont->m_CornerSelection, zone_cont->m_CornerSelection,
false ); false );
} }
else if( Begin_Zone( DC ) ) else if( Begin_Zone( aDC ) )
{ {
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
DrawStruct = GetBoard()->m_CurrentZoneContour; DrawStruct = GetBoard()->m_CurrentZoneContour;
...@@ -289,7 +286,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -289,7 +286,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
&& (DrawStruct->m_Flags & IS_NEW) ) && (DrawStruct->m_Flags & IS_NEW) )
{ // Add a new corner to the current outline beeing created: { // Add a new corner to the current outline beeing created:
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( DC ); Begin_Zone( aDC );
DrawStruct = GetBoard()->m_CurrentZoneContour; DrawStruct = GetBoard()->m_CurrentZoneContour;
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( DrawStruct );
} }
...@@ -300,13 +297,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -300,13 +297,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_PCB_ADD_TEXT_BUTT: case ID_PCB_ADD_TEXT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
SetCurItem( Create_Texte_Pcb( DC ) ); SetCurItem( Create_Texte_Pcb( aDC ) );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct->Type() == TYPE_TEXTE ) else if( DrawStruct->Type() == TYPE_TEXTE )
{ {
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC ); Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
} }
else else
...@@ -317,14 +314,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -317,14 +314,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawStruct = Load_Module_From_Library( wxEmptyString, DC ); DrawStruct = Load_Module_From_Library( wxEmptyString, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
if( DrawStruct ) if( DrawStruct )
StartMove_Module( (MODULE*) DrawStruct, DC ); StartMove_Module( (MODULE*) DrawStruct, aDC );
} }
else if( DrawStruct->Type() == TYPE_MODULE ) else if( DrawStruct->Type() == TYPE_MODULE )
{ {
Place_Module( (MODULE*) DrawStruct, DC ); Place_Module( (MODULE*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
} }
else else
...@@ -339,7 +336,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -339,7 +336,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
DrawStruct = Begin_Dimension( NULL, DC ); DrawStruct = Begin_Dimension( NULL, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
...@@ -347,7 +344,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -347,7 +344,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
&& (DrawStruct->Type() == TYPE_DIMENSION) && (DrawStruct->Type() == TYPE_DIMENSION)
&& (DrawStruct->m_Flags & IS_NEW) ) && (DrawStruct->m_Flags & IS_NEW) )
{ {
DrawStruct = Begin_Dimension( (DIMENSION*) DrawStruct, DC ); DrawStruct = Begin_Dimension( (DIMENSION*) DrawStruct, aDC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
...@@ -361,23 +358,23 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -361,23 +358,23 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct && (DrawStruct->m_Flags == 0) ) if( DrawStruct && (DrawStruct->m_Flags == 0) )
{ {
RemoveStruct( DrawStruct, DC ); RemoveStruct( DrawStruct, aDC );
SetCurItem( DrawStruct = NULL ); SetCurItem( DrawStruct = NULL );
} }
} }
break; break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT: case ID_PCB_PLACE_OFFSET_COORD_BUTT:
DrawPanel->DrawAuxiliaryAxis( DC, GR_XOR ); DrawPanel->DrawAuxiliaryAxis( aDC, GR_XOR );
m_Auxiliary_Axis_Position = GetScreen()->m_Curseur; m_Auxiliary_Axis_Position = GetScreen()->m_Curseur;
DrawPanel->DrawAuxiliaryAxis( DC, GR_COPY ); DrawPanel->DrawAuxiliaryAxis( aDC, GR_COPY );
OnModify(); OnModify();
break; break;
case ID_PCB_PLACE_GRID_COORD_BUTT: case ID_PCB_PLACE_GRID_COORD_BUTT:
DrawPanel->DrawGridAxis( DC, GR_XOR ); DrawPanel->DrawGridAxis( aDC, GR_XOR );
GetScreen()->m_GridOrigin = GetScreen()->m_Curseur; GetScreen()->m_GridOrigin = GetScreen()->m_Curseur;
DrawPanel->DrawGridAxis( DC, GR_COPY ); DrawPanel->DrawGridAxis( aDC, GR_COPY );
break; break;
default: default:
...@@ -391,7 +388,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -391,7 +388,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/* handle the double click on the mouse left button /* handle the double click on the mouse left button
*/ */
void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_PcbFrame::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
{ {
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
...@@ -417,12 +414,12 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -417,12 +414,12 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_VIA: case TYPE_VIA:
if( DrawStruct->m_Flags & IS_NEW ) if( DrawStruct->m_Flags & IS_NEW )
{ {
End_Route( (TRACK*) DrawStruct, DC ); End_Route( (TRACK*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
} }
else if( DrawStruct->m_Flags == 0 ) else if( DrawStruct->m_Flags == 0 )
{ {
Edit_TrackSegm_Width( DC, (TRACK*) DrawStruct ); Edit_TrackSegm_Width( aDC, (TRACK*) DrawStruct );
} }
break; break;
...@@ -432,18 +429,18 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -432,18 +429,18 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_MIRE: case TYPE_MIRE:
case TYPE_DIMENSION: case TYPE_DIMENSION:
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
OnEditItemRequest( DC, DrawStruct ); OnEditItemRequest( aDC, DrawStruct );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
OnEditItemRequest( DC, DrawStruct ); OnEditItemRequest( aDC, DrawStruct );
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
if( DrawStruct->m_Flags ) if( DrawStruct->m_Flags )
break; break;
OnEditItemRequest( DC, DrawStruct ); OnEditItemRequest( aDC, DrawStruct );
break; break;
default: default:
...@@ -455,13 +452,13 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -455,13 +452,13 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{ {
End_Route( (TRACK*) DrawStruct, DC ); End_Route( (TRACK*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
} }
break; break;
case ID_PCB_ZONES_BUTT: case ID_PCB_ZONES_BUTT:
if( End_Zone( DC ) ) if( End_Zone( aDC ) )
{ {
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL ); SetCurItem( NULL );
...@@ -481,7 +478,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -481,7 +478,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
} }
if( (DrawStruct->m_Flags & IS_NEW) ) if( (DrawStruct->m_Flags & IS_NEW) )
{ {
End_Edge( (DRAWSEGMENT*) DrawStruct, DC ); End_Edge( (DRAWSEGMENT*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL ); SetCurItem( NULL );
} }
...@@ -494,20 +491,20 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -494,20 +491,20 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/** /**
* Function OnEditItemRequest * Function OnEditItemRequest
* Install the corresponding dialog editor for the given item * Install the corresponding dialog editor for the given item
* @param DC = the current device context * @param aDC = the current device context
* @param aItem = a pointer to the BOARD_ITEM to edit * @param aItem = a pointer to the BOARD_ITEM to edit
*/ */
void WinEDA_PcbFrame::OnEditItemRequest( wxDC* DC, BOARD_ITEM* aItem ) void WinEDA_PcbFrame::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
{ {
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_VIA: case TYPE_VIA:
Edit_TrackSegm_Width( DC, (TRACK*) aItem ); Edit_TrackSegm_Width( aDC, (TRACK*) aItem );
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
InstallTextPCBOptionsFrame( (TEXTE_PCB*) aItem, DC ); InstallTextPCBOptionsFrame( (TEXTE_PCB*) aItem, aDC );
break; break;
case TYPE_PAD: case TYPE_PAD:
...@@ -515,27 +512,27 @@ void WinEDA_PcbFrame::OnEditItemRequest( wxDC* DC, BOARD_ITEM* aItem ) ...@@ -515,27 +512,27 @@ void WinEDA_PcbFrame::OnEditItemRequest( wxDC* DC, BOARD_ITEM* aItem )
break; break;
case TYPE_MODULE: case TYPE_MODULE:
InstallModuleOptionsFrame( (MODULE*) aItem, DC ); InstallModuleOptionsFrame( (MODULE*) aItem, aDC );
break; break;
case TYPE_MIRE: case TYPE_MIRE:
InstallMireOptionsFrame( (MIREPCB*) aItem, DC ); InstallMireOptionsFrame( (MIREPCB*) aItem, aDC );
break; break;
case TYPE_DIMENSION: case TYPE_DIMENSION:
Install_Edit_Dimension( (DIMENSION*) aItem, DC ); Install_Edit_Dimension( (DIMENSION*) aItem, aDC );
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) aItem, DC ); InstallTextModOptionsFrame( (TEXTE_MODULE*) aItem, aDC );
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) aItem, DC ); InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) aItem, aDC );
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
Edit_Zone_Params( DC, (ZONE_CONTAINER*) aItem ); Edit_Zone_Params( aDC, (ZONE_CONTAINER*) aItem );
break; break;
default: default:
......
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