]>
Commit | Line | Data |
---|---|---|
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/utils.h" |
31 | #include "wx/dialog.h" | |
e4db172a | 32 | #include "wx/log.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" |
b713f891 | 39 | #include "wx/math.h" |
2bda0e17 | 40 | |
2bda0e17 KB |
41 | #include <stdlib.h> |
42 | #include <string.h> | |
43 | ||
11c7d5b6 VZ |
44 | // ---------------------------------------------------------------------------- |
45 | // wxWin macros | |
46 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 47 | |
6fe19057 | 48 | IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) |
2bda0e17 | 49 | |
11c7d5b6 VZ |
50 | // ============================================================================ |
51 | // implementation | |
52 | // ============================================================================ | |
2bda0e17 | 53 | |
11c7d5b6 VZ |
54 | // ---------------------------------------------------------------------------- |
55 | // wxFontDialog | |
56 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 57 | |
11c7d5b6 | 58 | int wxFontDialog::ShowModal() |
2bda0e17 | 59 | { |
5e80ff3d JS |
60 | // It should be OK to always use GDI simulations |
61 | DWORD flags = CF_SCREENFONTS /* | CF_NOSIMULATIONS */ ; | |
2bda0e17 | 62 | |
11c7d5b6 | 63 | LOGFONT logFont; |
2bda0e17 | 64 | |
11c7d5b6 VZ |
65 | CHOOSEFONT chooseFontStruct; |
66 | wxZeroMemory(chooseFontStruct); | |
2bda0e17 KB |
67 | |
68 | chooseFontStruct.lStructSize = sizeof(CHOOSEFONT); | |
11c7d5b6 VZ |
69 | if ( m_parent ) |
70 | chooseFontStruct.hwndOwner = GetHwndOf(m_parent); | |
2bda0e17 KB |
71 | chooseFontStruct.lpLogFont = &logFont; |
72 | ||
ae500232 | 73 | if ( m_fontData.m_initialFont.Ok() ) |
2bda0e17 | 74 | { |
11c7d5b6 | 75 | flags |= CF_INITTOLOGFONTSTRUCT; |
ae500232 | 76 | wxFillLogFont(&logFont, &m_fontData.m_initialFont); |
2bda0e17 KB |
77 | } |
78 | ||
ae500232 | 79 | if ( m_fontData.m_fontColour.Ok() ) |
951cf90d | 80 | { |
ae500232 | 81 | chooseFontStruct.rgbColors = wxColourToRGB(m_fontData.m_fontColour); |
951cf90d | 82 | } |
2bda0e17 | 83 | |
11c7d5b6 VZ |
84 | // CF_ANSIONLY flag is obsolete for Win32 |
85 | if ( !m_fontData.GetAllowSymbols() ) | |
86 | { | |
11c7d5b6 VZ |
87 | flags |= CF_SELECTSCRIPT; |
88 | logFont.lfCharSet = ANSI_CHARSET; | |
11c7d5b6 VZ |
89 | } |
90 | ||
91 | if ( m_fontData.GetEnableEffects() ) | |
2bda0e17 | 92 | flags |= CF_EFFECTS; |
11c7d5b6 | 93 | if ( m_fontData.GetShowHelp() ) |
2bda0e17 | 94 | flags |= CF_SHOWHELP; |
11c7d5b6 | 95 | |
ae500232 | 96 | if ( m_fontData.m_minSize != 0 || m_fontData.m_maxSize != 0 ) |
2bda0e17 | 97 | { |
ae500232 JS |
98 | chooseFontStruct.nSizeMin = m_fontData.m_minSize; |
99 | chooseFontStruct.nSizeMax = m_fontData.m_maxSize; | |
11c7d5b6 | 100 | flags |= CF_LIMITSIZE; |
2bda0e17 KB |
101 | } |
102 | ||
103 | chooseFontStruct.Flags = flags; | |
2bda0e17 | 104 | |
11c7d5b6 | 105 | if ( ChooseFont(&chooseFontStruct) != 0 ) |
2bda0e17 | 106 | { |
ae500232 JS |
107 | wxRGBToColour(m_fontData.m_fontColour, chooseFontStruct.rgbColors); |
108 | m_fontData.m_chosenFont = wxCreateFontFromLogFont(&logFont); | |
11c7d5b6 VZ |
109 | m_fontData.EncodingInfo().facename = logFont.lfFaceName; |
110 | m_fontData.EncodingInfo().charset = logFont.lfCharSet; | |
2bda0e17 | 111 | |
11c7d5b6 | 112 | return wxID_OK; |
2bda0e17 | 113 | } |
2bda0e17 | 114 | else |
a1d58ddc | 115 | { |
11c7d5b6 VZ |
116 | // common dialog failed - why? |
117 | #ifdef __WXDEBUG__ | |
118 | DWORD dwErr = CommDlgExtendedError(); | |
119 | if ( dwErr != 0 ) | |
120 | { | |
121 | // this msg is only for developers | |
122 | wxLogError(wxT("Common dialog failed with error code %0lx."), | |
123 | dwErr); | |
124 | } | |
125 | //else: it was just cancelled | |
126 | #endif | |
a1d58ddc | 127 | |
11c7d5b6 | 128 | return wxID_CANCEL; |
a1d58ddc | 129 | } |
2bda0e17 | 130 | } |
1e6feb95 VZ |
131 | |
132 | #endif // wxUSE_FONTDLG |