]> git.saurik.com Git - wxWidgets.git/blame - src/msw/fontdlg.cpp
Move POSIX implementation of wxThread::Create() to wxThreadInternal.
[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
ce5d92e1 29#include "wx/fontdlg.h"
643e9cf9 30#include "wx/testing.h"
ce5d92e1 31
2bda0e17 32#ifndef WX_PRECOMP
57bd4c60 33 #include "wx/msw/wrapcdlg.h"
11c7d5b6
VZ
34 #include "wx/utils.h"
35 #include "wx/dialog.h"
e4db172a 36 #include "wx/log.h"
18680f86 37 #include "wx/math.h"
2bda0e17
KB
38#endif
39
2bda0e17
KB
40#include <stdlib.h>
41#include <string.h>
42
11c7d5b6
VZ
43// ----------------------------------------------------------------------------
44// wxWin macros
45// ----------------------------------------------------------------------------
2bda0e17 46
6fe19057 47IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
2bda0e17 48
11c7d5b6
VZ
49// ============================================================================
50// implementation
51// ============================================================================
2bda0e17 52
11c7d5b6
VZ
53// ----------------------------------------------------------------------------
54// wxFontDialog
55// ----------------------------------------------------------------------------
2bda0e17 56
11c7d5b6 57int wxFontDialog::ShowModal()
2bda0e17 58{
643e9cf9
VS
59 WX_TESTING_SHOW_MODAL_HOOK();
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
a1b806b9 74 if ( m_fontData.m_initialFont.IsOk() )
2bda0e17 75 {
11c7d5b6 76 flags |= CF_INITTOLOGFONTSTRUCT;
ae500232 77 wxFillLogFont(&logFont, &m_fontData.m_initialFont);
2bda0e17
KB
78 }
79
a1b806b9 80 if ( m_fontData.m_fontColour.IsOk() )
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 DWORD dwErr = CommDlgExtendedError();
118 if ( dwErr != 0 )
119 {
4b6a582b 120 wxLogError(_("Common dialog failed with error code %0lx."), dwErr);
11c7d5b6
VZ
121 }
122 //else: it was just cancelled
a1d58ddc 123
11c7d5b6 124 return wxID_CANCEL;
a1d58ddc 125 }
2bda0e17 126}
1e6feb95
VZ
127
128#endif // wxUSE_FONTDLG