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
textgadg.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 text gadget class TGadget.
7/// Definition for TDynamicTextGadget.
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_TEXTGADG_H)
11#define OWL_TEXTGADG_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/gadgetwi.h>
19#include <owl/gadget.h>
20
21
22namespace owl {
23
24#include <owl/preclass.h>
25
26//
27/// \class TTextGadget
28// ~~~~~ ~~~~~~~~~~~
29/// Derived from TGadget, TTextGadget is a text gadget object.
30///
31/// When constructing the text gadget specify how many characters you want
32/// room for and how the text should be aligned horizontally.
33///
34/// The inner bounds are computed by multiplying the number of characters by
35/// the maximum character width.
36//
38 public:
39
40/// Enumerates the text-alignment attributes.
41 enum TAlign
42 {
43 Left, ///< Aligns the text at the left edge of the bounding rectangle.
44 Center, ///< Aligns the text horizontally at the center of the bounding rectangle.
45 Right ///< Aligns the text at the right edge of the bounding rectangle.
46 };
47
48 TTextGadget(int id = 0, TBorderStyle = Recessed, TAlign = Left,
49 uint numChars = 10, LPCTSTR text = 0,
50 TFont* font = 0);
51
53 int id,
54 TBorderStyle,
55 TAlign,
57 const tstring& text,
58 TFont* font = 0);
59
61
62 const TFont& GetFont() const;
63 void SetFont(const TFont&, bool repaint = true);
64
65 // Return a copy of gadget's text
66 //
67 LPCTSTR GetText() const;
68
69 // Makes a copy of the text
70 //
71 void SetText(LPCTSTR text);
72 void SetText(const tstring& text) {SetText(text.c_str());}
73
74 TColor GetBkgndColor() const;
75 TColor GetTextColor() const;
76 void SetBkgndColor(const TColor& color);
77 void SetTextColor(const TColor& color);
78 void ResetBkgndColor();
79 void ResetTextColor();
80
81 protected:
82 // Override virtual methods defined in TGadget
83 //
84 void Paint(TDC& dc);
85 virtual TColor GetEnabledColor() const;
86 void GetDesiredSize(TSize &size);
87 void Invalidate();
88
89 // Data members -- will become private
90 //
92 LPTSTR Text; ///< new'd copy of the text for this gadget
93 uint TextLen; ///< strlen of the above text
94 TAlign Align; ///< Alignment: left, center or right
95 uint NumChars; ///< Number of chars to reserve space for
96 TFont* Font; ///< display font
97 TColor BkgndColor; ///< background color of the gadget
98 TColor TextColor; ///< text color of the gadget
99
100 private:
101 // Hidden to prevent accidental copying or assignment
102 //
103 TTextGadget(const TTextGadget&);
105};
106
107//
108/// \class TDynamicTextGadget
109// ~~~~~ ~~~~~~~~~~~~~~~~~~
110/// Small class will send EvEnable to window,
111/// You can set text by handling EvCommandEnable message
112//
114 public:
115 TDynamicTextGadget(int id = 0,
116 TBorderStyle = Recessed,
117 TAlign = Left,
118 uint numChars = 10,
119 LPCTSTR text = 0,
120 TFont* font = 0);
121
123 int id,
125 TAlign,
127 const tstring& text,
128 TFont* = 0);
129
130 public:
131 virtual void CommandEnable();
132};
133
134#include <owl/posclass.h>
135
136
137// -----------------------------------------------------------------------------
138// Inline implementation
139//
140
141//
142/// Returns the text for the gadget.
143//
145 return Text;
146}
147
149 return TextColor;
150}
151
152//
153/// Returns the background color for the gadget.
154//
156{
157 return BkgndColor;
158}
159
160//
161/// Returns the text color for the gadget
162//
164{
165 return TextColor;
166}
167
168//
169/// Sets the background color for the gadget.
170//
172{
173 BkgndColor = color;
174}
175
176//
177/// Sets the text color for the gadget when enabled
178//
180{
181 TextColor = color;
182}
183
184
185//------------------------------------------------------------------------------
186
187} // OWL namespace
188
189
190#endif // OWL_TEXTGADG_H
Class wrapper for management of color values.
Definition color.h:245
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
Small class will send EvEnable to window, You can set text by handling EvCommandEnable message.
Definition textgadg.h:113
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
TGadget is the base class for the following derived gadget classes:
Definition gadget.h:120
TBorderStyle
Gadget border styles.
Definition gadget.h:127
The tagSIZE struct is defined as.
Definition geometry.h:234
Derived from TGadget, TTextGadget is a text gadget object.
Definition textgadg.h:37
TAlign
Enumerates the text-alignment attributes.
Definition textgadg.h:42
@ Left
Aligns the text at the left edge of the bounding rectangle.
Definition textgadg.h:43
@ Center
Aligns the text horizontally at the center of the bounding rectangle.
Definition textgadg.h:44
LPCTSTR GetText() const
Returns the text for the gadget.
Definition textgadg.h:144
virtual TColor GetEnabledColor() const
Definition textgadg.h:148
void SetText(const tstring &text)
Definition textgadg.h:72
TColor GetBkgndColor() const
Returns the background color for the gadget.
Definition textgadg.h:155
TColor GetTextColor() const
Returns the text color for the gadget.
Definition textgadg.h:163
void SetBkgndColor(const TColor &color)
Sets the background color for the gadget.
Definition textgadg.h:171
void SetTextColor(const TColor &color)
Sets the text color for the gadget when enabled.
Definition textgadg.h:179
Base class TGadget and simple derived TSeparatorGadget.
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338