Property Comments
Darren V Hart <[email protected]> Sat, 13 Sep 2003 08:14:23 -0600
| Newsgroups | gmane.comp.embedded.stk.gui.devel |
|---|---|
| Message-ID | <1063462462.20307.12.camel@brain> |
Regarding Properties:
What did you have in mind marc? I properties interface like GTK doesn't
sound like your style. It does make sense to store a font_properties
object (using the class we already have) and a color_properties object
(again, existing object) to force the theme to use those rather than the
defaults. But do we want to write all the property methods in every
widget? Or would something like this be reasonable:
void widget::foreground_color(color_properties::ptr color_props);
void widget::background_color(color_properties::ptr color_props);
void widget::font(font_properties::ptr font_props);
color_properties::ptr widget::foreground_color();
color_properties::ptr widget::background_color();
font_properties::ptr widget::font();
There would be a few more, perhaps adding ones for the widget states
focused and hover. Or, we could make it a bit more generic and do it
like this:
void widget::color_property(const std::string& label,
color_properties::ptr color_props);
void widget::font_property(const std::string& label,
color_properties::ptr color_props);
color_properties::ptr widget::color_property(const std::string& label);
font_properties::ptr widget::font_property(const std::string& label);
which of course would be used like this:
widget::ptr my_widget;
// assign my_widget to something in the tree...
my_widget.font("foreground", my_font_props);
my_widget.color("hover_selected", my_font_props);
This latter methods puts much less strain on the API, but does allow for
unexpected behavior (unless of course we document it well and make it
blatantly obvious that a null smart pointer is returned if a property is
requested that has not been assigned). Each widget would then simply
have to define what property labels are valid for that widget.
I am a fan of the second approach with the labels, opinions? Come on
Marc, I know you have one!!! *gggg*
Darren