Commit ccfa4e0a authored by charras's avatar charras

Eeschema: Libedit: fixed hang when using the repeat function (insert key) after creating a pin.

Fixed others minor problems 
parent d1f2a16c
......@@ -76,13 +76,14 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ) );
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
EnableScrolling( TRUE, TRUE );
m_ClipBox.SetSize( size );
m_ClipBox.SetX( 0 );
m_ClipBox.SetY( 0 );
m_CanStartBlock = -1; // Command block can start if >= 0
m_AbortEnable = m_AbortRequest = FALSE;
m_AbortEnable = m_AbortRequest = false;
m_AutoPAN_Enable = TRUE;
m_IgnoreMouseEvents = 0;
......@@ -93,8 +94,8 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable,
true );
m_AutoPAN_Request = FALSE;
m_Block_Enable = FALSE;
m_AutoPAN_Request = false;
m_Block_Enable = false;
m_PanelDefaultCursor = m_PanelCursor = wxCURSOR_ARROW;
m_CursorLevel = 0;
m_PrintIsMirrored = false;
......@@ -212,7 +213,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
/** Function IsPointOnDisplay
* @param ref_pos is the position to test in pixels, relative to the panel.
* @return TRUE if ref_pos is a point currently visible on screen
* FALSE if ref_pos is out of screen
* false if ref_pos is out of screen
*/
bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
{
......@@ -225,7 +226,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
// Slightly decreased the size of the useful screen area to avoid drawing
// limits.
#define PIXEL_MARGIN 8
display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN );
display_rect.Inflate( -PIXEL_MARGIN );
// Convert physical coordinates.
pos = CalcUnscrolledPosition( display_rect.GetPosition() );
......@@ -564,11 +565,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC.GetGraphicsContext()->Translate(0.5, 0.5);
#else
#ifdef KICAD_USE_BUFFERED_DC
wxBufferedPaintDC paintDC( this );
#else
wxPaintDC paintDC( this );
#endif
INSTALL_PAINTDC( paintDC, this );
#endif
EDA_Rect tmp;
wxRect PaintClipBox;
......@@ -622,7 +619,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#endif
// Be sure the drawpanel clipbox is bigger than the region to repair:
m_ClipBox.Inflate(1,1); // Give it one pixel more in each direction
m_ClipBox.Inflate(1); // Give it one pixel more in each direction
#if 0 && defined (DEBUG)
printf( "2) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n",
......@@ -705,7 +702,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
BASE_SCREEN* screen = GetScreen();
int ii, jj, xg, yg, color;
wxRealPoint screen_grid_size;
bool drawgrid = FALSE;
bool drawgrid = false;
wxSize size;
wxPoint org;
......@@ -729,7 +726,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
dgrid.x *= 2;
}
if( dgrid.x < 5 )
drawgrid = FALSE; // The grid is too small: do not show it
drawgrid = false; // The grid is too small: do not show it
if( dgrid.y < 5 )
{
......@@ -737,7 +734,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
dgrid.y *= 2;
}
if( dgrid.y < 5 )
drawgrid = FALSE; // The grid is too small
drawgrid = false; // The grid is too small
GetViewStart( &org.x, &org.y );
GetScrollPixelsPerUnit( &ii, &jj );
......@@ -856,7 +853,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
m_IgnoreMouseEvents = TRUE;
PopupMenu( &MasterMenu, pos );
MouseToCursorSchema();
m_IgnoreMouseEvents = FALSE;
m_IgnoreMouseEvents = false;
return true;
}
......@@ -866,7 +863,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event )
{
if( ManageCurseur == NULL ) // No command in progress.
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
if( !m_AutoPAN_Enable || !m_AutoPAN_Request || m_IgnoreMouseEvents )
return;
......@@ -899,11 +896,12 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled()
|| !rect.Contains( event.GetPosition() ) )
{
#if 0
wxLogDebug( wxT( "OnMouseWheel() position(%d, %d) " ) \
wxT( "rectangle(%d, %d, %d, %d)" ),
event.GetPosition().x, event.GetPosition().y,
rect.x, rect.y, rect.width, rect.height );
#endif
event.Skip();
return;
}
......@@ -964,7 +962,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
}
if( ManageCurseur == NULL ) // No command in progress
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
if( m_Parent->m_FrameIsActive )
SetFocus();
......@@ -1123,7 +1121,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
{
if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
{
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
m_Parent->HandleBlockPlace( &DC );
s_IgnoreNextLeftButtonRelease = true;
}
......@@ -1188,13 +1186,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( ForceCloseManageCurseur )
{
ForceCloseManageCurseur( this, &DC );
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
}
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
}
else if( screen->m_BlockLocate.m_State == STATE_BLOCK_END )
{
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
m_Parent->HandleBlockEnd( &DC );
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
......@@ -1216,7 +1214,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( ForceCloseManageCurseur )
{
ForceCloseManageCurseur( this, &DC );
m_AutoPAN_Request = FALSE;
m_AutoPAN_Request = false;
}
}
}
......@@ -1237,7 +1235,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
{
long key, localkey;
bool escape = FALSE;
bool escape = false;
wxPoint pos;
key = localkey = event.GetKeyCode();
......
......@@ -1561,7 +1561,7 @@ void LIB_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( Buf_Poly_Drawings == NULL )
{
DisplayError( NULL, _( "Cannot allocate memory to draw polylines." ) );
DisplayError( NULL, wxT( "Cannot allocate memory to draw polylines." ) );
}
}
......
......@@ -103,7 +103,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Name:</property>
<property name="label">Pin &amp;name:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText1</property>
......@@ -376,7 +376,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">N&amp;umber:</property>
<property name="label">Pin n&amp;umber:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText4</property>
......@@ -385,7 +385,7 @@
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="tooltip">Pin number: 1 to 4 ASCII letters and/or digits</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......@@ -918,7 +918,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Electical type:</property>
<property name="label">&amp;Electrical type:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText6</property>
......@@ -927,7 +927,7 @@
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="tooltip">Used by the ERC.</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
......@@ -1060,7 +1060,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Style:</property>
<property name="label">Graphic &amp;Style:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText7</property>
......
......@@ -21,7 +21,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("&Name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Pin &name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
......@@ -42,8 +42,10 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
m_staticNameTextSizeUnits->Wrap( -1 );
fgSizer1->Add( m_staticNameTextSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("N&umber:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Pin n&umber:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
m_staticText4->SetToolTip( _("Pin number: 1 to 4 ASCII letters and/or digits") );
fgSizer1->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_textNumber = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
......@@ -86,8 +88,10 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
m_staticLengthUnits->Wrap( -1 );
fgSizer1->Add( m_staticLengthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("&Electical type:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("&Electrical type:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
m_staticText6->SetToolTip( _("Used by the ERC.") );
fgSizer1->Add( m_staticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxArrayString m_choiceElectricalTypeChoices;
......@@ -107,7 +111,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
fgSizer1->Add( 0, 0, 0, wxEXPAND, 3 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("&Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Graphic &Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
fgSizer1->Add( m_staticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
......
......@@ -654,6 +654,9 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
INSTALL_DC( dc, DrawPanel );
switch( id )
{
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
break;
case ID_LIBEDIT_SELECT_CURRENT_LIB:
SelectActiveLibrary();
break;
......
......@@ -178,8 +178,12 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
wxPoint newpos;
bool status;
if( CurrentPin == NULL )
// Some tests
if( (CurrentPin == NULL) || (CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE) )
{
wxMessageBox( wxT("WinEDA_LibeditFrame::PlacePin() error") );
return;
}
newpos.x = GetScreen()->m_Curseur.x;
newpos.y = -GetScreen()->m_Curseur.y;
......@@ -544,20 +548,15 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
{
LIB_PIN* Pin;
wxString msg;
int ox = 0, oy = 0;
if( m_component == NULL || SourcePin == NULL
|| SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
Pin = (LIB_PIN*) SourcePin->GenCopy();
m_component->AddDrawItem( Pin );
Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x;
ox = Pin->m_Pos.x;
Pin->m_Pos.y += -g_RepeatStep.y;
oy = Pin->m_Pos.y;
IncrementLabelMember( Pin->m_PinName );
Pin->ReturnPinStringNum( msg );
......@@ -573,7 +572,12 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur.x = Pin->m_Pos.x;
GetScreen()->m_Curseur.y = -Pin->m_Pos.y;
// Add this new pin in list, and creates pins for others parts if needed
m_drawItem = Pin;
PlacePin( DC );
m_lastDrawItem = Pin;
GetScreen()->m_Curseur = savepos;
DrawPanel->CursorOn( DC );
......
......@@ -214,7 +214,13 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
Text->m_Orient = m_textOrientation;
Text->m_Pos = GetScreen()->m_Curseur;
NEGATE( Text->m_Pos.y );
// Enter the graphic text info
DrawPanel->m_IgnoreMouseEvents = true;
EditSymbolText( NULL, Text );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = false;
if( Text->m_Text.IsEmpty() )
{
SAFE_DELETE( Text );
......
......@@ -30,8 +30,11 @@ public:
KicadGraphicContext _cDC( parent );\
wxBufferedDC name(&_cDC, _cDC.GetSize() );
#define INSTALL_PAINTDC(name,parent) wxBufferedPaintDC name(parent )
#else
#define INSTALL_DC(name,parent) KicadGraphicContext name( parent );
#define INSTALL_DC(name,parent) KicadGraphicContext name( parent )
#define INSTALL_PAINTDC(name,parent) wxPaintDC name( parent )
#endif
#endif // __KICAD_DEVICE_CONTEXT_H__
......@@ -21,8 +21,16 @@
*/
static inline const wxChar* GetChars( wxString s )
{
#if wxCHECK_VERSION(2,9,0)
return (const wxChar*) s.wx_str();
#if wxCHECK_VERSION( 2, 9, 0 )
/* To be Fixed:
* Currently, access to the actual character data in <wxString::Printf
* is a moving target
* So, with wxWidgets 2.9.0 this line is subject to change:
*/
// return (const wxChar*) s.wx_str();
return (const wxChar*) s.c_str();
#else
return s.GetData();
#endif
......@@ -40,9 +48,10 @@ static inline const wxChar* GetChars( wxString s )
#define ABS( y ) ( (y) >= 0 ? (y) : ( -(y) ) )
#endif
#define NEGATE(x) (x = -x)
#define NEGATE( x ) (x = -x)
/// # of elements in an arrray
#define DIM(x) (sizeof(x)/sizeof((x)[0]))
#define DIM( x ) ( sizeof(x) / sizeof( (x)[0] ) )
#define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 )
......@@ -52,28 +61,28 @@ static inline const wxChar* GetChars( wxString s )
#define NORMALIZE_ANGLE( Angle ) { while( Angle < 0 ) \
Angle += 3600;\
while( Angle > 3600 ) \
Angle -= 3600; }
Angle -= 3600;}
/* Normalize angle to be in the 0.0 .. 360.0 range: */
#define NORMALIZE_ANGLE_POS( Angle ) { while( Angle < 0 ) \
Angle += 3600;while( Angle >= 3600 ) \
Angle -= 3600; }
Angle -= 3600;}
#define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) \
{ Angle = -Angle; while( Angle < 0 ) \
Angle += 3600;while( Angle >= 3600 ) \
Angle -= 3600; }
Angle -= 3600;}
/* Normalize angle to be in the -90.0 .. 90.0 range */
#define NORMALIZE_ANGLE_90( Angle ) { while( Angle < -900 ) \
Angle += 1800;\
while( Angle > 900 ) \
Angle -= 1800; }
Angle -= 1800;}
/* Normalize angle to be in the -180.0 .. 180.0 range */
#define NORMALIZE_ANGLE_180( Angle ) { while( Angle <= -1800 ) \
Angle += 3600;\
while( Angle > 1800 ) \
Angle -= 3600; }
Angle += 3600;\
while( Angle > 1800 ) \
Angle -= 3600;}
/*****************************/
/* macro to exchange 2 items */
......@@ -104,7 +113,7 @@ BOOST_TYPEOF_REGISTER_TYPE( const D_PAD* );
class BOARD_ITEM;
BOOST_TYPEOF_REGISTER_TYPE( BOARD_ITEM* );
#define EXCHG( a, b ) { BOOST_TYPEOF(a) __temp__ = (a); \
#define EXCHG( a, b ) { BOOST_TYPEOF( a ) __temp__ = (a); \
(a) = (b); \
(b) = __temp__; }
......@@ -140,7 +149,7 @@ static inline void ADD_MENUITEM_WITH_SUBMENU( wxMenu* menu, wxMenu* submenu,
int id, const wxString& text,
const wxBitmap& icon )
{
wxMenuItem* l_item;
wxMenuItem* l_item;
l_item = new wxMenuItem( menu, id, text );
l_item->SetSubMenu( submenu );
......@@ -155,7 +164,7 @@ static inline void ADD_MENUITEM_WITH_HELP_AND_SUBMENU( wxMenu* menu,
const wxString& help,
const wxBitmap& icon )
{
wxMenuItem* l_item;
wxMenuItem* l_item;
l_item = new wxMenuItem( menu, id, text, help );
l_item->SetSubMenu( submenu );
......
No preview for this file type
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment