HoverRace  2.0
BaseText.h
Go to the documentation of this file.
1 
2 // BaseText.h
3 //
4 // Copyright (c) 2015-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 "Color.h"
25 #include "UiFont.h"
26 
27 #include "UiViewModel.h"
28 
29 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
30 # ifdef MR_ENGINE
31 # define MR_DllDeclare __declspec( dllexport )
32 # else
33 # define MR_DllDeclare __declspec( dllimport )
34 # endif
35 #else
36 # define MR_DllDeclare
37 #endif
38 
39 namespace HoverRace {
40 namespace Display {
41 
46 class BaseText : public UiViewModel
47 {
48  using SUPER = UiViewModel;
49 
50 public:
51  struct Props
52  {
53  enum
54  {
60  };
61  };
62 
63 public:
64  BaseText(const std::string &text, const UiFont &font, const Color color,
66  virtual ~BaseText() { }
67 
68 public:
69  const Color GetColor() const { return color; }
70  void SetColor(const Color color);
71 
72  const UiFont &GetFont() const { return font; }
73  void SetFont(const UiFont &font);
74 
75  const std::string &GetText() const { return text; }
76  void SetText(const std::string &text);
77 
82  bool IsFixedScale() const { return fixedScale; }
83  void SetFixedScale(bool fixedScale);
84 
85 private:
86  std::string text;
89  bool fixedScale;
90 };
91 
92 } // namespace Display
93 } // namespace HoverRace
94 
95 #undef MR_DllDeclare
bool IsFixedScale() const
Check if the scaling is fixed (i.e., ignores user text scale config).
Definition: BaseText.h:82
Definition: Color.h:40
const std::string & GetText() const
Definition: BaseText.h:75
Describes a font used for the UI.
Definition: UiFont.h:44
Base class for UI (2D) components.
Definition: UiViewModel.h:56
UiViewModel(uiLayoutFlags_t layoutFlags=0)
Definition: UiViewModel.h:91
UiFont font
Definition: BaseText.h:87
std::string text
Definition: BaseText.h:86
uiLayoutFlags_t layoutFlags
Definition: UiViewModel.h:224
virtual ~BaseText()
Definition: BaseText.h:66
void SetFixedScale(bool fixedScale)
Definition: BaseText.cpp:69
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
void SetFont(const UiFont &font)
Definition: BaseText.cpp:53
bool fixedScale
Definition: BaseText.h:89
void SetText(const std::string &text)
Definition: BaseText.cpp:61
Color color
Definition: BaseText.h:88
const UiFont & GetFont() const
Definition: BaseText.h:72
First index for subclasses.
Definition: BaseText.h:59
Base class for widgets that display text.
Definition: BaseText.h:46
Definition: BaseText.h:51
Definition: Announcement.h:24
void SetColor(const Color color)
Definition: BaseText.cpp:45
BaseText(const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
Constructor for automatically-sized widget.
Definition: BaseText.cpp:36
const Color GetColor() const
Definition: BaseText.h:69
First index for subclasses.
Definition: UiViewModel.h:68