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"
30 #include "wx/modalhook.h"
33 #include "wx/msw/wrapcdlg.h"
35 #include "wx/dialog.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
49 // ============================================================================
51 // ============================================================================
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 int wxFontDialog::ShowModal()
59 WX_HOOK_MODAL_DIALOG();
61 // It should be OK to always use GDI simulations
62 DWORD flags
= CF_SCREENFONTS
/* | CF_NOSIMULATIONS */ ;
66 CHOOSEFONT chooseFontStruct
;
67 wxZeroMemory(chooseFontStruct
);
69 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
71 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
72 chooseFontStruct
.lpLogFont
= &logFont
;
74 if ( m_fontData
.m_initialFont
.IsOk() )
76 flags
|= CF_INITTOLOGFONTSTRUCT
;
77 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
80 if ( m_fontData
.m_fontColour
.IsOk() )
82 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
85 // CF_ANSIONLY flag is obsolete for Win32
86 if ( !m_fontData
.GetAllowSymbols() )
88 flags
|= CF_SELECTSCRIPT
;
89 logFont
.lfCharSet
= ANSI_CHARSET
;
92 if ( m_fontData
.GetEnableEffects() )
94 if ( m_fontData
.GetShowHelp() )
97 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
99 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
100 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
101 flags
|= CF_LIMITSIZE
;
104 chooseFontStruct
.Flags
= flags
;
106 if ( ChooseFont(&chooseFontStruct
) != 0 )
108 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
109 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
110 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
111 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
117 DWORD dwErr
= CommDlgExtendedError();
120 wxLogError(_("Common dialog failed with error code %0lx."), dwErr
);
122 //else: it was just cancelled
128 #endif // wxUSE_FONTDLG