OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
choosefo.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of TChooseFontDialog, a Choose Font Common Dialog class
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9#include <owl/choosefo.h>
10
11#if !defined(ctlFirst)
12# include <dlgs.h>
13#endif
14
15namespace owl {
16
18DIAG_DECLARE_GROUP(OwlCommDialog); // diagnostic group for common dialogs
19
20DEFINE_RESPONSE_TABLE1(TChooseFontDialog, TCommonDialog)
22
23//
24/// Initialize the ChooseFont data members.
25//
26/// Constructs a dialog box with specified data, parent window, resource identifier,
27/// window caption, and module ID. Sets the attributes of the dialog box based on
28/// the font information in the TChooseFontDialog::TData structure.
29//
31 TData& data,
34 TModule* module)
35:
36 TCommonDialog(parent, title, module),
37 Data(data)
38{
39 memset(&Cf, 0, sizeof(CHOOSEFONT));
40 Cf.lStructSize = sizeof(CHOOSEFONT);
41 Cf.hwndOwner = GetParentO() ? GetParentO()->GetHandle() : nullptr;
42 Cf.hInstance = *GetModule();
43 Cf.Flags = CF_ENABLEHOOK | Data.Flags;
44 if (templateId) {
45 Cf.lpTemplateName = templateId;
46 Cf.Flags |= CF_ENABLETEMPLATE;
47 }
48 else
49 Cf.Flags &= ~CF_ENABLETEMPLATE;
50 Cf.lpfnHook = nullptr;
51
52 Cf.hDC = Data.DC;
53 Cf.lpLogFont = &Data.LogFont;
54 Cf.iPointSize = Data.PointSize;
55 Cf.rgbColors = Data.Color;
56 Cf.lpszStyle = Data.Style;
57 Cf.nFontType = Data.FontType;
58 Cf.nSizeMin = Data.SizeMin;
59 Cf.nSizeMax = Data.SizeMax;
60
61 TRACEX(OwlCommDialog, OWL_CDLEVEL, "TChooseFontDialog constructed @" << (void*)this);
62}
63
64
65//
66/// Destructor for this object does nothing in the non-diagnostic versions
67/// of the library.
68/// In the diagnostic version, it produces a trace message.
69//
71{
72 TRACEX(OwlCommDialog, OWL_CDLEVEL, "TChooseFontDialog destructed @" << (void*)this);
73}
74
75
76//
77/// Override the virtual DialogFunction.
78/// It does no additional processing.
79//
80/// Returns true if a dialog box message is handled.
81//
87
88//
89/// Execute the dialog to retrieve the font selected by the user.
90//
91/// If no error occurs, DoExecute copies the flag values and font information into
92/// Ddata, and returns IDOK or IDCANCEL. If an error occurs, DoExecute returns an
93/// error code from TChooseFontDialog::TData structure's Error data member.
94//
95int
97{
98 Cf.lpfnHook = LPCFHOOKPROC(StdDlgProc);
99 int ret = ChooseFont(&Cf);
100 if (ret) {
101 Data.Flags = Cf.Flags;
102 Data.Error = 0;
103 Data.PointSize = Cf.iPointSize;
104 Data.Color = Cf.rgbColors;
105 Data.Style = Cf.lpszStyle;
106 Data.FontType = Cf.nFontType;
107 }
108 else
110
111 return ret ? IDOK : IDCANCEL;
112}
113
114} // OWL namespace
115//////////////////////////////////////////////
116
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
Definition of Choose Font Common Dialog class.
Defines information necessary to initialize the dialog box with the user's font selection.
Definition choosefo.h:47
int PointSize
Point size of the font.
Definition choosefo.h:97
HDC DC
Handle to the device context from which fonts are obtained.
Definition choosefo.h:91
TCHAR * Style
Style of the font such as bold, italic, underline, or strikeout.
Definition choosefo.h:104
uint32 Flags
Flags can be a combination of the following constants that control the appearance and functionality o...
Definition choosefo.h:76
uint32 Error
If the dialog box is successfully executed, Error returns 0.
Definition choosefo.h:88
uint16 FontType
Font type or name.
Definition choosefo.h:107
LOGFONT LogFont
Attributes of the font.
Definition choosefo.h:94
int SizeMax
Maximum size of the font.
Definition choosefo.h:113
TColor Color
Indicates the font color that is initially selected when the dialog box is created; contains the user...
Definition choosefo.h:101
int SizeMin
Minimum size of the font.
Definition choosefo.h:110
auto DoExecute() -> int override
Execute the dialog to retrieve the font selected by the user.
Definition choosefo.cpp:96
auto DialogFunction(TMsgId, TParam1, TParam2) -> INT_PTR override
Override the virtual DialogFunction.
Definition choosefo.cpp:83
TChooseFontDialog(TWindow *parent, TData &data, TResId templateId=0, LPCTSTR title=nullptr, TModule *module=nullptr)
Initialize the ChooseFont data members.
Definition choosefo.cpp:30
CHOOSEFONT Cf
New name.
Definition choosefo.h:144
~TChooseFontDialog() override
Destructor for this object does nothing in the non-diagnostic versions of the library.
Definition choosefo.cpp:70
Derived from TDialog, TCommonDialog is the abstract base class for TCommonDialog objects.
Definition commdial.h:62
virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2)
Override this to process messages within the dialog function.
Definition dialog.cpp:353
static INT_PTR CALLBACK StdDlgProc(HWND, UINT, WPARAM, LPARAM) noexcept
Callback procs for hooking TDialog to native window.
Definition dialog.cpp:440
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
TModule * GetModule() const
Returns a pointer to the module object.
Definition window.h:1841
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
OWL_DIAGINFO
Definition animctrl.cpp:14
END_RESPONSE_TABLE
Definition button.cpp:26
#define OWL_CDLEVEL
Definition defs.h:171