neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_surface_manager.hpp
Go to the documentation of this file.
1// i_surface_manager.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
25#include <neogfx/hid/i_nest.hpp>
26
27namespace neogfx
28{
29 class i_display;
30
31 struct nest_not_found : std::logic_error { nest_not_found() : std::logic_error{ "neogfx::nest_not_found" } {} };
32 struct wrong_nest_type : std::logic_error { wrong_nest_type() : std::logic_error{ "neogfx::wrong_nest_type" } {} };
33 struct nest_not_active : std::logic_error { nest_not_active() : std::logic_error{ "neogfx::nest_not_active" } {} };
34 struct cannot_destroy_active_nest : std::logic_error { cannot_destroy_active_nest() : std::logic_error{ "neogfx::cannot_destroy_active_nest" } {} };
35
37 {
38 public:
39 declare_event(dpi_changed, i_surface&)
40 public:
41 struct surface_not_found : std::logic_error { surface_not_found() : std::logic_error("neogfx::i_surface_manager::surface_not_found") {} };
42 public:
43 virtual ~i_surface_manager() = default;
44 public:
45 virtual bool initialising_surface() const = 0;
46 virtual void add_surface(i_surface& aSurface) = 0;
47 virtual void remove_surface(i_surface& aSurface) = 0;
48 virtual std::size_t surface_count() const = 0;
49 virtual i_surface& surface(std::size_t aIndex) = 0;
50 virtual bool any_strong_surfaces() const = 0;
51 virtual std::size_t strong_surface_count() const = 0;
52 virtual bool process_events(bool& aLastWindowClosed) = 0;
53 virtual void layout_surfaces() = 0;
54 virtual void invalidate_surfaces() = 0;
55 virtual void render_surfaces() = 0;
56 virtual void display_error_message(std::string const& aTitle, std::string const& aMessage) const = 0;
57 virtual void display_error_message(i_native_window const& aParent, std::string const& aTitle, std::string const& aMessage) const = 0;
58 virtual uint32_t display_count() const = 0;
59 virtual i_display& display(uint32_t aDisplayIndex = 0) const = 0;
60 virtual i_display& display(i_surface const& aSurface) const = 0;
61 virtual rect desktop_rect(uint32_t aDisplayIndex = 0) const = 0;
62 virtual rect desktop_rect(i_surface const& aSurface) const = 0;
63 public:
64 virtual const i_surface& surface_at_position(i_surface const& aProgenitor, point const& aPosition, bool aForMouseEvent = false) const = 0;
65 virtual i_surface& surface_at_position(i_surface const& aProgenitor, point const& aPosition, bool aForMouseEvent = false) = 0;
66 public:
67 virtual i_nest& nest_for(i_widget& aNestWidget, nest_type aNestType) const = 0;
68 virtual i_nest& find_nest(i_native_window const& aNestedWindow) const = 0;
69 virtual void destroy_nest(i_nest& aNest) = 0;
70 virtual i_nest& active_nest() const = 0;
71 virtual void activate_nest(i_nest& aNest) = 0;
72 virtual void deactivate_nest(i_nest& aNest) = 0;
73 public:
74 virtual bool is_surface_attached(void* aNativeSurfaceHandle) const = 0;
75 virtual i_surface& attached_surface(void* aNativeSurfaceHandle) = 0;
76 public:
77 static uuid const& iid() { static uuid const sIid{ 0xf189b8a1, 0x37d3, 0x4288, 0x9654, { 0xf8, 0xd, 0x19, 0xf1, 0xe, 0x2d } }; return sIid; }
78 };
79
81 {
82 public:
83 scoped_nest(i_widget& aNestWidget, nest_type aNestType) :
84 iNest{ service<i_surface_manager>().nest_for(aNestWidget, aNestType) }
85 {
86 service<i_surface_manager>().activate_nest(iNest);
87 }
89 {
90 service<i_surface_manager>().deactivate_nest(iNest);
91 }
92 private:
93 i_nest& iNest;
94 };
95}
virtual i_surface & surface(std::size_t aIndex)=0
virtual void remove_surface(i_surface &aSurface)=0
virtual rect desktop_rect(uint32_t aDisplayIndex=0) const =0
virtual void destroy_nest(i_nest &aNest)=0
static uuid const & iid()
virtual bool process_events(bool &aLastWindowClosed)=0
virtual void invalidate_surfaces()=0
virtual void activate_nest(i_nest &aNest)=0
virtual i_nest & active_nest() const =0
virtual i_nest & find_nest(i_native_window const &aNestedWindow) const =0
virtual i_surface & attached_surface(void *aNativeSurfaceHandle)=0
virtual rect desktop_rect(i_surface const &aSurface) const =0
virtual bool is_surface_attached(void *aNativeSurfaceHandle) const =0
virtual void display_error_message(i_native_window const &aParent, std::string const &aTitle, std::string const &aMessage) const =0
virtual std::size_t strong_surface_count() const =0
virtual void render_surfaces()=0
virtual bool any_strong_surfaces() const =0
virtual void display_error_message(std::string const &aTitle, std::string const &aMessage) const =0
virtual i_surface & surface_at_position(i_surface const &aProgenitor, point const &aPosition, bool aForMouseEvent=false)=0
virtual void add_surface(i_surface &aSurface)=0
virtual std::size_t surface_count() const =0
virtual ~i_surface_manager()=default
virtual bool initialising_surface() const =0
virtual i_display & display(i_surface const &aSurface) const =0
virtual const i_surface & surface_at_position(i_surface const &aProgenitor, point const &aPosition, bool aForMouseEvent=false) const =0
virtual i_display & display(uint32_t aDisplayIndex=0) const =0
virtual i_nest & nest_for(i_widget &aNestWidget, nest_type aNestType) const =0
virtual uint32_t display_count() const =0
virtual void deactivate_nest(i_nest &aNest)=0
virtual void layout_surfaces()=0
scoped_nest(i_widget &aNestWidget, nest_type aNestType)
nest_type
Definition i_nest.hpp:30
Service & service()
Definition services.hpp:113
#define declare_event(declName,...)
Definition i_event.hpp:305