The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
popup.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
17 #include "gui/dialogs/popup.hpp"
18 
19 #include "gui/widgets/window.hpp"
20 #include "video.hpp"
21 
22 namespace gui2
23 {
24 
25 tpopup::tpopup() : window_(nullptr)
26 {
27 }
28 
30 {
31  hide();
32 }
33 
34 void tpopup::show(CVideo& video,
35  const bool allow_interaction,
36  const unsigned /*auto_close_time*/)
37 {
38  if(video.faked()) {
39  return;
40  }
41 
42  hide();
43 
44  window_ = build_window(video);
45 
47 
48  pre_show(*window_);
49 
50  if(allow_interaction) {
52  } else {
53  window_->show_tooltip(/*auto_close_time*/);
54  }
55 }
56 
58 {
59  if(window_) {
60  window_->undraw();
61  delete window_;
62  window_ = nullptr;
63  }
64 }
65 
67 {
68  return build(video, window_id());
69 }
70 
71 void tpopup::post_build(twindow& /*window*/)
72 {
73  /* DO NOTHING */
74 }
75 
76 void tpopup::pre_show(twindow& /*window*/)
77 {
78  /* DO NOTHING */
79 }
80 
81 } // namespace gui2
twindow * window_
The window, used in show.
Definition: popup.hpp:85
twindow * build(CVideo &video, const twindow_builder::tresolution *definition)
Builds a window.
Definition: video.hpp:58
This file contains the window object, this object is a top level container which has the event manage...
void undraw()
Undraws the window.
Definition: window.cpp:917
-file util.hpp
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
void show(CVideo &video, const bool allow_interaction=false, const unsigned auto_close_time=0)
Shows the window.
Definition: popup.cpp:34
twindow * build_window(CVideo &video) const
Builds the window.
Definition: popup.cpp:66
virtual const std::string & window_id() const =0
The id of the window to build.
void show_tooltip()
Shows the window as a tooltip.
Definition: window.cpp:547
void hide()
Hides the window.
Definition: popup.cpp:57
virtual void pre_show(twindow &window)
Actions to be taken before showing the window.
Definition: popup.cpp:76
virtual void post_build(twindow &window)
Actions to be taken directly after the window is build.
Definition: popup.cpp:71
void show_non_modal()
Shows the window non modal.
Definition: window.cpp:569
bool faked() const
Definition: video.hpp:166
virtual ~tpopup()
Definition: popup.cpp:29