]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/fontdlg.cpp
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
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/fontdlg.h"
20 #include "wx/dialog.h"
24 #include "wx/fontutil.h"
25 #include "wx/modalhook.h"
30 #include "wx/os2/private.h"
35 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
37 int wxFontDialog::ShowModal()
39 WX_HOOK_MODAL_DIALOG();
42 char zCurrentFont
[FACESIZE
];
46 memset(&vFontDlg
, '\0', sizeof(FONTDLG
));
47 zCurrentFont
[0] = '\0';
50 // Set the fontdlg fields
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
;
62 hWndFontDlg
= WinFontDlg( HWND_DESKTOP
63 ,GetParent()->GetHWND()
66 if (hWndFontDlg
&& vFontDlg
.lReturn
== DID_OK
)
68 wxColour
vColour((unsigned long)0x00000000);
69 wxNativeFontInfo vInfo
;
71 m_fontData
.m_fontColour
= vColour
;
73 memset(&vFn
, '\0', sizeof(FACENAMEDESC
));
74 vFn
.usSize
= sizeof(FACENAMEDESC
);
75 vFn
.usWeightClass
= vFontDlg
.usWeight
;
76 vFn
.usWidthClass
= vFontDlg
.usWidth
;
78 memset(&vInfo
.fa
, '\0', sizeof(FATTRS
));
79 memcpy(&vInfo
.fn
, &vFn
, sizeof(FACENAMEDESC
));
81 vInfo
.fa
.usRecordLength
= vFontDlg
.fAttrs
.usRecordLength
;
82 strcpy(vInfo
.fa
.szFacename
, vFontDlg
.fAttrs
.szFacename
);
83 vInfo
.fa
.lMatch
= vFontDlg
.fAttrs
.lMatch
;
88 wxFont
vChosenFont(vInfo
);
90 int nPointSize
= vFontDlg
.fxPointSize
>> 16;
92 vChosenFont
.SetPointSize(nPointSize
);
93 m_fontData
.m_chosenFont
= vChosenFont
;
95 m_fontData
.EncodingInfo().facename
= (wxChar
*)vFontDlg
.fAttrs
.szFacename
;
96 m_fontData
.EncodingInfo().charset
= vFontDlg
.fAttrs
.usCodePage
;
101 } // end of wxFontDialg::ShowModal