]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/fontdlg.cpp
Patch #1446110: use of uninitialized variables
[wxWidgets.git] / src / mac / carbon / fontdlg.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: fontdlg.cpp
72fcdc75
RN
3// Purpose: wxFontDialog class for carbon 10.2+.
4// Author: Ryan Norton
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
72fcdc75
RN
8// Copyright: (c) Ryan Norton
9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
1553abf4
RN
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
1553abf4
RN
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
1553abf4
RN
28 #include "wx/cmndata.h"
29#endif
e9576ca5 30
356c775f 31#include "wx/fontdlg.h"
154ad28b 32
356c775f
RN
33
34#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
35
551caf8b
RN
36#undef wxFontDialog
37
38#include "wx/mac/fontdlg.h"
39
cfe590ae
JS
40#include "wx/fontenum.h"
41#include "wx/colordlg.h"
42#include "wx/spinctrl.h"
72fcdc75 43
1553abf4
RN
44// ---------------------------------------------------------------------------
45// wxFontDialog stub for mac OS's without a native font dialog
46// ---------------------------------------------------------------------------
e9576ca5 47
f75ae77c
JS
48static const wxChar *FontFamilyIntToString(int family);
49static int FontFamilyStringToInt(const wxChar *family);
cfe590ae
JS
50
51
52//-----------------------------------------------------------------------------
53// helper class - wxFontPreviewCtrl
54//-----------------------------------------------------------------------------
55
56class WXDLLEXPORT wxFontPreviewCtrl : public wxWindow
57{
58public:
59 wxFontPreviewCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = 0) :
60 wxWindow(parent, id, pos, sz, style)
61 {
62 SetBackgroundColour(*wxWHITE);
63 }
64
65private:
66 void OnPaint(wxPaintEvent& event);
67 DECLARE_EVENT_TABLE()
68};
69
70BEGIN_EVENT_TABLE(wxFontPreviewCtrl, wxWindow)
71 EVT_PAINT(wxFontPreviewCtrl::OnPaint)
72END_EVENT_TABLE()
73
74void wxFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
75{
76 wxPaintDC dc(this);
77
78 wxSize size = GetSize();
79 wxFont font = GetFont();
80
81 if ( font.Ok() )
82 {
83 dc.SetFont(font);
84 // Calculate vertical centre
85 long w = 0, h = 0;
86 dc.GetTextExtent( wxT("X"), &w, &h);
87 dc.SetTextForeground(GetForegroundColour());
88 dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
89 dc.DrawText(_("ABCDEFGabcdefg12345"),
90 10, size.y/2 - h/2);
91 dc.DestroyClippingRegion();
92 }
93}
94
95/*
96 * A control for displaying a small preview of a colour or bitmap
97 */
98
99class wxFontColourSwatchCtrl: public wxControl
100{
101 DECLARE_CLASS(wxFontColourSwatchCtrl)
102public:
103 wxFontColourSwatchCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
104 ~wxFontColourSwatchCtrl();
105
106 void OnPaint(wxPaintEvent& event);
107 void OnMouseEvent(wxMouseEvent& event);
108
109 void SetColour(const wxColour& colour) { m_colour = colour; SetBackgroundColour(m_colour); }
110
111 wxColour& GetColour() { return m_colour; }
112
113 virtual wxSize DoGetBestSize() const { return GetSize(); }
114
115protected:
116 wxColour m_colour;
117
118DECLARE_EVENT_TABLE()
119};
120
121/*
122 * A control for displaying a small preview of a colour or bitmap
123 */
124
125BEGIN_EVENT_TABLE(wxFontColourSwatchCtrl, wxControl)
126 EVT_MOUSE_EVENTS(wxFontColourSwatchCtrl::OnMouseEvent)
127END_EVENT_TABLE()
128
129IMPLEMENT_CLASS(wxFontColourSwatchCtrl, wxControl)
130
131wxFontColourSwatchCtrl::wxFontColourSwatchCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
132 wxControl(parent, id, pos, size, style)
133{
134 SetColour(* wxWHITE);
135 SetBackgroundStyle(wxBG_STYLE_COLOUR);
136}
137
138wxFontColourSwatchCtrl::~wxFontColourSwatchCtrl()
139{
140}
141
142void wxFontColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
143{
144 if (event.LeftDown())
145 {
146 wxWindow* parent = GetParent();
147 while (parent != NULL && !parent->IsKindOf(CLASSINFO(wxDialog)) && !parent->IsKindOf(CLASSINFO(wxFrame)))
148 parent = parent->GetParent();
149
150 wxColourData data;
151 data.SetChooseFull(TRUE);
152 data.SetColour(m_colour);
153 wxColourDialog *dialog = new wxColourDialog(parent, &data);
154 // Crashes on wxMac (no m_peer)
155#ifndef __WXMAC__
156 dialog->SetTitle(_("Background colour"));
157#endif
158 if (dialog->ShowModal() == wxID_OK)
159 {
160 wxColourData retData = dialog->GetColourData();
161 m_colour = retData.GetColour();
162 SetBackgroundColour(m_colour);
163 }
164 dialog->Destroy();
165 Refresh();
166
167 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
168 GetEventHandler()->ProcessEvent(event);
169 }
170}
171
172/*!
173 * wxFontDialog type definition
174 */
175
176IMPLEMENT_DYNAMIC_CLASS( wxFontDialog, wxDialog )
177
178/*!
179 * wxFontDialog event table definition
180 */
181
182BEGIN_EVENT_TABLE( wxFontDialog, wxDialog )
183 EVT_LISTBOX( wxID_FONTDIALOG_FACENAME, wxFontDialog::OnFontdialogFacenameSelected )
184 EVT_SPINCTRL( wxID_FONTDIALOG_FONTSIZE, wxFontDialog::OnFontdialogFontsizeUpdated )
185 EVT_TEXT( wxID_FONTDIALOG_FONTSIZE, wxFontDialog::OnFontdialogFontsizeTextUpdated )
186 EVT_CHECKBOX( wxID_FONTDIALOG_BOLD, wxFontDialog::OnFontdialogBoldClick )
187 EVT_CHECKBOX( wxID_FONTDIALOG_ITALIC, wxFontDialog::OnFontdialogItalicClick )
188 EVT_CHECKBOX( wxID_FONTDIALOG_UNDERLINED, wxFontDialog::OnFontdialogUnderlinedClick )
189 EVT_BUTTON( wxID_OK, wxFontDialog::OnOkClick )
190 EVT_BUTTON(wxID_FONTDIALOG_COLOUR, wxFontDialog::OnColourChanged)
191END_EVENT_TABLE()
192
193/*!
194 * wxFontDialog constructors
195 */
196
197wxFontDialog::wxFontDialog( )
e9576ca5
SC
198{
199 m_dialogParent = NULL;
200}
201
cfe590ae 202wxFontDialog::wxFontDialog(wxWindow* parent, const wxFontData& fontData)
e9576ca5 203{
cfe590ae
JS
204 m_dialogParent = NULL;
205
206 Create(parent, fontData);
e9576ca5
SC
207}
208
b9242cc7
DS
209wxFontDialog::~wxFontDialog()
210{
211 // empty
212}
213
cfe590ae
JS
214/*!
215 * wxFontDialog creator
216 */
217
218bool wxFontDialog::Create(wxWindow* parent, const wxFontData& fontData)
72fcdc75 219{
cfe590ae
JS
220 m_fontData = fontData;
221 m_suppressUpdates = false;
222
223 wxString caption = _("Font");
224
225 m_facenameCtrl = NULL;
226 m_sizeCtrl = NULL;
227 m_boldCtrl = NULL;
228 m_italicCtrl = NULL;
229 m_underlinedCtrl = NULL;
230 m_colourCtrl = NULL;
231 m_previewCtrl = NULL;
232
233 InitializeFont();
234
235 SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
236 wxDialog::Create( parent, wxID_ANY, caption, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
237
238 CreateControls();
239 GetSizer()->Fit(this);
240 GetSizer()->SetSizeHints(this);
241 Centre();
242
243 return true;
72fcdc75
RN
244}
245
cfe590ae
JS
246/*!
247 * Control creation for wxFontDialog
248 */
249
250void wxFontDialog::CreateControls()
251{
252 wxFontDialog* itemDialog1 = this;
253
254 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
255 itemDialog1->SetSizer(itemBoxSizer2);
256
257 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
258 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
259
260 wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(6, 2, 10, 0);
261 itemFlexGridSizer4->AddGrowableRow(4);
262 itemFlexGridSizer4->AddGrowableCol(1);
263 itemBoxSizer3->Add(itemFlexGridSizer4, 1, wxGROW|wxALL, 5);
264
265 wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
266 itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_TOP|wxALL|wxADJUST_MINSIZE, 5);
267
268 wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL);
269 itemFlexGridSizer4->Add(itemBoxSizer6, 0, wxGROW|wxGROW, 5);
270
271 wxString* m_facenameCtrlStrings = NULL;
272 m_facenameCtrl = new wxListBox( itemDialog1, wxID_FONTDIALOG_FACENAME, wxDefaultPosition, wxSize(320, 100), 0, m_facenameCtrlStrings, wxLB_SINGLE );
273 itemBoxSizer6->Add(m_facenameCtrl, 0, wxGROW|wxALL, 5);
274
275 wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
276 itemFlexGridSizer4->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
277
278 m_sizeCtrl = new wxSpinCtrl( itemDialog1, wxID_FONTDIALOG_FONTSIZE, _T("12"), wxDefaultPosition, wxSize(60, -1), wxSP_ARROW_KEYS, 1, 300, 12 );
279 m_sizeCtrl->SetHelpText(_("The font size in points."));
280 if (ShowToolTips())
281 m_sizeCtrl->SetToolTip(_("The font size in points."));
282 itemFlexGridSizer4->Add(m_sizeCtrl, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
283
284 wxStaticText* itemStaticText10 = new wxStaticText( itemDialog1, wxID_STATIC, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
285 itemFlexGridSizer4->Add(itemStaticText10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
286
287 wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
288 itemFlexGridSizer4->Add(itemBoxSizer11, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
289
290 m_boldCtrl = new wxCheckBox( itemDialog1, wxID_FONTDIALOG_BOLD, _("Bold"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
291 m_boldCtrl->SetValue(false);
292 m_boldCtrl->SetHelpText(_("Check to make the font bold."));
293 if (ShowToolTips())
294 m_boldCtrl->SetToolTip(_("Check to make the font bold."));
295 itemBoxSizer11->Add(m_boldCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
296
297 m_italicCtrl = new wxCheckBox( itemDialog1, wxID_FONTDIALOG_ITALIC, _("Italic"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
298 m_italicCtrl->SetValue(false);
299 m_italicCtrl->SetHelpText(_("Check to make the font italic."));
300 if (ShowToolTips())
301 m_italicCtrl->SetToolTip(_("Check to make the font italic."));
302 itemBoxSizer11->Add(m_italicCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
303
304 if (m_fontData.GetEnableEffects())
305 {
306 m_underlinedCtrl = new wxCheckBox( itemDialog1, wxID_FONTDIALOG_UNDERLINED, _("Underlined"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
307 m_underlinedCtrl->SetValue(false);
308 m_underlinedCtrl->SetHelpText(_("Check to make the font underlined."));
309 if (ShowToolTips())
310 m_underlinedCtrl->SetToolTip(_("Check to make the font underlined."));
311 itemBoxSizer11->Add(m_underlinedCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
312 }
313
314 if (m_fontData.GetEnableEffects())
315 {
316 wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
317 itemFlexGridSizer4->Add(itemStaticText15, 0, wxALIGN_RIGHT|wxALIGN_TOP|wxALL|wxADJUST_MINSIZE, 5);
318
319 m_colourCtrl = new wxFontColourSwatchCtrl( itemDialog1, wxID_FONTDIALOG_COLOUR, wxDefaultPosition, wxSize(-1, 30), wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
320 m_colourCtrl->SetHelpText(_("Click to change the font colour."));
321 if (ShowToolTips())
322 m_colourCtrl->SetToolTip(_("Click to change the font colour."));
323 itemFlexGridSizer4->Add(m_colourCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
324 }
325
326 wxStaticText* itemStaticText17 = new wxStaticText( itemDialog1, wxID_STATIC, _("Preview:"), wxDefaultPosition, wxDefaultSize, 0 );
327 itemFlexGridSizer4->Add(itemStaticText17, 0, wxALIGN_RIGHT|wxALIGN_TOP|wxALL|wxADJUST_MINSIZE, 5);
328
329 m_previewCtrl = new wxFontPreviewCtrl( itemDialog1, wxID_FONTDIALOG_PREVIEW, wxDefaultPosition, wxSize(-1, 70), wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
330 m_previewCtrl->SetHelpText(_("Shows a preview of the font."));
331 if (ShowToolTips())
332 m_previewCtrl->SetToolTip(_("Shows a preview of the font."));
333 itemFlexGridSizer4->Add(m_previewCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
334
335 wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
336 itemBoxSizer3->Add(itemBoxSizer19, 0, wxALIGN_RIGHT|wxALL, 5);
337
338 wxButton* itemButton20 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
339 itemButton20->SetHelpText(_("Click to cancel changes to the font."));
340 if (ShowToolTips())
341 itemButton20->SetToolTip(_("Click to cancel changes to the font."));
342 itemBoxSizer19->Add(itemButton20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
343
344 wxButton* itemButton21 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
345 itemButton21->SetDefault();
346 itemButton21->SetHelpText(_("Click to confirm changes to the font."));
347 if (ShowToolTips())
348 itemButton21->SetToolTip(_("Click to confirm changes to the font."));
349 itemBoxSizer19->Add(itemButton21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
350
351 wxFontEnumerator enumerator;
352 enumerator.EnumerateFacenames();
353 wxArrayString* facenames = enumerator.GetFacenames();
354 if (facenames)
355 {
356 facenames->Add(_("<Any>"));
357 facenames->Add(_("<Any Roman>"));
358 facenames->Add(_("<Any Decorative>"));
359 facenames->Add(_("<Any Modern>"));
360 facenames->Add(_("<Any Script>"));
361 facenames->Add(_("<Any Swiss>"));
362 facenames->Add(_("<Any Teletype>"));
363 facenames->Sort();
364 m_facenameCtrl->Append(*facenames);
365 }
366
367 InitializeControls();
368 m_previewCtrl->SetFont(m_dialogFont);
369 if (m_fontData.GetColour().Ok())
370 {
371 m_previewCtrl->SetForegroundColour(m_fontData.GetColour());
372 }
373 m_previewCtrl->Refresh();
374}
375
376/*!
377 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for wxID_FONTDIALOG_FONTSIZE
378 */
379
380void wxFontDialog::OnFontdialogFontsizeUpdated( wxSpinEvent& WXUNUSED(event) )
381{
382 ChangeFont();
383}
384
385/*!
386 * wxEVT_COMMAND_TEXT_UPDATED event handler for wxID_FONTDIALOG_FONTSIZE
387 */
388
389void wxFontDialog::OnFontdialogFontsizeTextUpdated( wxCommandEvent& WXUNUSED(event) )
e9576ca5 390{
cfe590ae
JS
391 ChangeFont();
392}
e9576ca5 393
cfe590ae
JS
394/*!
395 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_BOLD
396 */
e9576ca5 397
cfe590ae
JS
398void wxFontDialog::OnFontdialogBoldClick( wxCommandEvent& WXUNUSED(event) )
399{
400 ChangeFont();
401}
402
403/*!
404 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_ITALIC
405 */
406
407void wxFontDialog::OnFontdialogItalicClick( wxCommandEvent& WXUNUSED(event) )
408{
409 ChangeFont();
410}
411
412/*!
413 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_UNDERLINED
414 */
415
416void wxFontDialog::OnFontdialogUnderlinedClick( wxCommandEvent& WXUNUSED(event) )
417{
418 ChangeFont();
419}
420
421/*!
422 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
423 */
424
425void wxFontDialog::OnOkClick( wxCommandEvent& event )
426{
427 event.Skip();
428}
429
430
431/*!
432 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for wxID_FONTDIALOG_FACENAME
433 */
434
435void wxFontDialog::OnFontdialogFacenameSelected( wxCommandEvent& WXUNUSED(event) )
436{
437 ChangeFont();
438}
439
440void wxFontDialog::OnColourChanged(wxCommandEvent & WXUNUSED(event))
441{
442 m_fontData.SetColour(m_colourCtrl->GetColour());
443 m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour());
444 m_previewCtrl->Refresh();
445}
446
447/*!
448 * Should we show tooltips?
449 */
450
451bool wxFontDialog::ShowToolTips()
452{
453 return true;
454}
455
456void wxFontDialog::InitializeFont()
457{
458 int fontFamily = wxSWISS;
459 int fontWeight = wxNORMAL;
460 int fontStyle = wxNORMAL;
461 int fontSize = 12;
462 bool fontUnderline = false;
463 wxString fontName;
464
465 if (m_fontData.m_initialFont.Ok())
466 {
467 fontFamily = m_fontData.m_initialFont.GetFamily();
468 fontWeight = m_fontData.m_initialFont.GetWeight();
469 fontStyle = m_fontData.m_initialFont.GetStyle();
470 fontSize = m_fontData.m_initialFont.GetPointSize();
471 fontUnderline = m_fontData.m_initialFont.GetUnderlined();
472 fontName = m_fontData.m_initialFont.GetFaceName();
473 }
474
475 m_dialogFont = wxFont(fontSize, fontFamily, fontStyle,
476 fontWeight, fontUnderline, fontName);
477
478 if (m_previewCtrl)
479 m_previewCtrl->SetFont(m_dialogFont);
480
481 m_fontData.SetChosenFont(m_dialogFont);
482}
483
484/// Set controls according to current font
485void wxFontDialog::InitializeControls()
486{
487 m_suppressUpdates = true;
488
489 if (m_underlinedCtrl)
490 m_underlinedCtrl->SetValue(m_dialogFont.GetUnderlined());
491
492 m_boldCtrl->SetValue(m_dialogFont.GetWeight() == wxBOLD);
493 m_italicCtrl->SetValue(m_dialogFont.GetStyle() == wxITALIC);
494 m_sizeCtrl->SetValue(m_dialogFont.GetPointSize());
495
496 wxString facename = m_dialogFont.GetFaceName();
497 if (facename.empty() || m_facenameCtrl->FindString(facename) == wxNOT_FOUND)
498 {
f75ae77c 499 facename = FontFamilyIntToString(m_dialogFont.GetFamily());
cfe590ae
JS
500 }
501 m_facenameCtrl->SetStringSelection(facename);
502
503 if (m_colourCtrl && m_fontData.GetColour().Ok())
504 {
505 m_colourCtrl->SetColour(m_fontData.GetColour());
506 m_colourCtrl->Refresh();
507 }
508
509 m_suppressUpdates = false;
510}
511
512/// Respond to font change
513void wxFontDialog::ChangeFont()
514{
515 if (m_suppressUpdates)
516 return;
517
518 bool underlined = m_underlinedCtrl ? m_underlinedCtrl->GetValue() : false;
519 bool italic = m_italicCtrl->GetValue();
520 bool bold = m_boldCtrl->GetValue();
521 int size = m_sizeCtrl->GetValue();
522 wxString facename = m_facenameCtrl->GetStringSelection();
523
f75ae77c 524 int family = FontFamilyStringToInt(facename);
cfe590ae
JS
525 if (family == -1)
526 family = wxDEFAULT;
527 else
528 facename = wxEmptyString;
529
530 m_dialogFont = wxFont(size, family, italic ? wxITALIC : wxNORMAL, bold ? wxBOLD : wxNORMAL,
531 underlined, facename);
532
533 m_fontData.SetChosenFont(m_dialogFont);
534
535 m_previewCtrl->SetFont(m_dialogFont);
536 m_previewCtrl->Refresh();
537}
538
539void wxFontDialog::SetData(const wxFontData& fontdata)
540{
541 m_fontData = fontdata;
e9576ca5
SC
542}
543
72fcdc75
RN
544bool wxFontDialog::IsShown() const
545{
546 return false;
547}
548
e9576ca5
SC
549int wxFontDialog::ShowModal()
550{
cfe590ae
JS
551 return wxDialog::ShowModal();
552}
553
554void wxFontDialog::OnPanelClose()
555{
e9576ca5
SC
556}
557
f75ae77c 558const wxChar *FontFamilyIntToString(int family)
cfe590ae
JS
559{
560 switch (family)
561 {
562 case wxROMAN:
563 return _("<Any Roman>");
564 case wxDECORATIVE:
565 return _("<Any Decorative>");
566 case wxMODERN:
567 return _("<Any Modern>");
568 case wxSCRIPT:
569 return _("<Any Script>");
570 case wxTELETYPE:
571 return _("<Any Teletype>");
572 case wxSWISS:
573 default:
574 return _("<Any Swiss>");
575 }
576}
577
f75ae77c 578int FontFamilyStringToInt(const wxChar *family)
cfe590ae
JS
579{
580 if (!family)
581 return wxSWISS;
582
583 if (wxStrcmp(family, _("<Any Roman")) == 0)
584 return wxROMAN;
585 else if (wxStrcmp(family, _("<Any Decorative>")) == 0)
586 return wxDECORATIVE;
587 else if (wxStrcmp(family, _("<Any Modern>")) == 0)
588 return wxMODERN;
589 else if (wxStrcmp(family, _("<Any Script>")) == 0)
590 return wxSCRIPT;
591 else if (wxStrcmp(family, _("<Any Teletype>")) == 0)
592 return wxTELETYPE;
593 else if (wxStrcmp(family, _("<Any Swiss>")) == 0)
594 return wxSWISS;
595 else return -1;
596}
597
598#endif // !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
599