Cleanup the stacked widget code.
Since the widget is fully initialized upon creation it makes no sense to fiddle around with its contents later on. So remove these features.
This commit is contained in:
parent
ca7ddfae04
commit
3cdc96164e
3 changed files with 14 additions and 76 deletions
|
@ -44,8 +44,6 @@ twidget* tbuilder_stacked_widget::build() const
|
|||
|
||||
init_control(widget);
|
||||
|
||||
widget->set_item_builder(stack);
|
||||
|
||||
DBG_GUI_G << "Window builder: placed stacked widget '"
|
||||
<< id << "' with defintion '"
|
||||
<< definition << "'.\n";
|
||||
|
@ -57,7 +55,7 @@ twidget* tbuilder_stacked_widget::build() const
|
|||
|
||||
widget->init_grid(conf->grid);
|
||||
|
||||
widget->finalize();
|
||||
widget->finalize(stack);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
|
|
@ -24,37 +24,11 @@ namespace gui2 {
|
|||
tstacked_widget::tstacked_widget()
|
||||
: tcontainer_(1)
|
||||
, generator_(NULL)
|
||||
, item_builder_()
|
||||
{
|
||||
generator_ = tgenerator_::build(
|
||||
false, false, tgenerator_::independant, false);
|
||||
}
|
||||
|
||||
void tstacked_widget::add_item(const string_map& item)
|
||||
{
|
||||
assert(generator_);
|
||||
foreach(const tbuilder_grid_const_ptr& builder, item_builder_) {
|
||||
generator_->create_item(-1, builder, item, NULL);
|
||||
generator_->select_item(get_item_count() - 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
void tstacked_widget::add_item(
|
||||
const std::map<std::string /* widget id */, string_map>& data)
|
||||
{
|
||||
assert(generator_);
|
||||
foreach(const tbuilder_grid_const_ptr& builder, item_builder_) {
|
||||
generator_->create_item(-1, builder, data, NULL);
|
||||
generator_->select_item(get_item_count() - 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned tstacked_widget::get_item_count() const
|
||||
{
|
||||
assert(generator_);
|
||||
return generator_->get_item_count();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
|
@ -88,15 +62,17 @@ void swap_grid(tgrid* grid,
|
|||
|
||||
} // namespace
|
||||
|
||||
void tstacked_widget::finalize()
|
||||
void tstacked_widget::finalize(
|
||||
std::vector<tbuilder_grid_const_ptr> widget_builder)
|
||||
{
|
||||
assert(generator_);
|
||||
foreach(const tbuilder_grid_const_ptr& builder, item_builder_) {
|
||||
generator_->create_item(-1, builder, string_map(), NULL);
|
||||
string_map empty_data;
|
||||
foreach(const tbuilder_grid_const_ptr& builder, widget_builder) {
|
||||
generator_->create_item(-1, builder, empty_data, NULL);
|
||||
}
|
||||
swap_grid(NULL, &grid(), generator_, "_content_grid");
|
||||
|
||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||
for(size_t i = 0; i < generator_->get_item_count(); ++i) {
|
||||
generator_->select_item(i, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,39 +35,6 @@ public:
|
|||
|
||||
tstacked_widget();
|
||||
|
||||
/***** ***** ***** ***** Stack handling. ***** ***** ****** *****/
|
||||
|
||||
/**
|
||||
* Adds single item to the grid.
|
||||
*
|
||||
* This function expect a item to one multiple widget.
|
||||
*
|
||||
* @param item The data to send to the set_members of the
|
||||
* widget.
|
||||
*/
|
||||
void add_item(const string_map& item);
|
||||
|
||||
/**
|
||||
* Adds single item to the grid.
|
||||
*
|
||||
* This function expect a item to have multiple widgets (either multiple
|
||||
* columns or one column with multiple widgets).
|
||||
*
|
||||
*
|
||||
* @param data The data to send to the set_members of the
|
||||
* widgets. If the member id is not an empty
|
||||
* string it is only send to the widget that
|
||||
* has the wanted id (if any). If the member
|
||||
* id is an empty string, it is send to all
|
||||
* members. Having both empty and non-empty
|
||||
* id's gives undefined behaviour.
|
||||
*/
|
||||
void add_item(const std::map<std::string /* widget id */,
|
||||
string_map>& data);
|
||||
|
||||
/** Returns the number of items. */
|
||||
unsigned get_item_count() const;
|
||||
|
||||
/***** ***** ***** inherited ***** ****** *****/
|
||||
|
||||
/** Inherited from tcontrol. */
|
||||
|
@ -76,15 +43,15 @@ public:
|
|||
/** Inherited from tcontrol. */
|
||||
unsigned get_state() const { return 0; }
|
||||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
|
||||
void set_item_builder(std::vector<tbuilder_grid_const_ptr> item_builder)
|
||||
{ item_builder_ = item_builder; }
|
||||
|
||||
private:
|
||||
|
||||
/** Finishes the building initialization of the widget. */
|
||||
void finalize();
|
||||
/**
|
||||
* Finishes the building initialization of the widget.
|
||||
*
|
||||
* @param widget_builder The builder to build the contents of the
|
||||
* widget.
|
||||
*/
|
||||
void finalize(std::vector<tbuilder_grid_const_ptr> widget_builder);
|
||||
|
||||
/**
|
||||
* Contains a pointer to the generator.
|
||||
|
@ -93,9 +60,6 @@ private:
|
|||
*/
|
||||
tgenerator_* generator_;
|
||||
|
||||
/** Contains the builder for the new items. */
|
||||
std::vector<tbuilder_grid_const_ptr> item_builder_;
|
||||
|
||||
/** Inherited from tcontrol. */
|
||||
const std::string& get_control_type() const
|
||||
{ static const std::string type = "stacked_widget"; return type; }
|
||||
|
|
Loading…
Add table
Reference in a new issue