![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2008 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtMenuPath.h,v $ $Revision: 1.9 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #ifndef DtMenuPath_H_ 00014 #define DtMenuPath_H_ 00015 00016 #include <vrvCore/vrvCore.h> 00017 #include <string> 00018 00019 namespace makVrv 00020 { 00021 00030 class DT_DLL_VRVCORE DtMenuPath 00031 { 00032 public: 00033 00034 //Internal class which is used to ensure that it is not possible to incorrectly 00035 //build a menu path. 00036 struct DT_DLL_VRVCORE MenuPathBuilder 00037 { 00038 public: 00039 friend class DtMenuPath; 00040 00041 //Add a menu to the path. 00042 MenuPathBuilder menu(const std::string& name) const; 00043 00046 DtMenuPath item(const std::string& name) const; 00047 00050 DtMenuPath operator/(const std::string& name) const; 00051 00053 DtMenuPath separator(const std::string& name) const; 00054 00055 protected: 00056 00057 //Access the path. 00058 inline const std::string& path() const { return myPath; } 00059 00060 //The CTOR this class is automatically created by the DtMenuPath. 00061 MenuPathBuilder(const std::string& name); 00062 00063 std::string myPath; 00064 }; 00065 00066 //Useful CTOR. 00067 DtMenuPath(const MenuPathBuilder& builder); 00068 00070 DtMenuPath(const DtMenuPath& copy); 00071 00072 //Create an empty menu path. 00073 static DtMenuPath empty(); 00074 00075 //Create an empty root menu path. 00076 static DtMenuPath root(); 00077 00078 //Create an empty popup menu path. 00079 static DtMenuPath popup(); 00080 00081 //Start a main menu. 00082 static MenuPathBuilder mainMenu(const std::string& name); 00083 00084 //Start a popup menu. 00085 static MenuPathBuilder popupMenu( const std::string& name ); 00086 00087 //Start a relative menu. 00088 static MenuPathBuilder menu(const std::string& name); 00089 00090 //Get the current path. 00091 inline const std::string& path() const { return myPath; } 00092 00095 DtMenuPath menuPart() const; 00096 00099 DtMenuPath parentMenu() const; 00100 00102 DtMenuPath rootParentMenu() const; 00103 00106 std::string name() const; 00107 00109 bool isEmpty() const; 00110 00112 bool isAbsolutePath() const; 00113 00115 bool isMainMenu() const; 00116 00118 bool isPopupPath() const; 00119 00121 bool isMenu() const; 00122 00124 bool isItem() const; 00125 00127 bool isChildOf(const DtMenuPath& parent) const; 00128 00130 bool isDescendant(const DtMenuPath& ancestor) const; 00131 00133 bool isSiblingOf(const DtMenuPath& sibling) const; 00134 00136 bool isSeparator() const; 00137 00138 bool operator ==(const DtMenuPath& other) const; 00139 bool operator <(const DtMenuPath& other) const; 00140 bool operator !=(const DtMenuPath& other) const; 00141 00142 protected: 00143 00145 DtMenuPath(const std::string& path); 00146 00148 std::string myPath; 00149 }; 00150 00151 00152 } 00153 00154 #endif 00155