~serge-hallyn/ubuntu/raring/spice/spice-fixed2

« back to all changes in this revision

Viewing changes to client/gui/gui.h

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2011-07-23 12:21:04 UTC
  • Revision ID: package-import@ubuntu.com-20110723122104-gvv70gd6ui6213qd
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
/*
 
3
   Copyright (C) 2010 Red Hat, Inc.
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
#ifndef _H_GUI
 
19
#define _H_GUI
 
20
 
 
21
#include "softrenderer.h"
 
22
#include "screen_layer.h"
 
23
#include "inputs_handler.h"
 
24
#include "application.h"
 
25
 
 
26
class RedPixmapSw;
 
27
 
 
28
class GUI : public ScreenLayer, public KeyHandler {
 
29
public:
 
30
    class Dialog;
 
31
    class Tab;
 
32
    class TabFactory;
 
33
 
 
34
    typedef std::list<TabFactory*> TabFactorys;
 
35
 
 
36
    GUI(Application& app, Application::State state);
 
37
    virtual ~GUI();
 
38
 
 
39
    void set_screen(RedScreen* screen); //show and hide
 
40
 
 
41
    Application& get_application() { return _app;}
 
42
#ifdef USE_GUI
 
43
    CEGUI::System& gui_system() { return *_gui_system;}
 
44
#endif // USE_GUI
 
45
 
 
46
    void set_state(Application::State state);
 
47
    bool is_visible() { return !!_dialog;}
 
48
    bool prepare_dialog();
 
49
    bool is_disconnect_allowed() { return _app.is_disconnect_allowed();}
 
50
 
 
51
    virtual bool pointer_test(int x, int y) { return contains_point(x, y);}
 
52
    virtual void on_pointer_enter(int x, int y, unsigned int buttons_state);
 
53
    virtual void on_pointer_leave();
 
54
    virtual void on_pointer_motion(int x, int y, unsigned int buttons_state);
 
55
    virtual void on_mouse_button_press(int button, int buttons_state);
 
56
    virtual void on_mouse_button_release(int button, int buttons_state);
 
57
 
 
58
    virtual void on_key_down(RedKey key);
 
59
    virtual void on_key_up(RedKey key);
 
60
    virtual void on_char(uint32_t ch);
 
61
    virtual bool permit_focus_loss() { return false;}
 
62
 
 
63
    void idle();
 
64
 
 
65
    virtual void copy_pixels(const QRegion& dest_region, RedDrawable& dest_dc);
 
66
    virtual void on_size_changed();
 
67
 
 
68
    void register_tab_factory(TabFactory& factory);
 
69
    void unregister_tab_factory(TabFactory& factory);
 
70
 
 
71
    class BoxResponse {
 
72
    public:
 
73
        virtual ~BoxResponse() {}
 
74
        virtual void response(int response) = 0;
 
75
        virtual void aborted() = 0;
 
76
    };
 
77
 
 
78
    enum MessageType {
 
79
        QUESTION,
 
80
        INFO,
 
81
        WARNING,
 
82
        ERROR_MSG
 
83
    };
 
84
 
 
85
    struct ButtonInfo {
 
86
        int id;
 
87
        const char *text;
 
88
    };
 
89
 
 
90
    typedef std::vector<ButtonInfo> ButtonsList;
 
91
    bool message_box(MessageType type, const char *text, const ButtonsList& buttons,
 
92
                     BoxResponse* _response_handler);
 
93
 
 
94
private:
 
95
    TabFactorys& get_factoris() { return _tab_factorys;}
 
96
 
 
97
    void create_dialog();
 
98
    void detach();
 
99
    void update_layer_area();
 
100
    void init_cegui();
 
101
    void conditional_update();
 
102
    void set_dialog(Dialog* dialog);
 
103
    void dettach_dialog(Dialog* dialog);
 
104
 
 
105
private:
 
106
    Application& _app;
 
107
    Application::State _state;
 
108
    RedPixmapSw* _pixmap;
 
109
#ifdef USE_GUI
 
110
    CEGUI::SoftRenderer* _renderer;
 
111
    CEGUI::System* _gui_system;
 
112
#endif // USE_GUI
 
113
    Dialog* _dialog;
 
114
    uint64_t _prev_time;
 
115
    TabFactorys _tab_factorys;
 
116
 
 
117
    friend class Dialog;
 
118
};
 
119
 
 
120
class GUI::Tab {
 
121
public:
 
122
    virtual ~Tab() {}
 
123
 
 
124
#ifdef USE_GUI
 
125
    virtual CEGUI::Window& get_root_window() = 0;
 
126
#endif // USE_GUI
 
127
    virtual const std::string& get_name() = 0;
 
128
};
 
129
 
 
130
class GUI::TabFactory {
 
131
public:
 
132
    TabFactory() : _order (-1) {}
 
133
    TabFactory(int order) : _order (order) {}
 
134
 
 
135
    virtual ~TabFactory() {}
 
136
    virtual Tab* create_tab(bool connected, int width, int hight) = 0;
 
137
    int get_order() { return _order;}
 
138
 
 
139
private:
 
140
    int _order;
 
141
};
 
142
 
 
143
#endif
 
144