neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
message_box.hpp
Go to the documentation of this file.
1// message_box.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
25namespace neogfx
26{
27 class message_box : public dialog
28 {
30 public:
31 struct no_response : std::logic_error { no_response() : std::logic_error("neogfx::message_box::no_response") {} };
32 public:
33 message_box(std::string const& aTitle, const image& aIcon, std::string const& aText, standard_button aButtons = standard_button::Ok);
34 message_box(std::string const& aTitle, const image& aIcon, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
35 message_box(i_widget& aParent, std::string const& aTitle, const image& aIcon, std::string const& aText, standard_button aButtons = standard_button::Ok);
36 message_box(i_widget& aParent, std::string const& aTitle, const image& aIcon, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
37 public:
38 static standard_button information(std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
39 static standard_button information(std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
40 static standard_button information(i_widget& aParent, std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
41 static standard_button information(i_widget& aParent, std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
42 static standard_button question(std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Yes | standard_button::No);
43 static standard_button question(std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Yes | standard_button::No);
44 static standard_button question(i_widget& aParent, std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Yes | standard_button::No);
45 static standard_button question(i_widget& aParent, std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Yes | standard_button::No);
46 static standard_button stop(std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
47 static standard_button stop(std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
48 static standard_button stop(i_widget& aParent, std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
49 static standard_button stop(i_widget& aParent, std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
50 static standard_button warning(std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
51 static standard_button warning(std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
52 static standard_button warning(i_widget& aParent, std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
53 static standard_button warning(i_widget& aParent, std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
54 static standard_button error(std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
55 static standard_button error(std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
56 static standard_button error(i_widget& aParent, std::string const& aTitle, std::string const& aText, standard_button aButtons = standard_button::Ok);
57 static standard_button error(i_widget& aParent, std::string const& aTitle, std::string const& aText, std::string const& aDetailedText, standard_button aButtons = standard_button::Ok);
58 public:
59 const image_widget& icon() const;
61 const text_widget& text() const;
63 const text_widget& detailed_text() const;
65 public:
66 bool has_response() const;
69 public:
70 dialog_result exec() override;
71 protected:
72 size maximum_size(optional_size const& aAvailableSpace = {}) const override;
73 private:
74 void init();
75 private:
76 horizontal_layout iLayout1;
77 vertical_layout iLayout2;
78 image_widget iIcon;
79 vertical_layout iLayout3;
80 text_widget iText;
81 text_widget iDetailedText;
82 std::optional<standard_button> iResponse;
83 };
84}
dialog_result exec() override
static standard_button error(i_widget &aParent, std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button error(i_widget &aParent, std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
text_widget & detailed_text()
bool has_response() const
static standard_button warning(std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
const text_widget & text() const
message_box(i_widget &aParent, std::string const &aTitle, const image &aIcon, std::string const &aText, standard_button aButtons=standard_button::Ok)
standard_button response() const
static standard_button stop(i_widget &aParent, std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
message_box(std::string const &aTitle, const image &aIcon, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button warning(i_widget &aParent, std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button information(std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
static standard_button stop(std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
const image_widget & icon() const
message_box(std::string const &aTitle, const image &aIcon, std::string const &aText, standard_button aButtons=standard_button::Ok)
size maximum_size(optional_size const &aAvailableSpace={}) const override
static standard_button stop(std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button question(i_widget &aParent, std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Yes|standard_button::No)
image_widget & icon()
static standard_button information(i_widget &aParent, std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
static standard_button error(std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button question(std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Yes|standard_button::No)
static standard_button error(std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
static standard_button stop(i_widget &aParent, std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button warning(std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
static standard_button question(i_widget &aParent, std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Yes|standard_button::No)
void set_response(standard_button aResponse)
message_box(i_widget &aParent, std::string const &aTitle, const image &aIcon, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
text_widget & text()
static standard_button warning(i_widget &aParent, std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Ok)
static standard_button question(std::string const &aTitle, std::string const &aText, standard_button aButtons=standard_button::Yes|standard_button::No)
static standard_button information(std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
static standard_button information(i_widget &aParent, std::string const &aTitle, std::string const &aText, std::string const &aDetailedText, standard_button aButtons=standard_button::Ok)
const text_widget & detailed_text() const
dialog_result
Definition dialog.hpp:29
#define meta_object(...)
Definition i_object.hpp:28