From c9d5df386ef2eef582fae95f65fc3dfb20fd27ee Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sun, 1 Feb 2009 11:37:52 +0000 Subject: [PATCH] Enable the wml markup in the [message] dialogs. The code is a bit of a hack and needs to be polished post 1.6. --- src/gui/dialogs/wml_message.cpp | 32 ++++++++++++++++++++++++++++++++ src/gui/widgets/listbox.hpp | 2 ++ 2 files changed, 34 insertions(+) diff --git a/src/gui/dialogs/wml_message.cpp b/src/gui/dialogs/wml_message.cpp index 89a0ed2bb74..f5e6dc6204f 100644 --- a/src/gui/dialogs/wml_message.cpp +++ b/src/gui/dialogs/wml_message.cpp @@ -49,6 +49,12 @@ void twml_message_::set_option_list( set_auto_close(false); } +/** + * @todo This function enables the wml markup for all items, but the interface + * is a bit hacky. Especially the fiddling in the internals of the listbox is + * 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. @@ -57,6 +63,17 @@ 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_)); + // Set the markup + tlabel* title = + dynamic_cast(window.find_widget("title", false)); + assert(title); + title->set_markup_mode(tcontrol::WML_MARKUP); + + tcontrol* label = + dynamic_cast(window.find_widget("label", false)); + assert(label); + label->set_markup_mode(tcontrol::WML_MARKUP); + // Find the input box related fields. tlabel* caption = dynamic_cast( window.find_widget("input_caption", false)); @@ -68,6 +85,7 @@ void twml_message_::pre_show(CVideo& video, twindow& window) if(has_input()) { caption->set_label(input_caption_); + caption->set_markup_mode(tcontrol::WML_MARKUP); input->set_value(*input_text_); input->set_maximum_length(input_maximum_lenght_); window.keyboard_capture(input); @@ -137,6 +155,20 @@ void twml_message_::pre_show(CVideo& video, twindow& window) data["label"]["label"] = label; data["description"]["label"] = description; options->add_row(data); + + // Set the markup flag. + assert(options->generator_); + tgrid& grid = options->generator_->get_item(i); + + tcontrol* control = dynamic_cast( + grid.find_widget("label", false)); + assert(control); + control->set_markup_mode(tcontrol::WML_MARKUP); + + control = dynamic_cast( + grid.find_widget("description", false)); + assert(control); + control->set_markup_mode(tcontrol::WML_MARKUP); } // Avoid negetive and 0 since item 0 is already selected. diff --git a/src/gui/widgets/listbox.hpp b/src/gui/widgets/listbox.hpp index ef685031bd7..fb0529f924e 100644 --- a/src/gui/widgets/listbox.hpp +++ b/src/gui/widgets/listbox.hpp @@ -28,6 +28,8 @@ class tlistbox friend struct tbuilder_listbox; friend class tdebug_layout_graph; + /** @todo Remove this item, part of the markup hack. */ + friend class twml_message_; public: /** * Constructor.