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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "fontdlg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/dialog.h"
39 #include "wx/fontdlg.h"
40 #include "wx/msw/wrapcdlg.h"
42 #include "wx/cmndata.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
55 // ============================================================================
57 // ============================================================================
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 int wxFontDialog::ShowModal()
65 // It should be OK to always use GDI simulations
66 DWORD flags
= CF_SCREENFONTS
/* | CF_NOSIMULATIONS */ ;
70 CHOOSEFONT chooseFontStruct
;
71 wxZeroMemory(chooseFontStruct
);
73 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
75 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
76 chooseFontStruct
.lpLogFont
= &logFont
;
78 if ( m_fontData
.m_initialFont
.Ok() )
80 flags
|= CF_INITTOLOGFONTSTRUCT
;
81 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
84 if ( m_fontData
.m_fontColour
.Ok() )
86 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.m_fontColour
);
89 // CF_ANSIONLY flag is obsolete for Win32
90 if ( !m_fontData
.GetAllowSymbols() )
92 flags
|= CF_SELECTSCRIPT
;
93 logFont
.lfCharSet
= ANSI_CHARSET
;
96 if ( m_fontData
.GetEnableEffects() )
98 if ( m_fontData
.GetShowHelp() )
101 if ( m_fontData
.m_minSize
!= 0 || m_fontData
.m_maxSize
!= 0 )
103 chooseFontStruct
.nSizeMin
= m_fontData
.m_minSize
;
104 chooseFontStruct
.nSizeMax
= m_fontData
.m_maxSize
;
105 flags
|= CF_LIMITSIZE
;
108 chooseFontStruct
.Flags
= flags
;
110 if ( ChooseFont(&chooseFontStruct
) != 0 )
112 wxRGBToColour(m_fontData
.m_fontColour
, chooseFontStruct
.rgbColors
);
113 m_fontData
.m_chosenFont
= wxCreateFontFromLogFont(&logFont
);
114 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
115 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
121 // common dialog failed - why?
123 DWORD dwErr
= CommDlgExtendedError();
126 // this msg is only for developers
127 wxLogError(wxT("Common dialog failed with error code %0lx."),
130 //else: it was just cancelled
137 #endif // wxUSE_FONTDLG