1 /***********************************************************************
2 created: Mon Jun 13 2005
3 author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27 #include "CEGUI/falagard/LayerSpecification.h"
28 #include "CEGUI/falagard/XMLHandler.h"
29 #include <iostream>
30 #include "CEGUI/PropertyHelper.h"
31 // Start of CEGUI namespace section
32 namespace CEGUI
33 {
34
LayerSpecification(uint priority)35 LayerSpecification::LayerSpecification(uint priority) :
36 d_layerPriority(priority)
37 {}
38
render(Window & srcWindow,const ColourRect * modcols,const Rectf * clipper,bool clipToDisplay) const39 void LayerSpecification::render(Window& srcWindow, const ColourRect* modcols, const Rectf* clipper, bool clipToDisplay) const
40 {
41 // render all sections in this layer
42 for(SectionList::const_iterator curr = d_sections.begin(); curr != d_sections.end(); ++curr)
43 {
44 (*curr).render(srcWindow, modcols, clipper, clipToDisplay);
45 }
46 }
47
render(Window & srcWindow,const Rectf & baseRect,const ColourRect * modcols,const Rectf * clipper,bool clipToDisplay) const48 void LayerSpecification::render(Window& srcWindow, const Rectf& baseRect, const ColourRect* modcols, const Rectf* clipper, bool clipToDisplay) const
49 {
50 // render all sections in this layer
51 for(SectionList::const_iterator curr = d_sections.begin(); curr != d_sections.end(); ++curr)
52 {
53 (*curr).render(srcWindow, baseRect, modcols, clipper, clipToDisplay);
54 }
55 }
56
addSectionSpecification(const SectionSpecification & section)57 void LayerSpecification::addSectionSpecification(const SectionSpecification& section)
58 {
59 d_sections.push_back(section);
60 }
61
clearSectionSpecifications()62 void LayerSpecification::clearSectionSpecifications()
63 {
64 d_sections.clear();
65 }
66
getLayerPriority() const67 uint LayerSpecification::getLayerPriority() const
68 {
69 return d_layerPriority;
70 }
71
setLayerPriority(uint priority)72 void LayerSpecification::setLayerPriority(uint priority)
73 {
74 d_layerPriority = priority;
75 }
76
writeXMLToStream(XMLSerializer & xml_stream) const77 void LayerSpecification::writeXMLToStream(XMLSerializer& xml_stream) const
78 {
79 xml_stream.openTag(Falagard_xmlHandler::LayerElement);
80
81 if (d_layerPriority != 0)
82 xml_stream.attribute(Falagard_xmlHandler::PriorityAttribute, PropertyHelper<uint>::toString(d_layerPriority));
83
84 // ouput all sections in this layer
85 for(SectionList::const_iterator curr = d_sections.begin(); curr != d_sections.end(); ++curr)
86 {
87 (*curr).writeXMLToStream(xml_stream);
88 }
89
90 xml_stream.closeTag();
91 }
92
93 LayerSpecification::SectionIterator
getSectionIterator() const94 LayerSpecification::getSectionIterator() const
95 {
96 return SectionIterator(d_sections.begin(), d_sections.end());
97 }
98
getSectionSpecificationPointers()99 LayerSpecification::SectionSpecificationPointerList LayerSpecification::getSectionSpecificationPointers()
100 {
101 LayerSpecification::SectionSpecificationPointerList pointerList;
102
103 SectionList::iterator sectionSpecificationIter = d_sections.begin();
104 SectionList::iterator sectionSpecificationEnd = d_sections.end();
105 while( sectionSpecificationIter != sectionSpecificationEnd )
106 {
107 pointerList.push_back(&(*sectionSpecificationIter));
108 ++sectionSpecificationIter;
109 }
110
111 return pointerList;
112 }
113
operator <(const LayerSpecification & otherLayerSpec) const114 bool LayerSpecification::operator< (const LayerSpecification& otherLayerSpec) const
115 {
116 return d_layerPriority < otherLayerSpec.getLayerPriority();
117 }
118
119 } // End of CEGUI namespace section
120