HoverRace  2.0
ActiveText.h
Go to the documentation of this file.
1 
2 // ActiveText.h
3 //
4 // Copyright (c) 2015 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 
49 class ActiveText : public BaseText
50 {
51  using SUPER = BaseText;
52 
53 public:
54  struct Props
55  {
56  enum
57  {
61  };
62  };
63 
64 public:
65  ActiveText(const std::string &text, const UiFont &font, const Color color,
67  virtual ~ActiveText() { }
68 
69 public:
70  void AttachView(Display &disp) override { AttachViewDynamic(disp, this); }
71 
72 public:
77  bool IsCaretVisible() const { return caretVisible; }
78  void SetCaretVisible(bool visible);
79 
84  size_t GetCaretPos() const { return caretPos; }
85  void SetCaretPos(size_t pos);
86 
87 private:
89  size_t caretPos;
90 };
91 
92 } // namespace Display
93 } // namespace HoverRace
94 
95 #undef MR_DllDeclare
Definition: Color.h:40
Definition: ActiveText.h:54
Describes a font used for the UI.
Definition: UiFont.h:44
virtual ~ActiveText()
Definition: ActiveText.h:67
UiFont font
Definition: BaseText.h:87
std::string text
Definition: BaseText.h:86
uiLayoutFlags_t layoutFlags
Definition: UiViewModel.h:224
void SetCaretVisible(bool visible)
Set the visibility of the caret.
Definition: ActiveText.cpp:47
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
size_t caretPos
Definition: ActiveText.h:89
Base class for display managers.
Definition: Display.h:73
bool caretVisible
Definition: ActiveText.h:88
Vec2 pos
Definition: UiViewModel.h:221
void AttachView(Display &disp) override
Definition: ActiveText.h:70
size_t GetCaretPos() const
Retrieve the position of the caret.
Definition: ActiveText.h:84
Color color
Definition: BaseText.h:88
void SetCaretPos(size_t pos)
Set the caret position.
Definition: ActiveText.cpp:60
First index for subclasses.
Definition: BaseText.h:59
First index for subclasses.
Definition: ActiveText.h:60
A text widget where the contents may change often (i.e., updated every few frames, or even every frame).
Definition: ActiveText.h:49
ActiveText(const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
Constructor.
Definition: ActiveText.cpp:34
Base class for widgets that display text.
Definition: BaseText.h:46
Definition: Announcement.h:24
bool IsCaretVisible() const
Check if the caret is visible.
Definition: ActiveText.h:77
BaseText(const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
Constructor for automatically-sized widget.
Definition: BaseText.cpp:36
void AttachViewDynamic(Display &disp, T *self)
Definition: ViewModel.h:68