00001
00021
00022
00023
00024
00025 #ifndef __SYNFIG_APP_UIMANAGER_H
00026 #define __SYNFIG_APP_UIMANAGER_H
00027
00028
00029
00030 #include <ETL/handle>
00031 #include <synfig/general.h>
00032 #include <synfig/string.h>
00033 #include <sigc++/object.h>
00034
00035
00036
00037
00038
00039
00040
00041 namespace synfigapp {
00042
00043 class UIInterface : public etl::shared_object, public synfig::ProgressCallback, public sigc::trackable
00044 {
00045 public:
00046 enum Response
00047 {
00048 RESPONSE_CANCEL=-1,
00049 RESPONSE_NO=0,
00050 RESPONSE_YES=1,
00051 RESPONSE_OK=2
00052 };
00053 virtual ~UIInterface() { }
00054 virtual Response confirmation(const std::string &title, const std::string &primaryText,
00055 const std::string &secondaryText, const std::string &confirmPhrase,
00056 const std::string &cancelPhrase, Response dflt=RESPONSE_OK)=0;
00057 virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
00058 virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
00059 virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)=0;
00060 };
00061
00062 class DefaultUIInterface : public UIInterface
00063 {
00064 public:
00065 Response confirmation(const std::string &, const std::string &,
00066 const std::string &, const std::string &,
00067 const std::string &, Response dflt)
00068 { return dflt; }
00069 Response yes_no(const std::string &, const std::string &,Response dflt)
00070 { return dflt; }
00071 Response yes_no_cancel(const std::string &, const std::string &,Response dflt)
00072 { return dflt; }
00073 Response ok_cancel(const std::string &, const std::string &,Response dflt)
00074 { return dflt; }
00075
00076 bool task(const std::string &)
00077 { return true; }
00078 bool error(const std::string &)
00079 { return true; }
00080 bool warning(const std::string &)
00081 { return true; }
00082 bool amount_complete(int , int )
00083 { return true; }
00084 };
00085
00086 class ConfidentUIInterface : public UIInterface
00087 {
00088 public:
00089 Response confirmation(const std::string &, const std::string &,
00090 const std::string &, const std::string &,
00091 const std::string &, Response )
00092 { return RESPONSE_OK; }
00093 Response yes_no(const std::string &, const std::string &,Response )
00094 { return RESPONSE_YES; }
00095 Response yes_no_cancel(const std::string &, const std::string &,Response )
00096 { return RESPONSE_YES; }
00097 Response ok_cancel(const std::string &, const std::string &,Response )
00098 { return RESPONSE_OK; }
00099
00100 bool task(const std::string &)
00101 { return true; }
00102 bool error(const std::string &)
00103 { return true; }
00104 bool warning(const std::string &)
00105 { return true; }
00106 bool amount_complete(int , int )
00107 { return true; }
00108 };
00109
00110 class ConsoleUIInterface : public UIInterface
00111 {
00112 public:
00113 Response confirmation(const std::string &title, const std::string &primaryText,
00114 const std::string &secondaryText, const std::string &confirmPhrase,
00115 const std::string &cancelPhrase, Response dflt);
00116 Response yes_no(const std::string &title, const std::string &message,Response dflt);
00117 Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt);
00118 Response ok_cancel(const std::string &title, const std::string &message,Response dflt);
00119
00120 bool task(const std::string &task);
00121 bool error(const std::string &task);
00122 bool warning(const std::string &task);
00123 bool amount_complete(int current, int total);
00124 };
00125
00126 };
00127
00128
00129
00130 #endif