| 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 | // 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 | #include "wx/fontdlg.h" |
| 17 | |
| 18 | #ifndef WX_PRECOMP |
| 19 | #include <stdio.h> |
| 20 | #include "wx/utils.h" |
| 21 | #include "wx/dialog.h" |
| 22 | #include "wx/math.h" |
| 23 | #endif |
| 24 | |
| 25 | #include "wx/fontutil.h" |
| 26 | #include "wx/modalhook.h" |
| 27 | |
| 28 | #define INCL_PM |
| 29 | #include <os2.h> |
| 30 | |
| 31 | #include "wx/os2/private.h" |
| 32 | |
| 33 | #include <stdlib.h> |
| 34 | #include <string.h> |
| 35 | |
| 36 | IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) |
| 37 | |
| 38 | int wxFontDialog::ShowModal() |
| 39 | { |
| 40 | WX_HOOK_MODAL_DIALOG(); |
| 41 | |
| 42 | FONTDLG vFontDlg; |
| 43 | char zCurrentFont[FACESIZE]; |
| 44 | HWND hWndFontDlg; |
| 45 | FACENAMEDESC vFn; |
| 46 | |
| 47 | memset(&vFontDlg, '\0', sizeof(FONTDLG)); |
| 48 | zCurrentFont[0] = '\0'; |
| 49 | |
| 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; |
| 62 | |
| 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; |
| 71 | |
| 72 | m_fontData.m_fontColour = vColour; |
| 73 | |
| 74 | memset(&vFn, '\0', sizeof(FACENAMEDESC)); |
| 75 | vFn.usSize = sizeof(FACENAMEDESC); |
| 76 | vFn.usWeightClass = vFontDlg.usWeight; |
| 77 | vFn.usWidthClass = vFontDlg.usWidth; |
| 78 | |
| 79 | memset(&vInfo.fa, '\0', sizeof(FATTRS)); |
| 80 | memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC)); |
| 81 | |
| 82 | vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength; |
| 83 | strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename); |
| 84 | vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch; |
| 85 | |
| 86 | // |
| 87 | // Debugging |
| 88 | // |
| 89 | wxFont vChosenFont(vInfo); |
| 90 | |
| 91 | int nPointSize = vFontDlg.fxPointSize >> 16; |
| 92 | |
| 93 | vChosenFont.SetPointSize(nPointSize); |
| 94 | m_fontData.m_chosenFont = vChosenFont; |
| 95 | |
| 96 | m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename; |
| 97 | m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage; |
| 98 | |
| 99 | return wxID_OK; |
| 100 | } |
| 101 | return wxID_CANCEL; |
| 102 | } // end of wxFontDialg::ShowModal |