File: button.h

package info (click to toggle)
atanks 6.6~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 12,692 kB
  • sloc: cpp: 27,094; makefile: 268; ansic: 127; xml: 78; sh: 7
file content (59 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (4)
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
#ifndef BUTTON_HEADER_
#define BUTTON_HEADER_

#include "main.h"

class BUTTON
{
public:

	/* --------------------
	 * --- constructors ---
	 * --------------------
	 */

	// Minimum ctor without text
	explicit
	BUTTON (int32_t left_, int32_t top_,
	        BITMAP* bmp_, BITMAP* hover_, BITMAP* depressed_);

	// ctor for using a bitmap.
	BUTTON (const char* text_, bool text_only_,
	        int32_t left_, int32_t top_,
	        BITMAP* bmp_, BITMAP* hover_, BITMAP* depressed_);

	// ctor for drawing a manual box.
	BUTTON (const char* text_, bool text_only_,
	        int32_t left_, int32_t top_, int32_t width_, int32_t height_);


	/* ----------------------
	 * --- Public methods ---
	 * ----------------------
	 */

	void draw ();
	void getLocation(int32_t &x,int32_t &y,int32_t &w,int32_t &h);
	bool isMouseOver ();
	bool isPressed ();
	void setText(const char* text_);

private:

	/* -----------------------
	 * --- Private members ---
	 * -----------------------
	 */

	BITMAP*     bmp        = nullptr;
	BITMAP*     depressed  = nullptr;
	BITMAP*     hover      = nullptr;
	BOX         location;               //!< is {0, 0, 0, 0} by default
	const char* text       = nullptr;
	bool        text_only  = false;     //!< If set to true, only the title is displayed.
	int32_t     text_width = 0;         //!< must not be recalculated over and over again...
	int32_t     x1, y1, x2, y2, x3, y3; //!< Shortcuts, as those stay fixed.
};

#endif