Writing of basic layout info to zionworx files
[kworship.git] / kworship / css / KwCssStandardise.h
blob10c4f76bd6d5480349a64f324b801067366ebfdc
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"
30 #include "KwCssSchema.h"
32 #include <kdemacros.h>
34 /// Simple class for accessing a style.
35 template <typename T>
36 class KDE_EXPORT KwCssStyleAccessor
38 public:
39 virtual ~KwCssStyleAccessor()
43 * Main interface
45 T operator () (const KwCssScope* scope) const
47 return scope->getStyles().getStyle<T>(m_name);
50 void registerToSchema(KwCssSchema* schema) const
52 schema->registerProperty<T>(m_name);
54 protected:
55 QString m_name;
58 #define KWCSS_SCHEMA \
59 inline KwCssSchema* schema() \
60 { \
61 static KwCssSchema* s = 0; \
62 if (0 == s) \
63 { \
64 s = new KwCssSchema; \
65 } \
66 return s; \
69 /// Start the root css namespace.
70 #define KWCSS_ROOT_NAMESPACE(NAME) \
71 namespace NAME \
72 { \
73 inline QString _scopeName() \
74 { \
75 return #NAME; \
78 /// Start a non-root css namespace.
79 #define KWCSS_START_NAMESPACE(PREV,NAME) \
80 namespace NAME \
81 { \
82 inline QString _scopeName() \
83 { \
84 return #PREV "." #NAME; \
87 /// End a css namespace.
88 #define KWCSS_END_NAMESPACE() \
91 /// Define a property in a css namespace.
92 #define KWCSS_DEFINE_PROPERTY(TYPE, LNAME) \
93 class KDE_EXPORT Acc_##LNAME : public KwCssStyleAccessor< TYPE > \
94 { \
95 public: \
96 Acc_##LNAME() \
97 { \
98 m_name = _scopeName(); \
99 m_name.append("." #LNAME); \
100 registerToSchema(schema()); \
102 }; \
103 KDE_EXPORT KWCSS_EXTERN Acc_##LNAME LNAME;
105 #define KWCSS_EXTERN extern
107 #endif // _KwCssStandardise_h_