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