]> git.saurik.com Git - wxWidgets.git/blame - src/os2/fontdlg.cpp
bracket 10.5 only code
[wxWidgets.git] / src / os2 / fontdlg.cpp
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
7520f3da 2// Name: src/os2/fontdlg.cpp
0e320a79
DW
3// Purpose: wxFontDialog class. NOTE: you can use the generic class
4// if you wish, instead of implementing this.
21802234 5// Author: David Webster
0e320a79 6// Modified by:
21802234 7// Created: 10/06/99
0e320a79 8// RCS-ID: $Id$
21802234 9// Copyright: (c) David Webster
65571936 10// Licence: wxWindows licence
0e320a79
DW
11/////////////////////////////////////////////////////////////////////////////
12
21802234
DW
13// For compilers that support precompilation, includes "wx.h".
14#include "wx/wxprec.h"
15
ce5d92e1
WS
16#include "wx/fontdlg.h"
17
21802234 18#ifndef WX_PRECOMP
7520f3da
WS
19 #include <stdio.h>
20 #include "wx/utils.h"
21 #include "wx/dialog.h"
22 #include "wx/math.h"
ce5d92e1 23 #include "wx/cmndata.h"
0e320a79
DW
24#endif
25
bd76e17e 26#include "wx/fontutil.h"
21802234
DW
27
28#define INCL_PM
29#include <os2.h>
30
31#include "wx/os2/private.h"
0e320a79 32
21802234
DW
33#include <stdlib.h>
34#include <string.h>
35
0e320a79 36IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
0e320a79 37
07df68c8 38int wxFontDialog::ShowModal()
0e320a79 39{
ce5d92e1
WS
40 FONTDLG vFontDlg;
41 char zCurrentFont[FACESIZE];
42 HWND hWndFontDlg;
43 FACENAMEDESC vFn;
0e320a79 44
07df68c8
DW
45 memset(&vFontDlg, '\0', sizeof(FONTDLG));
46 zCurrentFont[0] = '\0';
0e320a79 47
07df68c8
DW
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;
0e320a79 60
07df68c8
DW
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;
0e320a79 69
ae500232 70 m_fontData.m_fontColour = vColour;
07df68c8
DW
71
72 memset(&vFn, '\0', sizeof(FACENAMEDESC));
73 vFn.usSize = sizeof(FACENAMEDESC);
74 vFn.usWeightClass = vFontDlg.usWeight;
75 vFn.usWidthClass = vFontDlg.usWidth;
76
a4353f07 77 memset(&vInfo.fa, '\0', sizeof(FATTRS));
07df68c8
DW
78 memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));
79
a4353f07
DW
80 vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength;
81 strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename);
82 vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch;
83
07df68c8
DW
84 //
85 // Debugging
86 //
87 wxFont vChosenFont(vInfo);
a23692f0 88
a4353f07 89 int nPointSize = vFontDlg.fxPointSize >> 16;
07df68c8 90
a23692f0 91 vChosenFont.SetPointSize(nPointSize);
ae500232 92 m_fontData.m_chosenFont = vChosenFont;
07df68c8 93
0fba44b4 94 m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename;
07df68c8
DW
95 m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
96
97 return wxID_OK;
98 }
0e320a79 99 return wxID_CANCEL;
07df68c8 100} // end of wxFontDialg::ShowModal