Aether
SDL2 based UI Framework for NX
DateTime.hpp
1 #ifndef AETHER_DATETIME_HPP
2 #define AETHER_DATETIME_HPP
3 
4 #include <ctime>
5 #include "Aether/horizon/button/BorderButton.hpp"
6 #include "Aether/horizon/controls/ControlBar.hpp"
7 #include "Aether/horizon/input/Spinner.hpp"
8 #include "Aether/primary/Rectangle.hpp"
9 #include "Aether/Overlay.hpp"
10 
11 namespace Aether {
16  enum class DTFlag {
17  DateTime = 0b00111111,
18  Date = 0b00111000,
19  Time = 0b00000111,
20  Day = 0b00100000,
21  Month = 0b00010000,
22  Year = 0b00001000,
23  Hour = 0b00000100,
24  Min = 0b00000010,
25  Sec = 0b00000001
26  };
27 
35  inline DTFlag operator|(DTFlag a, DTFlag b) {
36  return static_cast<DTFlag>(static_cast<int>(a) | static_cast<int>(b));
37  }
38 
46  class DateTime : public Overlay {
47  private:
49  struct tm & refTm;
51  ControlBar * ctrl;
53  Rectangle * rect;
55  Rectangle * top;
57  Rectangle * bottom;
59  Text * title;
61  BorderButton * button;
63  Spinner * day;
65  Spinner * month;
67  Spinner * year;
69  Spinner * hour;
71  Spinner * min;
73  Spinner * sec;
75  Text * div1;
77  Text * div2;
79  Text * col1;
81  Text * col2;
82 
86  void setTmValues();
87 
88  public:
97  DateTime(std::string s, struct tm & t, DTFlag d = DTFlag::DateTime);
98 
107  bool handleEvent(InputEvent * e);
108 
114  void setBackLabel(std::string s);
115 
121  void setOKLabel(std::string s);
122 
128  void setDayHint(std::string s);
129 
135  void setMonthHint(std::string s);
136 
142  void setYearHint(std::string s);
143 
149  void setHourHint(std::string s);
150 
156  void setMinuteHint(std::string s);
157 
163  void setSecondHint(std::string s);
164 
170  Colour getBackgroundColour();
171 
177  void setBackgroundColour(Colour c);
178 
184  Colour getHighlightColour();
185 
191  void setHighlightColour(Colour c);
192 
198  Colour getInactiveColour();
199 
205  void setInactiveColour(Colour c);
206 
212  Colour getSeparatorColour();
213 
219  void setSeparatorColour(Colour c);
220 
226  Colour getTextColour();
227 
233  void setTextColour(Colour c);
234 
244  void setAllColours(Colour c1, Colour c2, Colour c3, Colour c4, Colour c5);
245  };
246 };
247 
248 #endif
A rectangle is a texture containing either a normal or rounded rectangle.
Definition: Rectangle.hpp:11
Element for rendering a single line of text. It can optionally scroll when overflowing.
Definition: Text.hpp:15
DTFlag operator|(DTFlag a, DTFlag b)
Bitwise OR operator for DTFlag.
Definition: DateTime.hpp:35
The BorderButton element looks similar to the unfilled buttons seen within Horizon.
Definition: BorderButton.hpp:13
A Spinner contains a number which can be increased/decreased by pressing the associated up/down butto...
Definition: Spinner.hpp:25
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
Base namespace for all Aether related classes and functions.
A container holding control elements (and nothing else) which automatically arranges them at the bott...
Definition: ControlBar.hpp:16
A class that represents an Aether input event.
Definition: InputEvent.hpp:25
An object representing an overlay.
Definition: Overlay.hpp:14
DTFlag
Spinners to show (create custom by passing bitwise OR of multiple flags!) Each bit represents in the ...
Definition: DateTime.hpp:16
The DateTime overlay is used to get the user to select a date/time. It must be passed a tm struct on ...
Definition: DateTime.hpp:46