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"
36 #include "wx/cmndata.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
49 // ============================================================================
51 // ============================================================================
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 int wxFontDialog::ShowModal()
59 // It should be OK to always use GDI simulations
60 DWORD flags
= CF_SCREENFONTS
/* | CF_NOSIMULATIONS */ ;
64 CHOOSEFONT chooseFontStruct
;
65 wxZeroMemory(chooseFontStruct
);
67 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
69 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
70 chooseFontStruct
.lpLogFont
= &logFont
;
72 if ( m_fontData
.m_initialFont
.Ok() )
74 flags
|= CF_INITTOLOGFONTSTRUCT
;
75 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
78 if ( m_fontData
.m_fontColour
.Ok() )
80 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
83 // CF_ANSIONLY flag is obsolete for Win32
84 if ( !m_fontData
.GetAllowSymbols() )
86 flags
|= CF_SELECTSCRIPT
;
87 logFont
.lfCharSet
= ANSI_CHARSET
;
90 if ( m_fontData
.GetEnableEffects() )
92 if ( m_fontData
.GetShowHelp() )
95 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
97 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
98 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
99 flags
|= CF_LIMITSIZE
;
102 chooseFontStruct
.Flags
= flags
;
104 if ( ChooseFont(&chooseFontStruct
) != 0 )
106 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
107 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
108 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
109 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
115 // common dialog failed - why?
117 DWORD dwErr
= CommDlgExtendedError();
120 // this msg is only for developers
121 wxLogError(wxT("Common dialog failed with error code %0lx."),
124 //else: it was just cancelled
131 #endif // wxUSE_FONTDLG