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