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"
31 #include "wx/dialog.h"
35 #include "wx/fontdlg.h"
36 #include "wx/msw/wrapcdlg.h"
38 #include "wx/cmndata.h"
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
50 // ============================================================================
52 // ============================================================================
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 int wxFontDialog::ShowModal()
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
.Ok() )
75 flags
|= CF_INITTOLOGFONTSTRUCT
;
76 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
79 if ( m_fontData
.m_fontColour
.Ok() )
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 // common dialog failed - why?
118 DWORD dwErr
= CommDlgExtendedError();
121 // this msg is only for developers
122 wxLogError(wxT("Common dialog failed with error code %0lx."),
125 //else: it was just cancelled
132 #endif // wxUSE_FONTDLG