Added checking of EnableEffects flag and not allowing changes to color or underlining...
[wxWidgets.git] / src / generic / fontdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/fontdlgg.cpp
3 // Purpose: Generic font dialog
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "fontdlgg.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #if wxUSE_FONTDLG && (!defined(__WXGTK__) || defined(__WXGPE__) || defined(__WXUNIVERSAL__))
24
25 #ifndef WX_PRECOMP
26 #include <stdio.h>
27 #include "wx/utils.h"
28 #include "wx/dialog.h"
29 #include "wx/listbox.h"
30 #include "wx/button.h"
31 #include "wx/stattext.h"
32 #include "wx/layout.h"
33 #include "wx/dcclient.h"
34 #include "wx/choice.h"
35 #include "wx/checkbox.h"
36 #include "wx/intl.h"
37 #endif
38
39 #include <string.h>
40 #include <stdlib.h>
41
42 #include "wx/cmndata.h"
43 #include "wx/sizer.h"
44 #include "wx/fontdlg.h"
45 #include "wx/generic/fontdlgg.h"
46 #include "wx/settings.h"
47
48 //-----------------------------------------------------------------------------
49 // helper class - wxFontPreviewer
50 //-----------------------------------------------------------------------------
51
52 class WXDLLEXPORT wxFontPreviewer : public wxWindow
53 {
54 public:
55 wxFontPreviewer(wxWindow *parent) : wxWindow(parent, wxID_ANY) {}
56
57 private:
58 void OnPaint(wxPaintEvent& event);
59 DECLARE_EVENT_TABLE()
60 };
61
62 BEGIN_EVENT_TABLE(wxFontPreviewer, wxWindow)
63 EVT_PAINT(wxFontPreviewer::OnPaint)
64 END_EVENT_TABLE()
65
66 void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event))
67 {
68 wxPaintDC dc(this);
69
70 wxSize size = GetSize();
71 wxFont font = GetFont();
72
73 dc.SetPen(*wxBLACK_PEN);
74 dc.SetBrush(*wxWHITE_BRUSH);
75 dc.DrawRectangle(0, 0, size.x, size.y);
76
77 if ( font.Ok() )
78 {
79 dc.SetFont(font);
80 // Calculate vertical centre
81 long w, h;
82 dc.GetTextExtent( wxT("X"), &w, &h);
83 dc.SetTextForeground(GetForegroundColour());
84 dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
85 dc.DrawText(_("ABCDEFGabcdefg12345"),
86 10, size.y/2 - h/2);
87 dc.DestroyClippingRegion();
88 }
89 }
90
91 //-----------------------------------------------------------------------------
92 // wxGenericFontDialog
93 //-----------------------------------------------------------------------------
94
95 IMPLEMENT_DYNAMIC_CLASS(wxGenericFontDialog, wxDialog)
96
97 BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog)
98 EVT_CHECKBOX(wxID_FONT_UNDERLINE, wxGenericFontDialog::OnChangeFont)
99 EVT_CHOICE(wxID_FONT_STYLE, wxGenericFontDialog::OnChangeFont)
100 EVT_CHOICE(wxID_FONT_WEIGHT, wxGenericFontDialog::OnChangeFont)
101 EVT_CHOICE(wxID_FONT_FAMILY, wxGenericFontDialog::OnChangeFont)
102 EVT_CHOICE(wxID_FONT_COLOUR, wxGenericFontDialog::OnChangeFont)
103 EVT_CHOICE(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont)
104 EVT_CLOSE(wxGenericFontDialog::OnCloseWindow)
105 END_EVENT_TABLE()
106
107
108 #define NUM_COLS 48
109 static wxString wxColourDialogNames[NUM_COLS]={wxT("ORANGE"),
110 wxT("GOLDENROD"),
111 wxT("WHEAT"),
112 wxT("SPRING GREEN"),
113 wxT("SKY BLUE"),
114 wxT("SLATE BLUE"),
115 wxT("MEDIUM VIOLET RED"),
116 wxT("PURPLE"),
117
118 wxT("RED"),
119 wxT("YELLOW"),
120 wxT("MEDIUM SPRING GREEN"),
121 wxT("PALE GREEN"),
122 wxT("CYAN"),
123 wxT("LIGHT STEEL BLUE"),
124 wxT("ORCHID"),
125 wxT("LIGHT MAGENTA"),
126
127 wxT("BROWN"),
128 wxT("YELLOW"),
129 wxT("GREEN"),
130 wxT("CADET BLUE"),
131 wxT("MEDIUM BLUE"),
132 wxT("MAGENTA"),
133 wxT("MAROON"),
134 wxT("ORANGE RED"),
135
136 wxT("FIREBRICK"),
137 wxT("CORAL"),
138 wxT("FOREST GREEN"),
139 wxT("AQUARAMINE"),
140 wxT("BLUE"),
141 wxT("NAVY"),
142 wxT("THISTLE"),
143 wxT("MEDIUM VIOLET RED"),
144
145 wxT("INDIAN RED"),
146 wxT("GOLD"),
147 wxT("MEDIUM SEA GREEN"),
148 wxT("MEDIUM BLUE"),
149 wxT("MIDNIGHT BLUE"),
150 wxT("GREY"),
151 wxT("PURPLE"),
152 wxT("KHAKI"),
153
154 wxT("BLACK"),
155 wxT("MEDIUM FOREST GREEN"),
156 wxT("KHAKI"),
157 wxT("DARK GREY"),
158 wxT("SEA GREEN"),
159 wxT("LIGHT GREY"),
160 wxT("MEDIUM SLATE BLUE"),
161 wxT("WHITE")
162 };
163
164 /*
165 * Generic wxFontDialog
166 */
167
168 void wxGenericFontDialog::Init()
169 {
170 m_useEvents = false;
171 m_previewer = NULL;
172 Create( m_parent ) ;
173 }
174
175 wxGenericFontDialog::~wxGenericFontDialog()
176 {
177 }
178
179 void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
180 {
181 EndModal(wxID_CANCEL);
182 }
183
184 bool wxGenericFontDialog::DoCreate(wxWindow *parent)
185 {
186 if ( !wxDialog::Create( parent , wxID_ANY , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
187 _T("fontdialog") ) )
188 {
189 wxFAIL_MSG( wxT("wxFontDialog creation failed") );
190 return false;
191 }
192
193 InitializeFont();
194 CreateWidgets();
195
196 // sets initial font in preview area
197 wxCommandEvent dummy;
198 OnChangeFont(dummy);
199
200 return true;
201 }
202
203 int wxGenericFontDialog::ShowModal()
204 {
205 int ret = wxDialog::ShowModal();
206
207 if (ret != wxID_CANCEL)
208 {
209 m_fontData.m_chosenFont = dialogFont;
210 }
211
212 return ret;
213 }
214
215 // This should be application-settable
216 static bool ShowToolTips() { return false; }
217
218 void wxGenericFontDialog::CreateWidgets()
219 {
220 wxString
221 *families = new wxString[6],
222 *styles = new wxString[3],
223 *weights = new wxString[3];
224 families[0] = _("Roman");
225 families[1] = _("Decorative");
226 families[2] = _("Modern");
227 families[3] = _("Script");
228 families[4] = _("Swiss" );
229 families[5] = _("Teletype" );
230 styles[0] = _("Normal");
231 styles[1] = _("Italic");
232 styles[2] = _("Slant");
233 weights[0] = _("Normal");
234 weights[1] = _("Light");
235 weights[2] = _("Bold");
236
237 wxString *pointSizes = new wxString[40];
238 int i;
239 for ( i = 0; i < 40; i++)
240 {
241 wxChar buf[5];
242 wxSprintf(buf, wxT("%d"), i + 1);
243 pointSizes[i] = buf;
244 }
245
246 // layout
247
248 bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
249 int noCols, noRows;
250 if (is_pda)
251 {
252 noCols = 2; noRows = 3;
253 }
254 else
255 {
256 noCols = 3; noRows = 2;
257 }
258
259 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
260 this->SetSizer(itemBoxSizer2);
261 this->SetAutoLayout(TRUE);
262
263 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
264 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
265
266 wxFlexGridSizer* itemGridSizer4 = new wxFlexGridSizer(noRows, noCols, 0, 0);
267 itemBoxSizer3->Add(itemGridSizer4, 0, wxGROW, 5);
268
269 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
270 itemGridSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
271 wxStaticText* itemStaticText6 = new wxStaticText( this, wxID_STATIC, _("&Font family:"), wxDefaultPosition, wxDefaultSize, 0 );
272 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
273
274 wxChoice* itemChoice7 = new wxChoice( this, wxID_FONT_FAMILY, wxDefaultPosition, wxDefaultSize, 5, families, 0 );
275 itemChoice7->SetHelpText(_("The font family."));
276 if (ShowToolTips())
277 itemChoice7->SetToolTip(_("The font family."));
278 itemBoxSizer5->Add(itemChoice7, 0, wxALIGN_LEFT|wxALL, 5);
279
280 wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
281 itemGridSizer4->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
282 wxStaticText* itemStaticText9 = new wxStaticText( this, wxID_STATIC, _("&Style:"), wxDefaultPosition, wxDefaultSize, 0 );
283 itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
284
285 wxChoice* itemChoice10 = new wxChoice( this, wxID_FONT_STYLE, wxDefaultPosition, wxDefaultSize, 3, styles, 0 );
286 itemChoice10->SetHelpText(_("The font style."));
287 if (ShowToolTips())
288 itemChoice10->SetToolTip(_("The font style."));
289 itemBoxSizer8->Add(itemChoice10, 0, wxALIGN_LEFT|wxALL, 5);
290
291 wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
292 itemGridSizer4->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
293 wxStaticText* itemStaticText12 = new wxStaticText( this, wxID_STATIC, _("&Weight:"), wxDefaultPosition, wxDefaultSize, 0 );
294 itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
295
296 wxChoice* itemChoice13 = new wxChoice( this, wxID_FONT_WEIGHT, wxDefaultPosition, wxDefaultSize, 3, weights, 0 );
297 itemChoice13->SetHelpText(_("The font weight."));
298 if (ShowToolTips())
299 itemChoice13->SetToolTip(_("The font weight."));
300 itemBoxSizer11->Add(itemChoice13, 0, wxALIGN_LEFT|wxALL, 5);
301
302 wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL);
303 itemGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
304 if (m_fontData.GetEnableEffects())
305 {
306 wxStaticText* itemStaticText15 = new wxStaticText( this, wxID_STATIC, _("C&olour:"), wxDefaultPosition, wxDefaultSize, 0 );
307 itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
308
309 wxChoice* itemChoice16 = new wxChoice( this, wxID_FONT_COLOUR, wxDefaultPosition, wxDefaultSize, NUM_COLS, wxColourDialogNames, 0 );
310 itemChoice16->SetHelpText(_("The font colour."));
311 if (ShowToolTips())
312 itemChoice16->SetToolTip(_("The font colour."));
313 itemBoxSizer14->Add(itemChoice16, 0, wxALIGN_LEFT|wxALL, 5);
314 }
315
316 wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
317 itemGridSizer4->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
318 wxStaticText* itemStaticText18 = new wxStaticText( this, wxID_STATIC, _("&Point size:"), wxDefaultPosition, wxDefaultSize, 0 );
319 itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
320
321 wxChoice* itemChoice19 = new wxChoice( this, wxID_FONT_SIZE, wxDefaultPosition, wxDefaultSize, 40, pointSizes, 0 );
322 itemChoice19->SetHelpText(_("The font point size."));
323 if (ShowToolTips())
324 itemChoice19->SetToolTip(_("The font point size."));
325 itemBoxSizer17->Add(itemChoice19, 0, wxALIGN_LEFT|wxALL, 5);
326
327 if (m_fontData.GetEnableEffects())
328 {
329 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL);
330 itemGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
331 wxCheckBox* itemCheckBox21 = new wxCheckBox( this, wxID_FONT_UNDERLINE, _("&Underline"), wxDefaultPosition, wxDefaultSize, 0 );
332 itemCheckBox21->SetValue(FALSE);
333 itemCheckBox21->SetHelpText(_("Whether the font is underlined."));
334 if (ShowToolTips())
335 itemCheckBox21->SetToolTip(_("Whether the font is underlined."));
336 itemBoxSizer20->Add(itemCheckBox21, 0, wxALIGN_LEFT|wxALL, 5);
337 }
338
339 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
340
341 wxStaticText* itemStaticText23 = new wxStaticText( this, wxID_STATIC, _("Preview:"), wxDefaultPosition, wxDefaultSize, 0 );
342 itemBoxSizer3->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
343
344 wxFontPreviewer* itemWindow24 = new wxFontPreviewer( this );
345 m_previewer = itemWindow24;
346 itemWindow24->SetHelpText(_("Shows the font preview."));
347 if (ShowToolTips())
348 itemWindow24->SetToolTip(_("Shows the font preview."));
349 itemBoxSizer3->Add(itemWindow24, 0, wxGROW|wxALL, 5);
350
351 wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
352 itemBoxSizer3->Add(itemBoxSizer25, 0, wxGROW, 5);
353 itemBoxSizer25->Add(5, 5, 1, wxGROW|wxALL, 5);
354
355 #ifdef __WXMAC__
356 wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
357 if (ShowToolTips())
358 itemButton28->SetToolTip(_("Click to cancel the font selection."));
359 itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
360
361 wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
362 itemButton27->SetDefault();
363 itemButton27->SetHelpText(_("Click to confirm the font selection."));
364 if (ShowToolTips())
365 itemButton27->SetToolTip(_("Click to confirm the font selection."));
366 itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
367 #else
368 wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
369 itemButton27->SetDefault();
370 itemButton27->SetHelpText(_("Click to confirm the font selection."));
371 if (ShowToolTips())
372 itemButton27->SetToolTip(_("Click to confirm the font selection."));
373 itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
374
375 wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
376 if (ShowToolTips())
377 itemButton28->SetToolTip(_("Click to cancel the font selection."));
378 itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
379 #endif
380
381 familyChoice = (wxChoice*) FindWindow(wxID_FONT_FAMILY);
382 styleChoice = (wxChoice*) FindWindow(wxID_FONT_STYLE);
383 weightChoice = (wxChoice*) FindWindow(wxID_FONT_WEIGHT);
384 colourChoice = (wxChoice*) FindWindow(wxID_FONT_COLOUR);
385 pointSizeChoice = (wxChoice*) FindWindow(wxID_FONT_SIZE);
386 underLineCheckBox = (wxCheckBox*) FindWindow(wxID_FONT_UNDERLINE);
387
388 familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) );
389 styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));
390 weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight()));
391
392 if (colourChoice)
393 {
394 wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour()));
395 if (name.length())
396 colourChoice->SetStringSelection(name);
397 else
398 colourChoice->SetStringSelection(wxT("BLACK"));
399 }
400
401 if (underLineCheckBox)
402 {
403 underLineCheckBox->SetValue(dialogFont.GetUnderlined());
404 }
405
406 pointSizeChoice->SetSelection(dialogFont.GetPointSize()-1);
407
408 GetSizer()->SetItemMinSize(m_previewer, 430, 100);
409 GetSizer()->SetSizeHints(this);
410 GetSizer()->Fit(this);
411
412 Centre(wxBOTH);
413
414 delete[] families;
415 delete[] styles;
416 delete[] weights;
417 delete[] pointSizes;
418
419 // Don't block events any more
420 m_useEvents = true;
421
422 }
423
424 void wxGenericFontDialog::InitializeFont()
425 {
426 int fontFamily = wxSWISS;
427 int fontWeight = wxNORMAL;
428 int fontStyle = wxNORMAL;
429 int fontSize = 12;
430 bool fontUnderline = false;
431
432 if (m_fontData.m_initialFont.Ok())
433 {
434 fontFamily = m_fontData.m_initialFont.GetFamily();
435 fontWeight = m_fontData.m_initialFont.GetWeight();
436 fontStyle = m_fontData.m_initialFont.GetStyle();
437 fontSize = m_fontData.m_initialFont.GetPointSize();
438 fontUnderline = m_fontData.m_initialFont.GetUnderlined();
439 }
440
441 dialogFont = wxFont(fontSize, fontFamily, fontStyle,
442 fontWeight, fontUnderline);
443
444 if (m_previewer)
445 m_previewer->SetFont(dialogFont);
446 }
447
448 void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event))
449 {
450 if (!m_useEvents) return;
451
452 int fontFamily = wxFontFamilyStringToInt(WXSTRINGCAST familyChoice->GetStringSelection());
453 int fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection());
454 int fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection());
455 int fontSize = wxAtoi(pointSizeChoice->GetStringSelection());
456 // Start with previous underline setting, we want to retain it even if we can't edit it
457 // dialogFont is always initialized because of the call to InitializeFont
458 int fontUnderline = dialogFont.GetUnderlined();
459
460 if (underLineCheckBox)
461 {
462 fontUnderline = underLineCheckBox->GetValue();
463 }
464
465 dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
466 m_previewer->SetFont(dialogFont);
467
468 if ( colourChoice )
469 {
470 if ( !colourChoice->GetStringSelection().empty() )
471 {
472 wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection());
473 if (col.Ok())
474 {
475 m_fontData.m_fontColour = col;
476 }
477 }
478 }
479 // Update color here so that we can also use the color originally passed in
480 // (EnableEffects may be false)
481 if (m_fontData.m_fontColour.Ok())
482 m_previewer->SetForegroundColour(m_fontData.m_fontColour);
483
484 m_previewer->Refresh();
485 }
486
487 const wxChar *wxFontWeightIntToString(int weight)
488 {
489 switch (weight)
490 {
491 case wxLIGHT:
492 return wxT("Light");
493 case wxBOLD:
494 return wxT("Bold");
495 case wxNORMAL:
496 default:
497 return wxT("Normal");
498 }
499 }
500
501 const wxChar *wxFontStyleIntToString(int style)
502 {
503 switch (style)
504 {
505 case wxITALIC:
506 return wxT("Italic");
507 case wxSLANT:
508 return wxT("Slant");
509 case wxNORMAL:
510 default:
511 return wxT("Normal");
512 }
513 }
514
515 const wxChar *wxFontFamilyIntToString(int family)
516 {
517 switch (family)
518 {
519 case wxROMAN:
520 return wxT("Roman");
521 case wxDECORATIVE:
522 return wxT("Decorative");
523 case wxMODERN:
524 return wxT("Modern");
525 case wxSCRIPT:
526 return wxT("Script");
527 case wxTELETYPE:
528 return wxT("Teletype");
529 case wxSWISS:
530 default:
531 return wxT("Swiss");
532 }
533 }
534
535 int wxFontFamilyStringToInt(wxChar *family)
536 {
537 if (!family)
538 return wxSWISS;
539
540 if (wxStrcmp(family, wxT("Roman")) == 0)
541 return wxROMAN;
542 else if (wxStrcmp(family, wxT("Decorative")) == 0)
543 return wxDECORATIVE;
544 else if (wxStrcmp(family, wxT("Modern")) == 0)
545 return wxMODERN;
546 else if (wxStrcmp(family, wxT("Script")) == 0)
547 return wxSCRIPT;
548 else if (wxStrcmp(family, wxT("Teletype")) == 0)
549 return wxTELETYPE;
550 else return wxSWISS;
551 }
552
553 int wxFontStyleStringToInt(wxChar *style)
554 {
555 if (!style)
556 return wxNORMAL;
557 if (wxStrcmp(style, wxT("Italic")) == 0)
558 return wxITALIC;
559 else if (wxStrcmp(style, wxT("Slant")) == 0)
560 return wxSLANT;
561 else
562 return wxNORMAL;
563 }
564
565 int wxFontWeightStringToInt(wxChar *weight)
566 {
567 if (!weight)
568 return wxNORMAL;
569 if (wxStrcmp(weight, wxT("Bold")) == 0)
570 return wxBOLD;
571 else if (wxStrcmp(weight, wxT("Light")) == 0)
572 return wxLIGHT;
573 else
574 return wxNORMAL;
575 }
576
577 #endif
578 // wxUSE_FONTDLG
579