The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
network_transmission.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Sergey Popov <[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 #ifndef GUI_DIALOGS_NETWORK_RECEIVE_HPP_INCLUDED
16 #define GUI_DIALOGS_NETWORK_RECEIVE_HPP_INCLUDED
17 
18 #include "gui/dialogs/dialog.hpp"
19 #include "gui/widgets/control.hpp"
20 #include "network_asio.hpp"
21 #include <boost/optional.hpp>
22 #include "events.hpp"
23 
24 namespace gui2
25 {
26 
27 
28 /**
29  * Dialog that tracks network transmissions
30  *
31  * It shows upload/download progress and allows the user
32  * to cancel the transmission.
33  */
35 {
36 public:
38  {
39  public:
40  virtual size_t total() { return 0; }
41  virtual size_t current() { return 0; }
42  virtual bool finished() = 0;
43  virtual void cancel() = 0;
44  virtual void poll() = 0;
45  virtual ~connection_data() {}
46  };
47 private:
49 
51  {
52  public:
54  virtual void process(events::pump_info&);
55 
57  : connection_(connection), window_()
58  {
59  }
60 
61  boost::optional<twindow&> window_;
62  } pump_monitor_;
63 
64 public:
66  const std::string& title,
67  const std::string& subtitle);
68 
69  void set_subtitle(const std::string&);
71  {
72  connection_ = &connection;
73  }
74 
75 protected:
76  /** Inherited from tdialog. */
77  void pre_show(twindow& window);
78 
79  /** Inherited from tdialog. */
80  void post_show(twindow& window);
81 
82 private:
83  /**
84  * The subtitle for the dialog.
85  *
86  * This field commonly shows the action in progress eg connecting,
87  * uploading, downloading etc..
88  */
90 
91  /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
92  virtual const std::string& window_id() const;
93 };
94 
95 } // namespace gui2
96 
97 #endif
void post_show(twindow &window)
Inherited from tdialog.
Dialog that tracks network transmissions.
void pre_show(twindow &window)
Inherited from tdialog.
gui2::tnetwork_transmission::pump_monitor pump_monitor_
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
Abstract base class for all dialogs.
Definition: dialog.hpp:121
void set_connection_data(connection_data &connection)
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
tnetwork_transmission(connection_data &connection, const std::string &title, const std::string &subtitle)
void set_subtitle(const std::string &)
int connection
Definition: network.hpp:74
virtual void process(events::pump_info &)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::string subtitle_
The subtitle for the dialog.