The Battle for Wesnoth  1.17.0-dev
progress_bar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
22 
23 namespace gui2
24 {
25 namespace implementation
26 {
27 struct builder_progress_bar;
28 }
29 
30 // ------------ WIDGET -----------{
31 
32 /**
33  * @ingroup GUIWidgetWML
34  *
35  * This object shows the progress of a certain action, or the value state of a certain item.
36  *
37  * The following states exist:
38  * * state_enabled - the progress bar is enabled.
39  */
41 {
42 public:
43  explicit progress_bar(const implementation::builder_progress_bar& builder);
44 
45  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
46 
47  /** See @ref styled_widget::set_active. */
48  virtual void set_active(const bool active) override;
49 
50  /** See @ref styled_widget::get_active. */
51  virtual bool get_active() const override;
52 
53  /** See @ref styled_widget::get_state. */
54  virtual unsigned get_state() const override;
55 
56  /** See @ref widget::disable_click_dismiss. */
57  bool disable_click_dismiss() const override;
58 
59 
60  /***** ***** ***** setters / getters for members ***** ****** *****/
61 
62  void set_percentage(unsigned percentage);
63  unsigned get_percentage() const
64  {
65  return percentage_;
66  }
67 
68 private:
69  /**
70  * Possible states of the widget.
71  *
72  * Note the order of the states must be the same as defined in settings.hpp.
73  */
74  enum state_t {
76  };
77 
78  /** The percentage done. */
79  unsigned percentage_;
80 
81 public:
82  /** Static type getter that does not rely on the widget being constructed. */
83  static const std::string& type();
84 
85 private:
86  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
87  virtual const std::string& get_control_type() const override;
88 };
89 
90 // }---------- DEFINITION ---------{
91 
93 {
94  explicit progress_bar_definition(const config& cfg);
95 
97  {
98  explicit resolution(const config& cfg);
99  };
100 };
101 
102 // }---------- BUILDER -----------{
103 
104 namespace implementation
105 {
106 
108 {
109 
110  explicit builder_progress_bar(const config& cfg);
111 
113 
114  virtual widget* build() const override;
115 };
116 
117 } // namespace implementation
118 
119 // }------------ END --------------
120 
121 } // namespace gui2
Base class of a resolution, contains the common keys for a resolution.
virtual widget * build() const =0
Base class for all widgets.
Definition: widget.hpp:49
This object shows the progress of a certain action, or the value state of a certain item...
unsigned get_percentage() const
Generic file dialog.
Definition: field-fwd.hpp:23
state_t
Possible states of the widget.
Base class for all visible items.
point resolution()
Definition: general.cpp:393
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
unsigned percentage_
The percentage done.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.