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
btntextg.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------//
2// ObjectWindows 1998 Copyright by Yura Bidus //
3// //
4// Used code and ideas from Dieter Windau and Joseph Parrello //
5// //
6// //
7// THIS CLASS AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //
8// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO //
9// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //
10// PARTICULAR PURPOSE. //
11/// \file //
12/// Definition of classes TButtonTextGadget. //
13//----------------------------------------------------------------------------//
14
15#if !defined(OWL_BTNTEXTG_H)
16#define OWL_BTNTEXTG_H
17
18#include <owl/private/defs.h>
19#if defined(BI_HAS_PRAGMA_ONCE)
20# pragma once
21#endif
22
23#include <owl/buttonga.h>
24
25namespace owl {
26
27#include <owl/preclass.h>
28
29//
30/// \addtogroup gadgets
31/// @{
32/// \class TButtonTextGadget
33/// Derived from TButtonGadget, TButtonTextGadget represents buttons with bitmap and
34/// text, or with text only, or with bitmap only, that you can click on or off. You
35/// can also apply attributes such as color, style, and shape (notched or unnotched)
36/// to your button-text gadgets.
37///
38/// In addition to TButtonGadget, TButtonTextGadget has several types to deal with text:
39///
40/// - \c \b TAlign Defines alignment for text (aLeft, aCenter, aRight),
41/// - \c \b TStyle Defines style of gadget (sBitmap, sText, sBitmapText).
42/// - \c \b TLayoutStyle Defines Layout Bitmap with text(lTextLeft,lTextTop,lTextRight,lTextBottom).
43//
45{
46 public:
47
48 //
49 /// Enumerates the text-alignment attributes.
50 //
51 enum TAlign
52 {
53 aLeft, ///< Aligns the text at the left edge of the bounding rectangle.
54 aCenter, ///< Aligns the text horizontally at the center of the bounding rectangle.
55 aRight ///< Aligns the text at the right edge of the bounding rectangle.
56 };
57
58 //
59 /// TStyle contains values that defines how gadget will be displayed:
60 //
61 enum TStyle
62 {
63 sBitmap=0x001, ///< Only the bitmap is displayed.
64 sText=0x002, ///< Only text is displayed.
65 sBitmapText=0x003 ///< Both text and bitmap are displayed.
66 };
67
68 //
69 /// TLayoutStyle contains values that defines how bitmap and text will be layout.
70 //
72 {
73 lTextLeft, ///< Text left, bitmap right.
74 lTextTop, ///< Text top, bitmap bottom.
75 lTextRight, ///< Text right, bitmap left.
76 lTextBottom ///< Text bottom, bitmap top.
77 };
78
80 int id,
82 TStyle style = sBitmapText,
83 TType type = Command,
84 bool enabled = false,
85 TState state = Up,
86 bool sharedGlyph = false,
87 uint numChars = 4);
88
89 virtual ~TButtonTextGadget();
90
91 LPCTSTR GetText() const;
92 void SetText(const tstring& text, bool repaint=true);
93 void SetText(LPCTSTR s, bool repaint = true) {SetText(s ? owl::tstring(s) : owl::tstring(), repaint);}
94 TStyle GetStyle() const;
95 void SetStyle(const TStyle style, bool repaint=true);
96 TAlign GetAlign() const;
97 void SetAlign(const TAlign align, bool repaint=true);
98 TLayoutStyle GetLayoutStyle() const;
99 void SetLayoutStyle(const TLayoutStyle style, bool repaint=true);
100
101 const TFont& GetFont() const;
102 void SetFont(const TFont&, bool repaint = true);
103
104 //
105 // Override virtual methods defined in TGadget
106 //
107 virtual void GetDesiredSize(TSize &size);
108 virtual void SetBounds(const TRect& rect);
109
110 //
111 // Override and initiate a WM_COMMAND_ENABLE message
112 //
113 virtual void CommandEnable();
114
115 protected:
116 virtual void Paint(TDC& dc);
117 virtual void Created();
118 virtual void Layout(TRect& srcRect, TRect& textRect, TRect& btnRect);
119 virtual void PaintText(TDC& dc, TRect& rect, const tstring& text);
120 virtual void SysColorChange();
121
122 void GetTextSize(TSize& size);
123
124 //
125 // Data members -- will become private
126 //
128 tstring Text;
129 uint NumChars; ///< Number of chars to reserve space for
130 TAlign Align; ///< Alignment: left, center or right
131 TStyle Style; ///< Style Bitmap, Text, Bitmap and Text
132 TLayoutStyle LayoutStyle;///< Layout style
133 TFont* Font; ///< The display font; if Font == 0, it will try to get the font from TGadgetWindow.
134
135 private:
136 //
137 // Hidden to prevent accidental copying or assignment
138 //
141};
142
143/// @}
144
145#include <owl/posclass.h>
146
147//
148// --------------------------------------------------------------------------
149// Inline implementation
150//
151
152//
153/// Returns the Style for the gadget.
154//
156 return Style;
157}
158
159//
160/// Returns the text for the gadget.
161//
163 return Text.c_str();
164}
165
166//
167/// Returns the Align for the gadget.
168//
170 return Align;
171}
172
173//
174/// Returns the LayoutStyle for the gadget.
175//
177 return LayoutStyle;
178}
179
180} // OWL namespace
181
182#endif // OWL_BTNTEXTG_H
Definition of class TButtonGadget.
Derived from TGadget, TButtonGadget represent buttons that you can click on or off.
Definition buttonga.h:65
Derived from TButtonGadget, TButtonTextGadget represents buttons with bitmap and text,...
Definition btntextg.h:45
TStyle GetStyle() const
Returns the Style for the gadget.
Definition btntextg.h:155
TStyle
TStyle contains values that defines how gadget will be displayed:
Definition btntextg.h:62
TAlign
Enumerates the text-alignment attributes.
Definition btntextg.h:52
@ aCenter
Aligns the text horizontally at the center of the bounding rectangle.
Definition btntextg.h:54
@ aLeft
Aligns the text at the left edge of the bounding rectangle.
Definition btntextg.h:53
TLayoutStyle GetLayoutStyle() const
Returns the LayoutStyle for the gadget.
Definition btntextg.h:176
LPCTSTR GetText() const
Returns the text for the gadget.
Definition btntextg.h:162
TAlign GetAlign() const
Returns the Align for the gadget.
Definition btntextg.h:169
TLayoutStyle
TLayoutStyle contains values that defines how bitmap and text will be layout.
Definition btntextg.h:72
@ lTextTop
Text top, bitmap bottom.
Definition btntextg.h:74
@ lTextRight
Text right, bitmap left.
Definition btntextg.h:75
@ lTextLeft
Text left, bitmap right.
Definition btntextg.h:73
void SetText(LPCTSTR s, bool repaint=true)
Definition btntextg.h:93
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
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