IWORKStyle.h Source File documentation

IWORKStyle.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libetonyek project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef IWORKSTYLE_H_INCLUDED
11 #define IWORKSTYLE_H_INCLUDED
12
13 #include "IWORKStyle_fwd.h"
14
15 #include <boost/any.hpp>
16 #include <boost/optional.hpp>
17
18 #include "IWORKPropertyMap.h"
19 #include "IWORKStylesheet.h"
20
21 namespace libetonyek
22 {
23
24 class IWORKStyleStack;
25
28 class IWORKStyle
29 {
30 public:
31 IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const boost::optional<std::string> &parentIdent);
32 IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const IWORKStylePtr_t &parent);
33
39 bool link(const IWORKStylesheetPtr_t &stylesheet);
40
45 void flatten();
46
49 const IWORKPropertyMap &getPropertyMap() const;
50
55 template<class Property>
56 bool has() const
57 {
58 return m_props.has<Property>(true);
59 }
60
65 template<class Property>
66 const typename IWORKPropertyInfo<Property>::ValueType &get() const
67 {
68 return m_props.get<Property>(true);
69 }
70
71 const boost::optional<std::string> &getIdent() const;
72
73 private:
74 IWORKPropertyMap m_props;
75
76 const boost::optional<std::string> m_ident;
77 const boost::optional<std::string> m_parentIdent;
78 IWORKStylePtr_t m_parent;
79 };
80
81 }
82
83 #endif // IWORKSTYLE_H_INCLUDED
84
85 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
IWORKStyle_fwd.h
libetonyek::IWORKStylesheetPtr_t
boost::shared_ptr< IWORKStylesheet > IWORKStylesheetPtr_t
Definition: IWORKStylesheet.h:19
libetonyek::IWORKStyle::link
bool link(const IWORKStylesheetPtr_t &stylesheet)
Find the parent style by its ID.
Definition: IWORKStyle.cpp:35
libetonyek
Definition: IWORKBezierElement.cpp:18
libetonyek::IWORKStyle::has
bool has() const
Check for the presence of a property.
Definition: IWORKStyle.h:56
libetonyek::IWORKStyle::getIdent
const boost::optional< std::string > & getIdent() const
Definition: IWORKStyle.cpp:71
libetonyek::IWORKToken::stylesheet
Definition: IWORKToken.h:257
libetonyek::IWORKStyle
Represents a hierarchical style.
Definition: IWORKStyle.h:28
libetonyek::IWORKStylePtr_t
boost::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::IWORKStyle::getPropertyMap
const IWORKPropertyMap & getPropertyMap() const
Get the style&#39;s property map.
Definition: IWORKStyle.cpp:66
libetonyek::IWORKStyle::IWORKStyle
IWORKStyle(const IWORKPropertyMap &props, const boost::optional< std::string > &ident, const boost::optional< std::string > &parentIdent)
Definition: IWORKStyle.cpp:17
libetonyek::IWORKPropertyMap
Represents a (hierarchical) property map.
Definition: IWORKPropertyMap.h:23
libetonyek::IWORKStyle::flatten
void flatten()
Copy attributes from parent style (recursively).
Definition: IWORKStyle.cpp:61
libetonyek::IWORKPropertyMap::get
const IWORKPropertyInfo< Property >::ValueType & get(bool lookInParent=false) const
Retrieve the value of a property.
Definition: IWORKPropertyMap.h:112
libetonyek::IWORKToken::ident
Definition: IWORKToken.h:317
libetonyek::IWORKPropertyInfo
Definition: IWORKPropertyInfo.h:21
libetonyek::IWORKStyle::m_parentIdent
const boost::optional< std::string > m_parentIdent
Definition: IWORKStyle.h:77
libetonyek::IWORKStyle::m_ident
const boost::optional< std::string > m_ident
Definition: IWORKStyle.h:76
IWORKPropertyMap.h
IWORKStylesheet.h
libetonyek::IWORKPropertyMap::has
bool has(bool lookInParent=false) const
Check for the presence of a property.
Definition: IWORKPropertyMap.h:77
libetonyek::IWORKStyle::m_props
IWORKPropertyMap m_props
Definition: IWORKStyle.h:74
libetonyek::IWORKStyle::m_parent
IWORKStylePtr_t m_parent
Definition: IWORKStyle.h:78