Move the widget fields to the widget class.

Some fields of the tbuilder_control are actually part of the twidget
class. These are now moved to the tbuilder_widget.

Some of these fields were also used in the tbuilder_grid and are moved
likewise. This means the tbuilder_grid now has some extra fields for
debugging. (`Inherited' from the tbuilder_control.)
This commit is contained in:
Mark de Wever 2012-05-19 08:46:07 +00:00
parent a45f9381b9
commit 8814152e92
4 changed files with 21 additions and 18 deletions

View File

@ -198,6 +198,16 @@ twindow *build(CVideo &video, const std::string &type)
return window;
}
tbuilder_widget::tbuilder_widget(const config& cfg)
: id(cfg["id"])
, linked_group(cfg["linked_group"])
#ifndef LOW_MEM
, debug_border_mode(cfg["debug_border_mode"])
, debug_border_color(decode_color(cfg["debug_border_color"]))
#endif
{
}
void register_builder_widget(const std::string& id
, boost::function<tbuilder_widget_ptr(config)> functor)
{
@ -427,8 +437,6 @@ twindow_builder::tresolution::ttip::ttip(const config& cfg)
tbuilder_grid::tbuilder_grid(const config& cfg) :
tbuilder_widget(cfg),
id(cfg["id"]),
linked_group(cfg["linked_group"]),
rows(0),
cols(0),
row_grow_factor(),

View File

@ -46,11 +46,20 @@ struct tbuilder_widget
: public reference_counted_object
{
public:
explicit tbuilder_widget(const config& /*cfg*/) {}
explicit tbuilder_widget(const config& cfg);
virtual ~tbuilder_widget() {}
virtual twidget* build() const = 0;
virtual ~tbuilder_widget() {}
/** Parameters for the widget. */
std::string id;
std::string linked_group;
#ifndef LOW_MEM
int debug_border_mode;
unsigned debug_border_color;
#endif
};
typedef boost::intrusive_ptr<tbuilder_widget> tbuilder_widget_ptr;
@ -90,8 +99,6 @@ struct tbuilder_grid
public:
explicit tbuilder_grid(const config& cfg);
std::string id;
std::string linked_group;
unsigned rows;
unsigned cols;

View File

@ -29,17 +29,11 @@ namespace implementation {
tbuilder_control::tbuilder_control(const config& cfg)
: tbuilder_widget(cfg)
, id(cfg["id"])
, definition(cfg["definition"])
, linked_group(cfg["linked_group"])
, label(cfg["label"].t_str())
, tooltip(cfg["tooltip"].t_str())
, help(cfg["help"].t_str())
, use_tooltip_on_label_overflow(true)
#ifndef LOW_MEM
, debug_border_mode(cfg["debug_border_mode"])
, debug_border_color(decode_color(cfg["debug_border_color"]))
#endif
{
if(definition.empty()) {
definition = "default";

View File

@ -35,17 +35,11 @@ public:
void init_control(tcontrol* control) const;
/** Parameters for the control. */
std::string id;
std::string definition;
std::string linked_group;
t_string label;
t_string tooltip;
t_string help;
bool use_tooltip_on_label_overflow;
#ifndef LOW_MEM
int debug_border_mode;
unsigned debug_border_color;
#endif
};
} // namespace implementation