1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/fontdlg.cpp
3 // Purpose: wxFontDialog class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
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"
41 #if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
45 #include "wx/msw/private.h"
46 #include "wx/cmndata.h"
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
59 // ============================================================================
61 // ============================================================================
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
67 wxFontDialog::wxFontDialog()
72 wxFontDialog::wxFontDialog(wxWindow
*parent
, wxFontData
*data
)
77 bool wxFontDialog::Create(wxWindow
*parent
, wxFontData
*data
)
81 wxCHECK_MSG( data
, FALSE
, _T("no font data in wxFontDialog") );
88 int wxFontDialog::ShowModal()
90 DWORD flags
= CF_SCREENFONTS
| CF_NOSIMULATIONS
;
94 CHOOSEFONT chooseFontStruct
;
95 wxZeroMemory(chooseFontStruct
);
97 chooseFontStruct
.lStructSize
= sizeof(CHOOSEFONT
);
99 chooseFontStruct
.hwndOwner
= GetHwndOf(m_parent
);
100 chooseFontStruct
.lpLogFont
= &logFont
;
102 if ( m_fontData
.initialFont
.Ok() )
104 flags
|= CF_INITTOLOGFONTSTRUCT
;
105 wxFillLogFont(&logFont
, &m_fontData
.initialFont
);
108 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.fontColour
);
110 // CF_ANSIONLY flag is obsolete for Win32
111 if ( !m_fontData
.GetAllowSymbols() )
114 flags
|= CF_ANSIONLY
;
116 flags
|= CF_SELECTSCRIPT
;
117 logFont
.lfCharSet
= ANSI_CHARSET
;
121 if ( m_fontData
.GetEnableEffects() )
123 if ( m_fontData
.GetShowHelp() )
124 flags
|= CF_SHOWHELP
;
126 if ( m_fontData
.minSize
!= 0 || m_fontData
.maxSize
!= 0 )
128 chooseFontStruct
.nSizeMin
= m_fontData
.minSize
;
129 chooseFontStruct
.nSizeMax
= m_fontData
.maxSize
;
130 flags
|= CF_LIMITSIZE
;
133 chooseFontStruct
.Flags
= flags
;
135 if ( ChooseFont(&chooseFontStruct
) != 0 )
137 wxRGBToColour(m_fontData
.fontColour
, chooseFontStruct
.rgbColors
);
138 m_fontData
.chosenFont
= wxCreateFontFromLogFont(&logFont
);
139 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
140 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
146 // common dialog failed - why?
148 DWORD dwErr
= CommDlgExtendedError();
151 // this msg is only for developers
152 wxLogError(wxT("Common dialog failed with error code %0lx."),
155 //else: it was just cancelled
162 #endif // wxUSE_FONTDLG