]> git.saurik.com Git - wxWidgets.git/blob - src/common/fontdata.cpp
Don't use "Cancel" button in the about dialog of the listctrl sample.
[wxWidgets.git] / src / common / fontdata.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/fontdata.cpp
3 // Author: Julian Smart
4 // RCS-ID: $Id$
5 // Copyright: (c) Julian Smart
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #include "wx/wxprec.h"
10
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14
15 #if wxUSE_FONTDLG || wxUSE_FONTPICKERCTRL
16
17 #include "wx/fontdata.h"
18
19 IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
20
21 wxFontData::wxFontData()
22 {
23 m_showHelp = false;
24 m_allowSymbols = true;
25 m_enableEffects = true;
26 m_minSize = 0;
27 m_maxSize = 0;
28
29 m_encoding = wxFONTENCODING_SYSTEM;
30 }
31
32 wxFontData::~wxFontData()
33 {
34 }
35
36 wxFontData::wxFontData(const wxFontData& data)
37 : wxObject(),
38 m_fontColour(data.m_fontColour),
39 m_showHelp(data.m_showHelp),
40 m_allowSymbols(data.m_allowSymbols),
41 m_enableEffects(data.m_enableEffects),
42 m_initialFont(data.m_initialFont),
43 m_chosenFont(data.m_chosenFont),
44 m_minSize(data.m_minSize),
45 m_maxSize(data.m_maxSize),
46 m_encoding(data.m_encoding),
47 m_encodingInfo(data.m_encodingInfo)
48 {
49 }
50
51 wxFontData& wxFontData::operator=(const wxFontData& data)
52 {
53 if (&data != this)
54 {
55 wxObject::operator=(data);
56 m_fontColour = data.m_fontColour;
57 m_showHelp = data.m_showHelp;
58 m_allowSymbols = data.m_allowSymbols;
59 m_enableEffects = data.m_enableEffects;
60 m_initialFont = data.m_initialFont;
61 m_chosenFont = data.m_chosenFont;
62 m_minSize = data.m_minSize;
63 m_maxSize = data.m_maxSize;
64 m_encoding = data.m_encoding;
65 m_encodingInfo = data.m_encodingInfo;
66 }
67 return *this;
68 }
69 #endif // wxUSE_FONTDLG || wxUSE_FONTPICKERCTRL
70
71 #if wxUSE_FONTDLG
72
73 #include "wx/fontdlg.h"
74
75 wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit, const wxString& caption)
76 {
77 wxFontData data;
78 if ( fontInit.IsOk() )
79 {
80 data.SetInitialFont(fontInit);
81 }
82
83 wxFont fontRet;
84 wxFontDialog dialog(parent, data);
85 if (!caption.empty())
86 dialog.SetTitle(caption);
87 if ( dialog.ShowModal() == wxID_OK )
88 {
89 fontRet = dialog.GetFontData().GetChosenFont();
90 }
91 //else: leave it invalid
92
93 return fontRet;
94 }
95 #endif // wxUSE_FONTDLG