The Battle for Wesnoth  1.19.0-dev
progress_bar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
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 
21 
22 namespace gui2
23 {
24 namespace implementation
25 {
26 struct builder_progress_bar;
27 }
28 
29 // ------------ WIDGET -----------{
30 
31 /**
32  * @ingroup GUIWidgetWML
33  *
34  * This object shows the progress of a certain action, or the value state of a certain item.
35  *
36  * The following states exist:
37  * * state_enabled - the progress bar is enabled.
38  */
40 {
41 public:
42  explicit progress_bar(const implementation::builder_progress_bar& builder);
43 
44  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
45 
46  /** See @ref styled_widget::set_active. */
47  virtual void set_active(const bool active) override;
48 
49  /** See @ref styled_widget::get_active. */
50  virtual bool get_active() const override;
51 
52  /** See @ref styled_widget::get_state. */
53  virtual unsigned get_state() const override;
54 
55  /** See @ref widget::disable_click_dismiss. */
56  bool disable_click_dismiss() const override;
57 
58 
59  /***** ***** ***** setters / getters for members ***** ****** *****/
60 
61  void set_percentage(unsigned percentage);
62  unsigned get_percentage() const
63  {
64  return percentage_;
65  }
66 
67 private:
68  /**
69  * Possible states of the widget.
70  *
71  * Note the order of the states must be the same as defined in settings.hpp.
72  */
73  enum state_t {
75  };
76 
77  /** The percentage done. */
78  unsigned percentage_;
79 
80 public:
81  /** Static type getter that does not rely on the widget being constructed. */
82  static const std::string& type();
83 
84 private:
85  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
86  virtual const std::string& get_control_type() const override;
87 };
88 
89 // }---------- DEFINITION ---------{
90 
92 {
93  explicit progress_bar_definition(const config& cfg);
94 
96  {
97  explicit resolution(const config& cfg);
98  };
99 };
100 
101 // }---------- BUILDER -----------{
102 
103 namespace implementation
104 {
105 
107 {
108 
109  explicit builder_progress_bar(const config& cfg);
110 
112 
113  virtual std::unique_ptr<widget> build() const override;
114 };
115 
116 } // namespace implementation
117 
118 // }------------ END --------------
119 
120 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
This object shows the progress of a certain action, or the value state of a certain item.
unsigned percentage_
The percentage done.
virtual unsigned get_state() const override
See styled_widget::get_state.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
void set_percentage(unsigned percentage)
state_t
Possible states of the widget.
unsigned get_percentage() const
progress_bar(const implementation::builder_progress_bar &builder)
virtual bool get_active() const override
See styled_widget::get_active.
virtual void set_active(const bool active) override
See styled_widget::set_active.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Base class for all visible items.
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
virtual std::unique_ptr< widget > build() const override
virtual std::unique_ptr< widget > build() const=0
progress_bar_definition(const config &cfg)
Base class of a resolution, contains the common keys for a resolution.