2 // Copyright (C) 2008 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // 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
29 #include <boost/smart_ptr.hpp>
34 # include <unordered_map>
35 #else /* PLATFORM_MSVC */
36 # include <tr1/unordered_map>
37 #endif /* PLATFORM_MSVC */
42 #include "gui/widget.h"
43 #include "gui/richtext.h"
49 class WidgetTemplate
{
56 StateTexture(uint us
, WidgetState ws
, const std::string
& t
)
57 : ustate(us
), wstate(ws
), tex(t
) {}
60 typedef std::vector
<StateTexture
> TexVector
;
63 Float2Vector texCoords
;
69 void LoadFromXml(TiXmlElement
& root
);
74 typedef boost::shared_ptr
<GuiSkin
> GuiSkinPtr
;
75 typedef boost::weak_ptr
<GuiSkin
> GuiSkinRef
;
77 class GuiSkinFactory
{
79 const GuiSkinPtr
CreateInstance(const std::string
& filename
);
82 typedef std::tr1::unordered_map
<std::string
, GuiSkinRef
> SkinMap
;
90 static GuiSkinFactory
& Factory(void)
92 static GuiSkinFactory fac
;
97 typedef cpair
<std::string
, WidgetTemplate
> TemplatePair
;
98 typedef std::vector
<TemplatePair
> TempVector
;
100 struct TextDefaults
{
103 TextStyle plainStyle
;
104 TextStyle richStyles
[ssLast
];
108 const std::string
& GetEffect(void) const {return effect_
;}
109 const TextDefaults
& GetTextDefaults(void) const {return textDefs_
;}
111 const WidgetTemplate
* GetTemplate(const std::string
& name
) const;
113 void LoadFromXml(TiXmlElement
& root
);
117 TextDefaults textDefs_
;
119 TempVector templates_
;