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
75ea2891
Commit
75ea2891
authored
Jan 29, 2009
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the superbly convenient EnsureTextCtrlWidth()
parent
fcedda3f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
31 deletions
+75
-31
CHANGELOG.txt
CHANGELOG.txt
+6
-3
common.cpp
common/common.cpp
+36
-0
dialog_edit_component_in_schematic.cpp
eeschema/dialog_edit_component_in_schematic.cpp
+15
-28
dialog_edit_component_in_schematic.h
eeschema/dialog_edit_component_in_schematic.h
+3
-0
common.h
include/common.h
+15
-0
No files found.
CHANGELOG.txt
View file @
75ea2891
...
@@ -16,10 +16,13 @@ email address.
...
@@ -16,10 +16,13 @@ email address.
2009-Jan-29 UPDATE Dick Hollenbeck <dick@softplc.com>
2009-Jan-29 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
++all
common.c added EnsureTextCtrlWidth()
++eeschema
++eeschema
dialog edit component in schematic: make sure chipname text control is wide
* dialog edit component in schematic: make sure chipname text control is wide
enough to handle unusually long chip names. Did not have time to look at
enough to handle unusually long chip names.
dialog edit component in library.
* Retain and re-use user's desired dialog edit component window size.
Did not have time to look at dialog edit component in library.
2009-Jan-27 UPDATE Vesa Solonen <vesa.solonen@hut.fi>
2009-Jan-27 UPDATE Vesa Solonen <vesa.solonen@hut.fi>
...
...
common/common.cpp
View file @
75ea2891
...
@@ -72,6 +72,42 @@ void SetLocaleTo_Default( void )
...
@@ -72,6 +72,42 @@ void SetLocaleTo_Default( void )
}
}
/********************************************************************/
bool
EnsureTextCtrlWidth
(
wxTextCtrl
*
aCtrl
,
const
wxString
*
aString
)
/********************************************************************/
{
wxWindow
*
window
=
aCtrl
->
GetParent
();
if
(
!
window
)
window
=
aCtrl
;
wxString
ctrlText
;
if
(
!
aString
)
{
ctrlText
=
aCtrl
->
GetValue
();
aString
=
&
ctrlText
;
}
wxCoord
width
;
wxCoord
height
;
{
wxClientDC
dc
(
window
);
dc
.
SetFont
(
aCtrl
->
GetFont
()
);
dc
.
GetTextExtent
(
*
aString
,
&
width
,
&
height
);
}
wxSize
size
=
aCtrl
->
GetSize
();
if
(
size
.
GetWidth
()
<
width
+
10
)
{
size
.
SetWidth
(
width
+
10
);
aCtrl
->
SetSizeHints
(
size
);
return
true
;
}
return
false
;
}
/*********************************************************************************************/
/*********************************************************************************************/
Ki_PageDescr
::
Ki_PageDescr
(
const
wxSize
&
size
,
const
wxPoint
&
offset
,
const
wxString
&
name
)
Ki_PageDescr
::
Ki_PageDescr
(
const
wxSize
&
size
,
const
wxPoint
&
offset
,
const
wxString
&
name
)
/*********************************************************************************************/
/*********************************************************************************************/
...
...
eeschema/dialog_edit_component_in_schematic.cpp
View file @
75ea2891
...
@@ -19,21 +19,7 @@
...
@@ -19,21 +19,7 @@
int
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_SelectedRow
;
int
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_SelectedRow
;
/**
wxSize
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_LastSize
=
wxDefaultSize
;
* Function GetTextSize
* computes the size of a text string in pixels from the wxFont used within a wxTextCtrl.
* @param aString is the text string to measure, must be a single line, no newlines.
* @param aWindow is the wxWindow which is the parent of the wxTextCtrl \a aCtrl.
* @param aWidth is where to put the width of the string in pixels.
* @param aHeight is where to put the heigth of the string in pixels.
*/
static
void
GetTextSize
(
const
wxString
&
aString
,
wxWindow
*
aWindow
,
wxTextCtrl
*
aCtrl
,
wxCoord
*
aWidth
,
wxCoord
*
aHeight
)
{
wxClientDC
dc
(
aWindow
);
dc
.
SetFont
(
aCtrl
->
GetFont
()
);
dc
.
GetTextExtent
(
aString
,
aWidth
,
aHeight
);
}
/**********************************************************************/
/**********************************************************************/
...
@@ -57,24 +43,25 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
...
@@ -57,24 +43,25 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
dialog
->
InitBuffers
(
aComponent
);
dialog
->
InitBuffers
(
aComponent
);
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
wxSize
sizeNow
=
dialog
->
GetSize
();
// this relies on wxDefaultSize being -1,-1, be careful here.
if
(
sizeNow
.
GetWidth
()
<
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_LastSize
.
GetWidth
()
||
sizeNow
.
GetHeight
()
<
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_LastSize
.
GetHeight
()
)
{
{
wxCoord
width
;
dialog
->
SetSize
(
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_LastSize
)
;
wxCoord
height
;
}
GetTextSize
(
dialog
->
chipnameTextCtrl
->
GetValue
(),
dialog
,
dialog
->
chipnameTextCtrl
,
&
width
,
&
height
);
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
EnsureTextCtrlWidth
(
dialog
->
chipnameTextCtrl
);
wxSize
size
=
dialog
->
chipnameTextCtrl
->
GetSize
();
dialog
->
ShowModal
();
if
(
size
.
GetWidth
()
<
width
+
10
)
// Some of the field values are long and are not always fully visible
{
// because the window comes up too narrow.
size
.
SetWidth
(
width
+
10
);
// Remember user's manual window resizing efforts here so it comes up wide enough next time.
dialog
->
chipnameTextCtrl
->
SetSizeHints
(
size
);
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
s_LastSize
=
dialog
->
GetSize
();
dialog
->
Layout
();
}
}
dialog
->
ShowModal
();
dialog
->
Destroy
();
dialog
->
Destroy
();
}
}
...
...
eeschema/dialog_edit_component_in_schematic.h
View file @
75ea2891
...
@@ -22,6 +22,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
...
@@ -22,6 +22,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
static
int
s_SelectedRow
;
static
int
s_SelectedRow
;
/// The size of the dialog window last time it was displayed;
static
wxSize
s_LastSize
;
/// a copy of the edited component's SCH_CMP_FIELDs
/// a copy of the edited component's SCH_CMP_FIELDs
SCH_CMP_FIELDS
m_FieldsBuf
;
SCH_CMP_FIELDS
m_FieldsBuf
;
...
...
include/common.h
View file @
75ea2891
...
@@ -389,6 +389,21 @@ but could make more easier an optional use of locale in kicad
...
@@ -389,6 +389,21 @@ but could make more easier an optional use of locale in kicad
*/
*/
void
SetLocaleTo_Default
(
void
);
void
SetLocaleTo_Default
(
void
);
/**
* Function EnsureTextCtrlWidth
* sets the minimum pixel width on a text control in order to make a text string
* be fully visible within it. The current font within the text control is considered.
* The text can come either from the control or be given as an argument.
* If the text control is larger than needed, then nothing is done.
* @param aCtrl the text control to potentially make wider.
* @param aString the text that is used in sizing the control's pixel width. If NULL, then
* the text already within the control is used.
* @return bool - true if the \a aCtrl had its size changed, else false.
*/
bool
EnsureTextCtrlWidth
(
wxTextCtrl
*
aCtrl
,
const
wxString
*
aString
=
NULL
);
/**
/**
* Operator << overload
* Operator << overload
* outputs a point to the argument string in a format resembling
* outputs a point to the argument string in a format resembling
...
...
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