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.h
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/// Definition of Choose Font Common Dialog class
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_CHOOSEFO_H)
10#define OWL_CHOOSEFO_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/commdial.h>
18
19namespace owl {
20
21#include <owl/preclass.h>
22
23
24class _OWLCLASS TColor;
25
26/// \addtogroup commdlg
27/// @{
28/// \class TChooseFontDialog
29// ~~~~~ ~~~~~~~~~~~~~~~~~
30/// Encapsulates the Choose-Font common dialog.
31//
32/// A TChooseFontDialog represents modal dialog-box interface elements that create a
33/// system-defined dialog box from which the user can select a font, a font style
34/// (such as bold or italic), a point size, an effect (such as strikeout or
35/// underline), and a color. TChooseFontDialog can be made to appear modeless by
36/// creating the dialog's parent as an invisible pop-up window and making the pop-up
37/// window a child of the main application window. TChooseFontDialog uses the
38/// TChooseFontDialog::TData structure to initialize the dialog box with the
39/// user-selected font styles.
40//
42 public:
43
44/// Defines information necessary to initialize the dialog box with the user's font
45/// selection.
47 {
48 public:
49
50/// Flags can be a combination of the following constants that control the
51/// appearance and functionality of the dialog box:
52/// - \c \b CF_APPLY Enables the display and use of the Apply button.
53/// - \c \b CF_ANSIONLY Specifies that the ChooseFontDialog structure allows only the
54/// selection of fonts that use the ANSI character set.
55/// - \c \b CF_BOTH Causes the dialog box to list both the available printer and screen
56/// fonts.
57/// - \c \b CF_EFFECTS Enables strikeout, underline, and color effects.
58/// - \c \b CF_FIXEDPITCHONLY Enables fixed-pitch fonts only.
59/// - \c \b CF_FORCEFONTEXIST Indicates an error if the user selects a nonexistent font or
60/// style.
61/// - \c \b CF_INITTOLOGFONTSTRUCT Uses the LOGFONT structure at which LogFont points to
62/// initialize the dialog controls.
63/// - \c \b CF_LIMITSIZE Limits font selection to those between SizeMin and SizeMax.
64/// - \c \b CF_NOSIMULATIONS Does not allow GDI font simulations.
65/// - \c \b CF_PRINTERFONTS Causes the dialog box to list only the fonts supported by the
66/// printer that is associated with the device context.
67/// - \c \b CF_SCALABLEONLY Allows only the selection of scalable fonts.
68/// - \c \b CF_SCREENFONTS Causes the dialog box to list only the system-supported screen
69/// fonts.
70/// - \c \b CF_SHOWHELP Causes the dialog box to show the Help button.
71/// - \c \b CF_TTONLY Enumerates and allows the selection of TrueType fonts only.
72/// - \c \b CF_USESTYLE Specifies that Style points to a buffer containing the style
73/// attributes used to initialize the selection of font styles.
74/// - \c \b CF_WYSIWYG Allows only the selection of fonts available on both the printer and
75/// the screen.
77
78/// If the dialog box is successfully executed, Error returns 0. Otherwise, it
79/// contains one of the following codes:
80/// - \c \b CDERR_DIALOGFAILURE Failed to create a dialog box.
81/// - \c \b CDERR_FINDRESFAILURE Failed to find a specified resource.
82/// - \c \b CDERR_LOCKRESOURCEFAILURE Failed to lock a specified resource.
83/// - \c \b CDERR_LOADRESFAILURE Failed to load a specified resource.
84/// - \c \b CDERR_LOADSTRFAILURE Failed to load a specified string.
85/// - \c \b CFERR_MAXLESSTHANMIN The size specified in SizeMax is less than the size in
86/// SizeMin.
87/// - \c \b CFERR_NOFONTS No fonts exist.
89
90/// Handle to the device context from which fonts are obtained.
92
93/// Attributes of the font.
95
96/// Point size of the font.
98
99/// Indicates the font color that is initially selected when the dialog box is
100/// created; contains the user's font color selection when the dialog box is closed.
102
103/// Style of the font such as bold, italic, underline, or strikeout.
105
106/// Font type or name.
108
109/// Minimum size of the font.
111
112/// Maximum size of the font.
114
115 };
116
118 TData& data,
119 TResId templateId = 0,
120 LPCTSTR title = nullptr,
121 TModule* module = nullptr);
122 ~TChooseFontDialog() override;
123
124 protected:
125 TData& GetData();
126 void SetData(TData& data);
127
128 CHOOSEFONT& GetCF();
129 void SetCF(const CHOOSEFONT& cf);
130
131 auto DoExecute() -> int override;
132 auto DialogFunction(TMsgId, TParam1, TParam2) -> INT_PTR override;
133
134 // Default behavior inline for message response functions
135 //
136 void CmFontApply(); // EV_COMMAND(psh3...
137
139/// Contains font attributes. cf is initialized using fields in the
140/// TChooseFontDialog::TData structure. It stores the length of the structure, the
141/// window that owns the dialog box and the data block that contains the dialog
142/// template. It also specifies the dialog-box initialization flags.
143 union {
144 CHOOSEFONT Cf; ///< New name
145 CHOOSEFONT cf; ///< old name
146 };
147
148/// Data is a reference to the TData object passed in the constructor.
149 TData& Data;
150
151 private:
153 TChooseFontDialog& operator=(const TChooseFontDialog&);
154
157};
158/// @}
159
160#include <owl/posclass.h>
161
162//----------------------------------------------------------------------------
163// Inline implementations
164//
165
166//
167/// Return the data associated with this dialog.
168//
170 return Data;
171}
172
173//
174/// Set the data associated with this dialog.
175/// Use this function with caution!
176//
178 Data = data;
179}
180
181//
182/// Return the CHOOSEFONT data structure for this dialog.
183//
185 return Cf;
186}
187
188//
189/// Set the CHOOSEFONT data structure for this dialog.
190//
192 Cf = c;
193}
194
195//
196/// User clicked on Apply for the font.
197//
198/// Default handler for the third push button (the Apply button) in the dialog box.
199//
203
204
205
206} // OWL namespace
207
208
209#endif // OWL_CHOOSEFO_H
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
Encapsulates the Choose-Font common dialog.
Definition choosefo.h:41
TData & GetData()
Return the data associated with this dialog.
Definition choosefo.h:169
void SetCF(const CHOOSEFONT &cf)
Set the CHOOSEFONT data structure for this dialog.
Definition choosefo.h:191
CHOOSEFONT cf
old name
Definition choosefo.h:145
void CmFontApply()
User clicked on Apply for the font.
Definition choosefo.h:200
void SetData(TData &data)
Set the data associated with this dialog.
Definition choosefo.h:177
CHOOSEFONT Cf
New name.
Definition choosefo.h:144
CHOOSEFONT & GetCF()
Return the CHOOSEFONT data structure for this dialog.
Definition choosefo.h:184
Class wrapper for management of color values.
Definition color.h:245
Derived from TDialog, TCommonDialog is the abstract base class for TCommonDialog objects.
Definition commdial.h:62
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
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
Definition window.cpp:852
Definition of Common Dialog abstract base class.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_CASTABLE
Definition objstrm.h:1440
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
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338