1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/***************************************************************************/
/* Dialog editor for text on copper and technical layers (TEXTE_PCB class) */
/***************************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "pcbnew.h"
enum id_TextPCB_properties {
ID_TEXTPCB_SELECT_LAYER = 1900
};
/************************************/
/* class WinEDA_TextPCBPropertiesFrame */
/************************************/
class WinEDA_TextPCBPropertiesFrame : public wxDialog
{
private:
WinEDA_PcbFrame* m_Parent;
wxDC* m_DC;
TEXTE_PCB* CurrentTextPCB;
WinEDA_EnterText* m_Name;
WinEDA_PositionCtrl* m_TxtPosCtrl;
WinEDA_SizeCtrl* m_TxtSizeCtrl;
WinEDA_ValueCtrl* m_TxtWidthCtlr;
wxRadioBox* m_Orient;
wxRadioBox* m_Mirror;
wxRadioBox* m_Style;
WinEDAChoiceBox* m_SelLayerBox;
public:
// Constructor and destructor
WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* parent,
TEXTE_PCB* TextPCB, wxDC* DC );
~WinEDA_TextPCBPropertiesFrame()
{
}
private:
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( WinEDA_TextPCBPropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_TextPCBPropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_TextPCBPropertiesFrame::OnCancelClick )
END_EVENT_TABLE()
/******************************************************************************/
void WinEDA_PcbFrame::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
/*******************************************************************************/
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_TextPCBPropertiesFrame* frame = new WinEDA_TextPCBPropertiesFrame( this, TextPCB, DC );
frame->ShowModal();
frame->Destroy();
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
}
/************************************************************************************/
WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* parent,
TEXTE_PCB* TextPCB, wxDC* DC ) :
wxDialog( parent, -1, _( "TextPCB properties" ), wxDefaultPosition, wxSize( 390, 340 ) )
/************************************************************************************/
{
wxButton* Button;
BOARD* board = parent->GetBoard();
m_Parent = parent;
SetFont( *g_DialogFont );
m_DC = DC;
Centre();
CurrentTextPCB = TextPCB;
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MiddleBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( MiddleBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
/* Creation des boutons de commande */
Button = new wxButton( this, wxID_OK, _( "OK" ) );
Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button->SetDefault();
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
m_Name = new WinEDA_EnterText( this, _( "Text:" ),
TextPCB->m_Text,
LeftBoxSizer, wxSize( 200, -1 ) );
m_Name->SetFocus();
m_Name->SetSelection( -1, -1 );
m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
TextPCB->m_Size,
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
m_TxtWidthCtlr = new WinEDA_ValueCtrl( this, _( "Width" ),
TextPCB->m_Width,
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
m_TxtPosCtrl = new WinEDA_PositionCtrl( this, _( "Position" ),
TextPCB->m_Pos,
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER,
wxDefaultPosition, wxDefaultSize );
MiddleBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxALL, 5 );
for( int layer=0; layer<NB_LAYERS; ++layer )
{
m_SelLayerBox->Append( board->GetLayerName( layer ) );
}
m_SelLayerBox->SetSelection( TextPCB->GetLayer() );
static const wxString orient_msg[4] = {
wxT( "0" ), wxT( "90" ), wxT( "180" ), wxT( "-90" ) };
m_Orient = new wxRadioBox( this, -1, _( "Orientation" ),
wxDefaultPosition, wxSize( -1, -1 ), 4, orient_msg,
1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add( m_Orient, 0, wxGROW | wxALL, 5 );
switch( TextPCB->m_Orient )
{
default:
m_Orient->SetSelection( 0 );
break;
case 900:
m_Orient->SetSelection( 1 );
break;
case 1800:
m_Orient->SetSelection( 2 );
break;
case 2700:
m_Orient->SetSelection( 3 );
break;
}
wxString display_msg[2] = { _( "Normal" ), _( "Mirror" ) };
m_Mirror = new wxRadioBox( this, -1, _( "Display" ),
wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg,
1, wxRA_SPECIFY_COLS );
if( TextPCB->m_Mirror )
m_Mirror->SetSelection( 1 );
MiddleBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 );
int style = 0;
if (CurrentTextPCB->m_Italic )
style = 1;
wxString style_msg[] = { _( "Normal" ), _( "Italic" ) };
m_Style = new wxRadioBox( this, -1, _( "Style" ),
wxDefaultPosition, wxSize( -1, -1 ), 2, style_msg,
1, wxRA_SPECIFY_COLS );
m_Style->SetSelection(style);
MiddleBoxSizer->Add( m_Style, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
}
/**********************************************************************/
void WinEDA_TextPCBPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
EndModal( -1 );
}
/**************************************************************************************/
void WinEDA_TextPCBPropertiesFrame::OnOkClick( wxCommandEvent& event )
/**************************************************************************************/
{
// test for acceptable values for parameters:
wxSize newsize = m_TxtSizeCtrl->GetValue();
if ( newsize.x < TEXTS_MIN_SIZE )
newsize.x = TEXTS_MIN_SIZE;
if ( newsize.y < TEXTS_MIN_SIZE )
newsize.y = TEXTS_MIN_SIZE;
if ( newsize.x > TEXTS_MAX_WIDTH )
newsize.x = TEXTS_MAX_WIDTH;
if ( newsize.y > TEXTS_MAX_WIDTH )
newsize.y = TEXTS_MAX_WIDTH;
if( m_DC ) // Erase old text on screen
{
CurrentTextPCB->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
}
if( !m_Name->GetValue().IsEmpty() )
{
CurrentTextPCB->m_Text = m_Name->GetValue();
}
CurrentTextPCB->m_Pos = m_TxtPosCtrl->GetValue();
CurrentTextPCB->m_Size = newsize;
CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue();
// test for acceptable values for parameters:
int max_tickness = min( CurrentTextPCB->m_Size.x, CurrentTextPCB->m_Size.y);
max_tickness /= 4;
if ( CurrentTextPCB->m_Width > max_tickness)
CurrentTextPCB->m_Width = max_tickness;
CurrentTextPCB->m_Mirror = (m_Mirror->GetSelection() == 1) ? true : false;
CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900;
CurrentTextPCB->SetLayer( m_SelLayerBox->GetChoice() );
CurrentTextPCB->m_Italic = m_Style->GetSelection() ? 1 : 0;
if( m_DC ) // Displya new text
{
CurrentTextPCB->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
}
m_Parent->GetScreen()->SetModify();
EndModal( 1 );
}