]> git.saurik.com Git - wxWidgets.git/blob - src/os2/fontdlg.cpp
supporting full style mask
[wxWidgets.git] / src / os2 / fontdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/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 #include "wx/fontdlg.h"
17
18 #ifndef WX_PRECOMP
19 #include <stdio.h>
20 #include "wx/utils.h"
21 #include "wx/dialog.h"
22 #include "wx/math.h"
23 #endif
24
25 #include "wx/fontutil.h"
26
27 #define INCL_PM
28 #include <os2.h>
29
30 #include "wx/os2/private.h"
31
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 FACENAMEDESC vFn;
43
44 memset(&vFontDlg, '\0', sizeof(FONTDLG));
45 zCurrentFont[0] = '\0';
46
47 //
48 // Set the fontdlg fields
49 //
50 vFontDlg.cbSize = sizeof(FONTDLG);
51 vFontDlg.hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
52 vFontDlg.hpsPrinter = NULL;
53 vFontDlg.pszFamilyname = zCurrentFont;
54 vFontDlg.fxPointSize = MAKEFIXED(12,0);
55 vFontDlg.usFamilyBufLen = FACESIZE;
56 vFontDlg.fl = FNTS_CENTER;
57 vFontDlg.clrFore = CLR_BLACK;
58 vFontDlg.clrBack = CLR_WHITE;
59
60 hWndFontDlg = WinFontDlg( HWND_DESKTOP
61 ,GetParent()->GetHWND()
62 ,&vFontDlg
63 );
64 if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
65 {
66 wxColour vColour((unsigned long)0x00000000);
67 wxNativeFontInfo vInfo;
68
69 m_fontData.m_fontColour = vColour;
70
71 memset(&vFn, '\0', sizeof(FACENAMEDESC));
72 vFn.usSize = sizeof(FACENAMEDESC);
73 vFn.usWeightClass = vFontDlg.usWeight;
74 vFn.usWidthClass = vFontDlg.usWidth;
75
76 memset(&vInfo.fa, '\0', sizeof(FATTRS));
77 memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));
78
79 vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength;
80 strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename);
81 vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch;
82
83 //
84 // Debugging
85 //
86 wxFont vChosenFont(vInfo);
87
88 int nPointSize = vFontDlg.fxPointSize >> 16;
89
90 vChosenFont.SetPointSize(nPointSize);
91 m_fontData.m_chosenFont = vChosenFont;
92
93 m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename;
94 m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
95
96 return wxID_OK;
97 }
98 return wxID_CANCEL;
99 } // end of wxFontDialg::ShowModal