gui_component.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "api_gui.h"
00036 #include "../Core/System/sharedptr.h"
00037 #include "../Core/Signals/callback_0.h"
00038 #include "../Core/Signals/callback_1.h"
00039 #include "../Core/Signals/callback_v0.h"
00040 #include "../Core/Signals/callback_v1.h"
00041 #include "../Core/Signals/callback_v2.h"
00042 #include "../Core/Signals/callback_v3.h"
00043 #include "../Core/Signals/callback_2.h"
00044 #include "../Core/IOData/virtual_directory.h"
00045 #include "../Display/Window/display_window_description.h"
00046 #include "../Display/Window/display_window.h"
00047 #include "../Display/Render/graphic_context.h"
00048 #include "../Display/Window/input_context.h"
00049 #include "gui_layout.h"
00050 #include <vector>
00051 
00052 class CL_DomDocument;
00053 class CL_GraphicContext;
00054 class CL_InputContext;
00055 class CL_InputEvent;
00056 class CL_Cursor;
00057 class CL_GUIMessage;
00058 class CL_GUIManager;
00059 class CL_GUITheme;
00060 class CL_ResourceManager;
00061 class CL_GUIConsumedKeys;
00062 class CL_GUIComponent_Impl;
00063 
00064 typedef CL_DisplayWindowDescription CL_GUITopLevelDescription;
00065 
00069 class CL_API_GUI CL_GUIComponent
00070 {
00073 public:
00075         CL_GUIComponent(CL_GUIComponent *parent);
00076 
00081         CL_GUIComponent(CL_GUIManager *manager, CL_GUITopLevelDescription description);
00082 
00087         CL_GUIComponent(CL_GUIComponent *owner, CL_GUITopLevelDescription description);
00088 
00089         virtual ~CL_GUIComponent();
00090 
00094 public:
00096         CL_Rect get_geometry() const;
00097 
00099         int get_width() const;
00100 
00102         int get_height() const;
00103 
00105         CL_Size get_size() const;
00106 
00108         CL_Rect get_window_geometry() const;
00109 
00111         CL_StringRef get_type_name() const;
00112 
00114         CL_StringRef get_class_name() const;
00115 
00117         CL_StringRef get_id_name() const;
00118 
00120         CL_StringRef get_element_name() const;
00121 
00123         bool has_focus() const;
00124 
00126         bool get_allow_resize() const;
00127 
00129         bool get_clip_children() const;
00130 
00132         enum FocusPolicy
00133         {
00134                 focus_refuse,
00135                 focus_local,
00136                 focus_group,
00137                 focus_parent
00138         };
00139 
00141         FocusPolicy get_focus_policy() const;
00142 
00144         CL_StringRef get_component_group_name() const;
00145 
00147         bool is_selected_in_group() const;
00148 
00150         bool get_blocks_default_action() const;
00151 
00153         CL_ResourceManager get_resources() const;
00154 
00156         CL_GUIManager get_gui_manager() const;
00157 
00159         CL_GUITheme get_theme() const;
00160 
00162 
00163         const CL_GUIComponent *get_parent_component() const;
00164 
00168         CL_GUIComponent *get_parent_component();
00169 
00171 
00172         const CL_GUIComponent *get_owner_component() const;
00173 
00177         CL_GUIComponent *get_owner_component();
00178 
00180         std::vector<CL_GUIComponent*> get_child_components() const;
00181 
00183         const CL_GUIComponent *get_first_child() const;
00184 
00188         CL_GUIComponent *get_first_child();
00189 
00191         const CL_GUIComponent *get_last_child() const;
00192 
00194         CL_GUIComponent *get_next_component_in_tree();
00195 
00197         CL_GUIComponent *get_previous_component_in_tree();
00198 
00202         CL_GUIComponent *get_last_child();
00203 
00205         std::vector<CL_GUIComponent*> get_child_component_group(const CL_String &group_name) const;
00206 
00208         CL_GUIComponent *get_group_selected_component();
00209 
00211         CL_GUIComponent *get_named_item(const CL_StringRef &id);
00212 
00214         bool has_child_components() const;
00215 
00217         const CL_GUIComponent *get_previous_sibling() const;
00218 
00222         CL_GUIComponent *get_previous_sibling();
00223 
00225         const CL_GUIComponent *get_next_sibling() const;
00226 
00230         CL_GUIComponent *get_next_sibling();
00231 
00235         bool is_descendant_of(CL_GUIComponent *component);
00236 
00240         bool is_ancestor_of(CL_GUIComponent *component);
00241 
00243         const CL_GUIComponent *get_top_level_component() const;
00244 
00248         CL_GUIComponent *get_top_level_component();
00249 
00251         CL_GraphicContext& get_gc();
00252 
00254         CL_InputContext& get_ic();
00255 
00257         bool is_enabled() const;
00258 
00260         bool is_visible() const;
00261 
00263         bool is_active() const;
00264 
00266         CL_GUIComponent *get_component_at(const CL_Point &point);
00267 
00269         virtual CL_Size get_preferred_size() const;
00270 
00272         int get_preferred_width() const;
00273 
00275         int get_preferred_height() const;
00276 
00278         CL_Point window_to_component_coords(const CL_Point &window_point) const;
00279 
00281         CL_Rect window_to_component_coords(const CL_Rect &window_rect) const;
00282 
00284         CL_Point component_to_window_coords(const CL_Point &component_point) const;
00285 
00287         CL_Rect component_to_window_coords(const CL_Rect &component_rect) const;
00288 
00290         CL_Point screen_to_component_coords(const CL_Point &screen_point) const;
00291 
00293         CL_Point component_to_screen_coords(const CL_Point &component_point) const;
00294 
00296         CL_GUILayout get_layout() const;
00297 
00299         CL_DisplayWindow get_display_window() const;
00300 
00302         bool is_default();
00303 
00305         bool is_cancel();
00306 
00308         bool get_constant_repaint() const;
00309 
00313 public:
00315         CL_Callback_v2<CL_GraphicContext &, const CL_Rect &> &func_render();
00316 
00318         CL_Callback_v1<CL_GUIMessage &> &func_process_message();
00319 
00321         CL_Callback_0<bool> &func_close();
00322 
00324         CL_Callback_0<bool> &func_activated();
00325 
00327         CL_Callback_0<bool> &func_deactivated();
00328 
00330         CL_Callback_0<bool> &func_focus_lost();
00331 
00333         CL_Callback_0<bool> &func_focus_gained();
00334 
00336         CL_Callback_0<bool> &func_pointer_enter();
00337 
00339         CL_Callback_0<bool> &func_pointer_exit();
00340 
00342         CL_Callback_v1<CL_GUIMessage&> &func_filter_message();
00343 
00345         CL_Callback_1<bool, const CL_InputEvent &> &func_input();
00346 
00348         CL_Callback_1<bool, const CL_InputEvent &> &func_input_pressed();
00349 
00351         CL_Callback_1<bool, const CL_InputEvent &> &func_input_released();
00352 
00354         CL_Callback_1<bool, const CL_InputEvent &> &func_input_doubleclick();
00355 
00357         CL_Callback_1<bool, const CL_InputEvent &> &func_input_pointer_moved();
00358 
00360         CL_Callback_v1<bool> &func_visibility_change();
00361 
00363         CL_Callback_v0 &func_style_changed();
00364 
00366         CL_Callback_v0 &func_enablemode_changed();
00367 
00369         CL_Callback_v0 &func_resized();
00370 
00372         CL_Callback_v1<CL_Rect &> &func_constrain_resize();
00373 
00375 
00378         virtual CL_Callback_2<CL_GUIComponent*, CL_GUIComponent*, CL_String> &func_create_custom_component();
00379 
00383 public:
00385         void render(CL_GraphicContext &gc, const CL_Rect &clip_rect, bool include_children = true);
00386 
00388 
00390         void paint();
00391 
00395         void paint(const CL_Rect &clip_rect);
00396 
00398         int exec();
00399 
00401 
00403         void exit_with_code(int exit_code);
00404 
00406         void set_geometry(CL_Rect geometry);
00407 
00409         void set_window_geometry(CL_Rect geometry);
00410 
00412         void set_type_name(const CL_StringRef &name); 
00413 
00415         void set_class_name(const CL_StringRef &name);
00416 
00418         void set_id_name(const CL_StringRef &name);
00419 
00421         void set_enabled(bool enable = true);
00422 
00424         void set_clip_children(bool clip = true);
00425 
00430         void set_visible(bool visible = true, bool activate_root_win=true);
00431 
00435         void set_focus(bool enable = true);
00436 
00438         void capture_mouse(bool capture);
00439 
00441         void capture_proximity(bool capture);
00442 
00444         void set_focus_policy(FocusPolicy policy);
00445 
00449         void set_component_group_name(const CL_StringRef &str);
00450 
00452         void set_selected_in_component_group(bool selected);
00453 
00455         void create_components(const CL_DomDocument &gui_xml);
00456 
00460         void create_components(const CL_StringRef &fullname);
00461 
00465         void create_components(CL_IODevice &file);
00466 
00471         void create_components(const CL_StringRef &filename, const CL_VirtualDirectory &dir);
00472 
00473         // Request an asynchronous redraw of the specified area.
00474         void request_repaint();
00475 
00479         void request_repaint(CL_Rect rect);
00480 
00482         void set_cliprect(CL_GraphicContext &gc, const CL_Rect &rect);
00483 
00485         void reset_cliprect(CL_GraphicContext &gc);
00486 
00488         void push_cliprect(CL_GraphicContext &gc, const CL_Rect &rect);
00489 
00491         void pop_cliprect(CL_GraphicContext &gc);
00492 
00494         void delete_child_components();
00495 
00497         void set_parent_component(CL_GUIComponent *new_parent);
00498 
00500         void set_layout(CL_GUILayout &layout);
00501 
00503         void set_cursor(const CL_Cursor &cursor);
00504 
00508         void set_cursor(enum CL_StandardCursor type);
00509 
00511         void focus_next();
00512 
00514         void focus_previous();
00515 
00517 
00518         void set_default(bool value);
00519 
00521 
00522         void set_cancel(bool value);
00523 
00525         void set_blocks_default_action(bool block);
00526 
00528         void set_constant_repaint(bool enable);
00529 
00533 private:
00534         CL_SharedPtr<CL_GUIComponent_Impl> impl;
00535 
00539         CL_GUIComponent(CL_GUIComponent &other);
00540 
00541         CL_GUIComponent &operator =(const CL_GUIComponent &other);
00542 
00543         CL_GraphicContext dummy_gc;
00544         CL_InputContext dummy_ic;
00545 
00546         friend class CL_GUIManager_Impl;
00547 
00548         friend class CL_GUIComponent_Impl;
00549 
00550         friend class CL_Window;
00551 
00552         friend class CL_Window_Impl;
00554 };
00555 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6