Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
floorplan.H
Go to the documentation of this file.
1 /*
2  * This file is part of the Home2L project.
3  *
4  * (C) 2015-2021 Gundolf Kiefer
5  *
6  * Home2L is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Home2L is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Home2L. If not, see <https://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 #ifndef _FLOORPLAN_
23 #define _FLOORPLAN_
24 
25 #include "ui_widgets.H"
26 
27 
39 #define FP_WIDTH 256
42 #define FP_HEIGHT 128
44 #define FP_UPDATE_INTERVAL 64
46 
47 #define COL_FP_MAIN BROWN
49 #define COL_FP_MAIN_DARKER ColorScale (COL_FP_MAIN, 0x80)
50 //~ #define COL_FP_MAIN DARK_BLUE
51 //~ #define COL_FP_MAIN_DARKER ColorDarker (COL_FP_MAIN, 0x40) ///< @internal
52 
53 
59  gtNone = 0,
60 
70 
75 
89 
92  gtEND
94 };
95 
96 
97 static inline bool GadgetTypeIsIcon (EGadgetType t) { return t >= gtLock; }
98  // NOTE: Icons must be last in 'EGadgetType'
99 
100 
101 
102 
103 
104 // *************************** Resource Dialog *********************************
105 
106 
107 void RunResourceDialog (class CResource *rc, EGadgetType subType = gtNone, const char *title = NULL, bool emphasize = false);
117 
118 
119 
120 
121 
122 // *************************** CWidgetFloorplan ********************************
123 
124 
129 class CWidgetFloorplan: public CFlatButton, public CTimer {
130  public:
131  CWidgetFloorplan ();
132  virtual ~CWidgetFloorplan ();
133 
134  void Setup (int x0, int y0, class CFloorplan *_floorplan = NULL, TTicks _tInterval = FP_UPDATE_INTERVAL);
136  bool IsOk () { return floorplan != NULL; }
137 
138  void Activate (bool on = true);
146 
147  protected:
148 
149  // Callbacks ...
150  virtual void OnTime (); // from 'CTimer'
151  virtual SDL_Surface *GetSurface (); // from 'C[Flat]Button'
152  virtual void OnPushed (bool longPush); // from 'C[Flat]Button'
153 
154  // Variables ...
155  class CFloorplan *floorplan;
156  TTicks tInterval;
157 
158  SDL_Surface *mapSurf;
159 };
160 
161 
162 
163 
164 
165 // *************************** Top-Level ***************************************
166 
167 
168 void FloorplanInit ();
169 void FloorplanDone ();
170 
173 
174 void FloorplanCheckAlert (CScreen *returnScreen = NULL);
179 
180 class CFloorplan *FloorplanGetMain ();
182 
190 
191 
192 
195 
196 
197 #endif
Flat Push-button widget.
Definition: ui_widgets.H:310
Home2L Resource.
Definition: resources.H:895
Screen object.
Definition: ui_screen.H:293
Timer class.
Definition: base.H:1580
Floorplan widget.
Definition: floorplan.H:129
void Setup(int x0, int y0, class CFloorplan *_floorplan=NULL, TTicks _tInterval=FP_UPDATE_INTERVAL)
Setup the widget.
virtual SDL_Surface * GetSurface()
Get an up-to-date surface or 'NULL' if none is available.
virtual void OnTime()
[T:timer] Virtual function called when the timer triggers.
void Activate(bool on=true)
(De-)Activate automatic updates of the mini-floorplan.
int64_t TTicks
Time value (relative, absolute, or monotonic).
Definition: base.H:1376
EGadgetType
Definition: floorplan.H:58
#define FP_UPDATE_INTERVAL
Number of milliseconds between updates.
Definition: floorplan.H:44
void FloorplanCheckAlert(CScreen *returnScreen=NULL)
Check for an alert and if so activate the floorplan screen.
void FloorplanActivate()
Activate the floorplan screen.
void FloorplanUnsubscribeAll()
Unsubscribe all resources of the floorplan.
class CFloorplan * FloorplanGetMain()
Get a reference to the main floorplan (for CWidgetFloorplan::Setup() ).
void RunResourceDialog(class CResource *rc, EGadgetType subType=gtNone, const char *title=NULL, bool emphasize=false)
Run a dialog allowing to edit, add or delete a user request.
@ gtMotion
motion status
Definition: floorplan.H:79
@ gtRoofWindow
roof window, optionally including shades
Definition: floorplan.H:67
@ gtWindow
window with a state of ERctWindowState (type rctBool is also allowed).
Definition: floorplan.H:63
@ gtGate
gate (visualized like a window)
Definition: floorplan.H:65
@ gtBluetooth
Bluetooth.
Definition: floorplan.H:85
@ gtPhone
phone (with state ERctPhoneState)
Definition: floorplan.H:82
@ gtTemp
temperature value
Definition: floorplan.H:73
@ gtWlan
Wifi access point.
Definition: floorplan.H:84
@ gtLight
light
Definition: floorplan.H:80
@ gtGarage
garage door (open/close)
Definition: floorplan.H:68
@ gtDoor
door (visualized like a window)
Definition: floorplan.H:64
@ gtShades
shades or blinds (type rctPercent)
Definition: floorplan.H:66
@ gtWarning
a warning sign
Definition: floorplan.H:87
@ gtService
some generic service
Definition: floorplan.H:86
@ gtMusic
music player
Definition: floorplan.H:83
@ gtLock
door lock
Definition: floorplan.H:78
@ gtMail
mail box
Definition: floorplan.H:81