libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Alertable.hpp
Go to the documentation of this file.
1 #ifndef IALERTABLE_HPP
2 #define IALERTABLE_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "Utilities.hpp"
23 #include "Theme.hpp"
24 #include "LateReturn.hpp"
25 
26 namespace AlgAudio{
27 
28 #undef IGNORE
29 
30 enum class ButtonID : int{
31  OK,
32  CANCEL,
33  YES,
34  NO,
35  QUIT,
36  IGNORE,
37  CUSTOM1,
38  CUSTOM2,
39 };
40 
41 #undef ERROR
42 enum class AlertType : int{
43  NONE,
44  INFO,
45  WARNING,
46  ERROR,
47 };
48 
49 namespace Exceptions{
50 struct WindowNotAlertable : public Exception{
51  WindowNotAlertable(std::string t) : Exception(t) {}
52 };
53 } //namespace Exceptions
54 
55 /* This is an interface implemented by all classes which are capable of
56  * displaying an alert. For example, the MainWindow is such class.
57  */
58 class IAlertable {
59 public:
62  std::string message,
63  std::string button1_text,
64  std::string button2_text,
66  Color button1_color = Theme::Get("bg-button-neutral"),
67  Color button2_color = Theme::Get("bg-button-neutral")
68  ) = 0;
69  virtual LateReturn<> ShowErrorAlert(std::string message, std::string button_text) = 0;
70 };
71 
72 } //namespace AlgAudio
73 
74 #endif // IALERTABLE_HPP
Definition: Color.hpp:28
Definition: Alertable.hpp:58
Definition: Alertable.hpp:50
virtual LateReturn< int > ShowSimpleAlert(std::string message, std::string button1_text, std::string button2_text, AlertType type=AlertType::NONE, Color button1_color=Theme::Get("bg-button-neutral"), Color button2_color=Theme::Get("bg-button-neutral"))=0
virtual LateReturn ShowErrorAlert(std::string message, std::string button_text)=0
Definition: Alertable.hpp:26
WindowNotAlertable(std::string t)
Definition: Alertable.hpp:51
ButtonID
Definition: Alertable.hpp:30
Definition: LateReturn.hpp:35
AlertType
Definition: Alertable.hpp:42
static const Color & Get(const std::string &)
Definition: Exception.hpp:29