Move tbutton_definition to a new file.

This commit is contained in:
Mark de Wever 2010-01-05 20:10:04 +00:00
parent f9ddf07e13
commit 84ff703caa
8 changed files with 100 additions and 45 deletions

View file

@ -10,6 +10,7 @@ src/gui/auxiliary/event/distributor.cpp
src/gui/auxiliary/event/handler.cpp
src/gui/auxiliary/log.cpp
src/gui/auxiliary/widget_definition.cpp
src/gui/auxiliary/widget_definition/button.cpp
src/gui/auxiliary/widget_definition/vertical_scrollbar.cpp
src/gui/auxiliary/window_builder/button.cpp
src/gui/auxiliary/window_builder/control.cpp

View file

@ -226,6 +226,7 @@ set(wesnoth-main_SRC
gui/auxiliary/log.cpp
gui/auxiliary/timer.cpp
gui/auxiliary/widget_definition.cpp
gui/auxiliary/widget_definition/button.cpp
gui/auxiliary/widget_definition/vertical_scrollbar.cpp
gui/auxiliary/window_builder/button.cpp
gui/auxiliary/window_builder/control.cpp

View file

@ -106,6 +106,7 @@ wesnoth_source = \
gui/auxiliary/log.cpp \
gui/auxiliary/timer.cpp \
gui/auxiliary/widget_definition.cpp \
gui/auxiliary/widget_definition/button.cpp \
gui/auxiliary/widget_definition/vertical_scrollbar.cpp \
gui/auxiliary/window_builder/button.cpp \
gui/auxiliary/window_builder/control.cpp \

View file

@ -266,6 +266,7 @@ wesnoth_sources = Split("""
gui/auxiliary/log.cpp
gui/auxiliary/timer.cpp
gui/auxiliary/widget_definition.cpp
gui/auxiliary/widget_definition/button.cpp
gui/auxiliary/widget_definition/vertical_scrollbar.cpp
gui/auxiliary/window_builder/button.cpp
gui/auxiliary/window_builder/control.cpp

View file

@ -0,0 +1,58 @@
/* $Id$ */
/*
Copyright (C) 2007 - 2010 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.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/auxiliary/widget_definition/button.hpp"
#include "gui/auxiliary/log.hpp"
namespace gui2 {
tbutton_definition::tbutton_definition(const config& cfg) :
tcontrol_definition(cfg)
{
DBG_GUI_P << "Parsing button " << id << '\n';
load_resolutions<tresolution>(cfg);
}
tbutton_definition::tresolution::tresolution(const config& cfg) :
tresolution_definition_(cfg)
{
/*WIKI
* @page = GUIWidgetDefinitionWML
* @order = 1_button
*
* == Button ==
*
* @macro = button_description
*
* The following states exist:
* * state_enabled, the button is enabled.
* * state_disabled, the button is disabled.
* * state_pressed, the left mouse button is down.
* * state_focussed, the mouse is over the button.
*
*/
// Note the order should be the same as the enum tstate is button.hpp.
state.push_back(tstate_definition(cfg.child("state_enabled")));
state.push_back(tstate_definition(cfg.child("state_disabled")));
state.push_back(tstate_definition(cfg.child("state_pressed")));
state.push_back(tstate_definition(cfg.child("state_focussed")));
}
} // namespace gui2

View file

@ -0,0 +1,37 @@
/* $Id$ */
/*
Copyright (C) 2007 - 2010 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_AUXILIARY_WIDGET_DEFINITION_BUTTON_HPP_INCLUDED
#define GUI_AUXILIARY_WIDGET_DEFINITION_BUTTON_HPP_INCLUDED
#include "gui/auxiliary/widget_definition.hpp"
namespace gui2 {
struct tbutton_definition
: public tcontrol_definition
{
explicit tbutton_definition(const config& cfg);
struct tresolution
: public tresolution_definition_
{
explicit tresolution(const config& cfg);
};
};
} // namespace gui2
#endif

View file

@ -25,6 +25,7 @@
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/button.hpp"
#include "gui/auxiliary/widget_definition/vertical_scrollbar.hpp"
#include "gui/widgets/window.hpp"
#include "serialization/parser.hpp"
@ -441,40 +442,6 @@ tstate_definition::tstate_definition(const config &cfg) :
canvas.set_cfg(draw);
}
tbutton_definition::tbutton_definition(const config& cfg) :
tcontrol_definition(cfg)
{
DBG_GUI_P << "Parsing button " << id << '\n';
load_resolutions<tresolution>(cfg);
}
tbutton_definition::tresolution::tresolution(const config& cfg) :
tresolution_definition_(cfg)
{
/*WIKI
* @page = GUIWidgetDefinitionWML
* @order = 1_button
*
* == Button ==
*
* @macro = button_description
*
* The following states exist:
* * state_enabled, the button is enabled.
* * state_disabled, the button is disabled.
* * state_pressed, the left mouse button is down.
* * state_focussed, the mouse is over the button.
*
*/
// Note the order should be the same as the enum tstate is button.hpp.
state.push_back(tstate_definition(cfg.child("state_enabled")));
state.push_back(tstate_definition(cfg.child("state_disabled")));
state.push_back(tstate_definition(cfg.child("state_pressed")));
state.push_back(tstate_definition(cfg.child("state_focussed")));
}
thorizontal_scrollbar_definition::
thorizontal_scrollbar_definition(const config& cfg) :
tcontrol_definition(cfg)

View file

@ -85,17 +85,6 @@ enum twindow_type {
const std::string& get_id(const twindow_type window_type);
struct tbutton_definition : public tcontrol_definition
{
tbutton_definition(const config& cfg);
struct tresolution : public tresolution_definition_
{
tresolution(const config& cfg);
};
};
/*
* A horizontal listbox definition is the same as a normal listbox.
* The big difference between them is the difference in the instanciation,