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"
32 #include "wx/dialog.h"
35 #include "wx/fontdlg.h"
36 #include "wx/msw/wrapcdlg.h"
38 #include "wx/cmndata.h"
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
51 // ============================================================================
53 // ============================================================================
55 // ----------------------------------------------------------------------------
57 // ----------------------------------------------------------------------------
59 int wxFontDialog::ShowModal()
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
.Ok() )
76 flags
|= CF_INITTOLOGFONTSTRUCT
;
77 wxFillLogFont(&logFont
, &m_fontData
.m_initialFont
);
80 if ( m_fontData
.m_fontColour
.Ok() )
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 // common dialog failed - why?
119 DWORD dwErr
= CommDlgExtendedError();
122 // this msg is only for developers
123 wxLogError(wxT("Common dialog failed with error code %0lx."),
126 //else: it was just cancelled
133 #endif // wxUSE_FONTDLG