The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
progress_bar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 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 #ifndef GUI_WIDGETS_PROGRESS_BAR_HPP_INCLUDED
16 #define GUI_WIDGETS_PROGRESS_BAR_HPP_INCLUDED
17 
18 #include "gui/widgets/control.hpp"
19 
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 class tprogress_bar : public tcontrol
29 {
30 public:
31  tprogress_bar() : tcontrol(COUNT), percentage_(static_cast<unsigned>(-1))
32  {
33  // Force canvas update
34  set_percentage(0);
35  }
36 
37  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
38 
39  /** See @ref tcontrol::set_active. */
40  virtual void set_active(const bool active) override;
41 
42  /** See @ref tcontrol::get_active. */
43  virtual bool get_active() const override;
44 
45  /** See @ref tcontrol::get_state. */
46  virtual unsigned get_state() const override;
47 
48  /** See @ref twidget::disable_click_dismiss. */
49  bool disable_click_dismiss() const override;
50 
51 
52  /***** ***** ***** setters / getters for members ***** ****** *****/
53 
54  void set_percentage(unsigned percentage);
55  unsigned get_percentage() const
56  {
57  return percentage_;
58  }
59 
60 private:
61  /**
62  * Possible states of the widget.
63  *
64  * Note the order of the states must be the same as defined in settings.hpp.
65  */
66  enum tstate {
69  };
70 
71  /** The percentage done. */
72  unsigned percentage_;
73 
74  /** See @ref tcontrol::get_control_type. */
75  virtual const std::string& get_control_type() const override;
76 };
77 
78 // }---------- DEFINITION ---------{
79 
81 {
82  explicit tprogress_bar_definition(const config& cfg);
83 
85  {
86  explicit tresolution(const config& cfg);
87  };
88 };
89 
90 // }---------- BUILDER -----------{
91 
92 namespace implementation
93 {
94 
96 {
97 
98  explicit tbuilder_progress_bar(const config& cfg);
99 
101 
102  twidget* build() const;
103 };
104 
105 } // namespace implementation
106 
107 // }------------ END --------------
108 
109 } // namespace gui2
110 
111 #endif
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
void set_percentage(unsigned percentage)
tstate
Possible states of the widget.
virtual unsigned get_state() const override
See tcontrol::get_state.
Base class of a resolution, contains the common keys for a resolution.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
virtual twidget * build() const =0
virtual void set_active(const bool active) override
See tcontrol::set_active.
unsigned percentage_
The percentage done.
tprogress_bar_definition(const config &cfg)
Base class for all visible items.
Definition: control.hpp:34
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
virtual bool get_active() const override
See tcontrol::get_active.
Base class for all widgets.
Definition: widget.hpp:49
unsigned get_percentage() const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.