![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2010 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtToolbarPath.h,v $ $Revision: 1.9 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 00015 #include <vrvCore/vrvCore.h> 00016 #include <makArchives/DtSerialize.h> 00017 #include <vrvCore/DtMenuPath.h> 00018 00019 #include <string> 00020 00021 namespace makVrv 00022 { 00023 class DtMenuPath; 00024 00043 class DT_DLL_VRVCORE DtToolbarPath 00044 { 00045 public: 00046 00047 //Internal class which is used to ensure that it is not possible to incorrectly 00048 //build a toolbar path. 00049 struct DT_DLL_VRVCORE ToolbarPathBuilder 00050 { 00051 public: 00052 friend class DtToolbarPath; 00053 00054 ToolbarPathBuilder(const DtMenuPath&); 00055 00057 ToolbarPathBuilder mainMenu(const std::string&); 00058 00060 DtToolbarPath widget(const std::string& name) const; 00061 00062 //Add a menu to the path. 00063 ToolbarPathBuilder menu(const std::string& name) const; 00064 00065 //Start a toolbar. 00066 ToolbarPathBuilder toolbar(const std::string& name) const; 00067 00070 DtToolbarPath item(const std::string& name) const; 00071 00073 DtToolbarPath separator(const std::string& name) const; 00074 00075 protected: 00076 00077 //Access the path. 00078 inline const std::string& path() const { return myPath; } 00079 00080 //The CTOR this class is automatically created by the DtToolbarPath. 00081 ToolbarPathBuilder(const std::string& name); 00082 00083 std::string myPath; 00084 }; 00085 00086 // CTOR. Used for serialization 00087 DtToolbarPath(); 00088 00089 //Useful CTOR. 00090 DtToolbarPath(const ToolbarPathBuilder& builder); 00091 00092 //Useful CTOR. 00093 DtToolbarPath(const DtMenuPath& copy); 00094 00096 DtToolbarPath(const DtToolbarPath& copy); 00097 00098 //Start a toolbar. 00099 static ToolbarPathBuilder toolbar(const std::string& name); 00100 00101 //Start a toolbar row. 00102 static ToolbarPathBuilder row(const std::string& name); 00103 00104 //Create an empty menu path. 00105 static DtToolbarPath empty(); 00106 00107 //Create an empty root menu path. 00108 static DtToolbarPath root(); 00109 00112 DtToolbarPath menuPart() const; 00113 00115 DtToolbarPath toolbarPart() const; 00116 00118 DtToolbarPath parentMenu() const; 00119 00121 bool isChildOf(const DtToolbarPath& parent) const; 00122 00124 bool isDescendant(const DtToolbarPath& ancestor) const; 00125 00127 bool isSiblingOf(const DtToolbarPath& sibling) const; 00128 00130 bool isToolbar() const; 00131 00133 bool isAbsolutePath() const; 00134 00136 bool isWidget() const; 00137 00138 //Get the current path. 00139 inline const std::string& path() const { return myPath; } 00140 00142 bool isEmpty() const; 00143 00145 bool isItem() const; 00146 00148 bool isMainMenu() const; 00149 00151 bool isSeparator() const; 00152 00154 bool isMenu() const; 00155 00157 bool isRow() const; 00158 00160 DtToolbarPath rootParentMenu() const; 00161 00164 std::string name() const; 00165 00166 bool operator ==(const DtToolbarPath& other) const; 00167 bool operator <(const DtToolbarPath& other) const; 00168 bool operator !=(const DtToolbarPath& other) const; 00169 00170 DT_DECLARE_serialize_FUNCTIONS 00171 00172 protected: 00173 00175 template<class Archive> 00176 void _serialize(Archive & ar, const unsigned int version) 00177 { 00178 ar & DT_SERIALIZE_MEMBER(myPath); 00179 } 00180 00182 DtToolbarPath(const std::string& path); 00183 00184 protected: 00185 00187 std::string myPath; 00188 }; 00189 }