]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/fontdlg.cpp
The list ctrl doesn't draw any focus
[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/private.h"
41
42#if !defined(__WIN32__) || defined(__WXWINCE__)
43#include <commdlg.h>
44#endif
45
46#include "wx/cmndata.h"
47#include "wx/log.h"
48
49#include <math.h>
50#include <stdlib.h>
51#include <string.h>
52
53// ----------------------------------------------------------------------------
54// wxWin macros
55// ----------------------------------------------------------------------------
56
57IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
58
59// ============================================================================
60// implementation
61// ============================================================================
62
63// ----------------------------------------------------------------------------
64// wxFontDialog
65// ----------------------------------------------------------------------------
66
67int wxFontDialog::ShowModal()
68{
69 DWORD flags = CF_SCREENFONTS | CF_NOSIMULATIONS;
70
71 LOGFONT logFont;
72
73 CHOOSEFONT chooseFontStruct;
74 wxZeroMemory(chooseFontStruct);
75
76 chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
77 if ( m_parent )
78 chooseFontStruct.hwndOwner = GetHwndOf(m_parent);
79 chooseFontStruct.lpLogFont = &logFont;
80
81 if ( m_fontData.m_initialFont.Ok() )
82 {
83 flags |= CF_INITTOLOGFONTSTRUCT;
84 wxFillLogFont(&logFont, &m_fontData.m_initialFont);
85 }
86
87 if ( m_fontData.m_fontColour.Ok() )
88 {
89 chooseFontStruct.rgbColors = wxColourToRGB(m_fontData.m_fontColour);
90
91 // need this for the colour to be taken into account
92 flags |= CF_EFFECTS;
93 }
94
95 // CF_ANSIONLY flag is obsolete for Win32
96 if ( !m_fontData.GetAllowSymbols() )
97 {
98#ifdef __WIN16__
99 flags |= CF_ANSIONLY;
100#else // Win32
101 flags |= CF_SELECTSCRIPT;
102 logFont.lfCharSet = ANSI_CHARSET;
103#endif // Win16/32
104 }
105
106 if ( m_fontData.GetEnableEffects() )
107 flags |= CF_EFFECTS;
108 if ( m_fontData.GetShowHelp() )
109 flags |= CF_SHOWHELP;
110
111 if ( m_fontData.m_minSize != 0 || m_fontData.m_maxSize != 0 )
112 {
113 chooseFontStruct.nSizeMin = m_fontData.m_minSize;
114 chooseFontStruct.nSizeMax = m_fontData.m_maxSize;
115 flags |= CF_LIMITSIZE;
116 }
117
118 chooseFontStruct.Flags = flags;
119
120 if ( ChooseFont(&chooseFontStruct) != 0 )
121 {
122 wxRGBToColour(m_fontData.m_fontColour, chooseFontStruct.rgbColors);
123 m_fontData.m_chosenFont = wxCreateFontFromLogFont(&logFont);
124 m_fontData.EncodingInfo().facename = logFont.lfFaceName;
125 m_fontData.EncodingInfo().charset = logFont.lfCharSet;
126
127 return wxID_OK;
128 }
129 else
130 {
131 // common dialog failed - why?
132#ifdef __WXDEBUG__
133 DWORD dwErr = CommDlgExtendedError();
134 if ( dwErr != 0 )
135 {
136 // this msg is only for developers
137 wxLogError(wxT("Common dialog failed with error code %0lx."),
138 dwErr);
139 }
140 //else: it was just cancelled
141#endif
142
143 return wxID_CANCEL;
144 }
145}
146
147#endif // wxUSE_FONTDLG