![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2008 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtMenuConfiguration.h,v $ $Revision: 1.9 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #ifndef DtMenuConfiguration_H_ 00014 #define DtMenuConfiguration_H_ 00015 00016 #include <vrvCore/vrvCore.h> 00017 #include <vrvCore/DtMenuPath.h> 00018 #include <vrvUtil/DtConfiguration.h> 00019 00020 #include <list> 00021 #include <set> 00022 00023 namespace makVrv 00024 { 00027 class DT_DLL_VRVCORE DtMenuConfiguration : public DtConfiguration 00028 { 00029 public: 00030 00031 //Ordered vector of paths. 00032 typedef std::list<DtMenuPath> MenuPathList; 00033 00034 typedef std::set<DtMenuPath> MenuPathSet; 00035 00036 public: 00038 DtMenuConfiguration(); 00039 00041 ~DtMenuConfiguration(); 00042 00044 void addMenuPath(const DtMenuPath&, int weight = -1); 00045 00049 void addMenuPathAfter(const DtMenuPath& newPath, const DtMenuPath& relativeTo); 00050 00052 void addMenuPathBefore(const DtMenuPath& newPath, const DtMenuPath& relativeTo); 00053 00055 void addConfiguration(const DtMenuConfiguration& subConfiguration); 00056 00058 void removeMenuPath(const DtMenuPath&); 00059 00061 void getRootPaths(MenuPathList& children) const; 00062 00071 void getChildren(const DtMenuPath& path, MenuPathList& children) const; 00072 00074 void sortChildren(MenuPathList& children) const; 00075 00077 int getNewWeight(); 00078 00079 DtMenuConfiguration& operator=(const DtMenuConfiguration& rhs) 00080 { 00081 if (this != &rhs) 00082 { 00083 myMenuPaths = rhs.myMenuPaths; 00084 myMenuOrder = rhs.myMenuOrder; 00085 myCurrentWeight = rhs.myCurrentWeight; 00086 } 00087 00088 return *this; 00089 } 00090 00093 void merge(const DtMenuConfiguration& rhs); 00094 00096 bool hasMenuPath(const DtMenuPath& p) const; 00097 00098 protected: 00099 00100 bool sortAbsolute(const DtMenuPath& a, const DtMenuPath& b) const; 00101 00102 struct OrderParameters 00103 { 00104 OrderParameters() 00105 : orderWeight(0) 00106 , relative(DtMenuPath::empty()) 00107 , beforeRelative(false) 00108 { 00109 } 00110 00111 int orderWeight; 00112 DtMenuPath relative; 00113 bool beforeRelative; 00114 }; 00115 00116 MenuPathSet myMenuPaths; 00117 00118 typedef std::map<DtMenuPath,OrderParameters> MenuPathOrderMap; 00119 MenuPathOrderMap myMenuOrder; 00120 00121 int myCurrentWeight; 00122 }; 00123 } 00124 00125 #endif 00126