forked from m0nkeykong/MethodsInSE_graphicSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.h
25 lines (20 loc) · 841 Bytes
/
Button.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
#pragma once
#include "Control.h"
class Button;
struct MouseListener{
virtual void MousePressed(Button &b, int x, int y, bool isLeft) = 0;
};
class Button : public Control {
private:
string value;
MouseListener* listener;
public:
Button(int);
void SetValue(string value) { this->value = value; } //set button text
string GetValue() { return this->value; } //get button text
bool canGetFocus() { return false; } //buttons can't be focused by project's demand
void keyDown(int, char) { this->graphics.clearScreen(); }
void AddListener(MouseListener &listener) { this->listener = &listener; }
void mousePressed(int xPos, int yPos, DWORD button) { listener->MousePressed(*this, xPos, yPos, true); }
void draw(Graphics, int, int, size_t);
};