ClanLib  2.3.7
display_window.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 ** Kenneth Gangstoe
29 */
30 
33 
34 #pragma once
35 
36 #include "../api_display.h"
37 #include "../../Core/System/sharedptr.h"
38 #include "../../Core/System/weakptr.h"
39 #include "../../Core/Signals/signal_v0.h"
40 #include "../../Core/Signals/signal_v1.h"
41 #include "../../Core/Signals/signal_v2.h"
42 #include "../../Core/Signals/callback_v1.h"
43 #include "../../Core/Signals/callback_0.h"
44 #include "../../Core/Text/string_types.h"
45 #include "../display_target.h"
46 
47 #if !defined(WIN32) && !defined(__APPLE__)
48 #include <X11/Xlib.h>
49 #endif
50 
51 class CL_Size;
52 class CL_Rect;
53 class CL_Display;
54 class CL_GraphicContext;
55 class CL_DisplayWindowMode;
57 class CL_InputContext;
58 class CL_Point;
59 class CL_Cursor;
61 class CL_DisplayWindow_Impl;
62 class CL_PixelBuffer;
63 
68 {
82 };
83 
88 {
91 public:
94 
105  const CL_StringRef &title,
106  int width,
107  int height,
108  bool start_fullscreen = false,
109  bool allow_resize = false,
110  int flipping_buffers = 2,
112 
118  const CL_DisplayWindowDescription &description,
120 
125 
126  ~CL_DisplayWindow();
127 
131 public:
133  CL_Rect get_geometry() const;
134 
136  CL_Rect get_viewport() const;
137 
139  bool is_fullscreen() const;
140 
142  bool has_focus() const;
143 
145  CL_GraphicContext& get_gc() const;
146 
148  CL_InputContext& get_ic() const;
149 
151  CL_Signal_v0 &sig_lost_focus();
152 
154  CL_Signal_v0 &sig_got_focus();
155 
157  CL_Signal_v2<int, int> &sig_resize();
158 
160  CL_Signal_v1<const CL_Rect &> &sig_paint();
161 
163  CL_Signal_v0 &sig_window_close();
164 
166  CL_Signal_v0 &sig_window_destroy();
167 
169  CL_Signal_v0 &sig_window_minimized();
170 
172  CL_Signal_v0 &sig_window_maximized();
173 
175  CL_Signal_v0 &sig_window_restored();
176 
178  CL_Signal_v0 &sig_window_moved();
179 
181  CL_Callback_v1<CL_Rect &> &func_window_resize();
182 
184  CL_Callback_0<bool> &func_minimize_clicked();
185 
187  bool is_null() const { return !impl; }
188 
190  void throw_if_null() const;
191 
193  bool is_visible() const;
194 
196  bool is_minimized() const;
197 
199  bool is_maximized() const;
200 
202  CL_DisplayWindowProvider *get_provider() const;
203 
205  bool is_clipboard_text_available() const;
206 
208  bool is_clipboard_image_available() const;
209 
211  CL_String get_clipboard_text() const;
212 
215  CL_PixelBuffer get_clipboard_image() const;
216 
218  CL_Size get_minimum_size(bool client_area=false);
219 
221  CL_Size get_maximum_size(bool client_area=false);
222 
224  CL_String get_title() const;
225 
226 #ifdef WIN32
227 
231  HWND get_hwnd() const;
232 #elif defined(__APPLE__)
233  // nothing
234 #else
235  Display *get_display() const;
237 
239  Window get_window() const;
240 #endif
241 
245 public:
247  CL_Point client_to_screen(const CL_Point &client);
248 
250  CL_Point screen_to_client(const CL_Point &screen);
251 
253  void capture_mouse(bool capture);
254 
256  void request_repaint(const CL_Rect &rect);
257 
259  void set_title(const CL_StringRef &title);
260 
265  void set_position(const CL_Rect &pos, bool client_area);
266 
271  void set_position(int x, int y);
272 
276  void set_enabled(bool enable);
277 
282  void set_visible(bool visible, bool activate);
283 
289  void set_size(int width, int height, bool client_area);
290 
292  void set_minimum_size(int width, int height, bool client_area);
293 
295  void set_maximum_size(int width, int height, bool client_area);
296 
298  void minimize();
299 
301  void restore();
302 
304  void maximize();
305 
307  void show(bool activate = true);
308 
310  void hide();
311 
313  void bring_to_front();
314 
318  void update(const CL_Rect &rect);
319 
331  void flip(int interval = -1);
332 
334  void show_cursor();
335 
337  void set_cursor(const CL_Cursor &cursor);
338 
342  void set_cursor(CL_StandardCursor type);
343 
345  void hide_cursor();
346 
348  void set_clipboard_text(const CL_StringRef &text);
349 
351  void set_clipboard_image(const CL_PixelBuffer &buf);
352 
354  void set_large_icon(const CL_PixelBuffer &image);
355 
357  void set_small_icon(const CL_PixelBuffer &image);
358 
362 private:
363  CL_SharedPtr<CL_DisplayWindow_Impl> impl;
364 
366 };
367