Polish ttransient_message.

The removal of a header also forced some additional files to be edited.
This commit is contained in:
Mark de Wever 2011-03-20 18:26:19 +00:00
parent a2097ad852
commit 9dd8fe33d1
4 changed files with 41 additions and 61 deletions

View file

@ -18,50 +18,51 @@
#include "gui/dialogs/transient_message.hpp"
#include "gettext.hpp"
#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "log.hpp"
namespace gui2 {
REGISTER_DIALOG(transient_message)
void ttransient_message::pre_show(CVideo& /*video*/, twindow& window)
ttransient_message::ttransient_message(const std::string& title
, const bool title_use_markup
, const std::string& message
, const bool message_use_markup
, const std::string& image)
{
tlabel& title = find_widget<tlabel>(&window, "title", false);
title.set_label(title_);
title.set_use_markup(title_use_markup_);
tlabel& message = find_widget<tlabel>(&window, "message", false);
message.set_label(message_);
message.set_use_markup(message_use_markup_);
message.set_can_wrap(true);
timage& image = find_widget<timage>(&window, "image", false);
if(!image_.empty()) {
image.set_image(image_);;
}
register_label2("title", true, title, title_use_markup);
register_label2("message", true, message, message_use_markup);
register_image2("image", true, image);
}
void show_transient_message(CVideo& video, const std::string& title,
const std::string& message, const std::string& image,
bool message_use_markup, bool title_use_markup)
void show_transient_message(CVideo& video
, const std::string& title
, const std::string& message
, const std::string& image
, const bool message_use_markup
, const bool title_use_markup)
{
ttransient_message dlg(title, title_use_markup,
message, message_use_markup, image);
ttransient_message dlg(title
, title_use_markup
, message
, message_use_markup
, image);
dlg.show(video);
}
void show_transient_error_message(CVideo& video
, const std::string& message
, const std::string& image
, bool message_use_markup)
, const bool message_use_markup)
{
LOG_STREAM(err, lg::general) << message << '\n';
show_transient_message(video, _("Error"), message, image, message_use_markup);
show_transient_message(video
, _("Error")
, message
, image
, message_use_markup);
}
} // namespace gui2

View file

@ -17,7 +17,6 @@
#define GUI_DIALOGS_TRANSIENT_MESSAGE_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/control.hpp"
namespace gui2 {
@ -26,37 +25,14 @@ class ttransient_message
: public tdialog
{
public:
ttransient_message(const std::string& title,
bool title_use_markup,
const std::string& message,
bool message_use_markup,
const std::string& image)
: title_(title)
, title_use_markup_(title_use_markup)
, message_(message)
, message_use_markup_(message_use_markup)
, image_(image)
{}
protected:
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
ttransient_message(const std::string& title
, const bool title_use_markup
, const std::string& message
, const bool message_use_markup
, const std::string& image);
private:
/** The title for the dialog. */
std::string title_;
/** Use markup for the title. */
bool title_use_markup_;
/** The message to show to the user. */
std::string message_;
/** Use markup for the message. */
bool message_use_markup_;
/** An optional image to show at the left of the text. */
std::string image_;
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
@ -68,7 +44,7 @@ private:
* This shows a dialog with a short message which can be dismissed with a
* single click.
*
* @note The message _should_ be small enough to fit on the window, the test
* @note The message _should_ be small enough to fit on the window, the text
* can contain newlines and will wrap when needed.
*
* @param video The video which contains the surface to draw
@ -79,11 +55,12 @@ private:
* @param message_use_markup Use markup for the message?
* @param title_use_markup Use markup for the title?
*/
void show_transient_message(CVideo& video, const std::string& title,
const std::string& message,
const std::string& image = std::string(),
bool message_use_markup = false,
bool title_use_markup = false);
void show_transient_message(CVideo& video
, const std::string& title
, const std::string& message
, const std::string& image = std::string()
, const bool message_use_markup = false
, const bool title_use_markup = false);
/**
* Shows a transient error message to the user.
@ -100,7 +77,7 @@ void show_transient_message(CVideo& video, const std::string& title,
void show_transient_error_message(CVideo& video
, const std::string& message
, const std::string& image = std::string()
, bool message_use_markup = false);
, const bool message_use_markup = false);
} // namespace gui2

View file

@ -26,6 +26,7 @@
#include "marked-up_text.hpp"
#include "multiplayer_wait.hpp"
#include "statistics.hpp"
#include "wml_exception.hpp"
#include "wml_separators.hpp"
#include "formula_string_utils.hpp"

View file

@ -25,6 +25,7 @@
#include "construct_dialog.hpp"
#include "display.hpp"
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/simple_item_selector.hpp"