neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_app.hpp
Go to the documentation of this file.
1// i_app.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>
23#include <boost/program_options.hpp>
25#include <neogfx/core/event.hpp>
31#include <neogfx/app/i18n.hpp>
32
33namespace neogfx
34{
35 class i_widget;
36 class i_mnemonic;
37 class i_image;
38 class i_menu;
39
40 class i_help;
41
42 class event_processing_context;
43
45 {
47 Edit
48 };
49
51 {
52 public:
53 struct invalid_options : std::runtime_error { invalid_options(std::string const& aReason) : std::runtime_error("Invalid program options: " + aReason) {} };
54 public:
55 virtual ~i_program_options() = default;
56 public:
57 virtual const boost::program_options::variables_map& options() const = 0;
58 public:
59 virtual bool console() const = 0;
60 virtual neogfx::renderer renderer() const = 0;
61 virtual std::optional<size_u32> full_screen() const = 0;
62 virtual std::optional<size_u32> dpi_override() const = 0;
63 virtual bool turbo() const = 0;
64 virtual bool nest() const = 0;
65 };
66
68 {
69 public:
70 declare_event(execution_started)
71 declare_event(name_changed)
72 declare_event(current_style_changed, style_aspect)
73 public:
74 struct main_window_closed_prematurely : std::runtime_error { main_window_closed_prematurely() : std::runtime_error("Main window closed prematurely!") {} };
75 struct unknown_standard_menu : std::logic_error { unknown_standard_menu() : std::logic_error("neogfx::i_app::unknown_standard_menu") {} };
76 public:
77 virtual const i_program_options& program_options() const = 0;
78 virtual std::string const& name() const = 0;
79 virtual void set_name(std::string const& aName) = 0;
80 virtual int exec(bool aQuitWhenLastWindowClosed = true) = 0;
81 virtual bool in_exec() const = 0;
82 virtual void quit(int aResultCode) = 0;
83 public:
84 virtual dimension x2_dpi_scale_factor() const = 0;
85 virtual dimension xn_dpi_scale_factor() const = 0;
86 public:
87 virtual const i_texture& default_window_icon() const = 0;
88 virtual void set_default_window_icon(const i_texture& aIcon) = 0;
89 virtual void set_default_window_icon(const i_image& aIcon) = 0;
90 virtual const i_style& current_style() const = 0;
91 virtual i_style& current_style() = 0;
92 virtual i_style& change_style(std::string const& aStyleName) = 0;
93 virtual i_style& register_style(const i_style& aStyle) = 0;
94 public:
96 virtual i_string const& translate(i_string const& aTranslatableString, i_string const& aContext = string{}, std::int64_t aPlurality = 1) const = 0;
97 public:
98 virtual i_action& action_file_new() = 0;
99 virtual i_action& action_file_open() = 0;
105 virtual i_action& action_undo() = 0;
106 virtual i_action& action_redo() = 0;
107 virtual i_action& action_cut() = 0;
108 virtual i_action& action_copy() = 0;
109 virtual i_action& action_paste() = 0;
110 virtual i_action& action_delete() = 0;
113 virtual i_action& add_action(i_string const& aText) = 0;
114 virtual i_action& add_action(i_string const& aText, i_string const& aImageUri, dimension aDpiScaleFactor = 1.0, texture_sampling aSampling = texture_sampling::Normal) = 0;
115 virtual i_action& add_action(i_string const& aText, const i_texture& aImage) = 0;
116 virtual i_action& add_action(i_string const& aText, const i_image& aImage) = 0;
117 virtual void remove_action(i_action& aAction) = 0;
118 virtual i_action& find_action(i_string const& aText) = 0;
119 virtual void add_mnemonic(i_mnemonic& aMnemonic) = 0;
120 virtual void remove_mnemonic(i_mnemonic& aMnemonic) = 0;
121 public:
122 virtual i_menu& add_standard_menu(i_menu& aParentMenu, standard_menu aStandardMenu) = 0;
123 public:
124 virtual i_help& help() const = 0;
125 public:
126 virtual bool process_events() = 0;
127 virtual bool process_events(i_event_processing_context& aContext) = 0;
129 public:
130 static uuid const& iid() { static uuid const sIid{ 0xa8bd88d7, 0xbd19, 0x4501, 0xb199, { 0x84, 0x84, 0x55, 0xfc, 0x80, 0x45 } }; return sIid; }
131 };
132}
virtual i_action & add_action(i_action &aAction)=0
virtual i_help & help() const =0
virtual void remove_action(i_action &aAction)=0
virtual i_action & action_copy()=0
virtual i_action & action_file_exit()=0
virtual void set_name(std::string const &aName)=0
virtual i_style & register_style(const i_style &aStyle)=0
virtual const i_program_options & program_options() const =0
virtual i_menu & add_standard_menu(i_menu &aParentMenu, standard_menu aStandardMenu)=0
virtual i_style & current_style()=0
virtual i_style & change_style(std::string const &aStyleName)=0
virtual i_action & action_cut()=0
virtual i_action & action_file_new()=0
virtual i_action & action_file_close()=0
virtual i_action & add_action(i_string const &aText, i_string const &aImageUri, dimension aDpiScaleFactor=1.0, texture_sampling aSampling=texture_sampling::Normal)=0
virtual i_action & add_action(i_string const &aText, const i_texture &aImage)=0
virtual int exec(bool aQuitWhenLastWindowClosed=true)=0
virtual i_action & action_paste()=0
virtual bool process_events(i_event_processing_context &aContext)=0
virtual bool process_events()=0
virtual i_action & action_redo()=0
virtual i_action & action_file_save_all()=0
virtual i_string const & translate(i_string const &aTranslatableString, i_string const &aContext=string{}, std::int64_t aPlurality=1) const =0
virtual const i_style & current_style() const =0
static uuid const & iid()
Definition i_app.hpp:130
virtual i_action & action_file_save()=0
virtual const i_texture & default_window_icon() const =0
virtual i_action & action_select_all()=0
virtual i_action & action_file_close_all()=0
virtual dimension x2_dpi_scale_factor() const =0
virtual i_action & add_action(i_string const &aText, const i_image &aImage)=0
virtual void set_default_window_icon(const i_image &aIcon)=0
virtual bool in_exec() const =0
virtual void remove_mnemonic(i_mnemonic &aMnemonic)=0
virtual dimension xn_dpi_scale_factor() const =0
virtual i_action & action_file_open()=0
virtual i_action & find_action(i_string const &aText)=0
virtual i_action & action_delete()=0
virtual i_action & action_undo()=0
virtual void set_default_window_icon(const i_texture &aIcon)=0
virtual i_event_processing_context & event_processing_context()=0
virtual std::string const & name() const =0
virtual i_action & add_action(i_string const &aText)=0
virtual void quit(int aResultCode)=0
virtual void add_mnemonic(i_mnemonic &aMnemonic)=0
declare_event(execution_started) declare_event(name_changed) declare_event(current_style_changed
virtual neogfx::renderer renderer() const =0
virtual ~i_program_options()=default
virtual std::optional< size_u32 > dpi_override() const =0
virtual bool nest() const =0
virtual bool console() const =0
virtual const boost::program_options::variables_map & options() const =0
virtual std::optional< size_u32 > full_screen() const =0
virtual bool turbo() const =0
standard_menu
Definition i_app.hpp:45
@ File
Definition i_app.hpp:46
@ Edit
Definition i_app.hpp:47
style_aspect
Definition i_style.hpp:31
default_geometry_value_type dimension
texture_sampling
Definition i_texture.hpp:42
#define declare_event(declName,...)
Definition i_event.hpp:305
invalid_options(std::string const &aReason)
Definition i_app.hpp:53