VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtToolbarConfiguration.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2010 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtToolbarConfiguration.h,v $ $Revision: 1.9 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #pragma once
00014 
00015 #include <vrvCore/vrvCore.h>
00016 #include <vrvCore/DtToolbarPath.h>
00017 #include <vrvCore/DtMenuPath.h>
00018 #include <vrvCore/DtMenuConfiguration.h>
00019 
00020 #include <list>
00021 #include <set>
00022 #include <boost/serialization/set.hpp>
00023 
00024 namespace makVrv
00025 {
00028    class DT_DLL_VRVCORE DtToolbarConfiguration : public DtConfiguration
00029    {
00030    public:
00031 
00032       typedef std::list<DtToolbarPath> ToolbarPathList;
00033       typedef std::set<DtToolbarPath> ToolbarPathSet;      
00034 
00035       enum ToolbarLocation
00036       {
00037          DockLeft = 0,
00038          DockRight = 1,
00039          DockTop = 2,
00040          DockBottom = 3,
00041          DockNone = 4
00042       };
00043 
00044       struct ToolbarGeometry
00045       {
00046          int windowId;
00047          int myTop;
00048          int myLeft;
00049          int myHeight;
00050          int myWidth;
00051 
00052          ToolbarGeometry()
00053          {
00054             windowId = -1;
00055             myTop = 0;
00056             myLeft = 0;
00057             myWidth = 0;
00058             myHeight = 0;
00059          }
00060 
00061          template<class Archive>
00062          void serialize(Archive & ar, const unsigned int version)
00063          {
00064             ar & DT_SERIALIZE_MEMBER(windowId);
00065             ar & DT_SERIALIZE_MEMBER(myTop);
00066             ar & DT_SERIALIZE_MEMBER(myLeft);
00067             ar & DT_SERIALIZE_MEMBER(myHeight);
00068             ar & DT_SERIALIZE_MEMBER(myWidth);
00069          }
00070       };
00071 
00072       struct ToolbarState
00073       {
00074          bool myIsVisible;
00075          bool myIsFloating;
00076          ToolbarLocation myLocation;
00077          ToolbarGeometry myGeometry;
00078 
00079          template<class Archive>
00080          void serialize(Archive & ar, const unsigned int version)
00081          {
00082             ar & DT_SERIALIZE_MEMBER(myIsVisible);
00083             ar & DT_SERIALIZE_MEMBER(myIsFloating);
00084             ar & DT_SERIALIZE_MEMBER(myLocation);
00085             ar & DT_SERIALIZE_MEMBER(myGeometry);
00086          }
00087       };
00088 
00089    public:
00090 
00091       typedef std::map<DtToolbarPath,ToolbarState> ToolbarStateMap;
00092 
00094       DtToolbarConfiguration ();
00095 
00097       ~DtToolbarConfiguration ();
00098 
00100       void addToolbarPath(const DtToolbarPath&, int weight = -1);
00101 
00102       void addToolbarPathAfter(const DtToolbarPath& newPath, const DtToolbarPath& relativeTo);
00103       void addToolbarPathBefore(const DtToolbarPath& newPath, const DtToolbarPath& relativeTo);
00104 
00106       void addMenuPath(const DtMenuPath&, int weight = -1);
00107 
00108       void addMenuPathAfter(const DtMenuPath& newPath, const DtMenuPath& relativeTo);
00109       void addMenuPathBefore(const DtMenuPath& newPath, const DtMenuPath& relativeTo);
00110       void removeMenuPath(const DtMenuPath& newPath);
00111 
00113       void addConfiguration(const DtToolbarConfiguration& subConfiguration);
00114 
00116       void removeToolbarPath(const DtToolbarPath&);
00117 
00119       void getRootPaths(ToolbarPathList& children) const;
00120 
00121       void getChildren(const DtToolbarPath& path, ToolbarPathList& children) const;
00122 
00124       void sortChildren(ToolbarPathList& children) const;
00125 
00127       int getNewWeight();
00128 
00129       DtToolbarConfiguration& operator=(const DtToolbarConfiguration& rhs)
00130       {
00131          if (this != &rhs)
00132          {
00133             myToolbarPaths = rhs.myToolbarPaths;
00134             myToolbarOrder = rhs.myToolbarOrder;
00135             myCurrentWeight = rhs.myCurrentWeight;
00136             myMenuConfiguration = rhs.myMenuConfiguration;
00137          }
00138 
00139          return *this;
00140       }
00141 
00145       const DtMenuConfiguration& menuConfiguration() const
00146       {
00147          return myMenuConfiguration;
00148       }
00149 
00152       void merge(const DtToolbarConfiguration& rhs);
00153 
00156       void copyValuesFrom( const DtToolbarConfiguration& source );
00157 
00158 
00161       void updateState(const DtToolbarPath& tb, ToolbarState& state);
00162 
00164       const ToolbarState* state(const DtToolbarPath& tb) const;
00165 
00167       const ToolbarStateMap& states() const;
00168 
00170       void setVisible( const DtToolbarPath& tb, bool isVisible );
00171 
00172       DT_DECLARE_serialize_FUNCTIONS
00173 
00174    protected:
00175 
00176       template<class Archive>
00177       void _serialize(Archive & ar, const unsigned int version)
00178       {
00180          ar & DT_SERIALIZE_BASE(DtConfiguration);
00181          ar & DT_SERIALIZE_MEMBER(myToolbarStates);         
00182       }
00183 
00184       bool sortAbsolute(const DtToolbarPath& a, const DtToolbarPath& b) const;
00185 
00186       struct OrderParameters
00187       {
00188          OrderParameters()
00189          : orderWeight(0)
00190          , relative(DtToolbarPath::empty())
00191          , beforeRelative(false)
00192          {
00193          }
00194 
00195          int orderWeight;
00196          DtToolbarPath relative;
00197          bool beforeRelative;
00198       };
00199 
00200       typedef std::map<DtToolbarPath,OrderParameters> ToolbarPathOrderMap;      
00201 
00202       ToolbarStateMap myToolbarStates;
00203       ToolbarPathSet myToolbarPaths;      
00204       ToolbarPathOrderMap myToolbarOrder;
00205       int myCurrentWeight;
00207       DtMenuConfiguration  myMenuConfiguration;
00208    };
00209 }
00210 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)