]> git.saurik.com Git - wxWidgets.git/blame - src/msw/fontdlg.cpp
Correct making the newly inserted menu item owner drawn in some cases.
[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
6c9a19aa 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
2bda0e17
KB
9/////////////////////////////////////////////////////////////////////////////
10
11c7d5b6
VZ
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
2bda0e17
KB
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
11c7d5b6 23 #pragma hdrstop
2bda0e17
KB
24#endif
25
1e6feb95
VZ
26#if wxUSE_FONTDLG
27
ce5d92e1 28#include "wx/fontdlg.h"
691745ab 29#include "wx/modalhook.h"
ce5d92e1 30
2bda0e17 31#ifndef WX_PRECOMP
57bd4c60 32 #include "wx/msw/wrapcdlg.h"
11c7d5b6
VZ
33 #include "wx/utils.h"
34 #include "wx/dialog.h"
e4db172a 35 #include "wx/log.h"
18680f86 36 #include "wx/math.h"
2bda0e17
KB
37#endif
38
2bda0e17
KB
39#include <stdlib.h>
40#include <string.h>
41
11c7d5b6
VZ
42// ----------------------------------------------------------------------------
43// wxWin macros
44// ----------------------------------------------------------------------------
2bda0e17 45
6fe19057 46IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
2bda0e17 47
11c7d5b6
VZ
48// ============================================================================
49// implementation
50// ============================================================================
2bda0e17 51
11c7d5b6
VZ
52// ----------------------------------------------------------------------------
53// wxFontDialog
54// ----------------------------------------------------------------------------
2bda0e17 55
11c7d5b6 56int wxFontDialog::ShowModal()
2bda0e17 57{
691745ab 58 WX_HOOK_MODAL_DIALOG();
643e9cf9 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
a1b806b9 73 if ( m_fontData.m_initialFont.IsOk() )
2bda0e17 74 {
11c7d5b6 75 flags |= CF_INITTOLOGFONTSTRUCT;
ae500232 76 wxFillLogFont(&logFont, &m_fontData.m_initialFont);
2bda0e17
KB
77 }
78
a1b806b9 79 if ( m_fontData.m_fontColour.IsOk() )
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 DWORD dwErr = CommDlgExtendedError();
117 if ( dwErr != 0 )
118 {
4b6a582b 119 wxLogError(_("Common dialog failed with error code %0lx."), dwErr);
11c7d5b6
VZ
120 }
121 //else: it was just cancelled
a1d58ddc 122
11c7d5b6 123 return wxID_CANCEL;
a1d58ddc 124 }
2bda0e17 125}
1e6feb95
VZ
126
127#endif // wxUSE_FONTDLG