1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/fontdlg.cpp
3 // Purpose: wxFontDialog class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
28 #include "wx/fontdlg.h"
29 #include "wx/modalhook.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 WX_HOOK_MODAL_DIALOG();
60 // It should be OK to always use GDI simulations
61 DWORD flags
= CF_SCREENFONTS
/* | CF_NOSIMULATIONS */ ;
65 CHOOSEFONT chooseFontStruct
;
66 wxZeroMemory(chooseFontStruct
);
68 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
70 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
71 chooseFontStruct
.lpLogFont
= &logFont
;
73 if ( m_fontData
.m_initialFont
.IsOk() )
75 flags
|= CF_INITTOLOGFONTSTRUCT
;
76 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
79 if ( m_fontData
.m_fontColour
.IsOk() )
81 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
84 // CF_ANSIONLY flag is obsolete for Win32
85 if ( !m_fontData
.GetAllowSymbols() )
87 flags
|= CF_SELECTSCRIPT
;
88 logFont
.lfCharSet
= ANSI_CHARSET
;
91 if ( m_fontData
.GetEnableEffects() )
93 if ( m_fontData
.GetShowHelp() )
96 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
98 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
99 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
100 flags
|= CF_LIMITSIZE
;
103 chooseFontStruct
.Flags
= flags
;
105 if ( ChooseFont(&chooseFontStruct
) != 0 )
107 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
108 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
109 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
110 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
116 DWORD dwErr
= CommDlgExtendedError();
119 wxLogError(_("Common dialog failed with error code %0lx."), dwErr
);
121 //else: it was just cancelled
127 #endif // wxUSE_FONTDLG