]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/fontdlg.cpp
preserve type when loaded image is rescaled, #11543
[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// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#if wxUSE_FONTDLG
28
29#include "wx/fontdlg.h"
30
31#ifndef WX_PRECOMP
32 #include "wx/msw/wrapcdlg.h"
33 #include "wx/utils.h"
34 #include "wx/dialog.h"
35 #include "wx/log.h"
36 #include "wx/cmndata.h"
37 #include "wx/math.h"
38#endif
39
40#include <stdlib.h>
41#include <string.h>
42
43// ----------------------------------------------------------------------------
44// wxWin macros
45// ----------------------------------------------------------------------------
46
47IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
48
49// ============================================================================
50// implementation
51// ============================================================================
52
53// ----------------------------------------------------------------------------
54// wxFontDialog
55// ----------------------------------------------------------------------------
56
57int wxFontDialog::ShowModal()
58{
59 // It should be OK to always use GDI simulations
60 DWORD flags = CF_SCREENFONTS /* | CF_NOSIMULATIONS */ ;
61
62 LOGFONT logFont;
63
64 CHOOSEFONT chooseFontStruct;
65 wxZeroMemory(chooseFontStruct);
66
67 chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
68 if ( m_parent )
69 chooseFontStruct.hwndOwner = GetHwndOf(m_parent);
70 chooseFontStruct.lpLogFont = &logFont;
71
72 if ( m_fontData.m_initialFont.Ok() )
73 {
74 flags |= CF_INITTOLOGFONTSTRUCT;
75 wxFillLogFont(&logFont, &m_fontData.m_initialFont);
76 }
77
78 if ( m_fontData.m_fontColour.Ok() )
79 {
80 chooseFontStruct.rgbColors = wxColourToRGB(m_fontData.m_fontColour);
81 }
82
83 // CF_ANSIONLY flag is obsolete for Win32
84 if ( !m_fontData.GetAllowSymbols() )
85 {
86 flags |= CF_SELECTSCRIPT;
87 logFont.lfCharSet = ANSI_CHARSET;
88 }
89
90 if ( m_fontData.GetEnableEffects() )
91 flags |= CF_EFFECTS;
92 if ( m_fontData.GetShowHelp() )
93 flags |= CF_SHOWHELP;
94
95 if ( m_fontData.m_minSize != 0 || m_fontData.m_maxSize != 0 )
96 {
97 chooseFontStruct.nSizeMin = m_fontData.m_minSize;
98 chooseFontStruct.nSizeMax = m_fontData.m_maxSize;
99 flags |= CF_LIMITSIZE;
100 }
101
102 chooseFontStruct.Flags = flags;
103
104 if ( ChooseFont(&chooseFontStruct) != 0 )
105 {
106 wxRGBToColour(m_fontData.m_fontColour, chooseFontStruct.rgbColors);
107 m_fontData.m_chosenFont = wxCreateFontFromLogFont(&logFont);
108 m_fontData.EncodingInfo().facename = logFont.lfFaceName;
109 m_fontData.EncodingInfo().charset = logFont.lfCharSet;
110
111 return wxID_OK;
112 }
113 else
114 {
115 DWORD dwErr = CommDlgExtendedError();
116 if ( dwErr != 0 )
117 {
118 wxLogError(_("Common dialog failed with error code %0lx."), dwErr);
119 }
120 //else: it was just cancelled
121
122 return wxID_CANCEL;
123 }
124}
125
126#endif // wxUSE_FONTDLG