display_window_provider.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 #pragma once
32 
33 #include "../../Core/Signals/signal.h"
34 #include "../Window/display_window.h"
35 #include <memory>
36 
37 namespace clan
38 {
41 
42  class Rect;
43  class Size;
44  class Point;
45  class DisplayWindowDescription;
46  class GraphicContext;
47  class InputDevice;
48  class CursorProvider;
49  class CursorDescription;
50 
53  {
54  public:
57 
60 
63 
66 
69 
72 
75 
78 
81 
83  std::function<void(Rectf &)> func_window_resize;
84 
86  std::function<bool()> func_minimize_clicked;
87 
90 
91 #ifdef WIN32
92  std::function<bool(HWND, UINT, WPARAM, LPARAM)> func_window_message;
94 #endif
95  };
96 
99  {
100  public:
101  virtual ~DisplayWindowProvider() { return; }
102 
104  virtual Rect get_geometry() const = 0;
105 
107  virtual Rect get_viewport() const = 0;
108 
112  virtual float get_pixel_ratio() const = 0;
113 
115  virtual bool has_focus() const = 0;
116 
118  virtual bool is_minimized() const = 0;
119 
121  virtual bool is_maximized() const = 0;
122 
124  virtual bool is_visible() const = 0;
125 
127  virtual bool is_fullscreen() const = 0;
128 
130  virtual Size get_minimum_size(bool client_area) const = 0;
131 
133  virtual Size get_maximum_size(bool client_area) const = 0;
134 
136  virtual std::string get_title() const = 0;
137 
139  virtual GraphicContext& get_gc() = 0;
140 
142  virtual InputDevice &get_keyboard() = 0;
143 
145  virtual InputDevice &get_mouse() = 0;
146 
148  virtual std::vector<InputDevice> &get_game_controllers() = 0;
149 
152  virtual DisplayWindowHandle get_handle() const = 0;
153 
155  virtual bool is_clipboard_text_available() const = 0;
156 
158  virtual bool is_clipboard_image_available() const = 0;
159 
161  virtual std::string get_clipboard_text() const = 0;
162 
164  virtual PixelBuffer get_clipboard_image() const = 0;
165 
167  virtual Point client_to_screen(const Point &client) = 0;
168 
170  virtual Point screen_to_client(const Point &screen) = 0;
171 
173  virtual void capture_mouse(bool capture) = 0;
174 
176  virtual void request_repaint() = 0;
177 
179  virtual void create(DisplayWindowSite *site, const DisplayWindowDescription &description) = 0;
180 
182  virtual void show_system_cursor() = 0;
183 
185  virtual void hide_system_cursor() = 0;
186 
188  virtual CursorProvider *create_cursor(const CursorDescription &cursor_description) = 0;
189 
191  virtual void set_cursor(CursorProvider *cursor) = 0;
192 
194  virtual void set_cursor(StandardCursor type) = 0;
195 
196 #ifdef WIN32
197  virtual void set_cursor_handle(HCURSOR cursor) = 0;
199 #endif
200 
202  virtual void set_title(const std::string &new_title) = 0;
203 
205  virtual void set_position(const Rect &pos, bool client_area) = 0;
206 
212  virtual void set_size(int width, int height, bool client_area) = 0;
213 
219  virtual void set_minimum_size(int width, int height, bool client_area) = 0;
220 
226  virtual void set_maximum_size(int width, int height, bool client_area) = 0;
227 
231  virtual void set_pixel_ratio(float ratio) = 0;
232 
234  virtual void set_enabled(bool enable) = 0;
235 
237  virtual void minimize() = 0;
238 
240  virtual void restore() = 0;
241 
243  virtual void maximize() = 0;
244 
247  virtual void toggle_fullscreen() = 0;
248 
250  virtual void show(bool activate) = 0;
251 
253  virtual void hide() = 0;
254 
256  virtual void bring_to_front() = 0;
257 
259  virtual void flip(int interval) = 0;
260 
262  virtual void set_clipboard_text(const std::string &text) = 0;
263 
265  virtual void set_clipboard_image(const PixelBuffer &buf) = 0;
266 
268  virtual void set_large_icon(const PixelBuffer &image) = 0;
269 
271  virtual void set_small_icon(const PixelBuffer &image) = 0;
272 
282  virtual void enable_alpha_channel(const Rect &blur_rect) = 0;
283 
287  virtual void extend_frame_into_client_area(int left, int top, int right, int bottom) = 0;
288  };
289 
291 }
Signal< void()> sig_window_maximized
Window maximized signal.
Definition: display_window_provider.h:77
Definition: clanapp.h:35
virtual float get_pixel_ratio() const =0
virtual bool is_clipboard_image_available() const =0
Returns true if an image is available in the clipboard.
Signal< void()> sig_got_focus
Obtained focus signal.
Definition: display_window_provider.h:59
virtual bool is_minimized() const =0
Returns true if the window is minimized.
virtual void set_position(const Rect &pos, bool client_area)=0
Sets the position and size of this window on the screen.
StandardCursor
Standard Cursor.
Definition: display_window.h:68
virtual void toggle_fullscreen()=0
virtual GraphicContext & get_gc()=0
Returns the graphic context for the window.
virtual InputDevice & get_mouse()=0
Returns the mouse input device.
virtual InputDevice & get_keyboard()=0
Returns the keyboard input device.
Display Window site.
Definition: display_window_provider.h:52
Signal< void()> sig_window_destroy
Window destroy signal.
Definition: display_window_provider.h:71
virtual void flip(int interval)=0
Flip the window display buffers.
virtual Size get_maximum_size(bool client_area) const =0
Returns the maximum size of the window.
Signal< void()> sig_window_close
Window close signal.
Definition: display_window_provider.h:68
virtual void show_system_cursor()=0
Shows the mouse cursor.
virtual void set_clipboard_image(const PixelBuffer &buf)=0
Stores an image in the clipboard.
virtual std::string get_clipboard_text() const =0
Returns the text stored in the clipboard.
virtual void create(DisplayWindowSite *site, const DisplayWindowDescription &description)=0
Creates window, assigning site and description to provider.
Signal< void()> sig_lost_focus
Lost focus signal.
Definition: display_window_provider.h:56
Pixel data container.
Definition: pixel_buffer.h:67
virtual Point screen_to_client(const Point &screen)=0
Convert from screen coordinates to client coordinates.
Definition: display_window.h:85
virtual void set_minimum_size(int width, int height, bool client_area)=0
Interface for implementing a Cursor target.
Definition: cursor_provider.h:37
virtual void set_large_icon(const PixelBuffer &image)=0
Sets the large icon used for this window.
Signal< void()> sig_paint
Paint signal.
Definition: display_window_provider.h:65
virtual std::string get_title() const =0
Returns the maximum size of the window.
virtual Point client_to_screen(const Point &client)=0
Convert from window client coordinates to screen coordinates.
virtual DisplayWindowHandle get_handle() const =0
virtual std::vector< InputDevice > & get_game_controllers()=0
Returns the game controller input device.
virtual void hide_system_cursor()=0
Hides the mouse cursor.
virtual void capture_mouse(bool capture)=0
Capture/Release the mouse.
virtual void restore()=0
Restores the window.
virtual void set_maximum_size(int width, int height, bool client_area)=0
virtual void minimize()=0
Minimizes the window.
virtual Rect get_viewport() const =0
Returns the drawable area of the window.
virtual Size get_minimum_size(bool client_area) const =0
Returns the minimum size of the window.
InputDevice.
Definition: input_device.h:46
virtual void set_title(const std::string &new_title)=0
Change window title.
virtual bool has_focus() const =0
Returns true if window has focus.
virtual bool is_fullscreen() const =0
Returns true if the window is fullscreen.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:488
virtual void set_enabled(bool enable)=0
Enables or disables input into this window.
virtual void enable_alpha_channel(const Rect &blur_rect)=0
Signal< void()> sig_window_restored
Window restored signal.
Definition: display_window_provider.h:80
virtual void show(bool activate)=0
Displays the window in its current size and position.
virtual Rect get_geometry() const =0
Returns the position and size of the window frame.
virtual void extend_frame_into_client_area(int left, int top, int right, int bottom)=0
Signal< void(float, float)> sig_resize
Resize signal.
Definition: display_window_provider.h:62
This class contains everything to construct a cursor - its data, default settings etc...
Definition: cursor_description.h:69
virtual void set_cursor(CursorProvider *cursor)=0
Sets the current cursor icon.
virtual bool is_clipboard_text_available() const =0
Returns true if text is available in the clipboard.
std::function< void(Rectf &)> func_window_resize
Window resize callback function.
Definition: display_window_provider.h:83
virtual void set_size(int width, int height, bool client_area)=0
virtual void set_clipboard_text(const std::string &text)=0
Stores text in the clipboard.
virtual bool is_maximized() const =0
Returns true if the window is maximized.
virtual void hide()=0
Hides the window.
Interface to drawing graphics.
Definition: graphic_context.h:256
2D (x,y) point structure - Integer
Definition: point.h:61
virtual PixelBuffer get_clipboard_image() const =0
Returns the image stored in the clipboard.
virtual void set_pixel_ratio(float ratio)=0
virtual void bring_to_front()=0
Raise window on top of other windows.
std::function< bool()> func_minimize_clicked
Minimize button is clicked callback function.
Definition: display_window_provider.h:86
Display window description class.
Definition: display_window_description.h:49
Interface for implementing a DisplayWindow target.
Definition: display_window_provider.h:98
Signal< void()> sig_window_minimized
Window minimized signal.
Definition: display_window_provider.h:74
2D (width,height) size structure - Integer
Definition: size.h:170
virtual ~DisplayWindowProvider()
Definition: display_window_provider.h:101
virtual void request_repaint()=0
Invalidates the screen, causing a repaint.
virtual bool is_visible() const =0
Returns true if the window is visible.
virtual void set_small_icon(const PixelBuffer &image)=0
Sets the small icon used for this window.
Signal< void()> sig_window_moved
Window moved signal.
Definition: display_window_provider.h:89
virtual CursorProvider * create_cursor(const CursorDescription &cursor_description)=0
Creates a new custom cursor.
virtual void maximize()=0
Maximizes the window.