Reverted 2009-05-13T17:57:34Z!koraq@xs4all.nl, as it caused Bug #13521

This commit is contained in:
Iurii Chernyi 2009-05-13 22:46:48 +00:00
parent 59b4f7a094
commit a82a901125
4 changed files with 18 additions and 196 deletions

View file

@ -103,7 +103,6 @@ Version 1.7.0-svn:
now causes a capture of that village.
* Rewrote the layout algoritm (still a work in progress)
* Fixed an multi-character UTF-8 handling bug in the password textbox
* Changed the tmessage dialog to be able to show four buttons
* WML Engine:
* Added [show_objectives] tag and allowed [show_if] tag in [objective]
tags. (bug #13042)

View file

@ -88,73 +88,19 @@
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[grid]
[button]
# This button will be shown or hidden depending on the
# whether or not a scrollbar is needed to show the
# text.
id = "ok"
definition = "default"
[row]
# This button will be shown or hidden depending on the
# whether or not a scrollbar is needed to show the
# text.
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[button]
id = "left_side"
definition = "default"
label = ""
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[button]
id = "cancel"
definition = "default"
label = _ "Cancel"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[button]
id = "ok"
definition = "default"
label = _ "Close"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[button]
id = "right_side"
definition = "default"
label = ""
[/button]
[/column]
[/row]
[/grid]
label = "close"
[/button]
[/column]
@ -165,4 +111,3 @@
[/resolution]
[/window]

View file

@ -16,7 +16,6 @@
#include "gui/dialogs/message.hpp"
#include "foreach.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
@ -24,53 +23,8 @@
namespace gui2 {
/**
* Helper to implement private functions without modifing the header.
*
* The class is a helper to avoid recompilation and only has static
* functions.
*/
struct tmessage_implementation
{
/**
* Initialiazes a button.
*
* @param window The window that contains the button.
* @param button_status The button status to modify.
* @param id The id of the button.
*/
static void
init_button(twindow& window, tmessage::tbutton_status& button_status,
const std::string& id)
{
button_status.button =
dynamic_cast<tbutton*>(window.find_widget(id, false));
VALIDATE(button_status.button, missing_widget(id));
button_status.button->set_visible(button_status.visible);
if(!button_status.caption.empty()) {
button_status.button->set_label(button_status.caption);
}
if(button_status.retval != twindow::NONE) {
button_status.button->set_retval(button_status.retval);
}
}
};
void tmessage::pre_show(CVideo& /*video*/, twindow& window)
{
// ***** Validate the required buttons ***** ***** ***** *****
tmessage_implementation::
init_button(window, buttons_[left_1], "left_side");
tmessage_implementation::
init_button(window, buttons_[cancel], "cancel");
tmessage_implementation::
init_button(window, buttons_[ok] ,"ok");
tmessage_implementation::
init_button(window, buttons_[right_1], "right_side");
// ***** ***** ***** ***** Set up the widgets ***** ***** ***** *****
if(!title_.empty()) {
tlabel* title =
dynamic_cast<tlabel*>(window.find_widget("title", false));
@ -104,56 +58,18 @@ void tmessage::pre_show(CVideo& /*video*/, twindow& window)
* 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()) {
set_button_visible(ok, twidget::VISIBLE);
button->set_visible(twidget::VISIBLE);
}
}
}
void tmessage::post_show(twindow& /*window*/)
{
foreach(tbutton_status& button_status, buttons_) {
button_status.button = NULL;
}
}
void tmessage::set_button_caption(const tbutton_id button,
const std::string& caption)
{
buttons_[button].caption = caption;
if(buttons_[button].button) {
buttons_[button].button->set_label(caption);
}
}
void tmessage::set_button_visible(const tbutton_id button,
const twidget::tvisible visible)
{
buttons_[button].visible = visible;
if(buttons_[button].button) {
buttons_[button].button->set_visible(visible);
}
}
void tmessage::set_button_retval(const tbutton_id button,
const int retval)
{
buttons_[button].retval = retval;
if(buttons_[button].button) {
buttons_[button].button->set_retval(retval);
}
}
tmessage::tbutton_status::tbutton_status()
: button(NULL)
, caption()
, visible(twidget::INVISIBLE)
, retval(twindow::NONE)
{
}
twindow* tmessage::build_window(CVideo& video)
{
return build(video, get_id(MESSAGE));

View file

@ -15,22 +15,18 @@
#ifndef GUI_DIALOGS_MESSAGE_HPP_INCLUDED
#define GUI_DIALOGS_MESSAGE_HPP_INCLUDED
#include "gui/widgets/widget.hpp"
#include "gui/dialogs/dialog.hpp"
namespace gui2 {
class tbutton;
/**
* 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.
* 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
{
friend struct tmessage_implementation;
public:
tmessage(const std::string& title, const std::string& message,
const bool auto_close)
@ -38,26 +34,8 @@ public:
, image_()
, message_(message)
, auto_close_(auto_close)
, buttons_(count)
{}
enum tbutton_id {
left_1 = 0
, cancel
, ok
, right_1
, count
};
void set_button_caption(const tbutton_id button,
const std::string& caption);
void set_button_visible(const tbutton_id button,
const twidget::tvisible visible);
void set_button_retval(const tbutton_id button,
const int retval);
/***** ***** ***** setters / getters for members ***** ****** *****/
void set_title(const std::string& title) { title_ = title; }
@ -72,9 +50,6 @@ protected:
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog. */
void post_show(twindow& window);
private:
/** The title for the dialog. */
std::string title_;
@ -95,19 +70,6 @@ private:
*/
bool auto_close_;
struct tbutton_status
{
tbutton_status();
tbutton* button;
std::string caption;
twidget::tvisible visible;
int retval;
};
/** Holds a pointer to the buttons. */
std::vector<tbutton_status> buttons_;
/** Inherited from tdialog. */
twindow* build_window(CVideo& video);
};