-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.hpp
More file actions
62 lines (46 loc) · 2.1 KB
/
Button.hpp
File metadata and controls
62 lines (46 loc) · 2.1 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
#pragma once
#include "TXLib.h"
#include "Vector.hpp"
#include "Window.hpp"
#include <string>
typedef void (*func_t) ();
enum binding {posX, posY, posZ, rotX, rotY, rotZ, szX, szY, szZ, colX, colY, colZ, matRefl, matRefr, matTr, matRough};
class AbstractButton {
public:
POINT wndPos_, fieldPos_, size_;
POINT fieldCoords_, fieldSize_;
Vector fill_color_, text_color_;
int status_;
func_t func_, pinched_func_;
AbstractButton(const POINT& pos, const POINT& size, const Vector& fill_color, const Vector& text_color, func_t func, func_t pinched_func);
virtual ~AbstractButton() = default;
virtual bool mouse_on_button(const POINT& mouse_pos) = 0;
virtual void draw (HDC dc, bool needToCopy = true) = 0;
virtual bool pinched(HDC dc) = 0;
virtual void pressed(HDC dc) = 0;
AbstractButton(const AbstractButton&) = delete;
AbstractButton& operator=(const AbstractButton&) = delete;
};
class BasicButton : public AbstractButton {
public:
std::string text_;
BasicButton(const POINT& pos, const POINT& size, const Vector& fill_color = EVEC * 255, const Vector& text_color = NULLVEC, std::string text = "", func_t func = nullptr, func_t pinched_func = nullptr);
virtual bool mouse_on_button(const POINT& mouse_pos) override final;
virtual void draw (HDC dc, bool needToCopy = true) override final;
virtual bool pinched(HDC dc) override;
virtual void pressed(HDC dc) override;
BasicButton(const BasicButton&) = delete;
BasicButton& operator=(const BasicButton&) = delete;
};
class TextButton : public BasicButton {
public:
double* val_;
int bind_;
int minv_, maxv_, mult_;
TextButton(double* val_, int bind, const POINT& pos, const POINT& size, const Vector& fill_color, const Vector& text_color, int minv_ = -INF, int maxv_ = INF, int mult = 1);
virtual bool pinched(HDC dc) override;
virtual void pressed(HDC dc) override;
TextButton(const TextButton&) = delete;
TextButton& operator=(const TextButton&) = delete;
};
double* getParam(int id, Object* obj);