display_window_provider.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 "../../Core/Signals/signal.h"
35 #include "../Window/display_window.h"
36 #include <memory>
37
38 namespace clan
39 {
42
43 class Rect;
44 class Size;
45 class Point;
46 class DisplayWindowDescription;
47 class GraphicContext;
48 class InputContext;
49 class CursorProvider;
50 class CursorDescription;
51
53 class DisplayWindowSite
54 {
57 public:
59 Signal<void()> sig_lost_focus;
60
62 Signal<void()> sig_got_focus;
63
65 Signal<void(float, float)> sig_resize;
66
68 Signal<void(const Rectf &)> sig_paint;
69
71 Signal<void()> sig_window_close;
72
74 Signal<void()> sig_window_destroy;
75
77 Signal<void()> sig_window_minimized;
78
80 Signal<void()> sig_window_maximized;
81
83 Signal<void()> sig_window_restored;
84
86 std::function<void(Rectf &)> func_window_resize;
87
89 std::function<bool()> func_minimize_clicked;
90
92 Signal<void()> sig_window_moved;
93
94 #ifdef WIN32
95 std::function<bool(HWND, UINT, WPARAM, LPARAM)> func_window_message;
96 #endif
97
99 };
100
102 class DisplayWindowProvider
103 {
106 public:
107 virtual ~DisplayWindowProvider() { return; }
108
112 public:
114 virtual Rect get_geometry() const = 0;
115
117 virtual Rect get_viewport() const = 0;
118
122 virtual float get_pixel_ratio() const = 0;
123
125 virtual bool has_focus() const = 0;
126
128 virtual bool is_minimized() const = 0;
129
131 virtual bool is_maximized() const = 0;
132
134 virtual bool is_visible() const = 0;
135
137 virtual bool is_fullscreen() const = 0;
138
140 virtual Size get_minimum_size(bool client_area) const = 0;
141
143 virtual Size get_maximum_size(bool client_area) const = 0;
144
146 virtual std::string get_title() const = 0;
147
149 virtual GraphicContext& get_gc() = 0;
150
152 virtual InputContext get_ic() = 0;
153
156 virtual DisplayWindowHandle get_handle() const = 0;
157
159 virtual bool is_clipboard_text_available() const = 0;
160
162 virtual bool is_clipboard_image_available() const = 0;
163
165 virtual std::string get_clipboard_text() const = 0;
166
168 virtual PixelBuffer get_clipboard_image() const = 0;
169
173 public:
174
176 virtual Point client_to_screen(const Point &client) = 0;
177
179 virtual Point screen_to_client(const Point &screen) = 0;
180
182 virtual void capture_mouse(bool capture) = 0;
183
185 virtual void request_repaint(const Rect &rect) = 0;
186
188 virtual void create(DisplayWindowSite *site, const DisplayWindowDescription &description) = 0;
189
191 virtual void show_system_cursor() = 0;
192
194 virtual void hide_system_cursor() = 0;
195
197 virtual CursorProvider *create_cursor(const CursorDescription &cursor_description) = 0;
198
200 virtual void set_cursor(CursorProvider *cursor) = 0;
201
203 virtual void set_cursor(StandardCursor type) = 0;
204
205 #ifdef WIN32
206 virtual void set_cursor_handle(HCURSOR cursor) = 0;
208 #endif
209
211 virtual void set_title(const std::string &new_title) = 0;
212
214 virtual void set_position(const Rect &pos, bool client_area) = 0;
215
221 virtual void set_size(int width, int height, bool client_area) = 0;
222
228 virtual void set_minimum_size(int width, int height, bool client_area) = 0;
229
235 virtual void set_maximum_size(int width, int height, bool client_area) = 0;
236
240 virtual void set_pixel_ratio(float ratio) = 0;
241
243 virtual void set_enabled(bool enable) = 0;
244
246 virtual void minimize() = 0;
247
249 virtual void restore() = 0;
250
252 virtual void maximize() = 0;
253
255 virtual void show(bool activate) = 0;
256
258 virtual void hide() = 0;
259
261 virtual void bring_to_front() = 0;
262
264 virtual void flip(int interval) = 0;
265
267 virtual void update(const Rect &rect) = 0;
268
270 virtual void set_clipboard_text(const std::string &text) = 0;
271
273 virtual void set_clipboard_image(const PixelBuffer &buf) = 0;
274
276 virtual void set_large_icon(const PixelBuffer &image) = 0;
277
279 virtual void set_small_icon(const PixelBuffer &image) = 0;
280
290 virtual void enable_alpha_channel(const Rect &blur_rect) = 0;
291
295 virtual void extend_frame_into_client_area(int left, int top, int right, int bottom) = 0;
296
297
301 private:
303 };
304
305 }
306
clan::DisplayWindowProvider::screen_to_client
virtual Point screen_to_client(const Point &screen)=0
Convert from screen coordinates to client coordinates.
clan
Definition: clanapp.h:35
clan::DisplayWindowProvider::hide
virtual void hide()=0
Hides the window.
clan::StandardCursor
StandardCursor
Standard Cursor.
Definition: display_window.h:70
clan::DisplayWindowProvider::set_small_icon
virtual void set_small_icon(const PixelBuffer &image)=0
Sets the small icon used for this window.
clan::DisplayWindowSite
Display Window site.
Definition: display_window_provider.h:53
clan::DisplayWindowProvider::~DisplayWindowProvider
virtual ~DisplayWindowProvider()
Definition: display_window_provider.h:107
clan::PixelBuffer
Pixel data container.
Definition: pixel_buffer.h:68
clan::DisplayWindowHandle
Definition: display_window.h:87
clan::DisplayWindowProvider::set_large_icon
virtual void set_large_icon(const PixelBuffer &image)=0
Sets the large icon used for this window.
clan::DisplayWindowProvider::has_focus
virtual bool has_focus() const =0
Returns true if window has focus.
clan::DisplayWindowProvider::maximize
virtual void maximize()=0
Maximizes the window.
clan::DisplayWindowSite::sig_window_destroy
Signal< void()> sig_window_destroy
Window destroy signal.
Definition: display_window_provider.h:74
clan::CursorProvider
Interface for implementing a Cursor target.
Definition: cursor_provider.h:39
clan::DisplayWindowProvider::create
virtual void create(DisplayWindowSite *site, const DisplayWindowDescription &description)=0
Creates window, assigning site and description to provider.
clan::DisplayWindowProvider::bring_to_front
virtual void bring_to_front()=0
Raise window on top of other windows.
clan::BrushType::image
clan::DisplayWindowProvider::create_cursor
virtual CursorProvider * create_cursor(const CursorDescription &cursor_description)=0
Creates a new custom cursor.
clan::DisplayWindowProvider::set_title
virtual void set_title(const std::string &new_title)=0
Change window title.
clan::DisplayWindowProvider::set_pixel_ratio
virtual void set_pixel_ratio(float ratio)=0
clan::DisplayWindowProvider::set_maximum_size
virtual void set_maximum_size(int width, int height, bool client_area)=0
clan::DisplayWindowProvider::get_geometry
virtual Rect get_geometry() const =0
Returns the position and size of the window frame.
clan::DisplayWindowProvider::get_clipboard_text
virtual std::string get_clipboard_text() const =0
Returns the text stored in the clipboard.
clan::StyleTokenType::string
@ keyword
clan::Rect
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:470
clan::DisplayWindowProvider::is_minimized
virtual bool is_minimized() const =0
Returns true if the window is minimized.
clan::DisplayWindowProvider::is_clipboard_text_available
virtual bool is_clipboard_text_available() const =0
Returns true if text is available in the clipboard.
clan::DisplayWindowProvider::is_visible
virtual bool is_visible() const =0
Returns true if the window is visible.
clan::DisplayWindowProvider::set_enabled
virtual void set_enabled(bool enable)=0
Enables or disables input into this window.
clan::DisplayWindowProvider::set_size
virtual void set_size(int width, int height, bool client_area)=0
clan::DisplayWindowProvider::capture_mouse
virtual void capture_mouse(bool capture)=0
Capture/Release the mouse.
clan::DisplayWindowProvider::get_minimum_size
virtual Size get_minimum_size(bool client_area) const =0
Returns the minimum size of the window.
clan::DisplayWindowProvider::get_ic
virtual InputContext get_ic()=0
Returns the input context for the window.
clan::DisplayWindowProvider::extend_frame_into_client_area
virtual void extend_frame_into_client_area(int left, int top, int right, int bottom)=0
clan::DisplayWindowProvider::restore
virtual void restore()=0
Restores the window.
clan::DisplayWindowSite::sig_resize
Signal< void(float, float)> sig_resize
Resize signal.
Definition: display_window_provider.h:65
clan::CursorDescription
This class contains everything to construct a cursor - its data, default settings etc...
Definition: cursor_description.h:70
clan::DisplayWindowProvider::set_minimum_size
virtual void set_minimum_size(int width, int height, bool client_area)=0
clan::Signal< void()>
clan::DisplayWindowProvider::get_handle
virtual DisplayWindowHandle get_handle() const =0
clan::DisplayWindowProvider::client_to_screen
virtual Point client_to_screen(const Point &client)=0
Convert from window client coordinates to screen coordinates.
clan::DisplayWindowProvider::show
virtual void show(bool activate)=0
Displays the window in its current size and position.
clan::DisplayWindowProvider::get_gc
virtual GraphicContext & get_gc()=0
Returns the graphic context for the window.
clan::DisplayWindowProvider::get_pixel_ratio
virtual float get_pixel_ratio() const =0
clan::DisplayWindowSite::sig_window_restored
Signal< void()> sig_window_restored
Window restored signal.
Definition: display_window_provider.h:83
clan::DisplayWindowSite::sig_window_moved
Signal< void()> sig_window_moved
Window moved signal.
Definition: display_window_provider.h:92
clan::GraphicContext
Interface to drawing graphics.
Definition: graphic_context.h:257
clan::Point
2D (x,y) point structure - Integer
Definition: point.h:62
clan::InputContext
InputContext.
Definition: input_context.h:44
clan::DisplayWindowSite::sig_window_maximized
Signal< void()> sig_window_maximized
Window maximized signal.
Definition: display_window_provider.h:80
clan::DisplayWindowProvider::is_maximized
virtual bool is_maximized() const =0
Returns true if the window is maximized.
clan::Key::left
clan::DisplayWindowProvider::minimize
virtual void minimize()=0
Minimizes the window.
clan::DisplayWindowProvider::flip
virtual void flip(int interval)=0
Flip the window display buffers.
clan::DisplayWindowDescription
Display window description class.
Definition: display_window_description.h:62
clan::Key::right
clan::DisplayWindowProvider
Interface for implementing a DisplayWindow target.
Definition: display_window_provider.h:102
clan::DisplayWindowSite::sig_lost_focus
Signal< void()> sig_lost_focus
Lost focus signal.
Definition: display_window_provider.h:59
clan::DisplayWindowProvider::set_position
virtual void set_position(const Rect &pos, bool client_area)=0
Sets the position and size of this window on the screen.
clan::DisplayWindowProvider::request_repaint
virtual void request_repaint(const Rect &rect)=0
Invalidates a region of a screen, causing a repaint.
clan::DisplayWindowProvider::set_clipboard_image
virtual void set_clipboard_image(const PixelBuffer &buf)=0
Stores an image in the clipboard.
clan::Size
2D (width,height) size structure - Integer
Definition: size.h:156
clan::DisplayWindowProvider::get_maximum_size
virtual Size get_maximum_size(bool client_area) const =0
Returns the maximum size of the window.
clan::DisplayWindowProvider::get_title
virtual std::string get_title() const =0
Returns the maximum size of the window.
clan::DisplayWindowSite::sig_window_minimized
Signal< void()> sig_window_minimized
Window minimized signal.
Definition: display_window_provider.h:77
clan::DisplayWindowSite::func_minimize_clicked
std::function< bool()> func_minimize_clicked
Minimize button is clicked callback function.
Definition: display_window_provider.h:89
clan::DisplayWindowSite::sig_got_focus
Signal< void()> sig_got_focus
Obtained focus signal.
Definition: display_window_provider.h:62
clan::DisplayWindowProvider::show_system_cursor
virtual void show_system_cursor()=0
Shows the mouse cursor.
clan::DisplayWindowSite::sig_window_close
Signal< void()> sig_window_close
Window close signal.
Definition: display_window_provider.h:71
clan::DisplayWindowProvider::set_clipboard_text
virtual void set_clipboard_text(const std::string &text)=0
Stores text in the clipboard.
clan::DisplayWindowSite::func_window_resize
std::function< void(Rectf &)> func_window_resize
Window resize callback function.
Definition: display_window_provider.h:86
clan::DisplayWindowProvider::enable_alpha_channel
virtual void enable_alpha_channel(const Rect &blur_rect)=0
clan::DisplayWindowProvider::set_cursor
virtual void set_cursor(CursorProvider *cursor)=0
Sets the current cursor icon.
clan::DisplayWindowProvider::update
virtual void update(const Rect &rect)=0
Copy a region of the backbuffer to the frontbuffer.
clan::DisplayWindowProvider::is_fullscreen
virtual bool is_fullscreen() const =0
Returns true if the window is fullscreen.
clan::DisplayWindowProvider::get_clipboard_image
virtual PixelBuffer get_clipboard_image() const =0
Returns the image stored in the clipboard.
clan::DisplayWindowProvider::get_viewport
virtual Rect get_viewport() const =0
Returns the drawable area of the window.
clan::DisplayWindowSite::sig_paint
Signal< void(const Rectf &)> sig_paint
Paint signal.
Definition: display_window_provider.h:68
clan::DisplayWindowProvider::hide_system_cursor
virtual void hide_system_cursor()=0
Hides the mouse cursor.
clan::DisplayWindowProvider::is_clipboard_image_available
virtual bool is_clipboard_image_available() const =0
Returns true if an image is available in the clipboard.