]> git.saurik.com Git - wxWidgets.git/blame - src/generic/fontdlgg.cpp
Better alphabetized the event handler macros
[wxWidgets.git] / src / generic / fontdlgg.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
c2c59b22 2// Name: src/generic/fontdlgg.cpp
c801d85f
KB
3// Purpose: Generic font dialog
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
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
47e118ba 23#if wxUSE_FONTDLG && (!defined(__WXGTK__) || defined(__WXGPE__) || defined(__WXUNIVERSAL__))
4234ea8b 24
c801d85f 25#ifndef WX_PRECOMP
53cf79fa
VS
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"
c801d85f
KB
37#endif
38
39#include <string.h>
40#include <stdlib.h>
41
42#include "wx/cmndata.h"
53cf79fa 43#include "wx/sizer.h"
c2c59b22 44#include "wx/fontdlg.h"
23c47bc1 45#include "wx/generic/fontdlgg.h"
47e118ba 46#include "wx/settings.h"
c801d85f 47
53cf79fa
VS
48//-----------------------------------------------------------------------------
49// helper class - wxFontPreviewer
50//-----------------------------------------------------------------------------
51
52class WXDLLEXPORT wxFontPreviewer : public wxWindow
53{
54public:
dabbc6a5 55 wxFontPreviewer(wxWindow *parent) : wxWindow(parent, wxID_ANY) {}
53cf79fa
VS
56
57private:
58 void OnPaint(wxPaintEvent& event);
59 DECLARE_EVENT_TABLE()
60};
61
62BEGIN_EVENT_TABLE(wxFontPreviewer, wxWindow)
63 EVT_PAINT(wxFontPreviewer::OnPaint)
64END_EVENT_TABLE()
65
66void 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 {
2b5f62a0 79 dc.SetFont(font);
53cf79fa
VS
80 // Calculate vertical centre
81 long w, h;
2b5f62a0 82 dc.GetTextExtent( wxT("X"), &w, &h);
53cf79fa
VS
83 dc.SetTextForeground(GetForegroundColour());
84 dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
dabbc6a5 85 dc.DrawText(_("ABCDEFGabcdefg12345"),
2b5f62a0 86 10, size.y/2 - h/2);
53cf79fa
VS
87 dc.DestroyClippingRegion();
88 }
89}
90
91//-----------------------------------------------------------------------------
92// wxGenericFontDialog
93//-----------------------------------------------------------------------------
94
c801d85f
KB
95IMPLEMENT_DYNAMIC_CLASS(wxGenericFontDialog, wxDialog)
96
97BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog)
c35414db
VZ
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)
c35414db 104 EVT_CLOSE(wxGenericFontDialog::OnCloseWindow)
c801d85f
KB
105END_EVENT_TABLE()
106
c801d85f
KB
107
108#define NUM_COLS 48
223d09f6
KB
109static 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")
c35414db 162 };
c801d85f
KB
163
164/*
165 * Generic wxFontDialog
166 */
167
c2c59b22 168void wxGenericFontDialog::Init()
c801d85f 169{
dabbc6a5 170 m_useEvents = false;
53cf79fa 171 m_previewer = NULL;
1bab9242 172 Create( m_parent ) ;
c801d85f
KB
173}
174
c2c59b22 175wxGenericFontDialog::~wxGenericFontDialog()
c801d85f
KB
176{
177}
178
74e3313b 179void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
c801d85f 180{
47e118ba 181 EndModal(wxID_CANCEL);
c801d85f 182}
c35414db 183
c2c59b22 184bool wxGenericFontDialog::DoCreate(wxWindow *parent)
c801d85f 185{
dabbc6a5 186 if ( !wxDialog::Create( parent , wxID_ANY , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
1bab9242
SC
187 _T("fontdialog") ) )
188 {
189 wxFAIL_MSG( wxT("wxFontDialog creation failed") );
dabbc6a5 190 return false;
1bab9242 191 }
fc8eba27 192
47e118ba
RR
193 InitializeFont();
194 CreateWidgets();
dabbc6a5 195
47e118ba
RR
196 // sets initial font in preview area
197 wxCommandEvent dummy;
198 OnChangeFont(dummy);
dabbc6a5
DS
199
200 return true;
c801d85f
KB
201}
202
c2c59b22 203int wxGenericFontDialog::ShowModal()
c801d85f 204{
1bab9242 205 int ret = wxDialog::ShowModal();
c801d85f
KB
206
207 if (ret != wxID_CANCEL)
208 {
ae500232 209 m_fontData.m_chosenFont = dialogFont;
c801d85f
KB
210 }
211
c35414db 212 return ret;
c801d85f
KB
213}
214
4566d7db
JS
215// This should be application-settable
216static bool ShowToolTips() { return false; }
217
c2c59b22 218void wxGenericFontDialog::CreateWidgets()
c801d85f 219{
47e118ba 220 wxString
36b3b54a 221 *families = new wxString[6],
59043ba2
KB
222 *styles = new wxString[3],
223 *weights = new wxString[3];
47e118ba
RR
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
47e118ba
RR
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 }
c801d85f 245
4566d7db 246 // layout
c801d85f 247
4566d7db
JS
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 }
c801d85f 258
4566d7db
JS
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 wxStaticText* itemStaticText15 = new wxStaticText( this, wxID_STATIC, _("C&olour:"), wxDefaultPosition, wxDefaultSize, 0 );
305 itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
306
307 wxChoice* itemChoice16 = new wxChoice( this, wxID_FONT_COLOUR, wxDefaultPosition, wxDefaultSize, NUM_COLS, wxColourDialogNames, 0 );
308 itemChoice16->SetHelpText(_("The font colour."));
309 if (ShowToolTips())
310 itemChoice16->SetToolTip(_("The font colour."));
311 itemBoxSizer14->Add(itemChoice16, 0, wxALIGN_LEFT|wxALL, 5);
312
313 wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
314 itemGridSizer4->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5);
315 wxStaticText* itemStaticText18 = new wxStaticText( this, wxID_STATIC, _("&Point size:"), wxDefaultPosition, wxDefaultSize, 0 );
316 itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
317
318 wxChoice* itemChoice19 = new wxChoice( this, wxID_FONT_SIZE, wxDefaultPosition, wxDefaultSize, 40, pointSizes, 0 );
319 itemChoice19->SetHelpText(_("The font point size."));
320 if (ShowToolTips())
321 itemChoice19->SetToolTip(_("The font point size."));
322 itemBoxSizer17->Add(itemChoice19, 0, wxALIGN_LEFT|wxALL, 5);
323
324 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL);
325 itemGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
326 wxCheckBox* itemCheckBox21 = new wxCheckBox( this, wxID_FONT_UNDERLINE, _("&Underline"), wxDefaultPosition, wxDefaultSize, 0 );
327 itemCheckBox21->SetValue(FALSE);
328 itemCheckBox21->SetHelpText(_("Whether the font is underlined."));
329 if (ShowToolTips())
330 itemCheckBox21->SetToolTip(_("Whether the font is underlined."));
331 itemBoxSizer20->Add(itemCheckBox21, 0, wxALIGN_LEFT|wxALL, 5);
332
333 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
334
335 wxStaticText* itemStaticText23 = new wxStaticText( this, wxID_STATIC, _("Preview:"), wxDefaultPosition, wxDefaultSize, 0 );
336 itemBoxSizer3->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
337
338 wxFontPreviewer* itemWindow24 = new wxFontPreviewer( this );
339 m_previewer = itemWindow24;
340 itemWindow24->SetHelpText(_("Shows the font preview."));
341 if (ShowToolTips())
342 itemWindow24->SetToolTip(_("Shows the font preview."));
343 itemBoxSizer3->Add(itemWindow24, 0, wxGROW|wxALL, 5);
344
345 wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
346 itemBoxSizer3->Add(itemBoxSizer25, 0, wxGROW, 5);
347 itemBoxSizer25->Add(5, 5, 1, wxGROW|wxALL, 5);
348
349#ifdef __WXMAC__
350 wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
351 if (ShowToolTips())
352 itemButton28->SetToolTip(_("Click to cancel the font selection."));
353 itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
354
355 wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
356 itemButton27->SetDefault();
357 itemButton27->SetHelpText(_("Click to confirm the font selection."));
358 if (ShowToolTips())
359 itemButton27->SetToolTip(_("Click to confirm the font selection."));
360 itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
361#else
362 wxButton* itemButton27 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
363 itemButton27->SetDefault();
364 itemButton27->SetHelpText(_("Click to confirm the font selection."));
365 if (ShowToolTips())
366 itemButton27->SetToolTip(_("Click to confirm the font selection."));
367 itemBoxSizer25->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
368
369 wxButton* itemButton28 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
370 if (ShowToolTips())
371 itemButton28->SetToolTip(_("Click to cancel the font selection."));
372 itemBoxSizer25->Add(itemButton28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
373#endif
c801d85f 374
4566d7db
JS
375 familyChoice = (wxChoice*) FindWindow(wxID_FONT_FAMILY);
376 styleChoice = (wxChoice*) FindWindow(wxID_FONT_STYLE);
377 weightChoice = (wxChoice*) FindWindow(wxID_FONT_WEIGHT);
378 colourChoice = (wxChoice*) FindWindow(wxID_FONT_COLOUR);
379 pointSizeChoice = (wxChoice*) FindWindow(wxID_FONT_SIZE);
380 underLineCheckBox = (wxCheckBox*) FindWindow(wxID_FONT_UNDERLINE);
381
47e118ba
RR
382 familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) );
383 styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));
384 weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight()));
385 wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour()));
448971f3
RD
386 if (name.length())
387 colourChoice->SetStringSelection(name);
388 else
389 colourChoice->SetStringSelection(wxT("BLACK"));
390
47e118ba
RR
391 underLineCheckBox->SetValue(dialogFont.GetUnderlined());
392 pointSizeChoice->SetSelection(dialogFont.GetPointSize()-1);
c801d85f 393
4566d7db
JS
394 GetSizer()->SetItemMinSize(m_previewer, 430, 100);
395 GetSizer()->SetSizeHints(this);
396 GetSizer()->Fit(this);
47e118ba
RR
397
398 Centre(wxBOTH);
399
400 delete[] families;
401 delete[] styles;
402 delete[] weights;
403 delete[] pointSizes;
dabbc6a5 404
47e118ba 405 // Don't block events any more
dabbc6a5 406 m_useEvents = true;
4566d7db 407
c801d85f
KB
408}
409
c2c59b22 410void wxGenericFontDialog::InitializeFont()
c801d85f 411{
47e118ba
RR
412 int fontFamily = wxSWISS;
413 int fontWeight = wxNORMAL;
414 int fontStyle = wxNORMAL;
415 int fontSize = 12;
dabbc6a5 416 bool fontUnderline = false;
53cf79fa 417
47e118ba
RR
418 if (m_fontData.m_initialFont.Ok())
419 {
420 fontFamily = m_fontData.m_initialFont.GetFamily();
421 fontWeight = m_fontData.m_initialFont.GetWeight();
422 fontStyle = m_fontData.m_initialFont.GetStyle();
423 fontSize = m_fontData.m_initialFont.GetPointSize();
424 fontUnderline = m_fontData.m_initialFont.GetUnderlined();
425 }
c801d85f 426
dabbc6a5
DS
427 dialogFont = wxFont(fontSize, fontFamily, fontStyle,
428 fontWeight, fontUnderline);
c801d85f 429
47e118ba
RR
430 if (m_previewer)
431 m_previewer->SetFont(dialogFont);
c801d85f
KB
432}
433
434void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event))
435{
47e118ba 436 if (!m_useEvents) return;
c35414db 437
47e118ba
RR
438 int fontFamily = wxFontFamilyStringToInt(WXSTRINGCAST familyChoice->GetStringSelection());
439 int fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection());
440 int fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection());
441 int fontSize = wxAtoi(pointSizeChoice->GetStringSelection());
442 int fontUnderline = underLineCheckBox->GetValue();
c801d85f 443
47e118ba
RR
444 dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
445 m_previewer->SetFont(dialogFont);
dabbc6a5 446 if ( !colourChoice->GetStringSelection().empty() )
c801d85f 447 {
47e118ba
RR
448 wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection());
449 if (col.Ok())
450 {
451 m_fontData.m_fontColour = col;
452 m_previewer->SetForegroundColour(col);
453 }
c801d85f 454 }
47e118ba 455 m_previewer->Refresh();
c801d85f
KB
456}
457
d0060e77 458const wxChar *wxFontWeightIntToString(int weight)
c801d85f
KB
459{
460 switch (weight)
461 {
462 case wxLIGHT:
223d09f6 463 return wxT("Light");
c801d85f 464 case wxBOLD:
223d09f6 465 return wxT("Bold");
c801d85f
KB
466 case wxNORMAL:
467 default:
223d09f6 468 return wxT("Normal");
c801d85f 469 }
c801d85f
KB
470}
471
d0060e77 472const wxChar *wxFontStyleIntToString(int style)
c801d85f
KB
473{
474 switch (style)
475 {
476 case wxITALIC:
223d09f6 477 return wxT("Italic");
c801d85f 478 case wxSLANT:
223d09f6 479 return wxT("Slant");
c801d85f
KB
480 case wxNORMAL:
481 default:
223d09f6 482 return wxT("Normal");
c801d85f 483 }
c801d85f
KB
484}
485
d0060e77 486const wxChar *wxFontFamilyIntToString(int family)
c801d85f
KB
487{
488 switch (family)
489 {
490 case wxROMAN:
223d09f6 491 return wxT("Roman");
c801d85f 492 case wxDECORATIVE:
223d09f6 493 return wxT("Decorative");
c801d85f 494 case wxMODERN:
223d09f6 495 return wxT("Modern");
c801d85f 496 case wxSCRIPT:
223d09f6 497 return wxT("Script");
36b3b54a 498 case wxTELETYPE:
223d09f6 499 return wxT("Teletype");
c801d85f
KB
500 case wxSWISS:
501 default:
223d09f6 502 return wxT("Swiss");
c801d85f 503 }
c801d85f
KB
504}
505
87138c52 506int wxFontFamilyStringToInt(wxChar *family)
c801d85f
KB
507{
508 if (!family)
509 return wxSWISS;
c35414db 510
223d09f6 511 if (wxStrcmp(family, wxT("Roman")) == 0)
c801d85f 512 return wxROMAN;
223d09f6 513 else if (wxStrcmp(family, wxT("Decorative")) == 0)
c801d85f 514 return wxDECORATIVE;
223d09f6 515 else if (wxStrcmp(family, wxT("Modern")) == 0)
c801d85f 516 return wxMODERN;
223d09f6 517 else if (wxStrcmp(family, wxT("Script")) == 0)
c801d85f 518 return wxSCRIPT;
223d09f6 519 else if (wxStrcmp(family, wxT("Teletype")) == 0)
36b3b54a 520 return wxTELETYPE;
c801d85f
KB
521 else return wxSWISS;
522}
523
87138c52 524int wxFontStyleStringToInt(wxChar *style)
c801d85f
KB
525{
526 if (!style)
527 return wxNORMAL;
223d09f6 528 if (wxStrcmp(style, wxT("Italic")) == 0)
c801d85f 529 return wxITALIC;
223d09f6 530 else if (wxStrcmp(style, wxT("Slant")) == 0)
c801d85f
KB
531 return wxSLANT;
532 else
533 return wxNORMAL;
534}
535
87138c52 536int wxFontWeightStringToInt(wxChar *weight)
c801d85f
KB
537{
538 if (!weight)
539 return wxNORMAL;
223d09f6 540 if (wxStrcmp(weight, wxT("Bold")) == 0)
c801d85f 541 return wxBOLD;
223d09f6 542 else if (wxStrcmp(weight, wxT("Light")) == 0)
c801d85f
KB
543 return wxLIGHT;
544 else
545 return wxNORMAL;
546}
547
3808e191
JS
548#endif
549 // wxUSE_FONTDLG
c801d85f 550