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 if ( m_fontData
.fontColour
.Ok() )
110 chooseFontStruct
.rgbColors
= wxColourToRGB(m_fontData
.fontColour
);
112 // need this for the colour to be taken into account
116 // CF_ANSIONLY flag is obsolete for Win32
117 if ( !m_fontData
.GetAllowSymbols() )
120 flags
|= CF_ANSIONLY
;
122 flags
|= CF_SELECTSCRIPT
;
123 logFont
.lfCharSet
= ANSI_CHARSET
;
127 if ( m_fontData
.GetEnableEffects() )
129 if ( m_fontData
.GetShowHelp() )
130 flags
|= CF_SHOWHELP
;
132 if ( m_fontData
.minSize
!= 0 || m_fontData
.maxSize
!= 0 )
134 chooseFontStruct
.nSizeMin
= m_fontData
.minSize
;
135 chooseFontStruct
.nSizeMax
= m_fontData
.maxSize
;
136 flags
|= CF_LIMITSIZE
;
139 chooseFontStruct
.Flags
= flags
;
141 if ( ChooseFont(&chooseFontStruct
) != 0 )
143 wxRGBToColour(m_fontData
.fontColour
, chooseFontStruct
.rgbColors
);
144 m_fontData
.chosenFont
= wxCreateFontFromLogFont(&logFont
);
145 m_fontData
.EncodingInfo().facename
= logFont
.lfFaceName
;
146 m_fontData
.EncodingInfo().charset
= logFont
.lfCharSet
;
152 // common dialog failed - why?
154 DWORD dwErr
= CommDlgExtendedError();
157 // this msg is only for developers
158 wxLogError(wxT("Common dialog failed with error code %0lx."),
161 //else: it was just cancelled
168 #endif // wxUSE_FONTDLG