]> git.saurik.com Git - wxWidgets.git/blob - src/os2/fontdlg.cpp
Fix recreating of wxBitmapComboBox using untyped client data.
[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 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/fontdlg.h"
16
17 #ifndef WX_PRECOMP
18 #include <stdio.h>
19 #include "wx/utils.h"
20 #include "wx/dialog.h"
21 #include "wx/math.h"
22 #endif
23
24 #include "wx/fontutil.h"
25 #include "wx/modalhook.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 WX_HOOK_MODAL_DIALOG();
40
41 FONTDLG vFontDlg;
42 char zCurrentFont[FACESIZE];
43 HWND hWndFontDlg;
44 FACENAMEDESC vFn;
45
46 memset(&vFontDlg, '\0', sizeof(FONTDLG));
47 zCurrentFont[0] = '\0';
48
49 //
50 // Set the fontdlg fields
51 //
52 vFontDlg.cbSize = sizeof(FONTDLG);
53 vFontDlg.hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
54 vFontDlg.hpsPrinter = NULL;
55 vFontDlg.pszFamilyname = zCurrentFont;
56 vFontDlg.fxPointSize = MAKEFIXED(12,0);
57 vFontDlg.usFamilyBufLen = FACESIZE;
58 vFontDlg.fl = FNTS_CENTER;
59 vFontDlg.clrFore = CLR_BLACK;
60 vFontDlg.clrBack = CLR_WHITE;
61
62 hWndFontDlg = WinFontDlg( HWND_DESKTOP
63 ,GetParent()->GetHWND()
64 ,&vFontDlg
65 );
66 if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
67 {
68 wxColour vColour((unsigned long)0x00000000);
69 wxNativeFontInfo vInfo;
70
71 m_fontData.m_fontColour = vColour;
72
73 memset(&vFn, '\0', sizeof(FACENAMEDESC));
74 vFn.usSize = sizeof(FACENAMEDESC);
75 vFn.usWeightClass = vFontDlg.usWeight;
76 vFn.usWidthClass = vFontDlg.usWidth;
77
78 memset(&vInfo.fa, '\0', sizeof(FATTRS));
79 memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));
80
81 vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength;
82 strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename);
83 vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch;
84
85 //
86 // Debugging
87 //
88 wxFont vChosenFont(vInfo);
89
90 int nPointSize = vFontDlg.fxPointSize >> 16;
91
92 vChosenFont.SetPointSize(nPointSize);
93 m_fontData.m_chosenFont = vChosenFont;
94
95 m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename;
96 m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
97
98 return wxID_OK;
99 }
100 return wxID_CANCEL;
101 } // end of wxFontDialg::ShowModal