display_window.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_display.h"
00037 #include "../../Core/System/sharedptr.h"
00038 #include "../../Core/System/weakptr.h"
00039 #include "../../Core/Signals/signal_v0.h"
00040 #include "../../Core/Signals/signal_v1.h"
00041 #include "../../Core/Signals/signal_v2.h"
00042 #include "../../Core/Signals/callback_v1.h"
00043 #include "../../Core/Signals/callback_0.h"
00044 #include "../../Core/Text/string_types.h"
00045 #include "../display_target.h"
00046 
00047 #if !defined(WIN32) && !defined(__APPLE__)
00048 #include <X11/Xlib.h>
00049 #endif
00050 
00051 class CL_Size;
00052 class CL_Rect;
00053 class CL_Display;
00054 class CL_GraphicContext;
00055 class CL_DisplayWindowMode;
00056 class CL_DisplayWindowDescription;
00057 class CL_InputContext;
00058 class CL_Point;
00059 class CL_Cursor;
00060 class CL_DisplayWindowProvider;
00061 class CL_DisplayWindow_Impl;
00062 class CL_PixelBuffer;
00063 
00067 enum CL_StandardCursor
00068 {
00069         cl_cursor_arrow,
00070         cl_cursor_appstarting,
00071         cl_cursor_cross,
00072         cl_cursor_hand,
00073         cl_cursor_ibeam,
00074         cl_cursor_no,
00075         cl_cursor_size_all,
00076         cl_cursor_size_nesw,
00077         cl_cursor_size_ns,
00078         cl_cursor_size_nwse,
00079         cl_cursor_size_we,
00080         cl_cursor_uparrow,
00081         cl_cursor_wait
00082 };
00083 
00087 class CL_API_DISPLAY CL_DisplayWindow
00088 {
00091 public:
00093         CL_DisplayWindow();
00094 
00104         CL_DisplayWindow(
00105                 const CL_StringRef &title,
00106                 int width,
00107                 int height,
00108                 bool start_fullscreen = false,
00109                 bool allow_resize = false,
00110                 int flipping_buffers = 2,
00111                 CL_DisplayTarget target = CL_DisplayTarget());
00112 
00117         CL_DisplayWindow(
00118                 const CL_DisplayWindowDescription &description,
00119                 CL_DisplayTarget target = CL_DisplayTarget());
00120 
00124         CL_DisplayWindow(CL_DisplayWindowProvider *provider);
00125 
00126         ~CL_DisplayWindow();
00127 
00131 public:
00133         CL_Rect get_geometry() const;
00134 
00136         CL_Rect get_viewport() const;
00137 
00139         bool is_fullscreen() const;
00140 
00142         bool has_focus() const;
00143 
00145         CL_GraphicContext& get_gc() const;
00146 
00148         CL_InputContext& get_ic() const;
00149 
00151         CL_Signal_v0 &sig_lost_focus();
00152 
00154         CL_Signal_v0 &sig_got_focus();
00155 
00157         CL_Signal_v2<int, int> &sig_resize();
00158 
00160         CL_Signal_v1<const CL_Rect &> &sig_paint();
00161 
00163         CL_Signal_v0 &sig_window_close();
00164 
00166         CL_Signal_v0 &sig_window_destroy();
00167 
00169         CL_Signal_v0 &sig_window_minimized();
00170 
00172         CL_Signal_v0 &sig_window_maximized();
00173 
00175         CL_Signal_v0 &sig_window_restored();
00176 
00178         CL_Signal_v0 &sig_window_moved();
00179 
00181         CL_Callback_v1<CL_Rect &> &func_window_resize();
00182 
00184         CL_Callback_0<bool> &func_minimize_clicked();
00185 
00187         bool is_null() const { return !impl; }
00188 
00190         void throw_if_null() const;
00191 
00193         bool is_visible() const;
00194 
00196         bool is_minimized() const;
00197 
00199         bool is_maximized() const;
00200 
00202         CL_DisplayWindowProvider *get_provider() const;
00203 
00205         bool is_clipboard_text_available() const;
00206 
00208         bool is_clipboard_image_available() const;
00209 
00211         CL_String get_clipboard_text() const;
00212 
00215         CL_PixelBuffer get_clipboard_image() const;
00216 
00218         CL_Size get_minimum_size(bool client_area=false);
00219 
00221         CL_Size get_maximum_size(bool client_area=false);
00222 
00224         CL_String get_title() const;
00225 
00226 #ifdef WIN32
00227 
00231         HWND get_hwnd() const;
00232 #elif defined(__APPLE__)
00233         // nothing
00234 #else
00235 
00236         Display *get_display() const;
00237 
00239         Window get_window() const;
00240 #endif
00241 
00245 public:
00247         CL_Point client_to_screen(const CL_Point &client);
00248 
00250         CL_Point screen_to_client(const CL_Point &screen);
00251 
00253         void capture_mouse(bool capture);
00254 
00256         void request_repaint(const CL_Rect &rect);
00257 
00259         void set_title(const CL_StringRef &title);
00260 
00265         void set_position(const CL_Rect &pos, bool client_area);
00266 
00271         void set_position(int x, int y);
00272 
00276         void set_enabled(bool enable);
00277 
00282         void set_visible(bool visible, bool activate);
00283 
00289         void set_size(int width, int height, bool client_area);
00290 
00292         void set_minimum_size(int width, int height, bool client_area);
00293 
00295         void set_maximum_size(int width, int height, bool client_area);
00296 
00298         void minimize();
00299 
00301         void restore();
00302 
00304         void maximize();
00305 
00307         void show(bool activate = true);
00308 
00310         void hide();
00311 
00313         void bring_to_front();
00314 
00318         void update(const CL_Rect &rect);
00319 
00331         void flip(int interval = -1);
00332 
00334         void show_cursor();
00335 
00337         void set_cursor(const CL_Cursor &cursor);
00338 
00342         void set_cursor(CL_StandardCursor type);
00343 
00345         void hide_cursor();
00346 
00348         void set_clipboard_text(const CL_StringRef &text);
00349 
00351         void set_clipboard_image(const CL_PixelBuffer &buf);
00352 
00354         void set_large_icon(const CL_PixelBuffer &image);
00355 
00357         void set_small_icon(const CL_PixelBuffer &image);
00358 
00362 private:
00363         CL_SharedPtr<CL_DisplayWindow_Impl> impl;
00364 
00366 };
00367