-
Notifications
You must be signed in to change notification settings - Fork 0
/
kspObject.h
73 lines (55 loc) · 1.77 KB
/
kspObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef KSPOBJECT_H
#define KSPOBJECT_H
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
class kspObject
{
public:
kspObject(Display *display, int ID, int X, int Y, unsigned int W, unsigned int H, const char *Label, const char *Text, bool Interactive);
~kspObject(void);
virtual void draw(Display *display, Window window, Drawable d);
void setText(const char *Text);
void activate(void);
void deactivate(void);
int ID(void) {return _ID;};
bool hitTest(int X, int Y); // true is the point is within the object
protected:
int _ID;
bool _isInteractive = false;
int _x;
int _y;
unsigned int _w;
unsigned int _h;
bool _isActive = false; // used to show binary state
char _Buffer[40] = {0};
char _Label[40] = {0};
bool _showLabel = false;
XFontStruct *_textFont;
XFontStruct *_labelFont;
char _activeRGB[8] = "#00FF00";
char _inactiveRGB[8]= "#003300";
};
class kspBarIndicator : public kspObject
{
public:
kspBarIndicator(Display *display, int ID, int X, int Y, unsigned int W, unsigned int H, const char *Label, const char *Text, bool Interactive);
void draw(Display *display, Window window, Drawable d);
void setValue(float Value);
void setBarColour(const char *activeRGB, const char *inactiveRGB);
private:
float _value = 0.0;
char _activeRGB[8] = "#00AA00";
char _inactiveRGB[8]= "#003300";
};
class kspLEDIndicator : public kspObject
{
public:
kspLEDIndicator(Display *display, int ID, int X, int Y, unsigned int W, unsigned int H, const char *Label, const char *Text, bool Interactive);
void draw(Display *display, Window window, Drawable d);
void setLEDColour(const char *activeRGB, const char *inactiveRGB);
};
#endif