Author: mordante
Date: Thu May 14 20:08:45 2009
New Revision: 35628
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35628&view=rev
Log:
Let twml_message inherit from tdialog.
The inheritance of tmessage doesn't really work since the dialogs are too
different. Bug 13521 was caused by this inheritance.
Modified:
trunk/src/gui/dialogs/wml_message.cpp
trunk/src/gui/dialogs/wml_message.hpp
trunk/src/gui/widgets/window.hpp
Modified: trunk/src/gui/dialogs/wml_message.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.cpp?rev=35628&r1=35627&r2=35628&view=diff
==============================================================================
--- trunk/src/gui/dialogs/wml_message.cpp (original)
+++ trunk/src/gui/dialogs/wml_message.cpp Thu May 14 20:08:45 2009
@@ -17,6 +17,7 @@
#include "gui/dialogs/wml_message.hpp"
#include "foreach.hpp"
+#include "gui/widgets/button.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/text_box.hpp"
@@ -33,8 +34,6 @@
input_caption_ = caption;
input_text_ = text;
input_maximum_lenght_ = maximum_length;
-
- set_auto_close(false);
}
void twml_message_::set_option_list(
@@ -45,8 +44,6 @@
option_list_ = option_list;
chosen_option_ = choosen_option;
-
- set_auto_close(false);
}
/**
@@ -55,11 +52,8 @@
* ugly. There needs to be a clean interface to set whether a widget has a
* markup and what kind of markup. These fixes will be post 1.6.
*/
-void twml_message_::pre_show(CVideo& video, twindow& window)
-{
- // Inherited.
- tmessage::pre_show(video, window);
-
+void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
+{
window.canvas(1).set_variable("portrait_image", variant(portrait_));
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
@@ -67,12 +61,17 @@
tlabel* title =
dynamic_cast<tlabel*>(window.find_widget("title",
false));
assert(title);
+ title->set_label(title_);
title->set_markup_mode(tcontrol::WML_MARKUP);
tcontrol* label =
dynamic_cast<tcontrol*>(window.find_widget("label",
false));
assert(label);
+ label->set_label(message_);
label->set_markup_mode(tcontrol::PANGO_MARKUP);
+ // The label might not always be a scroll_label but the capturing
+ // shouldn't hurt.
+ window.keyboard_capture(label);
// Find the input box related fields.
tlabel* caption = dynamic_cast<tlabel*>(
@@ -197,6 +196,25 @@
} else {
options->set_visible(twidget::INVISIBLE);
}
+
+ if(!has_input_) {
+ /*
+ * Hide the buttton and do the layout, if
window.does_easy_close() is
+ * false the scroll_label has a scrollbar so we need to show the
+ * button. When the button is hidden the text for the label is
bigger
+ * and thus not need a scrollbar. Also when the button is
visible
+ * easy_close will always return false.
+ */
+ tbutton* button =
+ dynamic_cast<tbutton*>(window.find_widget("ok", false));
+ VALIDATE(button, missing_widget("ok"));
+ button->set_visible(twidget::INVISIBLE);
+ window.layout();
+
+ if(! window.does_easy_close()) {
+ button->set_visible(twidget::VISIBLE);
+ }
+ }
}
void twml_message_::post_show(twindow& window)
Modified: trunk/src/gui/dialogs/wml_message.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.hpp?rev=35628&r1=35627&r2=35628&view=diff
==============================================================================
--- trunk/src/gui/dialogs/wml_message.hpp (original)
+++ trunk/src/gui/dialogs/wml_message.hpp Thu May 14 20:08:45 2009
@@ -15,7 +15,7 @@
#ifndef GUI_DIALOGS_WML_MESSAGE_HPP_INCLUDED
#define GUI_DIALOGS_WML_MESSAGE_HPP_INCLUDED
-#include "gui/dialogs/message.hpp"
+#include "gui/dialogs/dialog.hpp"
namespace gui2 {
@@ -24,12 +24,14 @@
*
* We have a separate sub class for left and right images.
*/
-class twml_message_ : public tmessage
+class twml_message_
+ : public tdialog
{
public:
twml_message_(const std::string& title, const std::string& message,
const std::string portrait, const bool mirror)
- : tmessage(title, message, true)
+ : title_(title)
+ , message_(message)
, portrait_(portrait)
, mirror_(mirror)
, has_input_(false)
@@ -57,6 +59,18 @@
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_;
/** Filename of the portrait. */
std::string portrait_;
@@ -82,13 +96,13 @@
int *chosen_option_;
/**
- * Inherited from tmessage.
+ * Inherited from tdialog.
*
* The subclasses need to implement the left or right definition.
*/
twindow* build_window(CVideo& /*video*/) = 0;
- /** Inherited from tmessage. */
+ /** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog. */
Modified: trunk/src/gui/widgets/window.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=35628&r1=35627&r2=35628&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Thu May 14 20:08:45 2009
@@ -63,6 +63,7 @@
// Wants to use layout().
friend class tmessage;
+ friend class twml_message_;
public:
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits