]>
Commit | Line | Data |
---|---|---|
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" | |
0e320a79 DW |
23 | #endif |
24 | ||
bd76e17e | 25 | #include "wx/fontutil.h" |
691745ab | 26 | #include "wx/modalhook.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 | 36 | IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) |
0e320a79 | 37 | |
07df68c8 | 38 | int wxFontDialog::ShowModal() |
0e320a79 | 39 | { |
691745ab | 40 | WX_HOOK_MODAL_DIALOG(); |
643e9cf9 | 41 | |
ce5d92e1 WS |
42 | FONTDLG vFontDlg; |
43 | char zCurrentFont[FACESIZE]; | |
44 | HWND hWndFontDlg; | |
45 | FACENAMEDESC vFn; | |
0e320a79 | 46 | |
07df68c8 DW |
47 | memset(&vFontDlg, '\0', sizeof(FONTDLG)); |
48 | zCurrentFont[0] = '\0'; | |
0e320a79 | 49 | |
07df68c8 DW |
50 | // |
51 | // Set the fontdlg fields | |
52 | // | |
53 | vFontDlg.cbSize = sizeof(FONTDLG); | |
54 | vFontDlg.hpsScreen = ::WinGetScreenPS(HWND_DESKTOP); | |
55 | vFontDlg.hpsPrinter = NULL; | |
56 | vFontDlg.pszFamilyname = zCurrentFont; | |
57 | vFontDlg.fxPointSize = MAKEFIXED(12,0); | |
58 | vFontDlg.usFamilyBufLen = FACESIZE; | |
59 | vFontDlg.fl = FNTS_CENTER; | |
60 | vFontDlg.clrFore = CLR_BLACK; | |
61 | vFontDlg.clrBack = CLR_WHITE; | |
0e320a79 | 62 | |
07df68c8 DW |
63 | hWndFontDlg = WinFontDlg( HWND_DESKTOP |
64 | ,GetParent()->GetHWND() | |
65 | ,&vFontDlg | |
66 | ); | |
67 | if (hWndFontDlg && vFontDlg.lReturn == DID_OK) | |
68 | { | |
69 | wxColour vColour((unsigned long)0x00000000); | |
70 | wxNativeFontInfo vInfo; | |
0e320a79 | 71 | |
ae500232 | 72 | m_fontData.m_fontColour = vColour; |
07df68c8 DW |
73 | |
74 | memset(&vFn, '\0', sizeof(FACENAMEDESC)); | |
75 | vFn.usSize = sizeof(FACENAMEDESC); | |
76 | vFn.usWeightClass = vFontDlg.usWeight; | |
77 | vFn.usWidthClass = vFontDlg.usWidth; | |
78 | ||
a4353f07 | 79 | memset(&vInfo.fa, '\0', sizeof(FATTRS)); |
07df68c8 DW |
80 | memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC)); |
81 | ||
a4353f07 DW |
82 | vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength; |
83 | strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename); | |
84 | vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch; | |
85 | ||
07df68c8 DW |
86 | // |
87 | // Debugging | |
88 | // | |
89 | wxFont vChosenFont(vInfo); | |
a23692f0 | 90 | |
a4353f07 | 91 | int nPointSize = vFontDlg.fxPointSize >> 16; |
07df68c8 | 92 | |
a23692f0 | 93 | vChosenFont.SetPointSize(nPointSize); |
ae500232 | 94 | m_fontData.m_chosenFont = vChosenFont; |
07df68c8 | 95 | |
0fba44b4 | 96 | m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename; |
07df68c8 DW |
97 | m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage; |
98 | ||
99 | return wxID_OK; | |
100 | } | |
0e320a79 | 101 | return wxID_CANCEL; |
07df68c8 | 102 | } // end of wxFontDialg::ShowModal |