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"
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 #if !USE_SHARED_LIBRARY
55 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
58 // ============================================================================
60 // ============================================================================
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
66 wxFontDialog::wxFontDialog()
71 wxFontDialog::wxFontDialog(wxWindow
*parent
, wxFontData
*data
)
76 bool wxFontDialog::Create(wxWindow
*parent
, wxFontData
*data
)
80 wxCHECK_MSG( data
, FALSE
, _T("no font data in wxFontDialog") );
87 int wxFontDialog::ShowModal()
89 DWORD flags
= CF_SCREENFONTS
| CF_NOSIMULATIONS
;
93 CHOOSEFONT chooseFontStruct
;
94 wxZeroMemory(chooseFontStruct
);
96 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
98 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
99 chooseFontStruct
.lpLogFont
= &logFont
;
101 if ( m_fontData
.initialFont
.Ok() )
103 flags
|= CF_INITTOLOGFONTSTRUCT
;
104 wxFillLogFont(&logFont
, &m_fontData
.initialFont
);
107 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.fontColour
);
109 // CF_ANSIONLY flag is obsolete for Win32
110 if ( !m_fontData
.GetAllowSymbols() )
113 flags
|= CF_ANSIONLY
;
115 flags
|= CF_SELECTSCRIPT
;
116 logFont
.lfCharSet
= ANSI_CHARSET
;
120 if ( m_fontData
.GetEnableEffects() )
122 if ( m_fontData
.GetShowHelp() )
123 flags
|= CF_SHOWHELP
;
125 if ( m_fontData
.minSize
!= 0 || m_fontData
.maxSize
!= 0 )
127 chooseFontStruct
.nSizeMin
= m_fontData
.minSize
;
128 chooseFontStruct
.nSizeMax
= m_fontData
.maxSize
;
129 flags
|= CF_LIMITSIZE
;
132 chooseFontStruct
.Flags
= flags
;
134 if ( ChooseFont(&chooseFontStruct
) != 0 )
136 wxRGBToColour(m_fontData
.fontColour
, chooseFontStruct
.rgbColors
);
137 m_fontData
.chosenFont
= wxCreateFontFromLogFont(&logFont
);
138 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
139 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
145 // common dialog failed - why?
147 DWORD dwErr
= CommDlgExtendedError();
150 // this msg is only for developers
151 wxLogError(wxT("Common dialog failed with error code %0lx."),
154 //else: it was just cancelled