neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
dialog.hpp
Go to the documentation of this file.
1// dialog.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>
24#include "dialog_button_box.hpp"
25
26namespace neogfx
27{
28 enum class dialog_result
29 {
33 Other
34 };
35
36 class dialog : public window
37 {
39 public:
40 define_event(TryAccept, try_accept, bool& /* aCanAccept */, bool /* aQueryOnly */)
41 define_event(TryReject, try_reject, bool& /* aCanReject */, bool /* aQueryOnly */)
42 define_event(Accepted, accepted)
43 define_event(Rejected, rejected)
44 define_event(HaveResult, have_result, dialog_result /* aResult */)
45 public:
47 dialog(std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
48 dialog(const size& aDimensions, window_style aStyle = window_style::DefaultDialog);
49 dialog(const size& aDimensions, std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
50 dialog(const point& aPosition, const size& aDimensions, window_style aStyle = window_style::DefaultDialog);
51 dialog(const point& aPosition, const size& aDimensions, std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
53 dialog(i_widget& aParent, std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
54 dialog(i_widget& aParent, const size& aDimensions, window_style aStyle = window_style::DefaultDialog);
55 dialog(i_widget& aParent, const size& aDimensions, std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
56 dialog(i_widget& aParent, const point& aPosition, const size& aDimensions, window_style aStyle = window_style::DefaultDialog);
57 dialog(i_widget& aParent, const point& aPosition, const size& aDimensions, std::string const& aDialogTitle, window_style aStyle = window_style::DefaultDialog);
58 ~dialog();
59 public:
60 virtual void accept();
61 virtual void reject();
62 virtual dialog_result result() const;
63 virtual void set_result(dialog_result aResult);
64 public:
65 void set_standard_layout(const size& aControlSpacing, const neogfx::padding& aPadding, bool aCreateButtonBox = true);
66 dialog_button_box& button_box();
67 public:
69 public:
70 neogfx::size_policy size_policy() const override;
71 public:
72 bool can_close() const override;
73 void close() override;
74 public:
75 bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
76 public:
77 using window::has_layout;
78 using window::layout;
79 bool has_layout(standard_layout aStandardLayout) const override;
80 const i_layout& layout(standard_layout aStandardLayout, layout_position aPosition = layout_position::None) const override;
81 i_layout& layout(standard_layout aStandardLayout, layout_position aPosition = layout_position::None) override;
82 private:
83 void init();
84 private:
85 std::optional<widget_timer> iUpdater;
86 vertical_layout iButtonBoxLayout;
87 std::optional<dialog_button_box> iButtonBox;
88 std::optional<dialog_result> iResult;
89 sink iSink;
90 };
91}
bool can_close() const override
virtual dialog_result exec()
const i_layout & layout(standard_layout aStandardLayout, layout_position aPosition=layout_position::None) const override
void set_standard_layout(const size &aControlSpacing, const neogfx::padding &aPadding, bool aCreateButtonBox=true)
dialog_button_box & button_box()
neogfx::size_policy size_policy() const override
virtual dialog_result result() const
bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
virtual void accept()
void close() override
bool has_layout(standard_layout aStandardLayout) const override
virtual void set_result(dialog_result aResult)
virtual void reject()
i_layout & layout(standard_layout aStandardLayout, layout_position aPosition=layout_position::None) override
const i_layout & layout() const override
Definition widget.ipp:611
bool has_layout() const override
Definition widget.ipp:573
dialog_result
Definition dialog.hpp:29
standard_layout
Definition i_layout.hpp:49
layout_position
Definition i_layout.hpp:39
#define meta_object(...)
Definition i_object.hpp:28
#define define_event(name, declName,...)
Definition event.hpp:200