ConfigurationEditor.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_ConfigurationEditor_h
00003 #define INCLUDED_ConfigurationEditor_h
00004
00005 #include "Behaviors/Controls/ControlBase.h"
00006 #include "Behaviors/Controls/FileInputControl.h"
00007 #include "Behaviors/Controls/StringInputControl.h"
00008 #include "Shared/plistCollections.h"
00009
00010
00011 class ConfigurationEditor : public ControlBase {
00012
00013
00014
00015
00016 public:
00017
00018 ConfigurationEditor(plist::Collection * rootCollection=NULL)
00019 : ControlBase("ConfigurationEditor","Provides interactive editing and loading/saving of a plist::Collection"),
00020 root(rootCollection), path(), load(rootCollection), save(rootCollection)
00021 {init();}
00022
00023 ConfigurationEditor(const std::string& n, plist::Collection * rootCollection=NULL)
00024 : ControlBase(n,"Provides interactive editing and loading/saving of a plist::Collection"),
00025 root(rootCollection), path(), load(rootCollection), save(rootCollection)
00026 {init();}
00027
00028 ConfigurationEditor(const std::string& n, const std::string& d, plist::Collection * rootCollection=NULL)
00029 : ControlBase(n,d), root(rootCollection), path(), load(rootCollection), save(rootCollection)
00030 {init();}
00031
00032
00033 virtual ~ConfigurationEditor() { clearSlots(); }
00034
00035 protected:
00036
00037 virtual void init();
00038
00039
00040
00041
00042
00043
00044 public:
00045
00046 virtual void refresh();
00047
00048
00049 virtual void clearSlots();
00050
00051
00052 virtual void setRootCollection(plist::Collection* rootCollection);
00053
00054
00055 virtual void setPath(const std::string& p);
00056
00057
00058 static plist::Dictionary& getObjectTemplates();
00059
00060
00061
00062
00063
00064 protected:
00065 plist::Collection * root;
00066 std::string path;
00067
00068
00069 class LoadSettings : public FileInputControl {
00070 public:
00071
00072 LoadSettings(plist::Collection * rootCollection) : FileInputControl("Load...","Load settings from disk","config"), rootcol(rootCollection) {}
00073
00074 virtual void setRootCollection(plist::Collection* rootCollection) { rootcol=rootCollection; }
00075 protected:
00076 virtual ControlBase* selectedFile(const std::string& f);
00077 plist::Collection * rootcol;
00078 private:
00079 LoadSettings(const LoadSettings&);
00080 LoadSettings& operator=(const LoadSettings&);
00081 };
00082 LoadSettings load;
00083
00084
00085 class SaveSettings : public FileInputControl {
00086 public:
00087
00088 SaveSettings(plist::Collection * rootCollection) : FileInputControl("Save...","Save settings to disk","config"), rootcol(rootCollection) { setAcceptNonExistant(true); }
00089
00090 virtual void setRootCollection(plist::Collection* rootCollection) { rootcol=rootCollection; }
00091 protected:
00092 virtual ControlBase* selectedFile(const std::string& f);
00093 plist::Collection * rootcol;
00094 private:
00095 SaveSettings(const SaveSettings&);
00096 SaveSettings& operator=(const SaveSettings&);
00097 };
00098 SaveSettings save;
00099
00100
00101 class AddCollectionEntry : public ControlBase {
00102 public:
00103 AddCollectionEntry(plist::Collection& target) : ControlBase("Add New Entry"), tgt(&target) {}
00104 virtual void refresh();
00105 virtual void deactivate() { clearSlots(); ControlBase::deactivate(); }
00106 protected:
00107 plist::Collection * tgt;
00108 private:
00109 AddCollectionEntry(const AddCollectionEntry&);
00110 AddCollectionEntry& operator=(const AddCollectionEntry&);
00111 };
00112
00113
00114 class NewCollectionEntry : public ControlBase {
00115 public:
00116 NewCollectionEntry(const std::string& n, plist::Collection& target, plist::ObjectBase& templ) : ControlBase(n), tgt(&target), obj(&templ) {}
00117 virtual void refresh();
00118 virtual void deactivate() { clearSlots(); ControlBase::deactivate(); }
00119 virtual ControlBase * doSelect();
00120 protected:
00121 plist::Collection * tgt;
00122 plist::ObjectBase * obj;
00123 private:
00124 NewCollectionEntry(const NewCollectionEntry&);
00125 NewCollectionEntry& operator=(const NewCollectionEntry&);
00126 };
00127
00128
00129
00130 class NamedEnumerationEditor : public StringInputControl {
00131 public:
00132
00133 NamedEnumerationEditor(const std::string& n, const std::string& prompt, plist::NamedEnumerationBase& target) : StringInputControl(n,prompt), tgt(&target) {}
00134 virtual void refresh();
00135
00136 virtual void deactivate() { clearSlots(); StringInputControl::deactivate(); }
00137
00138 virtual ControlBase * doSelect();
00139
00140 virtual void setHilights(const std::vector<unsigned int>& hi) {
00141 if(hi.empty())
00142 StringInputControl::setHilights(hi);
00143 else
00144 ControlBase::setHilights(std::vector<unsigned int>(1,hi.front()));
00145 }
00146 protected:
00147 plist::NamedEnumerationBase * tgt;
00148 private:
00149 NamedEnumerationEditor(const NamedEnumerationEditor&);
00150 NamedEnumerationEditor& operator=(const NamedEnumerationEditor&);
00151 };
00152
00153
00154
00155
00156
00157 private:
00158 ConfigurationEditor(const ConfigurationEditor&);
00159 ConfigurationEditor& operator=(const ConfigurationEditor&);
00160 };
00161
00162
00163
00164
00165
00166 #endif