-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuicore_Label.h
140 lines (109 loc) · 3.46 KB
/
uicore_Label.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
Copyright (C) 2007 Benjamin Litzelmann
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _UICORE_LABEL_H_
#define _UICORE_LABEL_H_
#include "uicore_BaseObject.h"
namespace UICore
{
class Label : public BaseObject
{
protected:
Font font;
Color fontColor;
Color disabledFontColor;
std::string caption;
Alignment textAlign;
bool multiline;
bool wordwrap;
virtual void Initialize( void );
virtual void FitTextToRect( const Rect &objectSrc, const Rect &objectDest, Rect &textSrc, Rect &textDest, const char *buf, float padLeft = 0, float padTop = 0 );
virtual void DrawText( const Rect &posSrc, const Rect &posDest, bool enabled = true );
static void ColorStrLastColor( int *lastcolor, const char *s, int byteofs );
public:
Label();
Label( BaseObject *parent, float x, float y, float w, float h, std::string caption = "" );
virtual ~Label();
MEMORY_OPERATORS
virtual void Draw( unsigned int deltatime, const Rect *parentPos = NULL, const Rect *parentPosSrc = NULL, bool enabled = true );
inline virtual void setFont( Font font );
inline virtual void setFontColor( const Color &color );
inline virtual void setDisabledFontColor( const Color &color );
inline virtual void setCaption( const std::string caption );
inline virtual void setAlign( Alignment align );
virtual void setMultiline( bool m );
virtual void setWordwrap( bool m );
inline virtual Font getFont( void ) const;
inline virtual Color getFontColor( void ) const;
inline virtual Color getDisabledFontColor( void ) const;
inline virtual std::string getCaption( void ) const;
inline virtual Alignment getAlign( void ) const;
inline virtual bool getMultiline( void ) const;
inline virtual bool getWordwrap( void ) const;
inline virtual std::string getType( void ) const;
};
void Label::setFont( Font font )
{
this->font = font;
}
void Label::setFontColor( const Color &color )
{
fontColor = color;
}
void Label::setDisabledFontColor( const Color &color )
{
disabledFontColor = color;
}
void Label::setCaption( const std::string caption )
{
this->caption = caption;
}
void Label::setAlign( Alignment align )
{
textAlign = align;
}
Font Label::getFont( void ) const
{
return font;
}
Color Label::getFontColor( void ) const
{
return fontColor;
}
Color Label::getDisabledFontColor( void ) const
{
return disabledFontColor;
}
std::string Label::getCaption( void ) const
{
return caption;
}
Alignment Label::getAlign( void ) const
{
return textAlign;
}
bool Label::getMultiline( void ) const
{
return multiline;
}
bool Label::getWordwrap( void ) const
{
return wordwrap;
}
std::string Label::getType( void ) const
{
return UICORE_TYPE_LABEL;
}
}
#endif