HoverRace  2.0
Label.h
Go to the documentation of this file.
1 
2 // Label.h
3 //
4 // Copyright (c) 2013-2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "BaseText.h"
25 
26 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
27 # ifdef MR_ENGINE
28 # define MR_DllDeclare __declspec( dllexport )
29 # else
30 # define MR_DllDeclare __declspec( dllimport )
31 # endif
32 #else
33 # define MR_DllDeclare
34 #endif
35 
36 namespace HoverRace {
37  namespace Display {
38  class Display;
39  }
40 }
41 
42 namespace HoverRace {
43 namespace Display {
44 
52 {
53  using SUPER = BaseText;
54 
55 public:
56  struct Props
57  {
58  enum
59  {
60  SCALE = SUPER::Props::NEXT_,
63  };
64  };
65 
66 public:
67  Label(const std::string &text, const UiFont &font, const Color color,
68  uiLayoutFlags_t layoutFlags = 0);
69  Label(double wrapWidth, const std::string &text, const UiFont &font,
70  const Color color, uiLayoutFlags_t layoutFlags = 0);
71  virtual ~Label() { }
72 
73 public:
74  void AttachView(Display &disp) override { AttachViewDynamic(disp, this); }
75 
76 public:
83  bool IsAutoWidth() const { return wrapWidth <= 0; }
84  void SetAutoWidth();
85 
90  double GetScale() const { return scale; }
91  void SetScale(const double scale);
92 
98  double GetWrapWidth() const { return wrapWidth; }
99  void SetWrapWidth(double wrapWidth);
100 
101 private:
102  double scale;
103  double wrapWidth;
104 };
105 
106 } // namespace Display
107 } // namespace HoverRace
108 
109 #undef MR_DllDeclare
Definition: Color.h:40
bool IsAutoWidth() const
Check if automatic width sizing is enabled.
Definition: Label.h:83
double GetScale() const
Gets the scaling of this label.
Definition: Label.h:90
Describes a font used for the UI.
Definition: UiFont.h:44
Base class for UI (2D) components.
Definition: UiViewModel.h:56
Definition: Label.h:56
A static text label.
Definition: Label.h:51
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
double wrapWidth
Definition: Label.h:103
void AttachView(Display &disp) override
Definition: Label.h:74
Base class for display managers.
Definition: Display.h:73
Fired when a fixed width is set or auto-width is enabled.
Definition: Label.h:61
#define MR_DllDeclare
Definition: Label.h:33
Base class for widgets that display text.
Definition: BaseText.h:46
First index for subclasses.
Definition: Label.h:62
Definition: Announcement.h:24
double scale
Definition: Label.h:102
virtual ~Label()
Definition: Label.h:71
double GetWrapWidth() const
Returns the set width, if a fixed width is set.
Definition: Label.h:98