]>
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
9 // Copyright: (c) David Webster
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
16 #include "wx/fontdlg.h"
21 #include "wx/dialog.h"
25 #include "wx/fontutil.h"
26 #include "wx/modalhook.h"
31 #include "wx/os2/private.h"
36 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
38 int wxFontDialog::ShowModal()
40 WX_HOOK_MODAL_DIALOG();
43 char zCurrentFont
[FACESIZE
];
47 memset(&vFontDlg
, '\0', sizeof(FONTDLG
));
48 zCurrentFont
[0] = '\0';
51 // Set the fontdlg fields
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
;
63 hWndFontDlg
= WinFontDlg( HWND_DESKTOP
64 ,GetParent()->GetHWND()
67 if (hWndFontDlg
&& vFontDlg
.lReturn
== DID_OK
)
69 wxColour
vColour((unsigned long)0x00000000);
70 wxNativeFontInfo vInfo
;
72 m_fontData
.m_fontColour
= vColour
;
74 memset(&vFn
, '\0', sizeof(FACENAMEDESC
));
75 vFn
.usSize
= sizeof(FACENAMEDESC
);
76 vFn
.usWeightClass
= vFontDlg
.usWeight
;
77 vFn
.usWidthClass
= vFontDlg
.usWidth
;
79 memset(&vInfo
.fa
, '\0', sizeof(FATTRS
));
80 memcpy(&vInfo
.fn
, &vFn
, sizeof(FACENAMEDESC
));
82 vInfo
.fa
.usRecordLength
= vFontDlg
.fAttrs
.usRecordLength
;
83 strcpy(vInfo
.fa
.szFacename
, vFontDlg
.fAttrs
.szFacename
);
84 vInfo
.fa
.lMatch
= vFontDlg
.fAttrs
.lMatch
;
89 wxFont
vChosenFont(vInfo
);
91 int nPointSize
= vFontDlg
.fxPointSize
>> 16;
93 vChosenFont
.SetPointSize(nPointSize
);
94 m_fontData
.m_chosenFont
= vChosenFont
;
96 m_fontData
.EncodingInfo().facename
= (wxChar
*)vFontDlg
.fAttrs
.szFacename
;
97 m_fontData
.EncodingInfo().charset
= vFontDlg
.fAttrs
.usCodePage
;
102 } // end of wxFontDialg::ShowModal