Font fixes for the font dialog
[wxWidgets.git] / src / os2 / fontdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontdlg.cpp
3 // Purpose: wxFontDialog class. NOTE: you can use the generic class
4 // if you wish, instead of implementing this.
5 // Author: David Webster
6 // Modified by:
7 // Created: 10/06/99
8 // RCS-ID: $Id$
9 // Copyright: (c) David Webster
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
15
16 #ifndef WX_PRECOMP
17 #include <stdio.h>
18 #include "wx/defs.h"
19 #include "wx/utils.h"
20 #include "wx/dialog.h"
21 #endif
22
23 #include "wx/fontdlg.h"
24
25 #define INCL_PM
26 #include <os2.h>
27
28 #include "wx/os2/private.h"
29 #include "wx/cmndata.h"
30
31 #include <math.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
36
37 int wxFontDialog::ShowModal()
38 {
39 FONTDLG vFontDlg;
40 char zCurrentFont[FACESIZE];
41 HWND hWndFontDlg;
42 FONTMETRICS vFm;
43 FACENAMEDESC vFn;
44
45 memset(&vFontDlg, '\0', sizeof(FONTDLG));
46 zCurrentFont[0] = '\0';
47
48 //
49 // Set the fontdlg fields
50 //
51 vFontDlg.cbSize = sizeof(FONTDLG);
52 vFontDlg.hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
53 vFontDlg.hpsPrinter = NULL;
54 vFontDlg.pszFamilyname = zCurrentFont;
55 vFontDlg.fxPointSize = MAKEFIXED(12,0);
56 vFontDlg.usFamilyBufLen = FACESIZE;
57 vFontDlg.fl = FNTS_CENTER;
58 vFontDlg.clrFore = CLR_BLACK;
59 vFontDlg.clrBack = CLR_WHITE;
60
61 hWndFontDlg = WinFontDlg( HWND_DESKTOP
62 ,GetParent()->GetHWND()
63 ,&vFontDlg
64 );
65 if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
66 {
67 wxColour vColour((unsigned long)0x00000000);
68 wxNativeFontInfo vInfo;
69
70 m_fontData.fontColour = vColour;
71
72 memset(&vFn, '\0', sizeof(FACENAMEDESC));
73 vFn.usSize = sizeof(FACENAMEDESC);
74 vFn.usWeightClass = vFontDlg.usWeight;
75 vFn.usWidthClass = vFontDlg.usWidth;
76
77 memcpy(&vInfo.fa, &vFontDlg.fAttrs, sizeof(FATTRS));
78 memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));
79
80 //
81 // Debugging
82 //
83 wxFont vChosenFont(vInfo);
84 int nFamily;
85 int nPointSize;
86 int nStyle;
87 int nWeight;
88 bool bUnderlined;
89 wxString sFaceName;
90 wxNativeFontInfo* pInfo;
91
92 nFamily = vChosenFont.GetFamily();
93 nPointSize = vChosenFont.GetPointSize();
94 nStyle = vChosenFont.GetStyle();
95 nWeight = vChosenFont.GetWeight();
96 bUnderlined = vChosenFont.GetUnderlined();
97 sFaceName = vChosenFont.GetFaceName();
98 pInfo = vChosenFont.GetNativeFontInfo();
99
100
101 m_fontData.chosenFont = vChosenFont;
102
103 nFamily = m_fontData.chosenFont.GetFamily();
104 nPointSize = m_fontData.chosenFont.GetPointSize();
105 nStyle = m_fontData.chosenFont.GetStyle();
106 nWeight = m_fontData.chosenFont.GetWeight();
107 bUnderlined = m_fontData.chosenFont.GetUnderlined();
108 sFaceName = m_fontData.chosenFont.GetFaceName();
109 pInfo = m_fontData.chosenFont.GetNativeFontInfo();
110
111 m_fontData.EncodingInfo().facename = vFontDlg.fAttrs.szFacename;
112 m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
113
114 return wxID_OK;
115 }
116 return wxID_CANCEL;
117 } // end of wxFontDialg::ShowModal
118