]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/fontdlg.cpp
Made the #if wxUSE_UNICODE check correctly...
[wxWidgets.git] / src / os2 / fontdlg.cpp
... / ...
CommitLineData
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#include "wx/fontutil.h"
25
26#define INCL_PM
27#include <os2.h>
28
29#include "wx/os2/private.h"
30#include "wx/cmndata.h"
31
32#include <math.h>
33#include <stdlib.h>
34#include <string.h>
35
36IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
37
38int wxFontDialog::ShowModal()
39{
40 FONTDLG vFontDlg;
41 char zCurrentFont[FACESIZE];
42 HWND hWndFontDlg;
43 FONTMETRICS vFm;
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 = 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
102