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
ef2337ca
Commit
ef2337ca
authored
Oct 09, 2014
by
John Beard
Committed by
Wayne Stambaugh
Oct 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve alias handling in component chooser dialog.
parent
a398d459
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
11 deletions
+60
-11
dialog_choose_component.cpp
eeschema/dialogs/dialog_choose_component.cpp
+60
-11
No files found.
eeschema/dialogs/dialog_choose_component.cpp
View file @
ef2337ca
...
@@ -76,7 +76,7 @@ LIB_ALIAS* DIALOG_CHOOSE_COMPONENT::GetSelectedAlias( int* aUnit ) const
...
@@ -76,7 +76,7 @@ LIB_ALIAS* DIALOG_CHOOSE_COMPONENT::GetSelectedAlias( int* aUnit ) const
void
DIALOG_CHOOSE_COMPONENT
::
OnSearchBoxChange
(
wxCommandEvent
&
aEvent
)
void
DIALOG_CHOOSE_COMPONENT
::
OnSearchBoxChange
(
wxCommandEvent
&
aEvent
)
{
{
m_search_container
->
UpdateSearchTerm
(
m_searchBox
->
GetLineText
(
0
)
);
m_search_container
->
UpdateSearchTerm
(
m_searchBox
->
GetLineText
(
0
)
);
updateSelection
();
updateSelection
();
m_searchBox
->
SetFocus
();
m_searchBox
->
SetFocus
();
}
}
...
@@ -114,7 +114,7 @@ void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke )
...
@@ -114,7 +114,7 @@ void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke )
selectIfValid
(
GetNextItem
(
*
m_libraryComponentTree
,
sel
)
);
selectIfValid
(
GetNextItem
(
*
m_libraryComponentTree
,
sel
)
);
break
;
break
;
// The foll
wo
ing keys we can only hijack if they are not needed by the textbox itself.
// The foll
ow
ing keys we can only hijack if they are not needed by the textbox itself.
case
WXK_LEFT
:
case
WXK_LEFT
:
if
(
m_searchBox
->
GetInsertionPoint
()
==
0
)
if
(
m_searchBox
->
GetInsertionPoint
()
==
0
)
...
@@ -215,31 +215,58 @@ bool DIALOG_CHOOSE_COMPONENT::updateSelection()
...
@@ -215,31 +215,58 @@ bool DIALOG_CHOOSE_COMPONENT::updateSelection()
font_bold
.
SetWeight
(
wxFONTWEIGHT_BOLD
);
font_bold
.
SetWeight
(
wxFONTWEIGHT_BOLD
);
wxTextAttr
headline_attribute
;
wxTextAttr
headline_attribute
;
headline_attribute
.
SetFont
(
font_bold
);
headline_attribute
.
SetFont
(
font_bold
);
wxTextAttr
text_attribute
;
wxTextAttr
text_attribute
;
text_attribute
.
SetFont
(
font_normal
);
text_attribute
.
SetFont
(
font_normal
);
const
wxString
name
=
selection
->
GetName
();
if
(
!
name
.
empty
()
)
{
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
AppendText
(
name
);
}
const
wxString
description
=
selection
->
GetDescription
();
const
wxString
description
=
selection
->
GetDescription
();
if
(
!
description
.
empty
()
)
if
(
!
description
.
empty
()
)
{
{
if
(
!
m_componentDetails
->
IsEmpty
()
)
m_componentDetails
->
AppendText
(
wxT
(
"
\n\n
"
)
);
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
AppendText
(
_
(
"Description
\n
"
)
);
m_componentDetails
->
AppendText
(
_
(
"Description
\n
"
)
);
m_componentDetails
->
SetDefaultStyle
(
text_attribute
);
m_componentDetails
->
SetDefaultStyle
(
text_attribute
);
m_componentDetails
->
AppendText
(
description
);
m_componentDetails
->
AppendText
(
description
);
m_componentDetails
->
AppendText
(
wxT
(
"
\n\n
"
)
);
}
}
const
wxString
keywords
=
selection
->
GetKeyWords
();
const
wxString
keywords
=
selection
->
GetKeyWords
();
if
(
!
keywords
.
empty
()
)
if
(
!
keywords
.
empty
()
)
{
{
if
(
!
m_componentDetails
->
IsEmpty
()
)
m_componentDetails
->
AppendText
(
wxT
(
"
\n\n
"
)
);
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
AppendText
(
_
(
"Keywords
\n
"
)
);
m_componentDetails
->
AppendText
(
_
(
"Keywords
\n
"
)
);
m_componentDetails
->
SetDefaultStyle
(
text_attribute
);
m_componentDetails
->
SetDefaultStyle
(
text_attribute
);
m_componentDetails
->
AppendText
(
keywords
);
m_componentDetails
->
AppendText
(
keywords
);
}
}
if
(
!
selection
->
IsRoot
()
)
{
LIB_PART
*
root_part
=
selection
->
GetPart
();
const
wxString
root_component_name
(
root_part
?
root_part
->
GetName
()
:
_
(
"Unknown"
)
);
if
(
!
m_componentDetails
->
IsEmpty
()
)
m_componentDetails
->
AppendText
(
wxT
(
"
\n\n
"
)
);
m_componentDetails
->
SetDefaultStyle
(
headline_attribute
);
m_componentDetails
->
AppendText
(
_
(
"Alias of "
)
);
m_componentDetails
->
SetDefaultStyle
(
text_attribute
);
m_componentDetails
->
AppendText
(
root_component_name
);
}
m_componentDetails
->
SetInsertionPoint
(
0
);
// scroll up.
m_componentDetails
->
SetInsertionPoint
(
0
);
// scroll up.
m_componentDetails
->
Thaw
();
m_componentDetails
->
Thaw
();
...
@@ -251,8 +278,28 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven
...
@@ -251,8 +278,28 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven
{
{
int
unit
=
0
;
int
unit
=
0
;
LIB_ALIAS
*
selection
=
m_search_container
->
GetSelectedAlias
(
&
unit
);
LIB_ALIAS
*
selection
=
m_search_container
->
GetSelectedAlias
(
&
unit
);
LIB_PART
*
part
=
selection
?
selection
->
GetPart
()
:
NULL
;
// Don't draw anything (not even the background) if we don't have
// a part to show
if
(
!
part
)
return
;
if
(
selection
->
IsRoot
()
)
{
// just show the part directly
renderPreview
(
part
,
unit
);
}
else
{
// switch out the name temporarily for the alias name
wxString
tmp
(
part
->
GetName
()
);
part
->
SetName
(
selection
->
GetName
()
);
renderPreview
(
part
,
unit
);
renderPreview
(
selection
?
selection
->
GetPart
()
:
NULL
,
unit
);
part
->
SetName
(
tmp
);
}
}
}
...
@@ -262,6 +309,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUni
...
@@ -262,6 +309,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUni
{
{
wxPaintDC
dc
(
m_componentView
);
wxPaintDC
dc
(
m_componentView
);
EDA_COLOR_T
bgcolor
=
m_parent
->
GetDrawBgColor
();
EDA_COLOR_T
bgcolor
=
m_parent
->
GetDrawBgColor
();
dc
.
SetBackground
(
bgcolor
==
BLACK
?
*
wxBLACK_BRUSH
:
*
wxWHITE_BRUSH
);
dc
.
SetBackground
(
bgcolor
==
BLACK
?
*
wxBLACK_BRUSH
:
*
wxWHITE_BRUSH
);
dc
.
Clear
();
dc
.
Clear
();
...
@@ -323,6 +371,7 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite
...
@@ -323,6 +371,7 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite
for
(
wxTreeItemId
walk
=
item
;
walk
.
IsOk
();
walk
=
tree
.
GetItemParent
(
walk
)
)
for
(
wxTreeItemId
walk
=
item
;
walk
.
IsOk
();
walk
=
tree
.
GetItemParent
(
walk
)
)
{
{
nextItem
=
tree
.
GetNextSibling
(
walk
);
nextItem
=
tree
.
GetNextSibling
(
walk
);
if
(
nextItem
.
IsOk
()
)
if
(
nextItem
.
IsOk
()
)
break
;
break
;
}
}
...
...
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