ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
label.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef SDLTK_LABEL_H
21 #define SDLTK_LABEL_H
22 
23 #include "def.h"
24 #include "widget.h"
25 
26 namespace sdltk
27 {
28  class Image;
29  class Point;
30  class Rect;
31 
33  class Label : public Widget
34  {
35 
36  public:
37  Label(Widget * parent = nullptr);
38  virtual ~Label();
39 
40  virtual void draw();
41 
42  virtual void setPos(int x, int y) {mRect.setX(x), mRect.setY(y); setBorder(mBorder);}
43 
44  virtual void onMouseMotion (SDL_MouseMotionEvent * event);
45  virtual void onMouseButton (SDL_MouseButtonEvent * event);
46 
47  void setImage(const String & fname, bool autosize=true, bool bg=false);
48  void setBorder(bool val);
49  void setBackground(bool val) {mBackground = val;}
50  void setText(const String & text) {mText = text;}
51  void setMoveable(bool moveable) {mMoveable = moveable;}
52  void setBorderColor(const Color & color, const Color & highlite)
53  {mBorderColor1 = color; mBorderColor2 = highlite;}
54 
55  const String & getText() const {return mText;}
56 
57  protected:
58  void drawBorder();
59  void drawBackground();
60  void drawBackground(const Color & color);
61  void drawText();
62 
63  void moveInit(SDL_MouseButtonEvent * event);
64  void move(SDL_MouseMotionEvent * event);
65 
66 
67  bool mBorder;
69  bool mMoveable;
70 
72 
76 
78 
83 
86 
87  };
88 
89 } // sdltk
90 
91 #endif // SDLTK_LABEL_H
virtual void setPos(int x, int y)
Sets the Position.
Definition: label.h:42
Color mBorderColor1
Definition: label.h:84
Image * mImage
Definition: label.h:71
bool mBorder
Definition: label.h:67
Image to display either on an OpenGL- or plain SDL-Surface.
Definition: image.h:39
String mText
Definition: label.h:73
bool mMoveable
Definition: label.h:69
Point mRightBottom
Definition: label.h:81
Sint16 y() const
Returns the y position of the upper left corner.
Definition: widget.h:100
virtual void onMouseButton(SDL_MouseButtonEvent *event)
Catch MouseButton events.
Definition: label.cpp:48
Color color() const
Returns the Color of the Widget.
Definition: widget.h:79
void moveInit(SDL_MouseButtonEvent *event)
Definition: label.cpp:53
virtual ~Label()
Definition: label.cpp:38
A Widget with text and background color or image.
Definition: label.h:33
void drawText()
Definition: label.cpp:147
Sint16 x() const
Returns the x position of the upper left corner.
Definition: widget.h:98
Label(Widget *parent=nullptr)
Definition: label.cpp:25
virtual void draw()
Definition: label.cpp:158
Point mRelativeMousePos
Definition: label.h:77
Point mTextOffset
Definition: label.h:75
void setBackground(bool val)
Definition: label.h:49
void drawBackground()
Definition: label.cpp:127
virtual void onMouseMotion(SDL_MouseMotionEvent *event)
Catch MouseMotion events.
Definition: label.cpp:43
Point mTextPos
Definition: label.h:74
void move(SDL_MouseMotionEvent *event)
Definition: label.cpp:69
void setImage(const String &fname, bool autosize=true, bool bg=false)
Definition: label.cpp:102
bool mBackground
Definition: label.h:68
void setText(const String &text)
Definition: label.h:50
Point mLeftBottom
Definition: label.h:82
void setBorder(bool val)
Definition: label.cpp:80
void drawBorder()
Definition: label.cpp:114
Point mRightTop
Definition: label.h:80
Baseclass for all Widgets.
Definition: widget.h:37
Defines a 2D point (x, y)
Definition: point.h:28
const String & getText() const
Definition: label.h:55
Point mLeftTop
Definition: label.h:79
void setX(Sint16 x)
Definition: rect.h:93
Color mBorderColor2
Definition: label.h:85
Rect mRect
Definition: widget.h:122
void setY(Sint16 y)
Definition: rect.h:94
void setMoveable(bool moveable)
Definition: label.h:51
RGBA Color Type.
Definition: color.h:30
std::string String
Definition: types.h:29
the SDL based Stuff
Definition: audio.cpp:22
const Widget * parent() const
Returns the parent.
Definition: widget.h:72
void setBorderColor(const Color &color, const Color &highlite)
Definition: label.h:52