00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef header_component
00012 #define header_component
00013
00014 #include <string>
00015
00016 #include "../signals.h"
00017 #include "../Core/Math/rect.h"
00018 #include "../Core/Math/point.h"
00019 #include "../Display/Input/key.h"
00020
00021 class CL_GUIManager;
00022 class CL_ComponentStyle;
00023 class CL_InputDevice;
00024 class CL_ComponentOptions;
00025 class CL_StyleManager;
00026 class CL_Component_Generic;
00027
00028 class CL_Component
00029
00030 {
00032 public:
00033 CL_Component(
00034 CL_Component *parent,
00035 CL_StyleManager *style = NULL);
00036
00037 CL_Component(
00038 const CL_Rect &pos,
00039 CL_Component *parent,
00040 CL_StyleManager *style = NULL);
00041
00042 CL_Component(
00043 const CL_ComponentOptions &options,
00044 CL_Component *parent,
00045 CL_StyleManager *style = NULL);
00046
00047 virtual ~CL_Component();
00048
00050 public:
00051 CL_Component *get_parent() const;
00052
00053
00054 CL_Component *get_root_parent();
00055
00056
00057 CL_GUIManager *get_gui_manager() const;
00058
00059
00060 CL_StyleManager *get_style_manager() const;
00061
00062
00063 int get_width() const;
00064
00065
00066 int get_height() const;
00067
00068
00069 CL_Rect get_screen_rect() const;
00070
00071
00072 const CL_Rect &get_position() const;
00073
00074
00075 bool has_child(CL_Component *component) const;
00076
00077
00078 std::list<CL_Component *> &get_children();
00079
00080
00081 const std::list<CL_Component *> &get_children() const;
00082
00083
00084 CL_Rect get_children_rect();
00085
00086
00087 CL_Component *get_component_at(int pos_x, int pos_y);
00088
00089
00090
00091
00092 bool is_visible() const;
00093
00094
00095 bool is_enabled() const;
00096
00097
00098 bool is_popup() const;
00099
00100
00101 bool has_focus() const;
00102
00103
00104 bool is_mouse_captured() const;
00105
00106
00107 bool is_removeflag_set() const;
00108
00109
00111 public:
00112 void update();
00113
00114
00115 void set_position(const CL_Rect &new_pos);
00116
00117
00118 void set_position(int new_x, int new_y);
00119
00120
00121 void set_size(int new_width, int new_height);
00122
00123
00124 void set_parent(CL_Component *parent);
00125
00126
00127 void set_gui_manager(CL_GUIManager *gui);
00128
00129
00130 void set_width(int width);
00131
00132
00133 void set_height(int height);
00134
00135
00136 void show(bool show = true);
00137
00138
00139 void enable(bool enable = true);
00140
00141
00142 void popup(bool popup);
00143
00144
00145 void set_focus();
00146
00147
00148 void capture_mouse();
00149
00150
00151
00152 void release_mouse();
00153
00154
00155 void close();
00156
00157
00158 void run(CL_GUIManager *parent = NULL);
00159
00160
00161 void quit();
00162
00163
00164 void clear_removeflag();
00165
00166
00167 void add_child(CL_Component *child, bool delete_child = false);
00168
00169
00170
00171 void remove_child(CL_Component *child);
00172
00173
00174 void add_components(class CL_ComponentManager *component_manager);
00175
00176
00177 void attach_style(CL_ComponentStyle *style);
00178
00179
00180 void detach_style(CL_ComponentStyle *style);
00181
00182
00184 public:
00185 CL_Signal_v0 &sig_paint();
00186
00187
00188
00189 CL_Signal_v0 &sig_begin_paint();
00190
00191
00192
00193 CL_Signal_v0 &sig_end_paint();
00194
00195
00196
00197 CL_Signal_v3<CL_Component *, CL_InputDevice *, CL_Key> &sig_key_down();
00198
00199
00200 CL_Signal_v3<CL_Component *, CL_InputDevice *, CL_Key> &sig_key_up();
00201
00202
00203 CL_Signal_v4<CL_Component *, CL_InputDevice *, int, int> &sig_mouse_moved();
00204
00205
00206 CL_Signal_v0 &sig_got_focus();
00207
00208
00209 CL_Signal_v0 &sig_lost_focus();
00210
00211
00212 CL_Signal_v2<int, int> &sig_resized();
00213
00214
00215 CL_Signal_v0 &sig_mouse_entered();
00216
00217
00218 CL_Signal_v0 &sig_mouse_left();
00219
00220
00221 CL_Signal_v1<CL_Component *> &sig_child_add();
00222
00223
00224 CL_Signal_v1<CL_Component *> &sig_child_remove();
00225
00226
00227 CL_Signal_v2<int &, int &> &sig_transform_coords();
00228
00229
00230
00231
00233 private:
00234 class CL_Component_Generic *impl;
00235 };
00236
00237 #endif