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
fb25b5c4
Commit
fb25b5c4
authored
Apr 28, 2009
by
drannou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding multi-line feature in PCBNEW and EESCHEMA
parent
fab8dece
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
193 additions
and
81 deletions
+193
-81
base_struct.cpp
common/base_struct.cpp
+56
-33
common.cpp
common/common.cpp
+32
-0
wxwineda.cpp
common/wxwineda.cpp
+8
-3
class_text-label.cpp
eeschema/class_text-label.cpp
+45
-23
dialog_edit_label.cpp
eeschema/dialog_edit_label.cpp
+26
-12
dialog_edit_label.h
eeschema/dialog_edit_label.h
+2
-2
dialog_edit_label_base.cpp
eeschema/dialog_edit_label_base.cpp
+11
-4
dialog_edit_label_base.h
eeschema/dialog_edit_label_base.h
+1
-1
base_struct.h
include/base_struct.h
+4
-0
common.h
include/common.h
+5
-0
wxstruct.h
include/wxstruct.h
+1
-1
dialog_pcb_text_properties.cpp
pcbnew/dialog_pcb_text_properties.cpp
+2
-2
No files found.
common/base_struct.cpp
View file @
fb25b5c4
...
...
@@ -171,7 +171,7 @@ EDA_TextStruct::EDA_TextStruct( const wxString& text )
m_Orient
=
0
;
/* Orient in 0.1 degrees */
m_Attributs
=
0
;
m_Mirror
=
false
;
// display mirror if true
m_HJustify
=
GR_TEXT_HJUSTIFY_
CENTER
;
m_HJustify
=
GR_TEXT_HJUSTIFY_
LEFT
;
m_VJustify
=
GR_TEXT_VJUSTIFY_CENTER
;
/* Justifications Horiz et Vert du texte */
m_Width
=
0
;
/* thickness */
m_Italic
=
false
;
/* true = italic shape */
...
...
@@ -264,7 +264,6 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int
aDrawMode
,
GRFillMode
aDisplayMode
,
EDA_Colors
aAnchor_color
)
/***************************************************************/
/** Function Draw
* @param aPanel = the current DrawPanel
* @param aDC = the current Device Context
...
...
@@ -274,10 +273,30 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* @param aDisplayMode = FILAIRE, FILLED or SKETCH
* @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
*/
{
int
width
;
wxPoint
pos
=
m_Pos
;
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
for
(
int
i
=
0
;
i
<
list
->
Count
();
i
++
)
{
wxString
txt
=
list
->
Item
(
i
);
wxSize
size
=
DrawOneLine
(
aPanel
,
aDC
,
aOffset
,
aColor
,
aDrawMode
,
aDisplayMode
,
aAnchor_color
,
txt
,
pos
);
pos
.
y
+=
1.5
*
(
size
.
y
);
}
delete
(
list
);
}
width
=
m_Width
;
wxSize
EDA_TextStruct
::
DrawOneLine
(
WinEDA_DrawPanel
*
aPanel
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
EDA_Colors
aColor
,
int
aDrawMode
,
GRFillMode
aDisplayMode
,
EDA_Colors
aAnchor_color
,
wxString
txt
,
wxPoint
pos
)
{
int
width
=
m_Width
;
if
(
aDisplayMode
==
FILAIRE
)
width
=
0
;
...
...
@@ -290,8 +309,8 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int
anchor_size
=
aPanel
->
GetScreen
()
->
Unscale
(
2
);
aAnchor_color
=
(
EDA_Colors
)
(
aAnchor_color
&
MASKCOLOR
);
int
cX
=
m_P
os
.
x
+
aOffset
.
x
;
int
cY
=
m_P
os
.
y
+
aOffset
.
y
;
int
cX
=
p
os
.
x
+
aOffset
.
x
;
int
cY
=
p
os
.
y
+
aOffset
.
y
;
GRLine
(
&
aPanel
->
m_ClipBox
,
aDC
,
cX
-
anchor_size
,
cY
,
cX
+
anchor_size
,
cY
,
0
,
aAnchor_color
);
...
...
@@ -302,17 +321,21 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if
(
aDisplayMode
==
SKETCH
)
width
=
-
width
;
wxSize
size
=
m_Size
;
if
(
m_Mirror
)
size
.
x
=
-
size
.
x
;
DrawGraphicText
(
aPanel
,
aDC
,
aOffset
+
m_Pos
,
aColor
,
m_Te
xt
,
aOffset
+
pos
,
aColor
,
t
xt
,
m_Orient
,
size
,
m_HJustify
,
m_VJustify
,
width
,
m_Italic
);
return
size
;
}
/******************/
/* Class EDA_Rect */
/******************/
...
...
common/common.cpp
View file @
fb25b5c4
...
...
@@ -378,6 +378,38 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
return
Value
;
}
/**
* Function wxStringSplit
* Split a String to a String List when founding 'splitter'
* @return the list
* @param txt : wxString : a String text
* @param splitter : wxChar : the 'split' character
*/
/**********************************************************/
wxArrayString
*
wxStringSplit
(
wxString
txt
,
wxChar
splitter
)
/**********************************************************/
{
wxArrayString
*
list
=
new
wxArrayString
();
while
(
1
)
{
int
index
=
txt
.
Find
(
splitter
);
if
(
index
==
wxNOT_FOUND
)
break
;
wxString
tmp
;
tmp
=
txt
.
Mid
(
0
,
index
);
txt
=
txt
.
Mid
(
index
+
1
,
txt
.
size
()
-
index
);
list
->
Add
(
tmp
);
}
if
(
!
txt
.
IsEmpty
())
{
list
->
Add
(
txt
);
}
return
list
;
}
/******************************************************************/
double
To_User_Unit
(
bool
is_metric
,
int
val
,
int
internal_unit_value
)
...
...
common/wxwineda.cpp
View file @
fb25b5c4
...
...
@@ -12,13 +12,13 @@
/**********************************************************************************/
/* Classe WinEDA_EnterText pour entrer une ligne texte au clavier dans les frames */
/* Classe WinEDA_EnterText pour entrer une
ou plusieurs
ligne texte au clavier dans les frames */
/**********************************************************************************/
WinEDA_EnterText
::
WinEDA_EnterText
(
wxWindow
*
parent
,
const
wxString
&
Title
,
const
wxString
&
TextToEdit
,
wxBoxSizer
*
BoxSizer
,
const
wxSize
&
Size
)
const
wxSize
&
Size
,
bool
Multiline
)
{
m_Modify
=
FALSE
;
if
(
!
TextToEdit
.
IsEmpty
()
)
...
...
@@ -28,7 +28,12 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
BoxSizer
->
Add
(
m_Title
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
m_FrameText
=
new
wxTextCtrl
(
parent
,
-
1
,
TextToEdit
,
wxDefaultPosition
,
Size
);
long
style
=
0
;
if
(
Multiline
)
style
=
wxTE_MULTILINE
;
m_FrameText
=
new
wxTextCtrl
(
parent
,
-
1
,
TextToEdit
,
wxDefaultPosition
,
Size
,
style
);
m_FrameText
->
SetInsertionPoint
(
1
);
BoxSizer
->
Add
(
m_FrameText
,
...
...
eeschema/class_text-label.cpp
View file @
fb25b5c4
...
...
@@ -189,46 +189,68 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
color
=
ReturnLayerColor
(
m_Layer
);
GRSetDrawMode
(
DC
,
DrawMode
);
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
wxPoint
pos
;
int
orientation
;
GRTextHorizJustifyType
Hjustify
;
GRTextVertJustifyType
Vjustify
;
pos
=
m_Pos
+
offset
;
switch
(
m_Orient
)
{
case
0
:
/* Horiz Normal Orientation (left justified) */
DrawGraphicText
(
panel
,
DC
,
wxPoint
(
m_Pos
.
x
+
offset
.
x
,
m_Pos
.
y
-
TXTMARGE
+
offset
.
y
),
color
,
m_Text
,
TEXT_ORIENT_HORIZ
,
m_Size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_BOTTOM
,
width
,
m_Italic
,
true
);
orientation
=
TEXT_ORIENT_HORIZ
;
Hjustify
=
GR_TEXT_HJUSTIFY_LEFT
;
Vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
pos
.
y
-=
TXTMARGE
;
break
;
case
1
:
/* Vert Orientation UP */
DrawGraphicText
(
panel
,
DC
,
wxPoint
(
m_Pos
.
x
-
TXTMARGE
+
offset
.
x
,
m_Pos
.
y
+
offset
.
y
),
color
,
m_Text
,
TEXT_ORIENT_VERT
,
m_Size
,
GR_TEXT_HJUSTIFY_RIGHT
,
GR_TEXT_VJUSTIFY_BOTTOM
,
width
,
m_Italic
,
true
);
orientation
=
TEXT_ORIENT_VERT
;
Hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
Vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
pos
.
x
-=
TXTMARGE
;
break
;
case
2
:
/* Horiz Orientation - Right justified */
DrawGraphicText
(
panel
,
DC
,
wxPoint
(
m_Pos
.
x
+
offset
.
x
,
m_Pos
.
y
-
TXTMARGE
+
offset
.
y
),
color
,
m_Text
,
TEXT_ORIENT_HORIZ
,
m_Size
,
GR_TEXT_HJUSTIFY_RIGHT
,
GR_TEXT_VJUSTIFY_BOTTOM
,
width
,
m_Italic
,
true
);
orientation
=
TEXT_ORIENT_HORIZ
;
Hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
Vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
pos
.
y
-=
TXTMARGE
;
break
;
case
3
:
/* Vert Orientation BOTTOM */
DrawGraphicText
(
panel
,
DC
,
wxPoint
(
m_Pos
.
x
-
TXTMARGE
+
offset
.
x
,
m_Pos
.
y
+
offset
.
y
),
color
,
m_Text
,
TEXT_ORIENT_VERT
,
m_Size
,
GR_TEXT_HJUSTIFY_RIGHT
,
GR_TEXT_VJUSTIFY_TOP
,
width
,
m_Italic
,
true
);
orientation
=
TEXT_ORIENT_VERT
;
Hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
Vjustify
=
GR_TEXT_VJUSTIFY_TOP
;
pos
.
x
-=
TXTMARGE
;
break
;
}
for
(
int
i
=
0
;
i
<
list
->
Count
();
i
++
)
{
wxString
txt
=
list
->
Item
(
i
);
DrawGraphicText
(
panel
,
DC
,
pos
,
color
,
txt
,
orientation
,
m_Size
,
Hjustify
,
Vjustify
,
width
,
m_Italic
,
true
);
if
(
orientation
==
TEXT_ORIENT_HORIZ
)
pos
.
y
+=
1.5
*
(
m_Size
.
y
);
else
pos
.
x
+=
1.5
*
(
m_Size
.
x
);
}
delete
(
list
);
if
(
m_IsDangling
)
DrawDanglingSymbol
(
panel
,
DC
,
m_Pos
+
offset
,
color
);
}
...
...
eeschema/dialog_edit_label.cpp
View file @
fb25b5c4
...
...
@@ -21,8 +21,22 @@
int
DialogLabelEditor
::
ShowModally
(
WinEDA_SchematicFrame
*
parent
,
SCH_TEXT
*
CurrentText
)
{
int
ret
;
bool
multiline
;
DialogLabelEditor
*
dialog
=
new
DialogLabelEditor
(
parent
,
CurrentText
);
switch
(
CurrentText
->
Type
()
)
{
case
TYPE_SCH_GLOBALLABEL
:
case
TYPE_SCH_HIERLABEL
:
case
TYPE_SCH_LABEL
:
multiline
=
false
;
break
;
default
:
multiline
=
true
;
break
;
}
DialogLabelEditor
*
dialog
=
new
DialogLabelEditor
(
parent
,
CurrentText
,
multiline
);
// doing any post construction resizing is better done here than in
// OnInitDialog() since it tends to flash/redraw the dialog less.
...
...
@@ -35,8 +49,8 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C
DialogLabelEditor
::
DialogLabelEditor
(
WinEDA_SchematicFrame
*
parent
,
SCH_TEXT
*
CurrentText
)
:
DialogLabelEditor_Base
(
parent
)
DialogLabelEditor
::
DialogLabelEditor
(
WinEDA_SchematicFrame
*
parent
,
SCH_TEXT
*
CurrentText
,
bool
multiline
)
:
DialogLabelEditor_Base
(
parent
,
wxID_ANY
,
multiline
)
{
m_Parent
=
parent
;
m_CurrentText
=
CurrentText
;
...
...
@@ -67,6 +81,7 @@ void DialogLabelEditor::init()
default
:
SetTitle
(
_
(
"Text Properties"
)
);
m_TextLabel
->
Disconnect
(
wxEVT_COMMAND_TEXT_ENTER
,
wxCommandEventHandler
(
DialogLabelEditor
::
onEnterKey
),
NULL
,
this
);
break
;
}
...
...
@@ -111,6 +126,14 @@ void DialogLabelEditor::init()
}
}
/*!
* wxTE_PROCESS_ENTER event handler for m_TextLabel
*/
void
DialogLabelEditor
::
onEnterKey
(
wxCommandEvent
&
event
)
{
TextPropertiesAccept
(
event
);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
...
...
@@ -132,12 +155,3 @@ void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event )
EndModal
(
-
1
);
}
/*!
* wxTE_PROCESS_ENTER event handler for m_TextLabel
*/
void
DialogLabelEditor
::
onEnterKey
(
wxCommandEvent
&
event
)
{
TextPropertiesAccept
(
event
);
}
eeschema/dialog_edit_label.h
View file @
fb25b5c4
...
...
@@ -18,7 +18,7 @@ private:
protected
:
// these are protected so that the static ShowModally() gets used.
DialogLabelEditor
(
WinEDA_SchematicFrame
*
parent
,
SCH_TEXT
*
CurrentText
);
DialogLabelEditor
(
WinEDA_SchematicFrame
*
parent
,
SCH_TEXT
*
CurrentText
,
bool
multiline
);
~
DialogLabelEditor
(){};
...
...
eeschema/dialog_edit_label_base.cpp
View file @
fb25b5c4
...
...
@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
DialogLabelEditor_Base
::
DialogLabelEditor_Base
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxString
&
title
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
long
style
)
:
wxDialog
(
parent
,
id
,
title
,
pos
,
size
,
style
)
DialogLabelEditor_Base
::
DialogLabelEditor_Base
(
wxWindow
*
parent
,
wxWindowID
id
,
bool
multiline
,
const
wxString
&
title
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
long
style
)
:
wxDialog
(
parent
,
id
,
title
,
pos
,
size
,
style
)
{
this
->
SetSizeHints
(
wxDefaultSize
,
wxDefaultSize
);
...
...
@@ -23,7 +23,14 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
m_staticText1
->
Wrap
(
-
1
);
bSizer2
->
Add
(
m_staticText1
,
0
,
wxTOP
|
wxRIGHT
|
wxLEFT
,
5
);
if
(
multiline
)
{
m_TextLabel
=
new
wxTextCtrl
(
this
,
wxID_VALUE
,
wxEmptyString
,
wxDefaultPosition
,
wxDefaultSize
,
wxTE_PROCESS_ENTER
|
wxTE_MULTILINE
);
}
else
{
m_TextLabel
=
new
wxTextCtrl
(
this
,
wxID_VALUE
,
wxEmptyString
,
wxDefaultPosition
,
wxDefaultSize
,
wxTE_PROCESS_ENTER
);
}
m_TextLabel
->
SetToolTip
(
_
(
"Enter the text to be used within the schematic"
)
);
bSizer2
->
Add
(
m_TextLabel
,
0
,
wxBOTTOM
|
wxRIGHT
|
wxLEFT
|
wxEXPAND
,
5
);
...
...
eeschema/dialog_edit_label_base.h
View file @
fb25b5c4
...
...
@@ -56,7 +56,7 @@ class DialogLabelEditor_Base : public wxDialog
public
:
DialogLabelEditor_Base
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxString
&
title
=
_
(
"Text Editor"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
600
,
300
),
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
DialogLabelEditor_Base
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
bool
multiline
=
false
,
const
wxString
&
title
=
_
(
"Text Editor"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
600
,
300
),
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
~
DialogLabelEditor_Base
();
};
...
...
include/base_struct.h
View file @
fb25b5c4
...
...
@@ -527,6 +527,10 @@ public:
int
aDisplayMode
,
GRFillMode
aDisplay_mode
=
FILAIRE
,
EDA_Colors
aAnchor_color
=
UNSPECIFIED_COLOR
);
wxSize
DrawOneLine
(
WinEDA_DrawPanel
*
aPanel
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
EDA_Colors
aColor
,
int
aDisplayMode
,
GRFillMode
aDisplay_mode
=
FILAIRE
,
EDA_Colors
aAnchor_color
=
UNSPECIFIED_COLOR
,
wxString
txt
=
wxString
(),
wxPoint
pos
=
wxPoint
(
0
,
0
)
);
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
...
...
include/common.h
View file @
fb25b5c4
...
...
@@ -351,6 +351,11 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value,
int
ReturnValueFromTextCtrl
(
const
wxTextCtrl
&
TextCtr
,
int
Internal_Unit
);
/* return a String List from a string, whith a specific splitter*/
//WX_DECLARE_LIST( wxString, StringList );
//WX_DEFINE_LIST( StringList );
wxArrayString
*
wxStringSplit
(
wxString
txt
,
wxChar
splitter
);
/**
* Function To_User_Unit
* Convert in inch or mm the variable "val" (double)given in internal units
...
...
include/wxstruct.h
View file @
fb25b5c4
...
...
@@ -398,7 +398,7 @@ public:
// Constructor and destructor
WinEDA_EnterText
(
wxWindow
*
parent
,
const
wxString
&
Title
,
const
wxString
&
TextToEdit
,
wxBoxSizer
*
BoxSizer
,
const
wxSize
&
Size
);
const
wxSize
&
Size
,
bool
Multiline
=
false
);
~
WinEDA_EnterText
()
{
...
...
pcbnew/dialog_pcb_text_properties.cpp
View file @
fb25b5c4
...
...
@@ -107,7 +107,7 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p
m_Name
=
new
WinEDA_EnterText
(
this
,
_
(
"Text:"
),
TextPCB
->
m_Text
,
LeftBoxSizer
,
wxSize
(
200
,
-
1
)
);
LeftBoxSizer
,
wxSize
(
200
,
60
),
true
);
m_Name
->
SetFocus
();
m_Name
->
SetSelection
(
-
1
,
-
1
);
...
...
@@ -232,7 +232,7 @@ void WinEDA_TextPCBPropertiesFrame::OnOkClick( wxCommandEvent& event )
CurrentTextPCB
->
SetLayer
(
m_SelLayerBox
->
GetChoice
()
);
CurrentTextPCB
->
m_Italic
=
m_Style
->
GetSelection
()
?
1
:
0
;
if
(
m_DC
)
// Displ
ya
new text
if
(
m_DC
)
// Displ
ay
new text
{
CurrentTextPCB
->
Draw
(
m_Parent
->
DrawPanel
,
m_DC
,
GR_OR
);
}
...
...
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