Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07_rc3 / src / synfigapp / uimanager.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file uimanager.h
3 **      \brief User Interface Manager Class
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_APP_UIMANAGER_H
26 #define __SYNFIG_APP_UIMANAGER_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <ETL/handle>
31 #include <synfig/general.h>
32 #include <synfig/string.h>
33 #include <sigc++/object.h>
34
35 /* === M A C R O S ========================================================= */
36
37 /* === T Y P E D E F S ===================================================== */
38
39 /* === C L A S S E S & S T R U C T S ======================================= */
40
41 namespace synfigapp {
42
43 class UIInterface : public etl::shared_object, public synfig::ProgressCallback, public sigc::trackable
44 {
45 public:
46         enum Response
47         {
48                 RESPONSE_CANCEL=-1,
49                 RESPONSE_NO=0,
50                 RESPONSE_YES=1,
51                 RESPONSE_OK=2
52         };
53         virtual ~UIInterface() { }
54         virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
55         virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
56         virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)=0;
57 };
58
59 class DefaultUIInterface : public UIInterface
60 {
61 public:
62         Response yes_no(const std::string &/*title*/, const std::string &/*message*/,Response dflt)
63                 { return dflt; }
64         Response yes_no_cancel(const std::string &/*title*/, const std::string &/*message*/,Response dflt)
65                 { return dflt; }
66         Response ok_cancel(const std::string &/*title*/, const std::string &/*message*/,Response dflt)
67                 { return dflt; }
68
69         bool task(const std::string &/*task*/)
70                 { return true; }
71         bool error(const std::string &/*task*/)
72                 { return true; }
73         bool warning(const std::string &/*task*/)
74                 { return true; }
75         bool amount_complete(int /*current*/, int /*total*/)
76                 { return true; }
77 };
78
79 class ConfidentUIInterface : public UIInterface
80 {
81 public:
82         Response yes_no(const std::string &/*title*/, const std::string &/*message*/,Response /*dflt*/)
83                 { return RESPONSE_YES; }
84         Response yes_no_cancel(const std::string &/*title*/, const std::string &/*message*/,Response /*dflt*/)
85                 { return RESPONSE_YES; }
86         Response ok_cancel(const std::string &/*title*/, const std::string &/*message*/,Response /*dflt*/)
87                 { return RESPONSE_OK; }
88
89         bool task(const std::string &/*task*/)
90                 { return true; }
91         bool error(const std::string &/*task*/)
92                 { return true; }
93         bool warning(const std::string &/*task*/)
94                 { return true; }
95         bool amount_complete(int /*current*/, int /*total*/)
96                 { return true; }
97 };
98
99 class ConsoleUIInterface : public UIInterface
100 {
101 public:
102         Response yes_no(const std::string &title, const std::string &message,Response dflt);
103         Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt);
104         Response ok_cancel(const std::string &title, const std::string &message,Response dflt);
105
106         bool task(const std::string &task);
107         bool error(const std::string &task);
108         bool warning(const std::string &task);
109         bool amount_complete(int current, int total);
110 };
111
112 }; // END of namespace synfigapp
113
114 /* === E N D =============================================================== */
115
116 #endif