Tweak with todo for checking validity of explicit styles in scope when importing
[kworship.git] / kworship / css / KwCssStandardise.h
blob833ca7b4572542d786b0912f7a91496c7adba568
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
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. *
9 * *
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. *
14 * *
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 _KwCssStandardise_h_
21 #define _KwCssStandardise_h_
23 /**
24 * @file KwCssStandardise.h
25 * @brief Macros for css standardisation.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwCssScope.h"
31 /// Simple class for accessing a style.
32 template <typename T>
33 class KwCssStyleAccessor
35 public:
36 virtual ~KwCssStyleAccessor()
40 * Main interface
42 T operator () (const KwCssScope* scope) const
44 return scope->getStyles().getStyle<T>(getName());
46 protected:
47 virtual QString getName() const = 0;
50 /// Start the root css namespace.
51 #define KWCSS_ROOT_NAMESPACE(NAME) \
52 namespace NAME \
53 { \
54 QString _scopeName() \
55 { \
56 return #NAME; \
59 /// Start a non-root css namespace.
60 #define KWCSS_START_NAMESPACE(PREV,NAME) \
61 namespace NAME \
62 { \
63 QString _scopeName() \
64 { \
65 return #PREV "." #NAME; \
68 /// End a css namespace.
69 #define KWCSS_END_NAMESPACE() \
72 /// Define a property in a css namespace.
73 #define KWCSS_DEFINE_PROPERTY(TYPE, LNAME) \
74 class Acc_##LNAME : public KwCssStyleAccessor< TYPE > \
75 { \
76 protected: \
77 virtual QString getName() const \
78 { \
79 QString name = _scopeName(); \
80 name.append("." #LNAME); \
81 return name; \
82 } \
83 } LNAME;
85 #endif // _KwCssStandardise_h_