Author: mordante
Date: Sun Sep 21 13:22:24 2008
New Revision: 29615

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29615&view=rev
Log:
Add a new proof-of-concept generic widget.

This widget will need some more changes to be able to replace the current
dialogs shown to the user. Only replaced one place where widgets are used in
order to test the dialog.

Added:
    trunk/src/gui/dialogs/message.cpp   (with props)
    trunk/src/gui/dialogs/message.hpp   (with props)
Modified:
    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/addon_management.cpp
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp

Modified: trunk/data/gui/default/window/message.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/message.cfg?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/data/gui/default/window/message.cfg (original)
+++ trunk/data/gui/default/window/message.cfg Sun Sep 21 13:22:24 2008
@@ -316,3 +316,69 @@
 [/window]
 
 #undef RESOLUTION_RIGHT
+
+[window]
+       id = "message"
+       description = "Message dialog with 1 ok button for now."
+
+       [resolution]
+               definition = "default"
+
+               [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
+                                       horizontal_alignment = "left"
+
+                                       [scroll_label]
+                                               id = "label"
+                                               definition = "default"
+                                       [/scroll_label]
+
+                               [/column]
+
+                       [/row]
+
+                       [row]
+
+                               [column]
+                                       border = "all"
+                                       border_size = 5
+                                       horizontal_alignment = "center"
+
+                                       [button]
+                                               id = "ok"
+                                               definition = "default"
+
+                                               label = "close"
+                                       [/button]
+
+                               [/column]
+
+                       [/row]
+
+               [/grid]
+
+       [/resolution]
+
+[/window]

Modified: trunk/po/wesnoth-lib/POTFILES.in
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Sun Sep 21 13:22:24 2008
@@ -8,6 +8,7 @@
 src/gui/dialogs/addon_connect.cpp
 src/gui/dialogs/dialog.cpp
 src/gui/dialogs/language_selection.cpp
+src/gui/dialogs/message.cpp
 src/gui/dialogs/mp_connect.cpp
 src/gui/dialogs/mp_create_game.cpp
 src/gui/dialogs/mp_method_selection.cpp

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Sun Sep 21 13:22:24 2008
@@ -232,6 +232,7 @@
     gui/dialogs/addon_connect.cpp
     gui/dialogs/dialog.cpp
     gui/dialogs/language_selection.cpp
+    gui/dialogs/message.cpp
     gui/dialogs/mp_connect.cpp
     gui/dialogs/mp_create_game.cpp
     gui/dialogs/mp_method_selection.cpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Sep 21 13:22:24 2008
@@ -75,6 +75,7 @@
        gui/dialogs/addon_connect.cpp \
        gui/dialogs/dialog.cpp \
        gui/dialogs/language_selection.cpp \
+       gui/dialogs/message.cpp \
        gui/dialogs/mp_connect.cpp \
        gui/dialogs/mp_create_game.cpp \
        gui/dialogs/mp_method_selection.cpp \

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sun Sep 21 13:22:24 2008
@@ -208,6 +208,7 @@
     gui/dialogs/addon_connect.cpp
     gui/dialogs/dialog.cpp
     gui/dialogs/language_selection.cpp
+    gui/dialogs/message.cpp
     gui/dialogs/mp_connect.cpp
     gui/dialogs/mp_create_game.cpp
     gui/dialogs/mp_method_selection.cpp

Modified: trunk/src/addon_management.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/addon_management.cpp?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/addon_management.cpp (original)
+++ trunk/src/addon_management.cpp Sun Sep 21 13:22:24 2008
@@ -27,6 +27,7 @@
 #include "gettext.hpp"
 #include "gui/dialogs/addon_connect.hpp"
 #include "gui/dialogs/language_selection.hpp"
+#include "gui/dialogs/message.hpp"
 #include "gui/dialogs/mp_method_selection.hpp"
 #include "gui/widgets/window.hpp"
 #include "log.hpp"
@@ -1092,7 +1093,9 @@
                prepare_addons_list_for_display(addons, addon_dirs, parentdir);
 
                if (addons.empty()) {
-                       gui::show_error_message(disp, _("You have no add-ons 
installed."));
+                       /** @todo should use a dialog which always shows the 
close button. */
+                       gui2::show_message(disp.video(), _("Error"), 
+                               _("You have no add-ons installed."));
                        return;
                }
 

Added: trunk/src/gui/dialogs/message.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.cpp?rev=29615&view=auto
==============================================================================
--- trunk/src/gui/dialogs/message.cpp (added)
+++ trunk/src/gui/dialogs/message.cpp Sun Sep 21 13:22:24 2008
@@ -1,0 +1,60 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   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/dialogs/message.hpp"
+
+#include "gui/widgets/label.hpp"
+#include "gui/widgets/widget.hpp"
+#include "gui/widgets/window.hpp"
+#include "gui/widgets/window_builder.hpp"
+#include "gui/widgets/settings.hpp"
+#include "gui/widgets/scroll_label.hpp"
+#include "log.hpp"
+
+#define DBG_GUI LOG_STREAM_INDENT(debug, gui)
+#define LOG_GUI LOG_STREAM_INDENT(info, gui)
+#define WRN_GUI LOG_STREAM_INDENT(warn, gui)
+#define ERR_GUI LOG_STREAM_INDENT(err, gui)
+
+namespace gui2 {
+
+twindow tmessage::build_window(CVideo& video)
+{
+       return build(video, get_id(MESSAGE));
+}
+
+void tmessage::pre_show(CVideo& /*video*/, twindow& window)
+{
+       tlabel* title = 
+               dynamic_cast<tlabel*>(window.find_widget("title", false));
+       VALIDATE(title, missing_widget("title"));
+
+       title->set_label(title_);
+
+       tcontrol* label = 
+               dynamic_cast<tcontrol*>(window.find_widget("label", false));
+       VALIDATE(label, missing_widget("label"));
+
+       label->set_label(message_);
+}
+
+/** @todo the caption is ignored. */
+void show_message(CVideo& video, const std::string& title, 
+       const std::string& message, const std::string& /*button_caption*/)
+{
+       tmessage(title, message).show(video);
+}
+
+} // namespace gui2
+

Propchange: trunk/src/gui/dialogs/message.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/message.cpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Added: trunk/src/gui/dialogs/message.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.hpp?rev=29615&view=auto
==============================================================================
--- trunk/src/gui/dialogs/message.hpp (added)
+++ trunk/src/gui/dialogs/message.hpp Sun Sep 21 13:22:24 2008
@@ -1,0 +1,76 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   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_DIALOGS_MESSAGE_HPP_INCLUDED
+#define GUI_DIALOGS_MESSAGE_HPP_INCLUDED
+
+#include "gui/dialogs/dialog.hpp"
+
+namespace gui2 {
+
+/**
+ * Main class to show messages to the user.
+ *
+ * It can be used to show a message or ask a result from the user. For the most
+ * common usage cases there are helper functions defined.
+ */
+class tmessage : public tdialog
+{
+public:
+       tmessage(const std::string& title, const std::string& message)
+               : title_(title)
+               , message_(message)
+       {}
+
+       /***** ***** ***** setters / getters for members ***** ****** *****/
+
+       void set_title(const std::string& title) {  title_ = title; }
+
+       void set_message(const std::string& message) {  message_ = message; }
+
+private:
+       /** The title for the dialog. */
+       std::string title_;
+
+       /** The message to show to the user. */
+       std::string message_;
+
+       /** Inherited from tdialog. */
+       twindow build_window(CVideo& video);
+
+       /** Inherited from tdialog. */
+       void pre_show(CVideo& video, twindow& window);
+};
+
+/**
+ * Shows a message to the user.
+ *
+ * Normally the dialog won't have a button only when the text doesn't fit in
+ * the dialog and a scrollbar is used the button will be shown.
+ *
+ * @todo Since the click close function isn't implemented yet a button is
+ * always shown.
+ *
+ * @param video               The video which contains the surface to draw 
upon.
+ * @param title               The title of the dialog.
+ * @param message             The message to show in the dialog.
+ * @param button_caption      The caption of the close button.
+ */
+void show_message(CVideo& video, const std::string& title, 
+       const std::string& message, const std::string& button_caption = "");
+
+} // namespace gui2
+
+#endif
+

Propchange: trunk/src/gui/dialogs/message.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/message.hpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Sun Sep 21 13:22:24 2008
@@ -89,6 +89,7 @@
 {
        window_type_list[ADDON_CONNECT] = "addon_connect";
        window_type_list[LANGUAGE_SELECTION] = "language_selection";
+       window_type_list[MESSAGE] = "message";
        window_type_list[MP_CONNECT] = "mp_connect";
        window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
        window_type_list[MP_SERVER_LIST] = "mp_server_list";

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=29615&r1=29614&r2=29615&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Sun Sep 21 13:22:24 2008
@@ -39,6 +39,7 @@
        TITLE_SCREEN,            /**< The main title screen of the game. */
        ADDON_CONNECT,           /**< The addon server connection dialog. */
        LANGUAGE_SELECTION,      /**< The language selection dialog. */
+       MESSAGE,                 /**< A generic message dialog. */
        MP_CONNECT,              /**< The mp server connection dialog. */
        MP_METHOD_SELECTION,     /**< 
                                  * The dialog which allows you to choose the 
kind


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to