gui_manager.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 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 **    Kenneth Gangstoe
00029 */
00030 
00033 
00034 #pragma once
00035 
00036 #include "api_gui.h"
00037 #include "../Core/System/sharedptr.h"
00038 #include "../Core/System/weakptr.h"
00039 #include "../Core/Signals/callback_0.h"
00040 #include "../Core/Signals/callback_1.h"
00041 #include "../Core/Signals/callback_2.h"
00042 #include "../Core/Signals/signal_v1.h"
00043 #include "../Core/Math/point.h"
00044 #include "accelerator_table.h"
00045 
00046 class CL_Size;
00047 class CL_Rect;
00048 class CL_CSSDocument;
00049 class CL_CSSLayout;
00050 class CL_GUIComponent;
00051 class CL_GUIMessage;
00052 class CL_GUITheme;
00053 class CL_GUIWindowManager;
00054 class CL_GUIManager_Impl;
00055 class CL_Font;
00056 class CL_FontDescription;
00057 class CL_VirtualDirectory;
00058 class CL_DisplayWindow;
00059 class CL_ResourceManager;
00060 
00064 class CL_API_GUI CL_GUIManager
00065 {
00068 public:
00072         CL_GUIManager();
00073 
00079         CL_GUIManager(const CL_DisplayWindow &display_window);
00080 
00084         CL_GUIManager(const CL_String &path_to_theme);
00085 
00090         CL_GUIManager(const CL_DisplayWindow &display_window, const CL_String &path_to_theme);
00091 
00096         CL_GUIManager(CL_GUIWindowManager &window_manager, const CL_String &path_to_theme);
00097 
00101         CL_GUIManager(CL_SharedPtr<CL_GUIManager_Impl> impl);
00102 
00103         virtual ~CL_GUIManager();
00104 
00108 public:
00110         bool is_gui_manager() const { return true; }
00111 
00113         CL_GUITheme get_theme() const;
00114 
00116         CL_CSSDocument get_css_document() const;
00117 
00119         CL_GUIWindowManager get_window_manager() const;
00120 
00122         CL_GUIComponent *get_capture_component() const;
00123 
00125         CL_GUIComponent *get_focused_component();
00126 
00128         bool get_exit_flag() const;
00129 
00131         int get_exit_code() const;
00132 
00134         CL_Font get_registered_font(const CL_FontDescription &desc);
00135 
00139         CL_String get_clipboard_text() const;
00140 
00144 public:
00146         CL_Signal_v1<CL_GUIMessage &> &sig_filter_message();
00147 
00149         CL_Callback_0<int> &func_exec_handler();
00150 
00154 public:
00157         void add_theme(const CL_String &path_to_theme);
00158 
00160         void set_theme(CL_GUITheme &theme);
00161 
00163         void set_css_document(CL_CSSDocument css);
00164 
00166         void set_css_document(const CL_String &fullname);
00167 
00172         void set_css_document(const CL_String &filename, const CL_VirtualDirectory &directory);
00173 
00175         void add_resources(const CL_ResourceManager &resources);
00176 
00178         void add_resources(const CL_String &filename);
00179 
00181         void add_resources(const CL_String &filename, const CL_VirtualDirectory &directory);
00182 
00184         void initialize_layout_manager(const CL_String &xml_fullname, const CL_String &css_fullname);
00185 
00187         void set_window_manager(CL_GUIWindowManager &window_manager);
00188 
00190         int exec();
00191 
00195         void process_messages(int timeout);
00196 
00198         void dispatch_message(CL_GUIMessage message);
00199 
00201         void exit_with_code(int exit_code);
00202 
00204         void clear_exit_flag();
00205 
00207         void set_capture_component(CL_GUIComponent *component, bool state);
00208 
00210         void request_repaint(const CL_Rect &rect, CL_GUIComponent *root_component);
00211 
00213         void register_font(const CL_Font &font, const CL_FontDescription &desc);
00214 
00216         void render_windows();
00217 
00219         void set_clipboard_text(const CL_StringRef &str);
00220 
00222         void set_tablet_proximity_component(CL_GUIComponent *, bool state);
00223 
00225         void set_accelerator_table(const CL_AcceleratorTable &table);
00226 
00228         CL_CSSLayout create_layout(CL_GUIComponent *component);
00229 
00231         bool has_layout(CL_GUIComponent *component);
00232 
00236 private:
00237         void initialize(CL_GUIWindowManager &window_manager, const CL_String & path_to_theme);
00238 
00239         CL_SharedPtr<CL_GUIManager_Impl> impl;
00240 
00241         friend class CL_GUIComponent_Impl;
00242         friend class CL_GUIThemePart;
00243         friend class CL_GUIThemePart_Impl;
00245 };
00246