Author: mordante
Date: Mon Sep 22 23:22:54 2008
New Revision: 29654
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29654&view=rev
Log:
Add a new image widget and optionally use it in the message dialog.
Modified:
trunk/changelog
trunk/data/gui/default/window/message.cfg
trunk/po/wesnoth-lib/POTFILES.in
trunk/src/CMakeLists.txt
trunk/src/Makefile.am
trunk/src/SConscript
trunk/src/gui/dialogs/message.cpp
trunk/src/gui/dialogs/message.hpp
trunk/src/gui/widgets/canvas.cpp
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/settings.hpp
trunk/src/gui/widgets/window_builder.cpp
trunk/src/gui/widgets/window_builder_private.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Sep 22 23:22:54 2008
@@ -24,7 +24,8 @@
* Added a new scroll label widget.
* Allowed usage of wildcards (? and *) in friend and ignore lists.
* Allowed usage of lists in /friend, /ignore and /remove commands. (feature
- #7492)
+ #7492)
+ * Added a new image widget.
* WML engine:
* New command, [store_time_of_day], makes it possible to store ToD info
in a WML array/container.
Modified: trunk/data/gui/default/window/message.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/message.cfg?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/data/gui/default/window/message.cfg (original)
+++ trunk/data/gui/default/window/message.cfg Mon Sep 22 23:22:54 2008
@@ -329,31 +329,69 @@
[row]
[column]
- border = "all"
- border_size = 5
- horizontal_alignment = "left"
-
- [label]
- id = "title"
- definition = "title"
- [/label]
-
- [/column]
-
- [/row]
-
- [row]
- grow_factor = 1
-
- [column]
- border = "all"
- border_size = 5
- horizontal_alignment = "left"
-
- [scroll_label]
- id = "label"
- definition = "default"
- [/scroll_label]
+
+ [grid]
+
+ [row]
+
+ [column]
+
vertical_alignment = "top"
+
+ [image]
+ id =
"image"
+
definition = "default"
+ [/image]
+
+ [/column]
+
+ [column]
+ grow_factor = 1
+
vertical_alignment = "top"
+
horizontal_alignment = "left"
+
+ [grid]
+
+ [row]
+
+
[column]
+
border = "all"
+
border_size = 5
+
horizontal_alignment = "left"
+
+
[label]
+
id = "title"
+
definition = "title"
+
[/label]
+
+
[/column]
+
+ [/row]
+
+ [row]
+
grow_factor = 1
+
+
[column]
+
border = "all"
+
border_size = 5
+
vertical_alignment = "top"
+
horizontal_alignment = "left"
+
+
[scroll_label]
+
id = "label"
+
definition = "default"
+
[/scroll_label]
+
+
[/column]
+
+ [/row]
+
+ [/grid]
+
+ [/column]
+
+ [/row]
+
+ [/grid]
[/column]
Modified: trunk/po/wesnoth-lib/POTFILES.in
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Mon Sep 22 23:22:54 2008
@@ -20,6 +20,7 @@
src/gui/widgets/event_handler.cpp
src/gui/widgets/grid.cpp
src/gui/widgets/helper.cpp
+src/gui/widgets/image.cpp
src/gui/widgets/label.cpp
src/gui/widgets/listbox.cpp
src/gui/widgets/menubar.cpp
Modified: trunk/src/CMakeLists.txt
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Mon Sep 22 23:22:54 2008
@@ -244,6 +244,7 @@
gui/widgets/event_handler.cpp
gui/widgets/grid.cpp
gui/widgets/helper.cpp
+ gui/widgets/image.cpp
gui/widgets/label.cpp
gui/widgets/listbox.cpp
gui/widgets/menubar.cpp
Modified: trunk/src/Makefile.am
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Sep 22 23:22:54 2008
@@ -87,6 +87,7 @@
gui/widgets/event_handler.cpp \
gui/widgets/grid.cpp \
gui/widgets/helper.cpp \
+ gui/widgets/image.cpp \
gui/widgets/label.cpp \
gui/widgets/listbox.cpp \
gui/widgets/menubar.cpp \
Modified: trunk/src/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Mon Sep 22 23:22:54 2008
@@ -220,6 +220,7 @@
gui/widgets/event_handler.cpp
gui/widgets/grid.cpp
gui/widgets/helper.cpp
+ gui/widgets/image.cpp
gui/widgets/label.cpp
gui/widgets/listbox.cpp
gui/widgets/menubar.cpp
Modified: trunk/src/gui/dialogs/message.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.cpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/dialogs/message.cpp (original)
+++ trunk/src/gui/dialogs/message.cpp Mon Sep 22 23:22:54 2008
@@ -14,6 +14,7 @@
#include "gui/dialogs/message.hpp"
+#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/widget.hpp"
#include "gui/widgets/window.hpp"
@@ -42,6 +43,12 @@
title->set_label(title_);
+ timage* image =
+ dynamic_cast<timage*>(window.find_widget("image", false));
+ VALIDATE(image, missing_widget("image"));
+
+ image->set_label(image_);
+
tcontrol* label =
dynamic_cast<tcontrol*>(window.find_widget("label", false));
VALIDATE(label, missing_widget("label"));
Modified: trunk/src/gui/dialogs/message.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.hpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/dialogs/message.hpp (original)
+++ trunk/src/gui/dialogs/message.hpp Mon Sep 22 23:22:54 2008
@@ -37,11 +37,20 @@
void set_title(const std::string& title) { title_ = title; }
+ void set_image(const std::string& image) { image_ = image; }
+
void set_message(const std::string& message) { message_ = message; }
private:
/** The title for the dialog. */
std::string title_;
+
+ /**
+ * The image which is shown in the dialog.
+ *
+ * This image can be an icon or portrait or any other image.
+ */
+ std::string image_;
/** The message to show to the user. */
std::string message_;
Modified: trunk/src/gui/widgets/canvas.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/canvas.cpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/widgets/canvas.cpp (original)
+++ trunk/src/gui/widgets/canvas.cpp Mon Sep 22 23:22:54 2008
@@ -20,7 +20,7 @@
#include "gui/widgets/canvas.hpp"
#include "config.hpp"
-#include "image.hpp"
+#include "../../image.hpp"
#include "gettext.hpp"
#include "gui/widgets/formula.hpp"
#include "gui/widgets/helper.hpp"
Modified: trunk/src/gui/widgets/settings.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Mon Sep 22 23:22:54 2008
@@ -188,6 +188,7 @@
* <span id="widget_list"></span>List of available widgets:
* @start_table = widget_definition
* button_definition A push button.
+ * image_definition An image.
* menubar_definition A menubar which is used in menus and the
* tabbar in a tabcontrol.
* minimap_definition A minimap to show the gamemap, this only
@@ -231,6 +232,7 @@
/***** Control definitions *****/
load_definitions<tbutton_definition>("button",
cfg.get_children("button_definition"));
+ load_definitions<timage_definition>("image",
cfg.get_children("image_definition"));
load_definitions<tlabel_definition>("label",
cfg.get_children("label_definition"));
load_definitions<tlistbox_definition>("listbox",
cfg.get_children("listbox_definition"));
load_definitions<tmenubar_definition>("menubar",
cfg.get_children("menubar_definition"));
@@ -522,6 +524,35 @@
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")));
+}
+
+timage_definition::timage_definition(const config& cfg) :
+ tcontrol_definition(cfg)
+{
+ DBG_G_P << "Parsing image " << id << '\n';
+
+ load_resolutions<tresolution>(cfg.get_children("resolution"));
+}
+
+timage_definition::tresolution::tresolution(const config& cfg) :
+ tresolution_definition_(cfg)
+{
+/*WIKI
+ * @page = GUIToolkitWML
+ * @order = 1_widget_image
+ *
+ * == Image ==
+ *
+ * The definition of an image. The label field of the widget is used as the
+ * name of file to show.
+ *
+ * The following states exist:
+ * * state_enabled, the image is enabled.
+ *
+ */
+
+ // Note the order should be the same as the enum tstate is image.hpp.
+ state.push_back(tstate_definition(cfg.child("state_enabled")));
}
tlabel_definition::tlabel_definition(const config& cfg) :
Modified: trunk/src/gui/widgets/settings.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Mon Sep 22 23:22:54 2008
@@ -149,6 +149,17 @@
};
+struct timage_definition : public tcontrol_definition
+{
+ timage_definition(const config& cfg);
+
+ struct tresolution : public tresolution_definition_
+ {
+ tresolution(const config& cfg);
+ };
+
+};
+
struct tlabel_definition : public tcontrol_definition
{
Modified: trunk/src/gui/widgets/window_builder.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Mon Sep 22 23:22:54 2008
@@ -17,6 +17,7 @@
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/widgets/button.hpp"
+#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/minimap.hpp"
@@ -185,6 +186,8 @@
if(cfg.child("button")) {
return new tbuilder_button(*(cfg.child("button")));
+ } else if(cfg.child("image")) {
+ return new tbuilder_image(*(cfg.child("image")));
} else if(cfg.child("label")) {
return new tbuilder_label(*(cfg.child("label")));
} else if(cfg.child("listbox")) {
@@ -443,6 +446,7 @@
*
* The widget is one of the following items:
* * button a button.
+ * * image an image.
* * grid a grid, this is used to nest items.
* * label a label.
* * listbox a listbox.
@@ -619,6 +623,18 @@
<< definition << "'.\n";
return button;
+}
+
+twidget* tbuilder_image::build() const
+{
+ timage* widget = new timage();
+
+ init_control(widget);
+
+ DBG_G << "Window builder: placed image '" << id << "' with defintion '"
+ << definition << "'.\n";
+
+ return widget;
}
tbuilder_gridcell::tbuilder_gridcell(const config& cfg) :
Modified: trunk/src/gui/widgets/window_builder_private.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder_private.hpp?rev=29654&r1=29653&r2=29654&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder_private.hpp (original)
+++ trunk/src/gui/widgets/window_builder_private.hpp Mon Sep 22 23:22:54 2008
@@ -60,6 +60,25 @@
private:
int retval_;
+};
+
+struct tbuilder_image : public tbuilder_control
+{
+/*WIKI
+ * @page = GUIToolkitWML
+ * @order = 3_widget_image
+ *
+ * == Image ==
+ *
+ * An image has no extra fields.
+ */
+
+ tbuilder_image(const config& cfg)
+ : tbuilder_control(cfg)
+ {
+ }
+
+ twidget* build () const;
};
/**
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits