Add a new matrix widget.

This widget is slated to replace the current listbox in the
future. The code however is only ready as proof-of-concept code, and
not usable in real code yet.

The code is used to experiment with a different approach of the
implementation of a listbox.
This commit is contained in:
Mark de Wever 2012-05-28 08:52:47 +00:00
parent 83b510cb16
commit c93d7d1484
12 changed files with 1018 additions and 0 deletions

View file

@ -0,0 +1,241 @@
#textdomain wesnoth-lib
###
### Definition of a matrix
###
#define _GUI_VIEW
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 0
[spacer]
[/spacer]
[/column]
[column]
grow_factor = 1
[viewport]
id = "_top_viewport"
[widget]
[instance]
id = "_top"
[/instance]
[/widget]
[/viewport]
[/column]
[column]
grow_factor = 0
[spacer]
[/spacer]
[/column]
[/row]
[row]
grow_factor = 1
[column]
[viewport]
id = "_left_viewport"
[widget]
[instance]
id = "_left"
[/instance]
[/widget]
[/viewport]
[/column]
[column]
[viewport]
id = "_main_viewport"
[widget]
[instance]
id = "_main"
[/instance]
[/widget]
[/viewport]
[/column]
[column]
[viewport]
id = "_right_viewport"
[widget]
[instance]
id = "_right"
[/instance]
[/widget]
[/viewport]
[/column]
[/row]
[row]
grow_factor = 0
[column]
[spacer]
[/spacer]
[/column]
[column]
[viewport]
id = "_bottom_viewport"
[widget]
[instance]
id = "_bottom"
[/instance]
[/widget]
[/viewport]
[/column]
[column]
[spacer]
[/spacer]
[/column]
[/row]
[/grid]
#enddef
#define _GUI_RESOLUTION RESOLUTION FONT_SIZE FONT_STYLE FONT_COLOR_ENABLED FONT_COLOR_DISABLED
[resolution]
{RESOLUTION}
min_width = 0
min_height = 0
default_width = 0
default_height = 0
max_width = 0
max_height = 0
text_font_size = {FONT_SIZE}
text_font_style = {FONT_STYLE}
[state_enabled]
[draw]
[/draw]
[/state_enabled]
[state_disabled]
[draw]
[/draw]
[/state_disabled]
[content]
[row]
grow_factor = 1
[column]
grow_factor = 1
{_GUI_VIEW}
[/column]
[column]
{GUI__VERTICAL_SCROLLBAR_GRID}
[/column]
[/row]
[row]
[column]
{GUI__HORIZONTAL_SCROLLBAR_GRID}
[/column]
[column]
[spacer]
[/spacer]
[/column]
[/row]
[/content]
[/resolution]
#enddef
[matrix_definition]
id = "default"
description = "Default matrix."
{_GUI_RESOLUTION
({GUI_TINY__RESOLUTION})
({GUI_TINY__FONT_SIZE__DEFAULT})
()
({GUI__FONT_COLOR_ENABLED__DEFAULT})
({GUI__FONT_COLOR_DISABLED__DEFAULT})
}
{_GUI_RESOLUTION
({GUI_NORMAL__RESOLUTION})
({GUI_NORMAL__FONT_SIZE__DEFAULT})
()
({GUI__FONT_COLOR_ENABLED__DEFAULT})
({GUI__FONT_COLOR_DISABLED__DEFAULT})
}
[/matrix_definition]
#undef _GUI_VIEW
#undef _GUI_RESOLUTION

View file

@ -705,6 +705,36 @@
[/link]
[/tag]
[/tag]
[tag]
name="matrix_definition"
min="0"
max="-1"
super="generic/widget_definition"
[tag]
name="resolution"
min="0"
max="-1"
super="generic/widget_definition/resolution"
[tag]
name="content"
min="1"
max="1"
super="gui/window/resolution/grid"
[/tag]
[tag]
name="state_disabled"
min="1"
max="1"
super="generic/state"
[/tag]
[tag]
name="state_enabled"
min="1"
max="1"
super="generic/state"
[/tag]
[/tag]
[/tag]
[tag]
name="minimap_definition"
min="0"
@ -1471,6 +1501,52 @@
default=initial_auto
[/key]
[/tag]
[tag]
name="matrix"
min="0"
max="-1"
super="generic/widget_instance"
[tag]
name="bottom"
min="0"
max="1"
super="gui/window/resolution/grid"
[/tag]
[tag]
name="left"
min="0"
max="1"
super="gui/window/resolution/grid"
[/tag]
[tag]
name="main"
min="1"
max="1"
super="gui/window/resolution/grid/row/column"
[/tag]
[tag]
name="right"
min="0"
max="1"
super="gui/window/resolution/grid"
[/tag]
[tag]
name="top"
min="0"
max="1"
super="gui/window/resolution/grid"
[/tag]
[key]
name="horizontal_scrollbar_mode"
type="scrollbar_mode"
default=initial_auto
[/key]
[key]
name="vertical_scrollbar_mode"
type="scrollbar_mode"
default=initial_auto
[/key]
[/tag]
[tag]
name="minimap"
min="0"

View file

@ -23,6 +23,7 @@ src/gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
src/gui/auxiliary/widget_definition/image.cpp
src/gui/auxiliary/widget_definition/label.cpp
src/gui/auxiliary/widget_definition/listbox.cpp
src/gui/auxiliary/widget_definition/matrix.cpp
src/gui/auxiliary/widget_definition/minimap.cpp
src/gui/auxiliary/widget_definition/multi_page.cpp
src/gui/auxiliary/widget_definition/panel.cpp
@ -50,6 +51,7 @@ src/gui/auxiliary/window_builder/image.cpp
src/gui/auxiliary/window_builder/instance.cpp
src/gui/auxiliary/window_builder/label.cpp
src/gui/auxiliary/window_builder/listbox.cpp
src/gui/auxiliary/window_builder/matrix.cpp
src/gui/auxiliary/window_builder/minimap.cpp
src/gui/auxiliary/window_builder/multi_page.cpp
src/gui/auxiliary/window_builder/pane.cpp
@ -114,6 +116,7 @@ src/gui/widgets/horizontal_scrollbar.cpp
src/gui/widgets/image.cpp
src/gui/widgets/label.cpp
src/gui/widgets/listbox.cpp
src/gui/widgets/matrix.cpp
src/gui/widgets/list.cpp
src/gui/widgets/minimap.cpp
src/gui/widgets/multi_page.cpp

View file

@ -431,6 +431,7 @@ set(wesnoth-main_SRC
gui/auxiliary/widget_definition/image.cpp
gui/auxiliary/widget_definition/label.cpp
gui/auxiliary/widget_definition/listbox.cpp
gui/auxiliary/widget_definition/matrix.cpp
gui/auxiliary/widget_definition/minimap.cpp
gui/auxiliary/widget_definition/multi_page.cpp
gui/auxiliary/widget_definition/panel.cpp
@ -458,6 +459,7 @@ set(wesnoth-main_SRC
gui/auxiliary/window_builder/image.cpp
gui/auxiliary/window_builder/label.cpp
gui/auxiliary/window_builder/listbox.cpp
gui/auxiliary/window_builder/matrix.cpp
gui/auxiliary/window_builder/minimap.cpp
gui/auxiliary/window_builder/multi_page.cpp
gui/auxiliary/window_builder/pane.cpp
@ -534,6 +536,7 @@ set(wesnoth-main_SRC
gui/widgets/label.cpp
gui/widgets/list.cpp
gui/widgets/listbox.cpp
gui/widgets/matrix.cpp
gui/widgets/minimap.cpp
gui/widgets/multi_page.cpp
gui/widgets/pane.cpp

View file

@ -275,6 +275,7 @@ wesnoth_sources = Split("""
gui/auxiliary/widget_definition/image.cpp
gui/auxiliary/widget_definition/label.cpp
gui/auxiliary/widget_definition/listbox.cpp
gui/auxiliary/widget_definition/matrix.cpp
gui/auxiliary/widget_definition/minimap.cpp
gui/auxiliary/widget_definition/multi_page.cpp
gui/auxiliary/widget_definition/panel.cpp
@ -302,6 +303,7 @@ wesnoth_sources = Split("""
gui/auxiliary/window_builder/image.cpp
gui/auxiliary/window_builder/label.cpp
gui/auxiliary/window_builder/listbox.cpp
gui/auxiliary/window_builder/matrix.cpp
gui/auxiliary/window_builder/minimap.cpp
gui/auxiliary/window_builder/multi_page.cpp
gui/auxiliary/window_builder/pane.cpp
@ -377,6 +379,7 @@ wesnoth_sources = Split("""
gui/widgets/label.cpp
gui/widgets/list.cpp
gui/widgets/listbox.cpp
gui/widgets/matrix.cpp
gui/widgets/minimap.cpp
gui/widgets/multi_page.cpp
gui/widgets/pane.cpp

View file

@ -0,0 +1,63 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/auxiliary/widget_definition/matrix.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
namespace gui2 {
tmatrix_definition::tmatrix_definition(const config& cfg)
: tcontrol_definition(cfg)
{
DBG_GUI_P << "Parsing matrix " << id << '\n';
load_resolutions<tresolution>(cfg);
}
tmatrix_definition::tresolution::tresolution(const config& cfg)
: tresolution_definition_(cfg)
, content(new tbuilder_grid(cfg.child("content", "[matrix_definition]")))
{
// Note the order should be the same as the enum tstate in matrix.hpp.
state.push_back(tstate_definition(cfg.child("state_enabled")));
state.push_back(tstate_definition(cfg.child("state_disabled")));
}
} // namespace gui2
/*WIKI
* @page = GUIWidgetDefinitionWML
* @order = 1_matrix
* @begin{parent}{name="gui/"}
* @begin{tag}{name="matrix_definition"}{min=0}{max=-1}{super="generic/widget_definition"}
* == Listbox ==
*
* @begin{tag}{name="resolution"}{min=0}{max=-1}{super=generic/widget_definition/resolution}
*
*
* @begin{tag}{name="state_enabled"}{min=1}{max=1}{super="generic/state"}
* @end{tag}{name="state_enabled"}
* @begin{tag}{name="state_disabled"}{min=1}{max=1}{super="generic/state"}
* @end{tag}{name="state_disabled"}
* @begin{tag}{name="content"}{min=1}{max=1}{super="gui/window/resolution/grid"}
* @end{tag}{name="content"}
* @end{tag}{name="resolution"}
* @end{tag}{name="matrix_definition"}
* @end{parent}{name="gui/"}
*/

View file

@ -0,0 +1,42 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_AUXILIARY_WIDGET_DEFINITION_MATRIX_HPP_INCLUDED
#define GUI_AUXILIARY_WIDGET_DEFINITION_MATRIX_HPP_INCLUDED
#include "gui/auxiliary/widget_definition.hpp"
#include "gui/auxiliary/window_builder.hpp"
namespace gui2 {
struct tmatrix_definition
: public tcontrol_definition
{
explicit tmatrix_definition(const config& cfg);
struct tresolution
: public tresolution_definition_
{
explicit tresolution(const config& cfg);
tbuilder_grid_ptr content;
};
};
} // namespace gui2
#endif

View file

@ -29,6 +29,7 @@
#include "gui/auxiliary/window_builder/stacked_widget.hpp"
#include "gui/auxiliary/window_builder/vertical_scrollbar.hpp"
#include "gui/auxiliary/window_builder/label.hpp"
#include "gui/auxiliary/window_builder/matrix.hpp"
#include "gui/auxiliary/window_builder/image.hpp"
#include "gui/auxiliary/window_builder/toggle_button.hpp"
#include "gui/auxiliary/window_builder/slider.hpp"
@ -215,6 +216,7 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg)
TRY(toggle_button);
TRY(slider);
TRY(scroll_label);
TRY(matrix);
TRY(minimap);
TRY(button);
TRY(drawing);

View file

@ -0,0 +1,108 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/auxiliary/window_builder/matrix.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/matrix.hpp"
#include "gui/auxiliary/window_builder/helper.hpp"
#include "gui/widgets/grid.hpp"
#include "gui/widgets/matrix.hpp"
#include "gui/widgets/pane.hpp"
#include "gui/widgets/viewport.hpp"
#include "gui/widgets/settings.hpp"
#include "wml_exception.hpp"
namespace gui2 {
namespace implementation {
tbuilder_matrix::tbuilder_matrix(const config& cfg)
: tbuilder_control(cfg)
, vertical_scrollbar_mode(
get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
, horizontal_scrollbar_mode(
get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
, builder_top(NULL)
, builder_bottom(NULL)
, builder_left(NULL)
, builder_right(NULL)
, builder_main(create_builder_widget(cfg.child("main", "[matrix]")))
{
if(const config& top = cfg.child("top")) {
builder_top = new tbuilder_grid(top);
}
if(const config& bottom = cfg.child("bottom")) {
builder_bottom = new tbuilder_grid(bottom);
}
if(const config& left = cfg.child("left")) {
builder_left = new tbuilder_grid(left);
}
if(const config& right = cfg.child("right")) {
builder_right = new tbuilder_grid(right);
}
}
twidget* tbuilder_matrix::build() const
{
return tmatrix::build(*this);
}
} // namespace implementation
} // namespace gui2
/*WIKI
* @page = GUIWidgetInstanceWML
* @order = 2_matrix
*
* == Listbox ==
* @begin{parent}{name="gui/window/resolution/grid/row/column/"}
* @begin{tag}{name="matrix"}{min=0}{max=-1}{super="generic/widget_instance"}
*
*
* List with the matrix specific variables:
* @begin{table}{config}
* vertical_scrollbar_mode & scrollbar_mode & initial_auto &
* Determines whether or not to show the
* scrollbar. $
* horizontal_scrollbar_mode & scrollbar_mode & initial_auto &
* Determines whether or not to show the
* scrollbar. $
* @end{table}
*
*
* @begin{tag}{name="top"}{min=0}{max=1}{super="gui/window/resolution/grid"}
* @end{tag}{name="top"}
* @begin{tag}{name="bottom"}{min=0}{max=1}{super="gui/window/resolution/grid"}
* @end{tag}{name="bottom"}
*
* @begin{tag}{name="left"}{min=0}{max=1}{super="gui/window/resolution/grid"}
* @end{tag}{name="left"}
* @begin{tag}{name="right"}{min=0}{max=1}{super="gui/window/resolution/grid"}
* @end{tag}{name="right"}
*
* @begin{tag}{name="main"}{min="1"}{max="1"}{super="gui/window/resolution/grid/row/column"}
* @end{tag}{name="main"}
* @end{tag}{name="matrix"}
*
* @end{parent}{name="gui/window/resolution/grid/row/column/"}
*/

View file

@ -0,0 +1,51 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_AUXILIARY_WINDOW_BUILDER_MATRIX_HPP_INCLUDED
#define GUI_AUXILIARY_WINDOW_BUILDER_MATRIX_HPP_INCLUDED
#include "gui/auxiliary/window_builder/control.hpp"
#include "gui/auxiliary/window_builder/pane.hpp"
#include "gui/widgets/scrollbar_container.hpp"
namespace gui2 {
namespace implementation {
struct tbuilder_matrix
: public tbuilder_control
{
explicit tbuilder_matrix(const config& cfg);
twidget* build() const;
tscrollbar_container::tscrollbar_mode vertical_scrollbar_mode;
tscrollbar_container::tscrollbar_mode horizontal_scrollbar_mode;
tbuilder_grid_ptr builder_top;
tbuilder_grid_ptr builder_bottom;
tbuilder_grid_ptr builder_left;
tbuilder_grid_ptr builder_right;
tbuilder_widget_ptr builder_main;
};
} // namespace implementation
} // namespace gui2
#endif

196
src/gui/widgets/matrix.cpp Normal file
View file

@ -0,0 +1,196 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/widgets/matrix.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/matrix.hpp"
#include "gui/auxiliary/window_builder/matrix.hpp"
#include "gui/widgets/settings.hpp"
#include <boost/bind.hpp>
#define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
#define LOG_HEADER LOG_SCOPE_HEADER + ':'
namespace gui2 {
REGISTER_WIDGET(matrix)
tstate_default::tstate_default()
: state_(ENABLED)
{
}
void tstate_default::set_active(const bool active)
{
if(get_active() != active) {
state_ = active ? ENABLED : DISABLED;
}
}
bool tstate_default::get_active() const
{
return state_ != DISABLED;
}
unsigned tstate_default::get_state() const
{
return state_;
}
tmatrix::tmatrix(const implementation::tbuilder_matrix& builder)
: tbase(builder, get_control_type())
, content_()
, pane_(NULL)
{
boost::intrusive_ptr<const tmatrix_definition::tresolution> cfg =
boost::dynamic_pointer_cast<
const tmatrix_definition::tresolution>(config());
tbuilder_widget::treplacements replacements;
replacements.insert(std::make_pair("_main", builder.builder_main));
if(builder.builder_top) {
replacements.insert(std::make_pair("_top", builder.builder_top));
}
if(builder.builder_left) {
replacements.insert(std::make_pair("_left", builder.builder_left));
}
if(builder.builder_right) {
replacements.insert(std::make_pair("_right", builder.builder_right));
}
if(builder.builder_bottom) {
replacements.insert(std::make_pair("_bottom", builder.builder_bottom));
}
cfg->content->build(content_, replacements);
content_.set_parent(this);
pane_ = find_widget<tpane>(&content_, "pane", false, true);
}
tmatrix* tmatrix::build(const implementation::tbuilder_matrix& builder)
{
return new tmatrix(builder);
}
unsigned tmatrix::create_item(
const std::map<std::string, string_map>& item_data
, const std::map<std::string, std::string>& tags)
{
return pane_->create_item(item_data, tags);
}
void tmatrix::place(const tpoint& origin, const tpoint& size)
{
twidget::place(origin, size);
content_.place(origin, size);
}
void tmatrix::layout_init(const bool full_initialization)
{
content_.layout_init(full_initialization);
}
void tmatrix::impl_draw_children(
surface& frame_buffer
, int x_offset
, int y_offset)
{
content_.draw_children(frame_buffer, x_offset, y_offset);
}
void tmatrix::layout_children()
{
content_.layout_children();
}
void tmatrix::child_populate_dirty_list(twindow& caller,
const std::vector<twidget*>& call_stack)
{
std::vector<twidget*> child_call_stack = call_stack;
content_.populate_dirty_list(caller, child_call_stack);
}
void tmatrix::request_reduce_width(const unsigned /*maximum_width*/)
{
}
twidget* tmatrix::find_at(const tpoint& coordinate, const bool must_be_active)
{
return content_.find_at(coordinate, must_be_active);
}
const twidget* tmatrix::find_at(
const tpoint& coordinate,
const bool must_be_active) const
{
return content_.find_at(coordinate, must_be_active);
}
twidget* tmatrix::find(const std::string& id, const bool must_be_active)
{
if(twidget* result = twidget::find(id, must_be_active)) {
return result;
} else {
return content_.find(id, must_be_active);
}
}
const twidget* tmatrix::find(
const std::string& id
, const bool must_be_active) const
{
if(const twidget* result = twidget::find(id, must_be_active)) {
return result;
} else {
return content_.find(id, must_be_active);
}
}
tpoint tmatrix::calculate_best_size() const
{
tpoint size = content_.get_best_size();
return size;
}
bool tmatrix::disable_click_dismiss() const
{
return false;
}
iterator::twalker_* tmatrix::create_walker()
{
/**
* @todo Implement properly.
*/
return NULL;
}
const std::string& tmatrix::get_control_type() const
{
static const std::string type = "matrix";
return type;
}
} // namespace gui2

230
src/gui/widgets/matrix.hpp Normal file
View file

@ -0,0 +1,230 @@
/* $Id$ */
/*
Copyright (C) 2012 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GUI_WIDGETS_MATRIX_HPP_INCLUDED
#define GUI_WIDGETS_MATRIX_HPP_INCLUDED
#include "gui/widgets/control.hpp"
#include "gui/widgets/pane.hpp"
namespace gui2 {
namespace implementation {
struct tbuilder_matrix;
}
class tstate_default
{
public:
tstate_default();
void set_active(const bool active);
bool get_active() const;
unsigned get_state() const;
protected:
/**
* Possible states of the widget.
*
* Note the order of the states must be the same as defined in settings.hpp.
*/
enum tstate { ENABLED, DISABLED, COUNT };
private:
/**
* Current state of the widget.
*
* The state of the widget determines what to render and how the widget
* reacts to certain 'events'.
*/
tstate state_;
};
template<class STATE>
class tcontrol_NEW
: public tcontrol
, public STATE
{
public:
tcontrol_NEW(
const implementation::tbuilder_control& builder
, const std::string& control_type)
: tcontrol(builder, STATE::COUNT, control_type)
{
}
void set_active(bool active)
{
STATE::set_active(active);
}
bool get_active() const
{
return STATE::get_active();
}
unsigned get_state() const
{
return STATE::get_state();
}
};
typedef tcontrol_NEW<tstate_default> tbase;
/** The matrix class. */
class tmatrix
: public tbase
{
friend class tdebug_layout_graph;
private:
tmatrix(const implementation::tbuilder_matrix& builder);
public:
static tmatrix* build(const implementation::tbuilder_matrix& builder);
/***** ***** ***** ***** Item handling. ***** ***** ****** *****/
unsigned create_item(
const std::map<std::string, string_map>& item_data
, const std::map<std::string, std::string>& tags);
/***** ***** ***** ***** Inherited operations. ***** ***** ****** *****/
/** Inherited from twidget. */
void place(const tpoint& origin, const tpoint& size);
/** Inherited from twidget. */
void layout_init(const bool full_initialization);
/** Inherited from twidget. */
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
/** Inherited from twidget. */
void layout_children();
/** Inherited from twidget. */
void child_populate_dirty_list(twindow& caller,
const std::vector<twidget*>& call_stack);
/** Inherited from twidget. */
void request_reduce_width(const unsigned maximum_width);
/** Inherited from twidget. */
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
/** Inherited from twidget. */
const twidget* find_at(
const tpoint& coordinate,
const bool must_be_active) const;
/** Inherited from twidget. */
twidget* find(const std::string& id, const bool must_be_active);
/** Inherited from twidget. */
const twidget* find(const std::string& id, const bool must_be_active) const;
/***** ***** ***** ***** Forwarded to pane_. ***** ***** ****** *****/
/**
* Sorts the contents of the pane.
*
* @param compare_functor The functor to use to sort the items.
*/
void sort(const tpane::tcompare_functor& compare_functor)
{
/********************** OUTLINE *******************/
pane_->sort(compare_functor);
}
/**
* Filters the contents of the pane.
*
* if the @p filter_functor returns @c true the item shown, else it's
* hidden.
*
* @param filter_functor The functor to determine whether an item
* should be shown or hidden.
*/
void filter(const tpane::tfilter_functor& filter_functor)
{
/********************** OUTLINE *******************/
pane_->filter(filter_functor);
}
private:
/** Inherited from twidget. */
tpoint calculate_best_size() const;
public:
/** Inherited from twidget. */
bool disable_click_dismiss() const;
/** Inherited from twidget. */
virtual iterator::twalker_* create_walker();
/**
* Returns a grid in the pane.
*
* @param id The id of the item whose grid to return. The
* id is the value returned by
* @ref create_item().
*
* @returns The wanted grid.
* @retval NULL The id isn't associated with an item.
*/
tgrid* grid(const unsigned id);
/**
* Returns a grid in the pane.
*
* @param id The id of the item whose grid to return. The
* id is the value returned by
* @ref create_item().
*
* @returns The wanted grid.
* @retval NULL The id isn't associated with an item.
*/
const tgrid* grid(const unsigned id) const;
private:
/** The grid containing our children. */
tgrid content_;
/**
* Contains the pane used for adding new items to the matrix.
*
* The pane is owned by a grid in the content layer.
*/
tpane* pane_;
/** Inherited from tcontrol. */
const std::string& get_control_type() const;
};
} // namespace gui2
#endif