1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwCssStyleState_h_
21 #define _KwCssStyleState_h_
24 * @file KwCssStyleState.h
25 * @brief Typed cascading style property state.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwCssAbstractStyleState.h"
30 #include "KwCssStyle.h"
36 /// Typed cascading style property state.
38 * @param T The type of the property.
41 class KwCssStyleState
: public KwCssAbstractStyleState
46 * Constructors + destructors
49 /// Default constructor.
51 : KwCssAbstractStyleState()
57 KwCssStyleState(const KwCssStyleState
& copy
)
58 : KwCssAbstractStyleState(copy
)
59 , m_value(copy
.m_value
)
64 virtual ~KwCssStyleState()
72 /// Create a new style for this state.
73 virtual KwCssAbstractStyle
* createStyle() const
75 return new KwCssStyle
<T
>;
78 /// Duplicate this style.
79 virtual KwCssAbstractStyleState
* duplicate() const
81 return new KwCssStyleState
<T
>(*this);
88 return m_value
.back();
100 /// Apply the style to this state.
101 virtual KwCssAbstractStyleState
& operator << (const KwCssAbstractStyle
* style
)
103 const KwCssStyle
<T
>* styleRetyped
= dynamic_cast<const KwCssStyle
<T
>*>(style
);
104 assert(styleRetyped
!= 0 &&"Bad style type for this style state");
106 switch (styleRetyped
->getOperation())
108 case KwCssStyle
<T
>::override
:
110 m_value
.push_back(styleRetyped
->getValue());
113 case KwCssStyle
<T
>::revert
:
115 if (m_value
.size() != 0)
121 case KwCssStyle
<T
>::clear
:
145 #endif // _KwCssStyleState_h_