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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef _H_GUI
#define _H_GUI
#include "softrenderer.h"
#include "screen_layer.h"
#include "inputs_handler.h"
#include "application.h"
class RedPixmapSw;
class GUI : public ScreenLayer, public KeyHandler {
public:
class Dialog;
class Tab;
class TabFactory;
typedef std::list<TabFactory*> TabFactorys;
GUI(Application& app, Application::State state);
virtual ~GUI();
void set_screen(RedScreen* screen); //show and hide
Application& get_application() { return _app;}
CEGUI::System& gui_system() { return *_gui_system;}
void set_state(Application::State state);
bool is_visible() { return !!_dialog;}
bool prepare_dialog();
bool is_disconnect_allowed() { return _app.is_disconnect_allowed();}
virtual bool pointer_test(int x, int y) { return contains_point(x, y);}
virtual void on_pointer_enter(int x, int y, unsigned int buttons_state);
virtual void on_pointer_leave();
virtual void on_pointer_motion(int x, int y, unsigned int buttons_state);
virtual void on_mouse_button_press(int button, int buttons_state);
virtual void on_mouse_button_release(int button, int buttons_state);
virtual void on_key_down(RedKey key);
virtual void on_key_up(RedKey key);
virtual void on_char(uint32_t ch);
virtual bool permit_focus_loss() { return false;}
void idle();
virtual void copy_pixels(const QRegion& dest_region, RedDrawable& dest_dc);
virtual void on_size_changed();
void register_tab_factory(TabFactory& factory);
void unregister_tab_factory(TabFactory& factory);
class BoxResponse {
public:
virtual ~BoxResponse() {}
virtual void response(int response) = 0;
virtual void aborted() = 0;
};
enum MessageType {
QUESTION,
INFO,
WARNING,
ERROR_MSG
};
struct ButtonInfo {
int id;
const char *text;
};
typedef std::vector<ButtonInfo> ButtonsList;
bool message_box(MessageType type, const char *text, const ButtonsList& buttons,
BoxResponse* _response_handler);
private:
TabFactorys& get_factoris() { return _tab_factorys;}
void create_dialog();
void detach();
void update_layer_area();
void init_cegui();
void conditional_update();
void set_dialog(Dialog* dialog);
void dettach_dialog(Dialog* dialog);
private:
Application& _app;
Application::State _state;
RedPixmapSw* _pixmap;
CEGUI::SoftRenderer* _renderer;
CEGUI::System* _gui_system;
Dialog* _dialog;
uint64_t _prev_time;
TabFactorys _tab_factorys;
friend class Dialog;
};
class GUI::Tab {
public:
virtual ~Tab() {}
virtual CEGUI::Window& get_root_window() = 0;
virtual const std::string& get_name() = 0;
};
class GUI::TabFactory {
public:
TabFactory() : _order (-1) {}
TabFactory(int order) : _order (order) {}
virtual ~TabFactory() {}
virtual Tab* create_tab(bool connected, int width, int hight) = 0;
int get_order() { return _order;}
private:
int _order;
};
#endif
|