The Battle for Wesnoth  1.19.7+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 
32 {
33 public:
34  explicit progress_bar(const implementation::builder_progress_bar& builder);
35 
36  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
37 
38  /** See @ref styled_widget::set_active. */
39  virtual void set_active(const bool active) override;
40 
41  /** See @ref styled_widget::get_active. */
42  virtual bool get_active() const override;
43 
44  /** See @ref styled_widget::get_state. */
45  virtual unsigned get_state() const override;
46 
47  /** See @ref widget::disable_click_dismiss. */
48  bool disable_click_dismiss() const override;
49 
50 
51  /***** ***** ***** setters / getters for members ***** ****** *****/
52 
53  void set_percentage(unsigned percentage);
54  unsigned get_percentage() const
55  {
56  return percentage_;
57  }
58 
59 private:
60  /**
61  * Possible states of the widget.
62  *
63  * Note the order of the states must be the same as defined in settings.hpp.
64  */
65  enum state_t {
67  };
68 
69  /** The percentage done. */
70  unsigned percentage_;
71 
72 public:
73  /** Static type getter that does not rely on the widget being constructed. */
74  static const std::string& type();
75 
76 private:
77  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
78  virtual const std::string& get_control_type() const override;
79 };
80 
81 // }---------- DEFINITION ---------{
82 
84 {
85  explicit progress_bar_definition(const config& cfg);
86 
88  {
89  explicit resolution(const config& cfg);
90  };
91 };
92 
93 // }---------- BUILDER -----------{
94 
95 namespace implementation
96 {
97 
99 {
100 
101  explicit builder_progress_bar(const config& cfg);
102 
104 
105  virtual std::unique_ptr<widget> build() const override;
106 };
107 
108 } // namespace implementation
109 
110 // }------------ END --------------
111 
112 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
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.
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)