Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
9c62d2df
Commit
9c62d2df
authored
Jan 02, 2013
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eeschema, Libedit: fix potential bugs.
parent
45bd4431
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
40 deletions
+23
-40
libedit_onleftclick.cpp
eeschema/libedit_onleftclick.cpp
+8
-19
libedit_onrightclick.cpp
eeschema/libedit_onrightclick.cpp
+15
-21
No files found.
eeschema/libedit_onleftclick.cpp
View file @
9c62d2df
...
@@ -40,9 +40,7 @@
...
@@ -40,9 +40,7 @@
void
LIB_EDIT_FRAME
::
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
aPosition
)
void
LIB_EDIT_FRAME
::
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
aPosition
)
{
{
LIB_ITEM
*
item
=
m_drawItem
;
LIB_ITEM
*
item
=
m_drawItem
;
bool
item_in_edit
=
false
;
bool
item_in_edit
=
item
&&
item
->
InEditMode
();
if
(
item
)
item_in_edit
=
item
->
IsNew
()
||
item
->
IsMoving
()
||
item
->
IsDragging
();
bool
no_item_edited
=
!
item_in_edit
;
bool
no_item_edited
=
!
item_in_edit
;
if
(
m_component
==
NULL
)
// No component loaded !
if
(
m_component
==
NULL
)
// No component loaded !
...
@@ -139,7 +137,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
...
@@ -139,7 +137,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
if
(
m_component
==
NULL
)
if
(
m_component
==
NULL
)
return
;
return
;
if
(
(
m_drawItem
==
NULL
)
||
(
m_drawItem
->
GetFlags
()
==
0
)
)
if
(
(
m_drawItem
==
NULL
)
||
!
m_drawItem
->
InEditMode
(
)
)
{
// We can locate an item
{
// We can locate an item
m_drawItem
=
LocateItemUsingCursor
(
aPosition
);
m_drawItem
=
LocateItemUsingCursor
(
aPosition
);
...
@@ -157,11 +155,12 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
...
@@ -157,11 +155,12 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
return
;
return
;
m_canvas
->
SetIgnoreMouseEvents
(
true
);
m_canvas
->
SetIgnoreMouseEvents
(
true
);
bool
not_edited
=
!
m_drawItem
->
InEditMode
();
switch
(
m_drawItem
->
Type
()
)
switch
(
m_drawItem
->
Type
()
)
{
{
case
LIB_PIN_T
:
case
LIB_PIN_T
:
if
(
m_drawItem
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
wxCommandEvent
cmd
(
wxEVT_COMMAND_MENU_SELECTED
);
wxCommandEvent
cmd
(
wxEVT_COMMAND_MENU_SELECTED
);
cmd
.
SetId
(
ID_LIBEDIT_EDIT_PIN
);
cmd
.
SetId
(
ID_LIBEDIT_EDIT_PIN
);
...
@@ -172,35 +171,25 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
...
@@ -172,35 +171,25 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
case
LIB_ARC_T
:
case
LIB_ARC_T
:
case
LIB_CIRCLE_T
:
case
LIB_CIRCLE_T
:
case
LIB_RECTANGLE_T
:
case
LIB_RECTANGLE_T
:
if
(
m_drawItem
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
EditGraphicSymbol
(
DC
,
m_drawItem
);
EditGraphicSymbol
(
DC
,
m_drawItem
);
}
break
;
break
;
case
LIB_POLYLINE_T
:
case
LIB_POLYLINE_T
:
if
(
m_drawItem
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
EditGraphicSymbol
(
DC
,
m_drawItem
);
EditGraphicSymbol
(
DC
,
m_drawItem
);
}
else
if
(
m_drawItem
->
IsNew
()
)
else
if
(
m_drawItem
->
IsNew
()
)
{
EndDrawGraphicItem
(
DC
);
EndDrawGraphicItem
(
DC
);
}
break
;
break
;
case
LIB_TEXT_T
:
case
LIB_TEXT_T
:
if
(
m_drawItem
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
EditSymbolText
(
DC
,
m_drawItem
);
EditSymbolText
(
DC
,
m_drawItem
);
}
break
;
break
;
case
LIB_FIELD_T
:
case
LIB_FIELD_T
:
if
(
m_drawItem
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
EditField
(
(
LIB_FIELD
*
)
m_drawItem
);
EditField
(
(
LIB_FIELD
*
)
m_drawItem
);
}
break
;
break
;
default
:
default
:
...
...
eeschema/libedit_onrightclick.cpp
View file @
9c62d2df
...
@@ -62,7 +62,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -62,7 +62,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return
true
;
return
true
;
// If Command in progress, put menu "cancel"
// If Command in progress, put menu "cancel"
if
(
item
&&
item
->
GetFlags
()
)
if
(
item
&&
item
->
InEditMode
()
)
{
{
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_CANCEL_EDITING
,
_
(
"Cancel"
),
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_CANCEL_EDITING
,
_
(
"Cancel"
),
KiBitmap
(
cancel_xpm
)
);
KiBitmap
(
cancel_xpm
)
);
...
@@ -94,6 +94,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -94,6 +94,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return
true
;
return
true
;
m_drawItem
=
item
;
m_drawItem
=
item
;
bool
not_edited
=
!
item
->
InEditMode
();
wxString
msg
;
wxString
msg
;
switch
(
item
->
Type
()
)
switch
(
item
->
Type
()
)
...
@@ -103,7 +104,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -103,7 +104,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_ARC_T
:
case
LIB_ARC_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Arc"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Arc"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
...
@@ -116,7 +117,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -116,7 +117,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg
=
AddHotkeyName
(
_
(
"Edit Arc Options"
),
s_Libedit_Hokeys_Descr
,
HK_EDIT
);
msg
=
AddHotkeyName
(
_
(
"Edit Arc Options"
),
s_Libedit_Hokeys_Descr
,
HK_EDIT
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
KiBitmap
(
options_arc_xpm
)
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
KiBitmap
(
options_arc_xpm
)
);
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Delete Arc"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
msg
=
AddHotkeyName
(
_
(
"Delete Arc"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_arc_xpm
)
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_arc_xpm
)
);
...
@@ -124,16 +125,12 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -124,16 +125,12 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_CIRCLE_T
:
case
LIB_CIRCLE_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Circle"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Circle"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST
,
msg
,
KiBitmap
(
move_circle_xpm
)
);
KiBitmap
(
move_circle_xpm
)
);
}
if
(
item
->
GetFlags
()
==
0
)
{
msg
=
AddHotkeyName
(
_
(
"Drag Circle Outline"
),
s_Libedit_Hokeys_Descr
,
HK_DRAG
);
msg
=
AddHotkeyName
(
_
(
"Drag Circle Outline"
),
s_Libedit_Hokeys_Descr
,
HK_DRAG
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MODIFY_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MODIFY_ITEM
,
msg
,
KiBitmap
(
move_rectangle_xpm
)
);
KiBitmap
(
move_rectangle_xpm
)
);
...
@@ -143,7 +140,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -143,7 +140,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
KiBitmap
(
options_circle_xpm
)
);
KiBitmap
(
options_circle_xpm
)
);
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Delete Circle"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
msg
=
AddHotkeyName
(
_
(
"Delete Circle"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
...
@@ -152,7 +149,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -152,7 +149,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_RECTANGLE_T
:
case
LIB_RECTANGLE_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Rectangle"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Rectangle"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
...
@@ -164,15 +161,11 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -164,15 +161,11 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
KiBitmap
(
options_rectangle_xpm
)
);
KiBitmap
(
options_rectangle_xpm
)
);
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Drag Rectangle Edge"
),
s_Libedit_Hokeys_Descr
,
HK_DRAG
);
msg
=
AddHotkeyName
(
_
(
"Drag Rectangle Edge"
),
s_Libedit_Hokeys_Descr
,
HK_DRAG
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MODIFY_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_MODIFY_ITEM
,
msg
,
KiBitmap
(
move_rectangle_xpm
)
);
KiBitmap
(
move_rectangle_xpm
)
);
}
if
(
item
->
GetFlags
()
==
0
)
{
msg
=
AddHotkeyName
(
_
(
"Delete Rectangle"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
msg
=
AddHotkeyName
(
_
(
"Delete Rectangle"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_rectangle_xpm
)
);
KiBitmap
(
delete_rectangle_xpm
)
);
...
@@ -181,7 +174,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -181,7 +174,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_TEXT_T
:
case
LIB_TEXT_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Text"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Text"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
...
@@ -195,7 +188,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -195,7 +188,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg
=
AddHotkeyName
(
_
(
"Rotate Text"
),
s_Libedit_Hokeys_Descr
,
HK_ROTATE
);
msg
=
AddHotkeyName
(
_
(
"Rotate Text"
),
s_Libedit_Hokeys_Descr
,
HK_ROTATE
);
AddMenuItem
(
PopMenu
,
ID_LIBEDIT_ROTATE_ITEM
,
msg
,
KiBitmap
(
edit_text_xpm
)
);
AddMenuItem
(
PopMenu
,
ID_LIBEDIT_ROTATE_ITEM
,
msg
,
KiBitmap
(
edit_text_xpm
)
);
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Delete Text"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
msg
=
AddHotkeyName
(
_
(
"Delete Text"
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_text_xpm
)
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_text_xpm
)
);
...
@@ -203,7 +196,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -203,7 +196,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_POLYLINE_T
:
case
LIB_POLYLINE_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Line"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Line"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
...
@@ -223,13 +216,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -223,13 +216,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM
,
msg
,
KiBitmap
(
options_segment_xpm
)
);
KiBitmap
(
options_segment_xpm
)
);
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Delete Line "
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
msg
=
AddHotkeyName
(
_
(
"Delete Line "
),
s_Libedit_Hokeys_Descr
,
HK_DELETE
);
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
AddMenuItem
(
PopMenu
,
ID_POPUP_LIBEDIT_DELETE_ITEM
,
msg
,
KiBitmap
(
delete_segment_xpm
)
);
KiBitmap
(
delete_segment_xpm
)
);
}
}
else
if
(
item
->
IsNew
()
)
if
(
item
->
IsNew
()
)
{
{
if
(
(
(
LIB_POLYLINE
*
)
item
)
->
GetCornerCount
()
>
2
)
if
(
(
(
LIB_POLYLINE
*
)
item
)
->
GetCornerCount
()
>
2
)
{
{
...
@@ -242,7 +236,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
...
@@ -242,7 +236,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break
;
break
;
case
LIB_FIELD_T
:
case
LIB_FIELD_T
:
if
(
item
->
GetFlags
()
==
0
)
if
(
not_edited
)
{
{
msg
=
AddHotkeyName
(
_
(
"Move Field"
),
s_Libedit_Hokeys_Descr
,
msg
=
AddHotkeyName
(
_
(
"Move Field"
),
s_Libedit_Hokeys_Descr
,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
HK_LIBEDIT_MOVE_GRAPHIC_ITEM
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment