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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/fontdlg.h"
32 #include "wx/msw/wrapcdlg.h"
34 #include "wx/dialog.h"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
48 // ============================================================================
50 // ============================================================================
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 int wxFontDialog::ShowModal()
58 // It should be OK to always use GDI simulations
59 DWORD flags
= CF_SCREENFONTS
/* | CF_NOSIMULATIONS */ ;
63 CHOOSEFONT chooseFontStruct
;
64 wxZeroMemory(chooseFontStruct
);
66 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
68 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
69 chooseFontStruct
.lpLogFont
= &logFont
;
71 if ( m_fontData
.m_initialFont
.IsOk() )
73 flags
|= CF_INITTOLOGFONTSTRUCT
;
74 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
77 if ( m_fontData
.m_fontColour
.IsOk() )
79 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
82 // CF_ANSIONLY flag is obsolete for Win32
83 if ( !m_fontData
.GetAllowSymbols() )
85 flags
|= CF_SELECTSCRIPT
;
86 logFont
.lfCharSet
= ANSI_CHARSET
;
89 if ( m_fontData
.GetEnableEffects() )
91 if ( m_fontData
.GetShowHelp() )
94 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
96 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
97 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
98 flags
|= CF_LIMITSIZE
;
101 chooseFontStruct
.Flags
= flags
;
103 if ( ChooseFont(&chooseFontStruct
) != 0 )
105 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
106 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
107 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
108 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
114 DWORD dwErr
= CommDlgExtendedError();
117 wxLogError(_("Common dialog failed with error code %0lx."), dwErr
);
119 //else: it was just cancelled
125 #endif // wxUSE_FONTDLG