VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtPageConfiguration.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2010 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile:  $ $Revision:  $ $State:  $
00007 ******************************************************************************/
00008 
00012 
00013 #pragma once
00014 
00015 #include <vrvCore/vrvCore.h>
00016 #include <vrvCore/DtPagePath.h>
00017 #include <vrvUtil/DtConfiguration.h>
00018 #include <vrvUtil/DtUnicode.h>
00019 #include <boost/unordered_map.hpp>
00020 #include <list>
00021 #include <set>
00022 #include <boost/serialization/set.hpp>
00023 
00024 namespace makVrv
00025 {
00028    class DT_DLL_VRVCORE DtPageConfiguration : public DtConfiguration
00029    {   
00030 
00031    public:
00032 
00033       typedef std::list<DtPagePath> PagePathList;
00034       typedef std::set<DtPagePath> PagePathSet;
00035 
00037       DtPageConfiguration();
00038 
00040       ~DtPageConfiguration();
00041 
00043       DtPageConfiguration& operator=(const DtPageConfiguration& rhs);
00044 
00045       enum PageCollectionLocation
00046       {
00047          DockLeft = 0,
00048          DockRight = 1,
00049          DockTop = 2,
00050          DockBottom = 3,
00051          FloatLeft = DockLeft | 4,
00052          FloatRight = DockRight | 4,
00053          FloatTop = DockTop | 4,
00054          FloatBottom = DockBottom | 4,
00055          Dialog,
00056          Location_End
00057       };
00058 
00059       struct PageColectionGeometry
00060       {
00061          int myWindowId;
00062          int myTop;
00063          int myLeft;
00064          int myWidth;         
00065          int myHeight;
00066 
00067          PageColectionGeometry()
00068          {
00069             myWindowId = -1;
00070             myTop = 10;
00071             myLeft = 10;
00072             myWidth = 10;
00073             myHeight = 10;
00074          }
00075 
00076          template<class Archive>
00077          void serialize(Archive & ar, const unsigned int version)
00078          {
00079             ar & DT_SERIALIZE_MEMBER(myTop);
00080             ar & DT_SERIALIZE_MEMBER(myLeft);
00081             ar & DT_SERIALIZE_MEMBER(myWidth);
00082             ar & DT_SERIALIZE_MEMBER(myHeight);
00083          }
00084       };
00085 
00086       struct PageCollectionState
00087       {
00088          DtUnicode myTitle; // deprecated.  Title is NOT state
00089          PageCollectionLocation myLocation;
00090          PageColectionGeometry myFloatingGeometry;
00091          PageColectionGeometry myDockedGeometry;
00092          bool myVisibleFlag;
00093          int myTabIndex;
00094          std::string myPageToShow;
00095          bool myClosable;
00096          bool myFloatable;
00097          bool myMovable;
00098 
00099          PageCollectionState()
00100          {
00101             myLocation = DtPageConfiguration::DockLeft;
00102             myVisibleFlag = true;
00103             myClosable = true;
00104             myFloatable = true;
00105             myMovable = true;
00106             myTabIndex = -1;
00107             myPageToShow = "";
00108          }
00109 
00110          template<class Archive>
00111          void serialize(Archive & ar, const unsigned int version)
00112          {
00113             // Name of temporary variable is very important here for
00114             // serializarion/deserialization. That name is used to define
00115             // the xml tag inside the record! Do not change it!
00116             if ( version < 1 )
00117             {
00118                std::string myLocalTitle;
00119                myTitle.toUtf8(myLocalTitle);
00120                ar & DT_SERIALIZE_MEMBER(myLocalTitle);
00121                myTitle = DtUnicode::fromUtf8(myLocalTitle);
00122             }
00123             ar & DT_SERIALIZE_MEMBER(myLocation);
00124             ar & DT_SERIALIZE_MEMBER(myDockedGeometry);
00125             ar & DT_SERIALIZE_MEMBER(myFloatingGeometry);
00126             ar & DT_SERIALIZE_MEMBER(myVisibleFlag);
00127             ar & DT_SERIALIZE_MEMBER(myPageToShow);
00128             ar & DT_SERIALIZE_MEMBER(myTabIndex);
00129             if ( version > 1 )
00130             {
00131                ar & DT_SERIALIZE_MEMBER(myClosable);
00132                ar & DT_SERIALIZE_MEMBER(myFloatable);
00133                ar & DT_SERIALIZE_MEMBER(myMovable);
00134             }
00135          }         
00136       };
00137 
00138       typedef std::map<std::string,PageCollectionState> PageCollectionStatesMap;
00139       typedef std::map<std::string,DtUnicode> PageCollectionTitlesMap;
00140 
00142       void addPageCollection(const std::string& collectionClassName,
00143          const DtUnicode& pageTitle, PageCollectionLocation location, 
00144          bool visible, const std::string& pageClassToShow, bool closable = true,
00145          bool floatable = true, bool movable = true);
00146 
00148       void removePageCollection(const std::string& collectionClassName);
00149 
00153       const PageCollectionState* findPageCollectionState(const std::string& collectionClassName) const;
00154       PageCollectionState* findPageCollectionState(const std::string& collectionClassName);
00155 
00159       const DtUnicode* findPageCollectionTitle(const std::string& collectionClassName) const;
00160       DtUnicode* findPageCollectionTitle(const std::string& collectionClassName);
00161 
00163       void addPagePath(const DtPagePath&, int weight = -1);
00164 
00168       void addPagePathAfter(const DtPagePath& newPath, const DtPagePath& relativeTo);
00169 
00171       void addPagePathBefore(const DtPagePath& newPath, const DtPagePath& relativeTo);
00172 
00174       void addConfiguration(const DtPageConfiguration& subConfiguration);
00175 
00177       void removePagePath(const DtPagePath&);
00178 
00180       void getRootPaths(PagePathList& children) const;
00181 
00190       void getChildren(const DtPagePath& path, PagePathList& children) const;
00191 
00193       void sortChildren(PagePathList& children) const;
00194 
00196       int getNewWeight();
00197 
00200       void merge(const DtPageConfiguration& rhs);
00201 
00204       void copyValuesFrom( const DtPageConfiguration& source );
00205 
00207       bool hasPagePath(const DtPagePath& p) const;
00208 
00210       const PageCollectionStatesMap& states() const;
00211 
00213       const PageCollectionTitlesMap& titles() const;
00214 
00220       DT_DECLARE_serialize_FUNCTIONS
00221    protected:
00222 
00223       template<class Archive>
00224       void _serialize(Archive & ar, const unsigned int version)
00225       {
00227          ar & DT_SERIALIZE_BASE(DtConfiguration);
00228          ar & DT_SERIALIZE_MEMBER(myCurrentWeight);         
00229          ar & DT_SERIALIZE_MEMBER(myCollections);
00230          ar & DT_SERIALIZE_MEMBER(myPagePaths);
00231          ar & DT_SERIALIZE_MEMBER(myPageOrder);
00232       }
00233 
00234       bool sortAbsolute(const DtPagePath& a, const DtPagePath& b) const;
00235 
00236       struct OrderParameters
00237       {
00238          OrderParameters()
00239          : orderWeight(0)
00240          , relative(DtPagePath::empty())
00241          , beforeRelative(false)
00242          {
00243          }
00244 
00245          template<class Archive>
00246          void serialize(Archive & ar, const unsigned int version)
00247          {
00248             ar & DT_SERIALIZE_MEMBER(orderWeight);
00249             ar & DT_SERIALIZE_MEMBER(relative);
00250             ar & DT_SERIALIZE_MEMBER(beforeRelative);
00251          }
00252 
00253          int orderWeight;
00254          DtPagePath relative;
00255          bool beforeRelative;
00256       };
00257 
00258    protected:
00259 
00260       typedef std::map<DtPagePath,OrderParameters> PagePathOrderMap; 
00261 
00262       PagePathSet myPagePaths;     
00263       PagePathOrderMap myPageOrder;
00264       PageCollectionStatesMap myCollections;
00265       PageCollectionTitlesMap myPageCollectionTitles;
00266       int myCurrentWeight;
00267    };
00268 }
00269 BOOST_CLASS_VERSION(makVrv::DtPageConfiguration::PageCollectionState,2)

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)