display_window_provider.h Source File - ClanLib SDK
Description: display_window_provider.h Source File

display_window_provider.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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
37namespace 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
52 class DisplayWindowSite
53 {
54 public:
56 Signal<void()> sig_lost_focus;
57
59 Signal<void()> sig_got_focus;
60
62 Signal<void(float, float)> sig_resize;
63
65 Signal<void()> sig_paint;
66
68 Signal<void()> sig_window_close;
69
71 Signal<void()> sig_window_destroy;
72
74 Signal<void()> sig_window_minimized;
75
77 Signal<void()> sig_window_maximized;
78
80 Signal<void()> sig_window_restored;
81
83 std::function<void(Rectf &)> func_window_resize;
84
86 std::function<bool()> func_minimize_clicked;
87
89 Signal<void()> sig_window_moved;
90
91#ifdef WIN32
92 std::function<bool(HWND, UINT, WPARAM, LPARAM)> func_window_message;
93 Signal<void(HWND, UINT, WPARAM, LPARAM)> sig_window_message;
94#endif
95 };
96
98 class DisplayWindowProvider
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
198 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}
clan::CursorDescription
This class contains everything to construct a cursor - its data, default settings etc.
Definition cursor_description.h:70
clan::CursorProvider
Interface for implementing a Cursor target.
Definition cursor_provider.h:38
clan::DisplayWindowDescription
Display window description class.
Definition display_window_description.h:50
clan::DisplayWindowProvider
Interface for implementing a DisplayWindow target.
Definition display_window_provider.h:99
clan::DisplayWindowProvider::set_pixel_ratio
virtual void set_pixel_ratio(float ratio)=0
clan::DisplayWindowProvider::is_visible
virtual bool is_visible() const =0
Returns true if the window is visible.
clan::DisplayWindowProvider::~DisplayWindowProvider
virtual ~DisplayWindowProvider()
Definition display_window_provider.h:101
clan::DisplayWindowProvider::get_mouse
virtual InputDevice & get_mouse()=0
Returns the mouse input device.
clan::DisplayWindowProvider::get_geometry
virtual Rect get_geometry() const =0
Returns the position and size of the window frame.
clan::DisplayWindowProvider::set_enabled
virtual void set_enabled(bool enable)=0
Enables or disables input into this window.
clan::DisplayWindowProvider::minimize
virtual void minimize()=0
Minimizes the window.
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::set_large_icon
virtual void set_large_icon(const PixelBuffer &image)=0
Sets the large icon used for this window.
clan::DisplayWindowProvider::hide_system_cursor
virtual void hide_system_cursor()=0
Hides the mouse cursor.
clan::DisplayWindowProvider::hide
virtual void hide()=0
Hides the window.
clan::DisplayWindowProvider::get_title
virtual std::string get_title() const =0
Returns the maximum size of the window.
clan::DisplayWindowProvider::create
virtual void create(DisplayWindowSite *site, const DisplayWindowDescription &description)=0
Creates window, assigning site and description to provider.
clan::DisplayWindowProvider::show
virtual void show(bool activate)=0
Displays the window in its current size and position.
clan::DisplayWindowProvider::bring_to_front
virtual void bring_to_front()=0
Raise window on top of other windows.
clan::DisplayWindowProvider::flip
virtual void flip(int interval)=0
Flip the window display buffers.
clan::DisplayWindowProvider::is_maximized
virtual bool is_maximized() const =0
Returns true if the window is maximized.
clan::DisplayWindowProvider::get_pixel_ratio
virtual float get_pixel_ratio() const =0
clan::DisplayWindowProvider::set_clipboard_text
virtual void set_clipboard_text(const std::string &text)=0
Stores text in the clipboard.
clan::DisplayWindowProvider::toggle_fullscreen
virtual void toggle_fullscreen()=0
clan::DisplayWindowProvider::set_size
virtual void set_size(int width, int height, bool client_area)=0
clan::DisplayWindowProvider::set_title
virtual void set_title(const std::string &new_title)=0
Change window title.
clan::DisplayWindowProvider::set_cursor
virtual void set_cursor(CursorProvider *cursor)=0
Sets the current cursor icon.
clan::DisplayWindowProvider::is_clipboard_image_available
virtual bool is_clipboard_image_available() const =0
Returns true if an image is available in the clipboard.
clan::DisplayWindowProvider::is_fullscreen
virtual bool is_fullscreen() const =0
Returns true if the window is fullscreen.
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_gc
virtual GraphicContext & get_gc()=0
Returns the graphic context for the window.
clan::DisplayWindowProvider::create_cursor
virtual CursorProvider * create_cursor(const CursorDescription &cursor_description)=0
Creates a new custom cursor.
clan::DisplayWindowProvider::restore
virtual void restore()=0
Restores the window.
clan::DisplayWindowProvider::get_clipboard_image
virtual PixelBuffer get_clipboard_image() const =0
Returns the image stored in the clipboard.
clan::DisplayWindowProvider::get_handle
virtual DisplayWindowHandle get_handle() const =0
clan::DisplayWindowProvider::set_minimum_size
virtual void set_minimum_size(int width, int height, bool client_area)=0
clan::DisplayWindowProvider::has_focus
virtual bool has_focus() const =0
Returns true if window has focus.
clan::DisplayWindowProvider::capture_mouse
virtual void capture_mouse(bool capture)=0
Capture/Release the mouse.
clan::DisplayWindowProvider::maximize
virtual void maximize()=0
Maximizes the window.
clan::DisplayWindowProvider::get_game_controllers
virtual std::vector< InputDevice > & get_game_controllers()=0
Returns the game controller input device.
clan::DisplayWindowProvider::get_maximum_size
virtual Size get_maximum_size(bool client_area) const =0
Returns the maximum size of the window.
clan::DisplayWindowProvider::is_minimized
virtual bool is_minimized() const =0
Returns true if the window is minimized.
clan::DisplayWindowProvider::show_system_cursor
virtual void show_system_cursor()=0
Shows the mouse cursor.
clan::DisplayWindowProvider::set_maximum_size
virtual void set_maximum_size(int width, int height, bool client_area)=0
clan::DisplayWindowProvider::set_cursor
virtual void set_cursor(StandardCursor type)=0
Sets the current cursor icon.
clan::DisplayWindowProvider::set_small_icon
virtual void set_small_icon(const PixelBuffer &image)=0
Sets the small icon used for this window.
clan::DisplayWindowProvider::get_keyboard
virtual InputDevice & get_keyboard()=0
Returns the keyboard input device.
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::client_to_screen
virtual Point client_to_screen(const Point &client)=0
Convert from window client coordinates to screen coordinates.
clan::DisplayWindowProvider::set_clipboard_image
virtual void set_clipboard_image(const PixelBuffer &buf)=0
Stores an image in the clipboard.
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::get_viewport
virtual Rect get_viewport() const =0
Returns the drawable area of the window.
clan::DisplayWindowProvider::enable_alpha_channel
virtual void enable_alpha_channel(const Rect &blur_rect)=0
clan::DisplayWindowProvider::request_repaint
virtual void request_repaint()=0
Invalidates the screen, causing a repaint.
clan::DisplayWindowProvider::get_clipboard_text
virtual std::string get_clipboard_text() const =0
Returns the text stored in the clipboard.
clan::DisplayWindowProvider::screen_to_client
virtual Point screen_to_client(const Point &screen)=0
Convert from screen coordinates to client coordinates.
clan::DisplayWindowSite
Display Window site.
Definition display_window_provider.h:53
clan::DisplayWindowSite::sig_got_focus
Signal< void()> sig_got_focus
Obtained focus signal.
Definition display_window_provider.h:59
clan::DisplayWindowSite::sig_window_close
Signal< void()> sig_window_close
Window close signal.
Definition display_window_provider.h:68
clan::DisplayWindowSite::sig_window_destroy
Signal< void()> sig_window_destroy
Window destroy signal.
Definition display_window_provider.h:71
clan::DisplayWindowSite::sig_window_maximized
Signal< void()> sig_window_maximized
Window maximized 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:86
clan::DisplayWindowSite::sig_lost_focus
Signal< void()> sig_lost_focus
Lost focus signal.
Definition display_window_provider.h:56
clan::DisplayWindowSite::sig_resize
Signal< void(float, float)> sig_resize
Resize signal.
Definition display_window_provider.h:62
clan::DisplayWindowSite::sig_window_restored
Signal< void()> sig_window_restored
Window restored signal.
Definition display_window_provider.h:80
clan::DisplayWindowSite::sig_paint
Signal< void()> sig_paint
Paint signal.
Definition display_window_provider.h:65
clan::DisplayWindowSite::sig_window_minimized
Signal< void()> sig_window_minimized
Window minimized signal.
Definition display_window_provider.h:74
clan::DisplayWindowSite::sig_window_moved
Signal< void()> sig_window_moved
Window moved signal.
Definition display_window_provider.h:89
clan::DisplayWindowSite::func_window_resize
std::function< void(Rectf &)> func_window_resize
Window resize callback function.
Definition display_window_provider.h:83
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::InputDevice
InputDevice.
Definition input_device.h:47
clan::PixelBuffer
Pixel data container.
Definition pixel_buffer.h:68
clan::Point
2D (x,y) point structure - Integer
Definition point.h:62
clan::Rect
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
clan::Rectf
2D (left,top,right,bottom) rectangle structure - Float
Definition rect.h:460
clan::Signal
Definition signal.h:105
clan::Size
2D (width,height) size structure - Integer
Definition size.h:176
clan::Handedness::right
@ right
Definition mat4.h:47
clan::Handedness::left
@ left
Definition mat4.h:46
clan::StandardCursor
StandardCursor
Standard Cursor.
Definition display_window.h:69
clan
Definition clanapp.h:36
clan::BrushType::image
@ image
Definition brush.h:54
clan::DisplayWindowHandle
Definition display_window.h:86