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
3f2fc340
Commit
3f2fc340
authored
May 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WX_UNIT_TEXT can handle default value.
parent
e2feefc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
wxunittext.cpp
common/wxunittext.cpp
+10
-2
wxunittext.h
include/wxunittext.h
+3
-0
No files found.
common/wxunittext.cpp
View file @
3f2fc340
...
...
@@ -101,13 +101,15 @@ void WX_UNIT_TEXT::SetUnits( EDA_UNITS_T aUnits, bool aConvert )
void
WX_UNIT_TEXT
::
SetValue
(
double
aValue
)
{
assert
(
aValue
>=
0.0
);
if
(
aValue
>=
0.0
)
{
m_inputValue
->
SetValue
(
wxString
(
Double2Str
(
aValue
).
c_str
(),
wxConvUTF8
)
);
m_inputValue
->
MarkDirty
();
}
else
{
m_inputValue
->
SetValue
(
DEFAULT_VALUE
);
}
}
...
...
@@ -169,6 +171,9 @@ boost::optional<double> WX_UNIT_TEXT::GetValue() const
wxString
text
=
m_inputValue
->
GetValue
();
double
value
;
if
(
text
==
DEFAULT_VALUE
)
return
boost
::
optional
<
double
>
(
-
1.0
);
if
(
!
text
.
ToDouble
(
&
value
)
)
return
boost
::
optional
<
double
>
();
...
...
@@ -189,3 +194,6 @@ void WX_UNIT_TEXT::onSpinDownEvent( wxSpinEvent& aEvent )
if
(
newValue
>=
0.0
)
SetValue
(
newValue
);
}
const
wxString
WX_UNIT_TEXT
::
DEFAULT_VALUE
=
_
(
"default "
);
include/wxunittext.h
View file @
3f2fc340
...
...
@@ -136,6 +136,9 @@ protected:
///> Step size (added/subtracted difference if spin buttons are used).
double
m_step
;
///> Default value (or non-specified)
static
const
wxString
DEFAULT_VALUE
;
};
#endif
/* WXUNITTEXT_H_ */
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