-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButton.h
More file actions
83 lines (63 loc) · 1.6 KB
/
Button.h
File metadata and controls
83 lines (63 loc) · 1.6 KB
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
74
75
76
77
78
79
80
81
82
83
#ifndef BUTTON_H
#define BUTTON_H
#include <allegro5/allegro.h>
class Button
{
public:
// constructor
Button();
// destructor
~Button();
// creates the button image
void Create();
// recreates the button image
void Recreate();
// updates the button
bool Update();
// renders the button
void Render(ALLEGRO_BITMAP* destination);
// callback functions
void (*OnMouseOver)(Button* object, void* data);
void (*OnMouseOut)(Button* object, void* data);
void (*OnClick)(Button* object, void* data);
void SetCaption(const char* caption);
void SetSize(int width, int height);
void SetPosition(int x, int y);
void SetPosition(ALLEGRO_BITMAP* anchorBitmap, int x, int y);
void SetTextColor(ALLEGRO_COLOR color);
void SetShadowColor(ALLEGRO_COLOR color);
void SetBorderColor(ALLEGRO_COLOR color);
void SetFaceColor(ALLEGRO_COLOR color);
// repositions the button in the center of the surface
void CenterOn(ALLEGRO_BITMAP* surface);
void SetMiscData(void* data);
void* GetMiscData();
int GetX();
int GetY();
int GetWidth();
int GetHeight();
ALLEGRO_COLOR GetTextColor();
ALLEGRO_COLOR GetShadowColor();
ALLEGRO_COLOR GetBorderColor();
ALLEGRO_COLOR GetFaceColor();
char* GetCaption();
private:
// void data pointer for use with callbacks
void* data_;
// the button image
ALLEGRO_BITMAP* image_;
// the text on the button
char* caption_;
// the coloring of the button
ALLEGRO_COLOR faceColor_;
ALLEGRO_COLOR borderColor_;
ALLEGRO_COLOR shadowColor_;
ALLEGRO_COLOR textColor_;
// the dimension of the button
int w_;
int h_;
// the position of the button
int x_;
int y_;
};
#endif