xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
progress_dialog.h
Go to the documentation of this file.
1 #pragma once
5 #include <xtd/ustring.h>
6 #include <xtd/forms/progress_dialog_flags.h>
7 #include "component.h"
8 #include "dialog_style.h"
9 #include "iwin32_window.h"
10 
12 namespace xtd {
14  namespace forms {
24  class forms_export_ progress_dialog final : public component {
25  public:
27 
30  progress_dialog() = default;
32 
34  ~progress_dialog() {hide();}
36 
38 
42  bool cancelled() const;
43 
46  bool skipped() const;
47 
50  xtd::forms::dialog_style dialog_style() const {return dialog_style_;}
55  if (dialog_style_ != dialog_style) {
56  dialog_style_ = dialog_style;
57  recreate_dialog();
58  }
59  return *this;
60  }
61 
64  const std::vector<xtd::ustring>& informations() const {return informations_;}
68  progress_dialog& informations(const std::vector<xtd::ustring>& informations);
69 
72  bool marquee() const {return get_option(PROGDLG_MARQUEEPROGRESS);}
77 
82  size_t marquee_animation_speed() {return marquee_animation_speed_;}
87  progress_dialog& marquee_animation_speed(size_t marquee_animation_speed);
88 
93  int32_t maximum() {return maximum_;}
98  progress_dialog& maximum(int32_t maximum);
99 
102  const xtd::ustring& message() const {return message_;}
107 
111  int32_t minimum() {return minimum_;}
116  progress_dialog& minimum(int32_t minimum);
117 
120  bool show_cancel_button() const {return !get_option(PROGDLG_NOCANCEL);}
125 
128  bool show_elapsed_time() const {return !get_option(PROGDLG_ELAPSEDTIME);}
133 
136  bool show_estimated_time() const {return !get_option(PROGDLG_ESTIMATEDTIME);}
141 
144  bool show_remaining_time() const {return !get_option(PROGDLG_AUTOTIME);}
149 
152  bool show_skip_button() const {return !get_option(PROGDLG_NOSKIP);}
157 
161  virtual int32_t step() {return step_;}
165  virtual progress_dialog& step(int32_t step);
166 
169  const xtd::ustring& text() const {return text_;}
174  if (text_ != text) {
175  text_ = text;
176  recreate_dialog();
177  }
178  return *this;
179  }
180 
186  int32_t value() {return value_;}
192  progress_dialog& value(int32_t value);
194 
196 
199  void hide();
200 
205  void increment(int32_t increment) {value(value_ + increment);}
206 
209  void perform_step() {increment(step());}
210 
212  void reset();
213 
215  void resume();
216 
218  void show();
220  void show(const iwin32_window& owner);
221 
223  void show_sheet(const iwin32_window& owner);
224 
226  void show_dialog();
228  void show_dialog(const iwin32_window& owner);
230  void show_sheet_dialog(const iwin32_window& owner);
232 
233  private:
234  bool get_option(size_t flag) const {return (options_ & flag) == flag;}
235  void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
236  void recreate_dialog();
237 
239  intptr_t handle_ = 0;
240  std::vector<xtd::ustring> informations_;
241  size_t marquee_animation_speed_ = 100;
242  int32_t maximum_ = 100;
243  xtd::ustring message_;
244  int32_t minimum_ = 0;
245  bool native_ = false;
246  size_t options_ = PROGDLG_NORMAL|PROGDLG_NOCANCEL|PROGDLG_NOSKIP;
247  const iwin32_window* owner_ = nullptr;
248  int32_t step_ = 10;
249  xtd::ustring text_;
250  int32_t value_ = 0;
251  };
252  }
253 }
bool show_skip_button() const
Gets a value that indicates whether skip button is shown.
Definition: progress_dialog.h:152
void perform_step()
Advances the current position of the progress bar by the amount of the Step property.
Definition: progress_dialog.h:209
dialog_style
Specifies the style of a dialog.
Definition: dialog_style.h:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
int32_t minimum()
Gets the minimum value of the range of the control.
Definition: progress_dialog.h:111
bool show_remaining_time() const
Gets a value that indicates whether remaining time is shown.
Definition: progress_dialog.h:144
bool marquee() const
Gets a value that Indicates progress by continuously scrolling a block across a progress_bar in a mar...
Definition: progress_dialog.h:72
const std::vector< xtd::ustring > & informations() const
Gets the information texts.
Definition: progress_dialog.h:64
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
size_t marquee_animation_speed()
Gets he time period, in milliseconds, that it takes the progress block to scroll across the progress ...
Definition: progress_dialog.h:82
Contains xtd::forms::iwin32_window interface.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
virtual int32_t step()
Gets the amount by which a call to the PerformStep() method increases the current position of the pro...
Definition: progress_dialog.h:161
int32_t value()
Gets the current position of the progress bar.
Definition: progress_dialog.h:186
progress_dialog & text(const xtd::ustring &text)
Sets the dialog title.
Definition: progress_dialog.h:173
void increment(int32_t increment)
Advances the current position of the progress bar by the specified amount.
Definition: progress_dialog.h:205
bool show_estimated_time() const
Gets a value that indicates whether estimated time is shown.
Definition: progress_dialog.h:136
Hides minimized windows by moving them off the visible area of the screen.
bool show_elapsed_time() const
Gets a value that indicates whether elapsed time is shown.
Definition: progress_dialog.h:128
Contains xtd::ustring class.
int32_t maximum()
Gets the maximum value of the range of the control.
Definition: progress_dialog.h:93
progress_dialog & dialog_style(xtd::forms::dialog_style dialog_style)
Sets the dialog style.
Definition: progress_dialog.h:54
Implements a Windows message.
Definition: message.h:25
const xtd::ustring & text() const
Gets the dialog title.
Definition: progress_dialog.h:169
Contains xtd::forms::dialog_style enum class.
Indicates progress by continuously scrolling a block across a progress_bar in a marquee fashion...
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Contains xtd::forms::component class.
xtd::forms::dialog_style dialog_style() const
Gets the dialog style.
Definition: progress_dialog.h:50
Represents a common dialog box that displays progress dialog.
Definition: progress_dialog.h:24
Provides the base implementation and enables object sharing between applications. ...
Definition: component.h:21
bool show_cancel_button() const
Gets a value that indicates whether cancel button is shown.
Definition: progress_dialog.h:120
const xtd::ustring & message() const
Gets the message text.
Definition: progress_dialog.h:102