Changeset f89c1c for molecuilder/src/UIElements/Dialog.hpp
- Timestamp:
- Jan 13, 2010, 10:22:29 AM (16 years ago)
- Children:
- 3896fc
- Parents:
- c489d9
- File:
-
- 1 edited
-
molecuilder/src/UIElements/Dialog.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/UIElements/Dialog.hpp
rc489d9 rf89c1c 12 12 #include<list> 13 13 14 class MoleculeListClass; 15 class Molecule; 16 14 17 class Dialog 15 18 { … … 18 21 virtual ~Dialog(); 19 22 20 void queryInt(const char *, int *); 21 void queryString(const char*, std::string *); 23 virtual void queryInt(const char *, int *)=0; 24 virtual void queryString(const char*, std::string *)=0; 25 // virtual void queryMolecule(const char*,MoleculeListClass*,Molecule*)=0; 22 26 23 virtual voiddisplay();27 virtual bool display(); 24 28 25 29 protected: 26 virtual void handleInt(std::string,int *)=0;27 virtual void handleString(std::string,std::string *)=0;28 29 30 private:31 30 // methodology for handling queries 32 31 // all queries are stored and then performed at appropriate times 33 32 34 33 //these queries can be handled by this dialog 35 enum QueryType {Int,String}; 36 struct Query { 34 35 //TODO: Find a way to reduce complexity... 36 //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs 37 //usual approach for reducing inheritance complexity (strategy pattern) does not work, 38 //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot) 39 40 //base class for all queries 41 class Query { 42 public: 43 Query(std::string _title); 44 ~Query(); 45 virtual bool handle()=0; 46 virtual void setResult()=0; 47 protected: 48 const std::string getTitle() const; 49 private: 37 50 std::string title; 38 QueryType type;39 void *target;40 51 }; 41 52 42 std::list<Query> queries; 53 //Specialized classes for certain types. GUI-Types are not specialized at this time 54 class IntQuery : public Query { 55 public: 56 IntQuery(std::string title,int *_target); 57 ~IntQuery(); 58 virtual bool handle()=0; 59 virtual void setResult(); 60 protected: 61 int tmp; 62 private: 63 int *target; 64 }; 65 66 class StringQuery : public Query { 67 public: 68 StringQuery(std::string title,std::string *_target); 69 ~StringQuery(); 70 virtual bool handle()=0; 71 virtual void setResult(); 72 protected: 73 std::string tmp; 74 private: 75 std::string *target; 76 }; 77 78 void registerQuery(Query* query); 79 80 private: 81 std::list<Query*> queries; 43 82 44 83 };
Note:
See TracChangeset
for help on using the changeset viewer.
