mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Button.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <string>
9 #include "MouseHandler.h"
10 #include "TextureFont.h"
11 #include "ClickableObject.h"
12 
14 class Button : public ClickableObject
15 {
16 public:
17  Button(int innerBorder, int outerBorder, MouseHandler * mouse, std::string text, TextureFont * tf, unsigned int minLength,
18  unsigned int centerx=0, unsigned int centery=0, int windowWidth=1, int windowHeight=1);
19  void draw();
20  bool isMouseOverObject();
21  void mouseClick();
22  void setCenter(unsigned int centerx, unsigned int centery);
23  void setWindowDimensions(int wwidth, int wheight);
24  size_t getButtonWidth();
25  size_t getButtonHeight();
26  unsigned int getButtonInnerWidth();
27  unsigned int getButtonInnerHeight();
28  bool isClicked();
29  void noClick();
30  void activateButton();
31  void deactivateButton();
32  void switchOn();
33  void switchOff();
34  bool isActive();
35  bool isOn();
36 public:
37  ~Button(void);
38 private:
39  int centerx, centery, windowWidth, windowHeight, messageHeight;
40  size_t messageWidth;
41  MouseHandler * mouse;
42  std::string text;
43  TextureFont * tf;
44  GLint outerBorder, innerBorder;
45 
46  GLfloat mouseOverColor[4];
47  GLfloat normalColor[4];
48  GLfloat inactiveColor[4];
49 
50  GLfloat normalFrameColor[4];
51  GLfloat clickedFrameColor[4];
52  GLfloat inactiveFrameColor[4];
53 
54 
55  /*bool mouseOver; */
56  bool clicked;
57  bool on; /* if button is not on, it cannot be clicked and is not drawn */
58  bool active; /* if button is not active, it cannot be blicked */
59 };