Move tpanel to it's own file, will get more refactoring later.

This commit is contained in:
Mark de Wever 2008-04-17 06:25:00 +00:00
parent 04a0723ed1
commit 7a602eccec
6 changed files with 140 additions and 69 deletions

View file

@ -557,6 +557,7 @@ libwesnoth_sources = Split("""
src/gui/widgets/event_handler.cpp
src/gui/widgets/grid.cpp
src/gui/widgets/label.cpp
src/gui/widgets/panel.cpp
src/gui/widgets/settings.cpp
src/gui/widgets/text_box.cpp
src/gui/widgets/helper.cpp

View file

@ -72,6 +72,7 @@ wesnoth_source = \
gui/widgets/event_handler.cpp \
gui/widgets/grid.cpp \
gui/widgets/label.cpp \
gui/widgets/panel.cpp \
gui/widgets/settings.cpp \
gui/widgets/text_box.cpp \
gui/widgets/tooltip.cpp \

View file

@ -243,74 +243,6 @@ private:
void layout(const tpoint& origin);
};
//! Visible container to hold children.
class tpanel : public tcontrol
{
public:
tpanel() :
tcontrol(0),
grid_(0, 0, 0, 0)
{
grid_.set_parent(this);
}
// Inherited from twidget.
twidget* get_widget(const tpoint& coordinate) { return grid_.get_widget(coordinate); }
// Inherited from twidget.
twidget* get_widget_by_id(const std::string& id) { return grid_.get_widget_by_id(id); }
// Inherited from twidget.
bool dirty() const { return twidget::dirty() || grid_.dirty(); }
//***** **** wrappers to the grid **** ****
tgrid::iterator begin() { return grid_.begin(); }
tgrid::iterator end() { return grid_.end(); }
void set_client_size(const SDL_Rect& rect) { grid_.set_size(rect); }
void set_rows(const unsigned rows) { grid_.set_rows(rows); }
unsigned int get_rows() const { return grid_.get_rows(); }
void set_cols(const unsigned cols) { grid_.set_cols(cols); }
unsigned int get_cols() const { return grid_.get_cols(); }
void set_rows_cols(const unsigned rows, const unsigned cols)
{ grid_.set_rows_cols(rows, cols); }
#if 0
// FIXME if these are really not needed remove them.
void add_child(twidget* widget, const unsigned row, const unsigned col)
{ grid_.add_child(widget, row, col); }
void add_child(twidget* widget, const unsigned row, const unsigned col, const unsigned flags)
{ grid_.add_child(widget, row, col, flags); }
#endif
void add_child(twidget* widget, const unsigned row,
const unsigned col, const unsigned flags, const unsigned border_size)
{ grid_.add_child(widget, row, col, flags, border_size); }
void set_row_scaling(const unsigned row, const unsigned scale)
{ grid_.set_row_scaling(row, scale); }
void set_col_scaling(const unsigned col, const unsigned scale)
{ grid_.set_col_scaling(col, scale); }
//! Inherited from twidget.
//FIXME we also need to load our own config
void draw(surface& surface) { grid_.draw(surface); }
//! Inherited from twidget.
//FIXME we also need to load our own config
void load_config() { grid_.load_config(); }
private:
tgrid grid_;
};
} // namespace gui2
#endif

43
src/gui/widgets/panel.cpp Normal file
View file

@ -0,0 +1,43 @@
/* $Id$ */
/*
copyright (c) 2008 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 version 2
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.
*/
#include "gui/widgets/panel.hpp"
#include "log.hpp"
#define DBG_G LOG_STREAM_INDENT(debug, gui)
#define LOG_G LOG_STREAM_INDENT(info, gui)
#define WRN_G LOG_STREAM_INDENT(warn, gui)
#define ERR_G LOG_STREAM_INDENT(err, gui)
#define DBG_G_D LOG_STREAM_INDENT(debug, gui_draw)
#define LOG_G_D LOG_STREAM_INDENT(info, gui_draw)
#define WRN_G_D LOG_STREAM_INDENT(warn, gui_draw)
#define ERR_G_D LOG_STREAM_INDENT(err, gui_draw)
#define DBG_G_E LOG_STREAM_INDENT(debug, gui_event)
#define LOG_G_E LOG_STREAM_INDENT(info, gui_event)
#define WRN_G_E LOG_STREAM_INDENT(warn, gui_event)
#define ERR_G_E LOG_STREAM_INDENT(err, gui_event)
#define DBG_G_P LOG_STREAM_INDENT(debug, gui_parse)
#define LOG_G_P LOG_STREAM_INDENT(info, gui_parse)
#define WRN_G_P LOG_STREAM_INDENT(warn, gui_parse)
#define ERR_G_P LOG_STREAM_INDENT(err, gui_parse)
namespace gui2 {
} // namespace gui2

94
src/gui/widgets/panel.hpp Normal file
View file

@ -0,0 +1,94 @@
/* $Id$ */
/*
copyright (c) 2008 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 version 2
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_PANEL_HPP_INCLUDED__
#define __GUI_WIDGETS_PANEL_HPP_INCLUDED__
#include "gui/widgets/grid.hpp"
namespace gui2 {
//! Visible container to hold children.
class tpanel : public tcontrol
{
public:
tpanel() :
tcontrol(0),
grid_(0, 0, 0, 0)
{
grid_.set_parent(this);
}
// Inherited from twidget.
twidget* get_widget(const tpoint& coordinate) { return grid_.get_widget(coordinate); }
// Inherited from twidget.
twidget* get_widget_by_id(const std::string& id) { return grid_.get_widget_by_id(id); }
// Inherited from twidget.
bool dirty() const { return twidget::dirty() || grid_.dirty(); }
//***** **** wrappers to the grid **** ****
tgrid::iterator begin() { return grid_.begin(); }
tgrid::iterator end() { return grid_.end(); }
void set_client_size(const SDL_Rect& rect) { grid_.set_size(rect); }
void set_rows(const unsigned rows) { grid_.set_rows(rows); }
unsigned int get_rows() const { return grid_.get_rows(); }
void set_cols(const unsigned cols) { grid_.set_cols(cols); }
unsigned int get_cols() const { return grid_.get_cols(); }
void set_rows_cols(const unsigned rows, const unsigned cols)
{ grid_.set_rows_cols(rows, cols); }
#if 0
// FIXME if these are really not needed remove them.
void add_child(twidget* widget, const unsigned row, const unsigned col)
{ grid_.add_child(widget, row, col); }
void add_child(twidget* widget, const unsigned row, const unsigned col, const unsigned flags)
{ grid_.add_child(widget, row, col, flags); }
#endif
void add_child(twidget* widget, const unsigned row,
const unsigned col, const unsigned flags, const unsigned border_size)
{ grid_.add_child(widget, row, col, flags, border_size); }
void set_row_scaling(const unsigned row, const unsigned scale)
{ grid_.set_row_scaling(row, scale); }
void set_col_scaling(const unsigned col, const unsigned scale)
{ grid_.set_col_scaling(col, scale); }
//! Inherited from twidget.
//FIXME we also need to load our own config
void draw(surface& surface) { grid_.draw(surface); }
//! Inherited from twidget.
//FIXME we also need to load our own config
void load_config() { grid_.load_config(); }
private:
tgrid grid_;
};
} // namespace gui2
#endif

View file

@ -21,8 +21,8 @@
#include "gui/widgets/canvas.hpp"
#include "gui/widgets/event_handler.hpp"
#include "gui/widgets/grid.hpp"
#include "gui/widgets/helper.hpp"
#include "gui/widgets/panel.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/tooltip.hpp"