]> git.saurik.com Git - wxWidgets.git/blame - src/msw/fontdlg.cpp
remove extraneous semicolons (patch 1299687)
[wxWidgets.git] / src / msw / fontdlg.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
1e6feb95 2// Name: src/msw/fontdlg.cpp
2bda0e17
KB
3// Purpose: wxFontDialog class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
11c7d5b6
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
2bda0e17
KB
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
11c7d5b6 24 #pragma hdrstop
2bda0e17
KB
25#endif
26
1e6feb95
VZ
27#if wxUSE_FONTDLG
28
2bda0e17 29#ifndef WX_PRECOMP
11c7d5b6
VZ
30 #include "wx/defs.h"
31 #include "wx/utils.h"
32 #include "wx/dialog.h"
2bda0e17
KB
33#endif
34
35#include "wx/fontdlg.h"
660296aa 36#include "wx/msw/wrapcdlg.h"
2bda0e17 37
2bda0e17 38#include "wx/cmndata.h"
01dba85a 39#include "wx/log.h"
b713f891 40#include "wx/math.h"
2bda0e17 41
2bda0e17
KB
42#include <stdlib.h>
43#include <string.h>
44
11c7d5b6
VZ
45// ----------------------------------------------------------------------------
46// wxWin macros
47// ----------------------------------------------------------------------------
2bda0e17 48
6fe19057 49IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
2bda0e17 50
11c7d5b6
VZ
51// ============================================================================
52// implementation
53// ============================================================================
2bda0e17 54
11c7d5b6
VZ
55// ----------------------------------------------------------------------------
56// wxFontDialog
57// ----------------------------------------------------------------------------
2bda0e17 58
11c7d5b6 59int wxFontDialog::ShowModal()
2bda0e17 60{
5e80ff3d
JS
61 // It should be OK to always use GDI simulations
62 DWORD flags = CF_SCREENFONTS /* | CF_NOSIMULATIONS */ ;
2bda0e17 63
11c7d5b6 64 LOGFONT logFont;
2bda0e17 65
11c7d5b6
VZ
66 CHOOSEFONT chooseFontStruct;
67 wxZeroMemory(chooseFontStruct);
2bda0e17
KB
68
69 chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
11c7d5b6
VZ
70 if ( m_parent )
71 chooseFontStruct.hwndOwner = GetHwndOf(m_parent);
2bda0e17
KB
72 chooseFontStruct.lpLogFont = &logFont;
73
ae500232 74 if ( m_fontData.m_initialFont.Ok() )
2bda0e17 75 {
11c7d5b6 76 flags |= CF_INITTOLOGFONTSTRUCT;
ae500232 77 wxFillLogFont(&logFont, &m_fontData.m_initialFont);
2bda0e17
KB
78 }
79
ae500232 80 if ( m_fontData.m_fontColour.Ok() )
951cf90d 81 {
ae500232 82 chooseFontStruct.rgbColors = wxColourToRGB(m_fontData.m_fontColour);
951cf90d 83 }
2bda0e17 84
11c7d5b6
VZ
85 // CF_ANSIONLY flag is obsolete for Win32
86 if ( !m_fontData.GetAllowSymbols() )
87 {
11c7d5b6
VZ
88 flags |= CF_SELECTSCRIPT;
89 logFont.lfCharSet = ANSI_CHARSET;
11c7d5b6
VZ
90 }
91
92 if ( m_fontData.GetEnableEffects() )
2bda0e17 93 flags |= CF_EFFECTS;
11c7d5b6 94 if ( m_fontData.GetShowHelp() )
2bda0e17 95 flags |= CF_SHOWHELP;
11c7d5b6 96
ae500232 97 if ( m_fontData.m_minSize != 0 || m_fontData.m_maxSize != 0 )
2bda0e17 98 {
ae500232
JS
99 chooseFontStruct.nSizeMin = m_fontData.m_minSize;
100 chooseFontStruct.nSizeMax = m_fontData.m_maxSize;
11c7d5b6 101 flags |= CF_LIMITSIZE;
2bda0e17
KB
102 }
103
104 chooseFontStruct.Flags = flags;
2bda0e17 105
11c7d5b6 106 if ( ChooseFont(&chooseFontStruct) != 0 )
2bda0e17 107 {
ae500232
JS
108 wxRGBToColour(m_fontData.m_fontColour, chooseFontStruct.rgbColors);
109 m_fontData.m_chosenFont = wxCreateFontFromLogFont(&logFont);
11c7d5b6
VZ
110 m_fontData.EncodingInfo().facename = logFont.lfFaceName;
111 m_fontData.EncodingInfo().charset = logFont.lfCharSet;
2bda0e17 112
11c7d5b6 113 return wxID_OK;
2bda0e17 114 }
2bda0e17 115 else
a1d58ddc 116 {
11c7d5b6
VZ
117 // common dialog failed - why?
118#ifdef __WXDEBUG__
119 DWORD dwErr = CommDlgExtendedError();
120 if ( dwErr != 0 )
121 {
122 // this msg is only for developers
123 wxLogError(wxT("Common dialog failed with error code %0lx."),
124 dwErr);
125 }
126 //else: it was just cancelled
127#endif
a1d58ddc 128
11c7d5b6 129 return wxID_CANCEL;
a1d58ddc 130 }
2bda0e17 131}
1e6feb95
VZ
132
133#endif // wxUSE_FONTDLG