]> git.saurik.com Git - wxWidgets.git/blame - src/os2/fontdlg.cpp
added and documented wxProcess::Is{Input|Error}Available() and IsInputOpened
[wxWidgets.git] / src / os2 / fontdlg.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: fontdlg.cpp
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
DW
9// Copyright: (c) David Webster
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
16#ifndef WX_PRECOMP
17#include <stdio.h>
18#include "wx/defs.h"
19#include "wx/utils.h"
20#include "wx/dialog.h"
0e320a79
DW
21#endif
22
21802234
DW
23#include "wx/fontdlg.h"
24
25#define INCL_PM
26#include <os2.h>
27
28#include "wx/os2/private.h"
0e320a79
DW
29#include "wx/cmndata.h"
30
21802234
DW
31#include <math.h>
32#include <stdlib.h>
33#include <string.h>
34
0e320a79 35IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
0e320a79 36
07df68c8 37int wxFontDialog::ShowModal()
0e320a79 38{
07df68c8
DW
39 FONTDLG vFontDlg;
40 char zCurrentFont[FACESIZE];
41 HWND hWndFontDlg;
42 FONTMETRICS vFm;
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
07df68c8
DW
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);
a23692f0 84
07df68c8 85 int nFamily;
a23692f0 86 int nPointSize = vFontDlg.lEmHeight;
07df68c8
DW
87 int nStyle;
88 int nWeight;
89 bool bUnderlined;
90 wxString sFaceName;
91 wxNativeFontInfo* pInfo;
92
a23692f0 93 vChosenFont.SetPointSize(nPointSize);
07df68c8
DW
94 nFamily = vChosenFont.GetFamily();
95 nPointSize = vChosenFont.GetPointSize();
96 nStyle = vChosenFont.GetStyle();
97 nWeight = vChosenFont.GetWeight();
98 bUnderlined = vChosenFont.GetUnderlined();
99 sFaceName = vChosenFont.GetFaceName();
100 pInfo = vChosenFont.GetNativeFontInfo();
101
102
103 m_fontData.chosenFont = vChosenFont;
104
105 nFamily = m_fontData.chosenFont.GetFamily();
106 nPointSize = m_fontData.chosenFont.GetPointSize();
107 nStyle = m_fontData.chosenFont.GetStyle();
108 nWeight = m_fontData.chosenFont.GetWeight();
109 bUnderlined = m_fontData.chosenFont.GetUnderlined();
110 sFaceName = m_fontData.chosenFont.GetFaceName();
111 pInfo = m_fontData.chosenFont.GetNativeFontInfo();
112
113 m_fontData.EncodingInfo().facename = vFontDlg.fAttrs.szFacename;
114 m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;
115
116 return wxID_OK;
117 }
0e320a79 118 return wxID_CANCEL;
07df68c8 119} // end of wxFontDialg::ShowModal
0e320a79 120