16 #ifndef OSGWIDGET_STYLE_MANAGER
17 #define OSGWIDGET_STYLE_MANAGER
20 #include <osgDB/Input>
21 #include <osgWidget/Box>
22 #include <osgWidget/Frame>
23 #include <osgWidget/Input>
24 #include <osgWidget/Canvas>
36 Style (
const std::string& =
"",
const std::string& =
"");
39 virtual bool applyStyle (
Widget*, Reader);
40 virtual bool applyStyle (
Label*, Reader);
41 virtual bool applyStyle (
Input*, Reader);
42 virtual bool applyStyle (
Window*, Reader);
44 virtual bool applyStyle (
Box*, Reader);
47 virtual bool applyStyle (
Canvas*, Reader);
67 static bool strToFill (
const std::string&);
73 bool _match(
const char* seq, Reader r) {
87 typedef std::map<std::string, osg::ref_ptr<Style> >
Styles;
96 bool addStyle(
Style*);
99 return _applyStyles(widget);
103 return _applyStyles(window);
110 bool _applySpecificStyle(T* t,
const std::string& style)
114 std::istringstream input(_styles[style]->getStyle());
122 if(_styles[style]->applyStyle(t, r))
134 bool _coerceAndApply(
136 const std::string& style,
137 const std::string& className
139 T* t =
dynamic_cast<T*
>(obj);
143 <<
"An attempt was made to coerce Object [" << obj->
getName()
144 <<
"] into a " << className <<
" but failed." << std::endl
150 return _applySpecificStyle(t, style);
154 bool _applyStyleToObject(
osg::Object*,
const std::string&);
160 bool _applyStyles(T* t)
165 <<
"Cannot call StyleManager::applyStyle with a NULL object."
177 <<
"Cannot coerce object into osg::Object in StyleManager:::applyStyle"
187 if(t->getStyle().empty())
190 if(_styles.find(c) == _styles.end())
return false;
192 return _applyStyleToObject(obj, c);
196 if(_styles.find(t->getStyle()) != _styles.end())
return _applyStyleToObject(
bool matchSequence(const char *str)
#define META_Object(library, name)
const std::string & getName() const
virtual const char * className() const =0
void attach(std::istream *input)
void advanceOverCurrentFieldOrBlock()