The Battle for Wesnoth  1.15.12+dev
progress_bar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
18 
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 widget* build() const override;
114 };
115 
116 } // namespace implementation
117 
118 // }------------ END --------------
119 
120 } // 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:22
state_t
Possible states of the widget.
Base class for all visible items.
point resolution()
Definition: general.cpp:387
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:59
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.