1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/fontdlg.cpp
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"
36 #include "wx/dialog.h"
39 #include "wx/fontdlg.h"
41 #if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
46 #include "wx/msw/private.h"
47 #include "wx/cmndata.h"
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
60 // ============================================================================
62 // ============================================================================
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 int wxFontDialog::ShowModal()
70 DWORD flags
= CF_SCREENFONTS
| CF_NOSIMULATIONS
;
74 CHOOSEFONT chooseFontStruct
;
75 wxZeroMemory(chooseFontStruct
);
77 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
79 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
80 chooseFontStruct
.lpLogFont
= &logFont
;
82 if ( m_fontData
.initialFont
.Ok() )
84 flags
|= CF_INITTOLOGFONTSTRUCT
;
85 wxFillLogFont(&logFont
, &m_fontData
.initialFont
);
88 if ( m_fontData
.fontColour
.Ok() )
90 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.fontColour
);
92 // need this for the colour to be taken into account
96 // CF_ANSIONLY flag is obsolete for Win32
97 if ( !m_fontData
.GetAllowSymbols() )
100 flags
|= CF_ANSIONLY
;
102 flags
|= CF_SELECTSCRIPT
;
103 logFont
.lfCharSet
= ANSI_CHARSET
;
107 if ( m_fontData
.GetEnableEffects() )
109 if ( m_fontData
.GetShowHelp() )
110 flags
|= CF_SHOWHELP
;
112 if ( m_fontData
.minSize
!= 0 || m_fontData
.maxSize
!= 0 )
114 chooseFontStruct
.nSizeMin
= m_fontData
.minSize
;
115 chooseFontStruct
.nSizeMax
= m_fontData
.maxSize
;
116 flags
|= CF_LIMITSIZE
;
119 chooseFontStruct
.Flags
= flags
;
121 if ( ChooseFont(&chooseFontStruct
) != 0 )
123 wxRGBToColour(m_fontData
.fontColour
, chooseFontStruct
.rgbColors
);
124 m_fontData
.chosenFont
= wxCreateFontFromLogFont(&logFont
);
125 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
126 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
132 // common dialog failed - why?
134 DWORD dwErr
= CommDlgExtendedError();
137 // this msg is only for developers
138 wxLogError(wxT("Common dialog failed with error code %0lx."),
141 //else: it was just cancelled
148 #endif // wxUSE_FONTDLG