The Battle for Wesnoth  1.15.0+dev
modeless_dialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 
18 
19 #include "gui/widgets/window.hpp"
20 #include "video.hpp"
21 
22 namespace gui2
23 {
24 namespace dialogs
25 {
26 
28 {
29 }
30 
32 {
33  hide();
34 }
35 
36 void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_close_time*/)
37 {
38  if(CVideo::get_singleton().faked()) {
39  return;
40  }
41 
42  hide();
43 
44  window_.reset(build_window());
45 
47 
48  pre_show(*window_);
49 
50  if(allow_interaction) {
51  open_window_stack.push_back(window_.get());
52  window_->show_non_modal();
53  } else {
54  window_->show_tooltip(/*auto_close_time*/);
55  }
56 }
57 
59 {
60  if(window_) {
61  // Don't bother if show_mode_ == tooltip, because in that case we didn't add it anyway.
62  if(window_->mode() == window::modeless) {
64  }
65 
66  window_->undraw();
67  window_.reset(nullptr); }
68 }
69 
71 {
72  return build(window_id());
73 }
74 
76 {
77  /* DO NOTHING */
78 }
79 
81 {
82  /* DO NOTHING */
83 }
84 
85 } // namespace dialogs
86 } // namespace gui2
window * build_window() const
Builds the window.
This file contains the window object, this object is a top level container which has the event manage...
virtual void post_build(window &window)
Actions to be taken directly after the window is build.
static CVideo & get_singleton()
Definition: video.hpp:43
-file util.hpp
virtual const std::string & window_id() const =0
The id of the window to build.
Generic file dialog.
Definition: field-fwd.hpp:22
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
Definition: handler.cpp:1108
void hide()
Hides the window.
Various uncategorised dialogs.
virtual void pre_show(window &window)
Actions to be taken before showing the window.
window * build(const builder_window::window_resolution *definition)
Builds a window.
std::unique_ptr< window > window_
The window, used in show.
void show(const bool allow_interaction=false, const unsigned auto_close_time=0)
Shows the window.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
std::vector< window * > open_window_stack
Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they...
Definition: handler.cpp:1106