1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/fontdlg.cpp
3 // Purpose: wxFontDialog class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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"
40 #include "wx/msw/private.h"
42 #if !defined(__WIN32__) || defined(__WXWINCE__)
46 #include "wx/cmndata.h"
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
59 // ============================================================================
61 // ============================================================================
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
67 int wxFontDialog::ShowModal()
69 DWORD flags
= CF_SCREENFONTS
| CF_NOSIMULATIONS
;
73 CHOOSEFONT chooseFontStruct
;
74 wxZeroMemory(chooseFontStruct
);
76 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
78 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
79 chooseFontStruct
.lpLogFont
= &logFont
;
81 if ( m_fontData
.m_initialFont
.Ok() )
83 flags
|= CF_INITTOLOGFONTSTRUCT
;
84 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
87 if ( m_fontData
.m_fontColour
.Ok() )
89 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
91 // need this for the colour to be taken into account
95 // CF_ANSIONLY flag is obsolete for Win32
96 if ( !m_fontData
.GetAllowSymbols() )
101 flags
|= CF_SELECTSCRIPT
;
102 logFont
.lfCharSet
= ANSI_CHARSET
;
106 if ( m_fontData
.GetEnableEffects() )
108 if ( m_fontData
.GetShowHelp() )
109 flags
|= CF_SHOWHELP
;
111 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
113 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
114 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
115 flags
|= CF_LIMITSIZE
;
118 chooseFontStruct
.Flags
= flags
;
120 if ( ChooseFont(&chooseFontStruct
) != 0 )
122 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
123 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
124 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
125 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
131 // common dialog failed - why?
133 DWORD dwErr
= CommDlgExtendedError();
136 // this msg is only for developers
137 wxLogError(wxT("Common dialog failed with error code %0lx."),
140 //else: it was just cancelled
147 #endif // wxUSE_FONTDLG