1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFontDialog class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "fontdlg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/dialog.h"
37 #include "wx/fontdlg.h"
39 #if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
43 #include "wx/msw/private.h"
44 #include "wx/cmndata.h"
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
57 // ============================================================================
59 // ============================================================================
61 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
65 wxFontDialog::wxFontDialog()
70 wxFontDialog::wxFontDialog(wxWindow
*parent
, wxFontData
*data
)
75 bool wxFontDialog::Create(wxWindow
*parent
, wxFontData
*data
)
79 wxCHECK_MSG( data
, FALSE
, _T("no font data in wxFontDialog") );
86 int wxFontDialog::ShowModal()
88 DWORD flags
= CF_SCREENFONTS
| CF_NOSIMULATIONS
;
92 CHOOSEFONT chooseFontStruct
;
93 wxZeroMemory(chooseFontStruct
);
95 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
97 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
98 chooseFontStruct
.lpLogFont
= &logFont
;
100 if ( m_fontData
.initialFont
.Ok() )
102 flags
|= CF_INITTOLOGFONTSTRUCT
;
103 wxFillLogFont(&logFont
, &m_fontData
.initialFont
);
106 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.fontColour
);
108 // CF_ANSIONLY flag is obsolete for Win32
109 if ( !m_fontData
.GetAllowSymbols() )
112 flags
|= CF_ANSIONLY
;
114 flags
|= CF_SELECTSCRIPT
;
115 logFont
.lfCharSet
= ANSI_CHARSET
;
119 if ( m_fontData
.GetEnableEffects() )
121 if ( m_fontData
.GetShowHelp() )
122 flags
|= CF_SHOWHELP
;
124 if ( m_fontData
.minSize
!= 0 || m_fontData
.maxSize
!= 0 )
126 chooseFontStruct
.nSizeMin
= m_fontData
.minSize
;
127 chooseFontStruct
.nSizeMax
= m_fontData
.maxSize
;
128 flags
|= CF_LIMITSIZE
;
131 chooseFontStruct
.Flags
= flags
;
133 if ( ChooseFont(&chooseFontStruct
) != 0 )
135 wxRGBToColour(m_fontData
.fontColour
, chooseFontStruct
.rgbColors
);
136 m_fontData
.chosenFont
= wxCreateFontFromLogFont(&logFont
);
137 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
138 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
144 // common dialog failed - why?
146 DWORD dwErr
= CommDlgExtendedError();
149 // this msg is only for developers
150 wxLogError(wxT("Common dialog failed with error code %0lx."),
153 //else: it was just cancelled