display_window.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 
31 
32 #pragma once
33 
34 #include "../api_display.h"
35 #include "../../Core/Signals/signal_v0.h"
36 #include "../../Core/Signals/signal_v1.h"
37 #include "../../Core/Signals/signal_v2.h"
38 #include "../../Core/Signals/callback_v1.h"
39 #include "../../Core/Signals/callback_0.h"
40 #include "../../Core/Signals/callback_4.h"
41 #include "../display_target.h"
42 #include <memory>
43 
44 #if !defined(WIN32) && !defined(__APPLE__)
45 #include <X11/Xlib.h>
46 #endif
47 
48 namespace clan
49 {
52 
53 class Size;
54 class Rect;
55 class Display;
56 class GraphicContext;
57 class DisplayWindowMode;
58 class DisplayWindowDescription;
59 class InputContext;
60 class Point;
61 class Cursor;
62 class DisplayWindowProvider;
63 class DisplayWindow_Impl;
64 class PixelBuffer;
65 
68 {
82 };
83 
85 class CL_API_DISPLAY DisplayWindow
86 {
89 public:
91  DisplayWindow();
92 
103  const std::string &title,
104  int width,
105  int height,
106  bool start_fullscreen = false,
107  bool allow_resize = false,
108  int flipping_buffers = 2);
109 
115  const DisplayWindowDescription &description);
116 
121 
122  ~DisplayWindow();
123 
127 public:
129  Rect get_geometry() const;
130 
132  Rect get_viewport() const;
133 
135  bool is_fullscreen() const;
136 
138  bool has_focus() const;
139 
141  GraphicContext& get_gc() const;
142 
144  InputContext get_ic() const;
145 
147  Signal_v0 &sig_lost_focus();
148 
150  Signal_v0 &sig_got_focus();
151 
153  Signal_v2<int, int> &sig_resize();
154 
156  Signal_v1<const Rect &> &sig_paint();
157 
159  Signal_v0 &sig_window_close();
160 
162  Signal_v0 &sig_window_destroy();
163 
165  Signal_v0 &sig_window_minimized();
166 
168  Signal_v0 &sig_window_maximized();
169 
171  Signal_v0 &sig_window_restored();
172 
174  Signal_v0 &sig_window_moved();
175 
177  Signal_v0 &sig_window_flip();
178 
180  Callback_v1<Rect &> &func_window_resize();
181 
183  Callback_0<bool> &func_minimize_clicked();
184 
185 #ifdef WIN32
186  Callback_4<bool, HWND, UINT, WPARAM, LPARAM> &func_window_message();
188 #endif
189 
191  bool is_null() const { return !impl; }
192 
194  void throw_if_null() const;
195 
197  bool is_visible() const;
198 
200  bool is_minimized() const;
201 
203  bool is_maximized() const;
204 
206  DisplayWindowProvider *get_provider() const;
207 
209  bool is_clipboard_text_available() const;
210 
212  bool is_clipboard_image_available() const;
213 
215  std::string get_clipboard_text() const;
216 
219  PixelBuffer get_clipboard_image() const;
220 
222  Size get_minimum_size(bool client_area=false);
223 
225  Size get_maximum_size(bool client_area=false);
226 
228  std::string get_title() const;
229 
230 #ifdef WIN32
231 
235  HWND get_hwnd() const;
236 
237 #elif defined(__APPLE__)
238  // nothing
239 #else
240  ::Display *get_display() const;
242 
244  ::Window get_window() const;
245 #endif
246 
250 public:
252  Point client_to_screen(const Point &client);
253 
255  Point screen_to_client(const Point &screen);
256 
258  void capture_mouse(bool capture);
259 
261  void request_repaint(const Rect &rect);
262 
264  void set_title(const std::string &title);
265 
270  void set_position(const Rect &pos, bool client_area);
271 
276  void set_position(int x, int y);
277 
281  void set_enabled(bool enable);
282 
287  void set_visible(bool visible, bool activate);
288 
294  void set_size(int width, int height, bool client_area);
295 
297  void set_minimum_size(int width, int height, bool client_area);
298 
300  void set_maximum_size(int width, int height, bool client_area);
301 
303  void minimize();
304 
306  void restore();
307 
309  void maximize();
310 
312  void show(bool activate = true);
313 
315  void hide();
316 
318  void bring_to_front();
319 
323  void update(const Rect &rect);
324 
336  void flip(int interval = -1);
337 
339  void show_cursor();
340 
342  void set_cursor(const Cursor &cursor);
343 
347  void set_cursor(StandardCursor type);
348 
349 #ifdef WIN32
350  void set_cursor_handle(HCURSOR cursor);
352 #endif
353 
355  void hide_cursor();
356 
358  void set_clipboard_text(const std::string &text);
359 
361  void set_clipboard_image(const PixelBuffer &buf);
362 
364  void set_large_icon(const PixelBuffer &image);
365 
367  void set_small_icon(const PixelBuffer &image);
368 
373  void enable_alpha_channel(const Rect &blur_rect);
374 
378  void extend_frame_into_client_area(int height);
379 
383 private:
384  std::shared_ptr<DisplayWindow_Impl> impl;
385 
387 };
388 
389 }
390 
Definition: display_window.h:78
StandardCursor
Standard Cursor.
Definition: display_window.h:67
Definition: display_window.h:72
Definition: display_window.h:81
Definition: display_window.h:70
Pixel data container.
Definition: pixel_buffer.h:69
Mouse cursor class.
Definition: cursor.h:48
Definition: display_window.h:77
Top level display class.
Definition: Sources/API/Display/display.h:50
Definition: display_window.h:73
Definition: display_window.h:69
Definition: display_window.h:79
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
Signal_v1.
Definition: signal_v1.h:110
Definition: display_window.h:80
Definition: display_window.h:71
bool is_null() const
Returns true if this object is invalid.
Definition: display_window.h:191
Definition: display_window.h:76
Callback_v1.
Definition: callback_v1.h:156
Interface to drawing graphics.
Definition: graphic_context.h:257
2D (x,y) point structure - Integer
Definition: point.h:63
InputContext.
Definition: input_context.h:45
Definition: display_window.h:74
Display window description class.
Definition: display_window_description.h:53
Interface for implementing a DisplayWindow target.
Definition: display_window_provider.h:108
2D (width,height) size structure - Integer
Definition: size.h:157
Signal_v0.
Definition: signal_v0.h:107
Top-level window class.
Definition: display_window.h:85
Callback_4.
Definition: callback_4.h:156
Window component.
Definition: window.h:51
Definition: display_window.h:75