16#ifndef OSGWIDGET_STYLE_MANAGER
17#define OSGWIDGET_STYLE_MANAGER
36 Style (
const std::string& =
"",
const std::string& =
"");
87 typedef std::map<std::string, osg::ref_ptr<Style> >
Styles;
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)
162 osg::Object* obj =
dynamic_cast<osg::Object*
>(t);
166 <<
"Cannot call StyleManager::applyStyle with a NULL object or coerce object into osg::Object."
175 if(t->getStyle().empty())
178 if(_styles.find(c) == _styles.end())
return false;
180 return _applyStyleToObject(obj, c);
184 if(_styles.find(t->getStyle()) != _styles.end())
return _applyStyleToObject(
The osgWidget library is a NodeKit that extends the core scene graph to support a 2D (and eventually ...
Definition Box:21
std::ostream & warn()
Definition Util:41
osgDB::FieldReaderIterator & Reader
Definition StyleManager:28
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
virtual const char * className() const =0
return the name of the object's class type.
const std::string & getName() const
Get the name of object.
Definition Object:213
deprecated.
Definition Input:185
void attach(std::istream *input)
void advanceOverCurrentFieldOrBlock()
increments the iterator of the next simple field or whole block if the current field[0] is an open br...
bool matchSequence(const char *str)
Definition StyleManager:31
static bool strToFill(const std::string &)
virtual bool applyStyle(Input *, Reader)
virtual bool applyStyle(Canvas *, Reader)
static Widget::Layer strToLayer(const std::string &)
virtual bool applyStyle(Label *, Reader)
virtual bool applyStyle(Widget *, Reader)
virtual bool applyStyle(Frame::Corner *, Reader)
virtual bool applyStyle(Window *, Reader)
META_Object(osgWidget, Style)
Style(const Style &, const osg::CopyOp &)
const std::string & getStyle() const
Definition StyleManager:59
std::string & getStyle()
Definition StyleManager:55
virtual bool applyStyle(Window::EmbeddedWindow *, Reader)
virtual bool applyStyle(Frame::Border *, Reader)
bool _match(const char *seq, Reader r)
Definition StyleManager:73
static Widget::HorizontalAlignment strToHAlign(const std::string &)
Style(const std::string &="", const std::string &="")
static Widget::VerticalAlignment strToVAlign(const std::string &)
void setStyle(const std::string &style)
Definition StyleManager:51
std::string _style
Definition StyleManager:71
virtual bool applyStyle(Box *, Reader)
static Widget::CoordinateMode strToCoordMode(const std::string &)
META_Object(osgWidget, StyleManager)
bool applyStyles(Widget *widget)
Definition StyleManager:98
std::map< std::string, osg::ref_ptr< Style > > Styles
Definition StyleManager:87
Styles::const_iterator ConstIterator
Definition StyleManager:89
StyleManager(const StyleManager &, const osg::CopyOp &)
bool applyStyles(Window *window)
Definition StyleManager:102
Styles::iterator Iterator
Definition StyleManager:88
HorizontalAlignment
Definition Widget:63
Layer
Definition Widget:49
CoordinateMode
Definition Widget:69
VerticalAlignment
Definition Widget:57
#define OSGWIDGET_EXPORT
Definition Export:42