Planeshift
pawsstyles.h
Go to the documentation of this file.
1 /*
2  * pawsstyles.h - Author: Ondrej Hurt
3  *
4  * Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  * http://www.atomicblue.org)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program 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  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PAWS_STYLES_HEADER
21 #define PAWS_STYLES_HEADER
22 
23 #include <csutil/csstring.h>
24 #include <csutil/ref.h>
25 #include <csutil/hash.h>
26 #include <iutil/vfs.h>
27 #include <util/psxmlparser.h>
28 
37 #define STRING_HASH(V) csHash <V, csString>
38 
68 {
69 public:
70  pawsStyles(iObjectRegistry* objectReg);
71 
73  bool LoadStyles(const csString &fileName);
74 
79  /* Styles need to be redesigned, the current design is too fragile. So do not use unless absolutely necessary. */
80  void ApplyStyle(const char* style, iDocumentNode* target);
81  void ApplyStyle(iDocumentNode* style, iDocumentNode* target);
82 
83 protected:
85  void InheritStyles();
86 
92  void InheritFromParent(iDocumentNode* style, STRING_HASH(bool) & alreadyInh, STRING_HASH(bool) & beingInh);
93 
94  iObjectRegistry* objectReg;
95 
97  STRING_HASH(csRef<iDocumentNode>) styles;
98 };
99 
100 
103 #endif
void InheritStyles()
All styles inherit attributes/nodes from parent styles.
bool LoadStyles(const csString &fileName)
Loads style definitions from file.
pawsStyles(iObjectRegistry *objectReg)
iObjectRegistry * objectReg
Definition: pawsstyles.h:94
Class pawsStyles keeps definitions of PAWS styles - a PAWS style is collection of XML attributes and ...
Definition: pawsstyles.h:67
STRING_HASH(csRef< iDocumentNode >) styles
Collection of styles - iDocumentNodes accessed by style names.
void InheritFromParent(iDocumentNode *style, STRING_HASH(bool)&alreadyInh, STRING_HASH(bool)&beingInh)
Inherits from parent - copies nodes/attributes from parent of &#39;style&#39; to &#39;style&#39;. ...
void ApplyStyle(const char *style, iDocumentNode *target)
Applies style with given name to &#39;target&#39;.