OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
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
25
namespace
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
//
44
class
_OWLCLASS
TButtonTextGadget
:
public
TButtonGadget
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
//
71
enum
TLayoutStyle
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
79
TButtonTextGadget
(
80
int
id
,
81
TResId
glyphResIdOrIndex,
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
//
127
protected_data
:
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
//
139
TButtonTextGadget
(
const
TButtonTextGadget
&);
140
TButtonTextGadget
& operator =(
const
TButtonTextGadget
&);
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
//
155
inline
TButtonTextGadget::TStyle
TButtonTextGadget::GetStyle
()
const
{
156
return
Style;
157
}
158
159
//
160
/// Returns the text for the gadget.
161
//
162
inline
LPCTSTR
TButtonTextGadget::GetText
()
const
{
163
return
Text.c_str();
164
}
165
166
//
167
/// Returns the Align for the gadget.
168
//
169
inline
TButtonTextGadget::TAlign
TButtonTextGadget::GetAlign
()
const
{
170
return
Align;
171
}
172
173
//
174
/// Returns the LayoutStyle for the gadget.
175
//
176
inline
TButtonTextGadget::TLayoutStyle
TButtonTextGadget::GetLayoutStyle
()
const
{
177
return
LayoutStyle;
178
}
179
180
}
// OWL namespace
181
182
#endif
// OWL_BTNTEXTG_H
buttonga.h
Definition of class TButtonGadget.
owl::TButtonGadget::TButtonGadget
TButtonGadget(TResId glyphResIdOrIndex, int id, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false)
Construct a button gadget that loads its own bitmap resource.
Definition
buttonga.cpp:107
owl::TButtonTextGadget
Derived from TButtonGadget, TButtonTextGadget represents buttons with bitmap and text,...
Definition
btntextg.h:45
owl::TButtonTextGadget::GetStyle
TStyle GetStyle() const
Returns the Style for the gadget.
Definition
btntextg.h:155
owl::TButtonTextGadget::TStyle
TStyle
TStyle contains values that defines how gadget will be displayed:
Definition
btntextg.h:62
owl::TButtonTextGadget::sBitmapText
@ sBitmapText
Both text and bitmap are displayed.
Definition
btntextg.h:65
owl::TButtonTextGadget::sBitmap
@ sBitmap
Only the bitmap is displayed.
Definition
btntextg.h:63
owl::TButtonTextGadget::sText
@ sText
Only text is displayed.
Definition
btntextg.h:64
owl::TButtonTextGadget::TAlign
TAlign
Enumerates the text-alignment attributes.
Definition
btntextg.h:52
owl::TButtonTextGadget::aCenter
@ aCenter
Aligns the text horizontally at the center of the bounding rectangle.
Definition
btntextg.h:54
owl::TButtonTextGadget::aLeft
@ aLeft
Aligns the text at the left edge of the bounding rectangle.
Definition
btntextg.h:53
owl::TButtonTextGadget::aRight
@ aRight
Aligns the text at the right edge of the bounding rectangle.
Definition
btntextg.h:55
owl::TButtonTextGadget::GetLayoutStyle
TLayoutStyle GetLayoutStyle() const
Returns the LayoutStyle for the gadget.
Definition
btntextg.h:176
owl::TButtonTextGadget::GetText
LPCTSTR GetText() const
Returns the text for the gadget.
Definition
btntextg.h:162
owl::TButtonTextGadget::TButtonTextGadget
TButtonTextGadget(int id, TResId glyphResIdOrIndex, TStyle style=sBitmapText, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false, uint numChars=4)
Constructs a TButtonTextGadget object using the specified bitmap ID, button gadget ID,...
Definition
btntextg.cpp:103
owl::TButtonTextGadget::GetAlign
TAlign GetAlign() const
Returns the Align for the gadget.
Definition
btntextg.h:169
owl::TButtonTextGadget::TLayoutStyle
TLayoutStyle
TLayoutStyle contains values that defines how bitmap and text will be layout.
Definition
btntextg.h:72
owl::TButtonTextGadget::lTextTop
@ lTextTop
Text top, bitmap bottom.
Definition
btntextg.h:74
owl::TButtonTextGadget::lTextBottom
@ lTextBottom
Text bottom, bitmap top.
Definition
btntextg.h:76
owl::TButtonTextGadget::lTextRight
@ lTextRight
Text right, bitmap left.
Definition
btntextg.h:75
owl::TButtonTextGadget::lTextLeft
@ lTextLeft
Text left, bitmap right.
Definition
btntextg.h:73
owl::TButtonTextGadget::SetText
void SetText(LPCTSTR s, bool repaint=true)
Definition
btntextg.h:93
owl::TDC
TDC is the root class for GDI DC wrappers.
Definition
dc.h:64
owl::TFont
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition
gdiobjec.h:296
owl::TRect
TRect is a mathematical class derived from tagRect.
Definition
geometry.h:308
owl::TResId
Definition
wsyscls.h:206
owl::TSize
The tagSIZE struct is defined as.
Definition
geometry.h:234
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::tstring
std::string tstring
Definition
defs.h:79
owl::uint
unsigned int uint
Definition
number.h:25
protected_data
#define protected_data
Definition
defs.h:208
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
include
owl
btntextg.h
Generated by
1.18.0