File: dialog_edit_label.cpp

package info (click to toggle)
kicad 0.0.20060829-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 56,544 kB
  • ctags: 9,194
  • sloc: cpp: 88,990; ansic: 4,790; makefile: 88; sh: 39
file content (257 lines) | stat: -rw-r--r-- 7,669 bytes parent folder | download
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_edit_label.cpp
// Purpose:     
// Author:      jean-pierre Charras
// Modified by: 
// Created:     19/02/2006 15:46:26
// RCS-ID:      
// Copyright:   License GNU
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// Generated by DialogBlocks (unregistered), 19/02/2006 15:46:26

/* This is the dialog box for labels, glob. labels and graphic texts edition */

////@begin includes
////@end includes

#include "dialog_edit_label.h"

////@begin XPM images
////@end XPM images

/*!
 * WinEDA_LabelPropertiesFrame type definition
 */

IMPLEMENT_DYNAMIC_CLASS( WinEDA_LabelPropertiesFrame, wxDialog )

/*!
 * WinEDA_LabelPropertiesFrame event table definition
 */

BEGIN_EVENT_TABLE( WinEDA_LabelPropertiesFrame, wxDialog )

////@begin WinEDA_LabelPropertiesFrame event table entries
    EVT_CLOSE( WinEDA_LabelPropertiesFrame::OnCloseWindow )

    EVT_BUTTON( wxID_OK, WinEDA_LabelPropertiesFrame::OnOkClick )

    EVT_BUTTON( wxID_CLOSE, WinEDA_LabelPropertiesFrame::OnCloseClick )

////@end WinEDA_LabelPropertiesFrame event table entries

END_EVENT_TABLE()

/*!
 * WinEDA_LabelPropertiesFrame constructors
 */

WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( )
{
}

WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent,
		DrawTextStruct * CurrentText,
		const wxPoint& pos,
		wxWindowID id, const wxString& caption, const wxSize& size, long style )
{
wxString msg;
	
	m_Parent = parent;
	m_CurrentText = CurrentText;
    Create(parent, id, caption, pos, size, style);
	m_TextLabel->SetValue(m_CurrentText->m_Text);
	m_TextLabel->SetFocus();
	switch( m_CurrentText->m_StructType )
	{
		case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
			SetTitle(_("Global Label properties"));
			break;

		case DRAW_LABEL_STRUCT_TYPE:
			SetTitle(_("Label properties"));
 			break;

		default:
			SetTitle(_("Text properties"));
			break;
	}
	
    
	msg = m_SizeTitle->GetLabel() + ReturnUnitSymbol();
	m_SizeTitle->SetLabel(msg);
	
	msg = ReturnStringFromValue(g_UnitMetric, m_CurrentText->m_Size.x, m_Parent->m_InternalUnits);
	m_TextSize->SetValue(msg);
}

/*!
 * WinEDA_LabelPropertiesFrame creator
 */

bool WinEDA_LabelPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_LabelPropertiesFrame member initialisation
    m_TextLabel = NULL;
    m_TextOrient = NULL;
    m_TextShape = NULL;
    m_SizeTitle = NULL;
    m_TextSize = NULL;
////@end WinEDA_LabelPropertiesFrame member initialisation

////@begin WinEDA_LabelPropertiesFrame creation
    SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    GetSizer()->Fit(this);
    GetSizer()->SetSizeHints(this);
    Centre();
////@end WinEDA_LabelPropertiesFrame creation
    return true;
}

/*!
 * Control creation for WinEDA_LabelPropertiesFrame
 */

void WinEDA_LabelPropertiesFrame::CreateControls()
{    
	SetFont(*g_DialogFont);
////@begin WinEDA_LabelPropertiesFrame content construction
    // Generated by DialogBlocks, 19/02/2006 16:49:06 (unregistered)

    WinEDA_LabelPropertiesFrame* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);

    wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Text "), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_TextLabel = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(250, -1), 0 );
    itemBoxSizer3->Add(m_TextLabel, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);

    wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer3->Add(itemBoxSizer6, 0, wxGROW|wxALL, 5);

    wxString m_TextOrientStrings[] = {
        _("Right"),
        _("Up"),
        _("Left"),
        _("Down")
    };
    m_TextOrient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Text Orient:"), wxDefaultPosition, wxDefaultSize, 4, m_TextOrientStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer6->Add(m_TextOrient, 0, wxALIGN_TOP|wxALL, 5);

    itemBoxSizer6->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxString m_TextShapeStrings[] = {
        _("Input"),
        _("Output"),
        _("Bidi"),
        _("TriState"),
        _("Passive")
    };
    m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, 5, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS );
    m_TextShape->Show(false);
    itemBoxSizer6->Add(m_TextShape, 0, wxALIGN_TOP|wxALL, 5);

    wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW|wxALL, 5);

    m_SizeTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Size "), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer10->Add(m_SizeTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_TextSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer10->Add(m_TextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);

    itemBoxSizer10->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton14 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton14->SetDefault();
    itemButton14->SetForegroundColour(wxColour(204, 0, 0));
    itemBoxSizer10->Add(itemButton14, 0, wxGROW|wxALL, 5);

    wxButton* itemButton15 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton15->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer10->Add(itemButton15, 0, wxGROW|wxALL, 5);

    // Set validators
    m_TextOrient->SetValidator( wxGenericValidator(& m_CurrentText->m_Orient) );
    m_TextShape->SetValidator( wxGenericValidator(& m_CurrentText->m_Shape) );
////@end WinEDA_LabelPropertiesFrame content construction

    if (m_CurrentText->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE )
        m_TextShape->Show(true);
}

/*!
 * Should we show tooltips?
 */

bool WinEDA_LabelPropertiesFrame::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap WinEDA_LabelPropertiesFrame::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin WinEDA_LabelPropertiesFrame bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end WinEDA_LabelPropertiesFrame bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon WinEDA_LabelPropertiesFrame::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin WinEDA_LabelPropertiesFrame icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end WinEDA_LabelPropertiesFrame icon retrieval
}
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void WinEDA_LabelPropertiesFrame::OnOkClick( wxCommandEvent& event )
{
   TextPropertiesAccept(event);
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
 */

void WinEDA_LabelPropertiesFrame::OnCloseClick( wxCommandEvent& event )
{
    Close();
}


/*!
 * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
 */

void WinEDA_LabelPropertiesFrame::OnCloseWindow( wxCloseEvent& event )
{
	m_Parent->DrawPanel->MouseToCursorSchema();
    event.Skip();
}