xtd - Reference Guide  0.1.1
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  progress_dialog() = default;
28  ~progress_dialog() {hide();}
29 
32  bool cancelled() const;
33 
36  bool skipped() const;
37 
40  xtd::forms::dialog_style dialog_style() const {return dialog_style_;}
45  if (dialog_style_ != dialog_style) {
46  dialog_style_ = dialog_style;
47  recreate_dialog();
48  }
49  return *this;
50  }
51 
54  const std::vector<xtd::ustring>& informations() const {return informations_;}
58  progress_dialog& informations(const std::vector<xtd::ustring>& informations);
59 
62  bool marquee() const {return get_option(PROGDLG_MARQUEEPROGRESS);}
66  progress_dialog& marquee(bool marquee);
67 
72  size_t marquee_animation_speed() {return marquee_animation_speed_;}
77  progress_dialog& marquee_animation_speed(size_t marquee_animation_speed);
78 
83  int32_t maximum() {return maximum_;}
88  progress_dialog& maximum(int32_t maximum);
89 
92  const xtd::ustring& message() const {return message_;}
97 
101  int32_t minimum() {return minimum_;}
106  progress_dialog& minimum(int32_t minimum);
107 
109  void resume();
110 
113  bool show_cancel_button() const {return !get_option(PROGDLG_NOCANCEL);}
117  progress_dialog& show_cancel_button(bool show_cancel_button);
118 
121  bool show_elapsed_time() const {return !get_option(PROGDLG_ELAPSEDTIME);}
125  progress_dialog& show_elapsed_time(bool show_elapsed_time);
126 
129  bool show_estimated_time() const {return !get_option(PROGDLG_ESTIMATEDTIME);}
133  progress_dialog& show_estimated_time(bool show_estimated_time);
134 
137  bool show_remaining_time() const {return !get_option(PROGDLG_AUTOTIME);}
141  progress_dialog& show_remaining_time(bool show_remaining_time);
142 
145  bool show_skip_button() const {return !get_option(PROGDLG_NOSKIP);}
149  progress_dialog& show_skip_button(bool show_skip_button);
150 
154  virtual int32_t step() {return step_;}
158  virtual progress_dialog& step(int32_t step);
159 
162  const xtd::ustring& text() const {return text_;}
167  if (text_ != text) {
168  text_ = text;
169  recreate_dialog();
170  }
171  return *this;
172  }
173 
179  int32_t value() {return value_;}
185  progress_dialog& value(int32_t value);
186 
188  void hide();
189 
194  void increment(int32_t increment) {value(value_ + increment);}
195 
198  void perform_step() {increment(step());}
199 
201  void reset();
202 
204  void show();
206  void show(const iwin32_window& owner);
207 
209  void show_sheet(const iwin32_window& owner);
210 
212  void show_dialog();
214  void show_dialog(const iwin32_window& owner);
216  void show_sheet_dialog(const iwin32_window& owner);
217 
218  private:
219  bool get_option(size_t flag) const {return (options_ & flag) == flag;}
220  void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
221  void recreate_dialog();
222 
224  intptr_t handle_ = 0;
225  std::vector<xtd::ustring> informations_;
226  size_t marquee_animation_speed_ = 100;
227  int32_t maximum_ = 100;
228  xtd::ustring message_;
229  int32_t minimum_ = 0;
230  bool native_ = false;
231  size_t options_ = PROGDLG_NORMAL|PROGDLG_NOCANCEL|PROGDLG_NOSKIP;
232  const iwin32_window* owner_ = nullptr;
233  int32_t step_ = 10;
234  xtd::ustring text_;
235  int32_t value_ = 0;
236  };
237  }
238 }
Provides the base implementation and enables object sharing between applications.
Definition: component.h:21
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
Implements a Windows message.
Definition: message.h:25
Represents a common dialog box that displays progress dialog.
Definition: progress_dialog.h:24
void reset()
Resets all properties to empty string.
bool show_remaining_time() const
Gets a value that indicates whether remaining time is shown.
Definition: progress_dialog.h:137
progress_dialog & maximum(int32_t maximum)
Sets the maximum value of the range of the control.
progress_dialog & minimum(int32_t minimum)
Sets the minimum value of the range of the control.
virtual progress_dialog & step(int32_t step)
Sets the amount by which a call to the PerformStep() method increases the current position of the pro...
const xtd::ustring & text() const
Gets the dialog title.
Definition: progress_dialog.h:162
progress_dialog()=default
Initializes a new instance of the progress_dialog class.
void show(const iwin32_window &owner)
Runs progress dialog box.
bool skipped() const
Gets whether user has clicked on skip button.
xtd::forms::dialog_style dialog_style() const
Gets the dialog style.
Definition: progress_dialog.h:40
bool show_estimated_time() const
Gets a value that indicates whether estimated time is shown.
Definition: progress_dialog.h:129
int32_t minimum()
Gets the minimum value of the range of the control.
Definition: progress_dialog.h:101
const xtd::ustring & message() const
Gets the message text.
Definition: progress_dialog.h:92
progress_dialog & message(const xtd::ustring &message)
Sets the message text.
void show_dialog()
Runs progress dialog box.
void hide()
Hides progress dialog box.
void perform_step()
Advances the current position of the progress bar by the amount of the Step property.
Definition: progress_dialog.h:198
bool show_elapsed_time() const
Gets a value that indicates whether elapsed time is shown.
Definition: progress_dialog.h:121
void resume()
Resume progress dialog box after Abort button clicked.
void increment(int32_t increment)
Advances the current position of the progress bar by the specified amount.
Definition: progress_dialog.h:194
void show_dialog(const iwin32_window &owner)
Runs progress dialog box.
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:62
progress_dialog & text(const xtd::ustring &text)
Sets the dialog title.
Definition: progress_dialog.h:166
void show_sheet(const iwin32_window &owner)
Runs progress dialog box as sheet.
void show_sheet_dialog(const iwin32_window &owner)
Runs progress dialog box.
void show()
Runs progress dialog box.
progress_dialog & show_cancel_button(bool show_cancel_button)
Sets a value that indicates whether cancel button is shown.
int32_t value()
Gets the current position of the progress bar.
Definition: progress_dialog.h:179
progress_dialog & show_skip_button(bool show_skip_button)
Sets a value that indicates whether skip button is shown.
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:72
progress_dialog & show_elapsed_time(bool show_elapsed_time)
Sets a value that indicates whether elapsed time is shown.
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:154
progress_dialog & informations(const std::vector< xtd::ustring > &informations)
Sets the information texts.
bool cancelled() const
Gets whether user has clicked on cancel button.
progress_dialog & marquee_animation_speed(size_t marquee_animation_speed)
Sets the time period, in milliseconds, that it takes the progress block to scroll across the progress...
const std::vector< xtd::ustring > & informations() const
Gets the information texts.
Definition: progress_dialog.h:54
progress_dialog & dialog_style(xtd::forms::dialog_style dialog_style)
Sets the dialog style.
Definition: progress_dialog.h:44
progress_dialog & show_remaining_time(bool show_remaining_time)
Sets a value that indicates whether remaining time is shown.
progress_dialog & marquee(bool marquee)
Gets a value that Indicates progress by continuously scrolling a block across a progress_bar in a mar...
int32_t maximum()
Gets the maximum value of the range of the control.
Definition: progress_dialog.h:83
progress_dialog & show_estimated_time(bool show_estimated_time)
Sets a value that indicates whether estimated time is shown.
bool show_cancel_button() const
Gets a value that indicates whether cancel button is shown.
Definition: progress_dialog.h:113
bool show_skip_button() const
Gets a value that indicates whether skip button is shown.
Definition: progress_dialog.h:145
progress_dialog & value(int32_t value)
Sets the current position of the progress bar.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::forms::component class.
Contains xtd::forms::dialog_style enum class.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
dialog_style
Specifies the style of a dialog.
Definition: dialog_style.h:17
@ system
System style dialog.
Contains xtd::forms::iwin32_window interface.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::ustring class.