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.
exception_dialog.h
Go to the documentation of this file.
1 #pragma once
5 #include <functional>
6 #include <string>
7 #include <xtd/version.h>
8 #include <xtd/drawing/icon.h>
9 #include <xtd/system_exception.h>
10 #include "component.h"
11 #include "dialog_result.h"
12 #include "dialog_style.h"
14 #include "iwin32_window.h"
16 
18 namespace xtd {
20  namespace forms {
30  class forms_export_ exception_dialog final : public component {
31  public:
33  exception_dialog() = default;
34 
37  xtd::forms::dialog_result dialog_result() const {return dialog_result_;}
38 
41  xtd::forms::dialog_style dialog_style() const {return dialog_style_;}
46  dialog_style_ = dialog_style;
47  return *this;
48  }
49 
52  std::reference_wrapper<const std::exception> exception() const {return std::reference_wrapper<const std::exception>(*exception_);}
57  exception_dialog& exception(const std::exception& exception) {
58  exception_ = &exception;
59  return *this;
60  }
61 
64  xtd::ustring text() const {return text_;}
69  if (text_ != text)
70  text_ = text;
71  return *this;
72  }
73 
75  void reset();
76 
83  void show_sheet(const iwin32_window& owner);
86 
90 
91  protected:
96  dialog_result_ = e.dialog_result();
97  dialog_closed(*this, e);
98  }
99 
100  private:
103  const std::exception* exception_ = nullptr;
104  xtd::ustring text_;
105  };
106  }
107 }
Contains xtd::forms::arranged_element_collection collection.
Represents an event.
Definition: event.h:21
Provides the base implementation and enables object sharing between applications.
Definition: component.h:21
Provides data for a dialog closed event.
Definition: dialog_closed_event_args.h:17
Represents a common dialog box that displays exception dialog.
Definition: exception_dialog.h:30
std::reference_wrapper< const std::exception > exception() const
Gets exception reference.
Definition: exception_dialog.h:52
xtd::forms::dialog_style dialog_style() const
Gets the dialog style.
Definition: exception_dialog.h:41
void on_dialog_closed(const dialog_closed_event_args &e)
Raises the close event.
Definition: exception_dialog.h:95
void show_sheet(const iwin32_window &owner)
Runs exception dialog box.
exception_dialog & dialog_style(xtd::forms::dialog_style dialog_style)
Sets the dialog style.
Definition: exception_dialog.h:45
xtd::ustring text() const
Gets the dialog caption text.
Definition: exception_dialog.h:64
exception_dialog()=default
Initializes a new instance of the exception_dialog class.
xtd::forms::dialog_result dialog_result() const
Get async dialog_result result after dialog box is closing.
Definition: exception_dialog.h:37
xtd::forms::dialog_result show_dialog(const iwin32_window &owner)
Runs exception dialog box.
exception_dialog & exception(const std::exception &exception)
Sets exception.
Definition: exception_dialog.h:57
exception_dialog & text(const xtd::ustring &text)
Sets the dialog caption text.
Definition: exception_dialog.h:68
xtd::forms::dialog_result show_sheet_dialog(const iwin32_window &owner)
Runs exception dialog box.
void reset()
Resets all properties to empty string.
xtd::forms::dialog_result show_dialog()
Runs exception dialog box.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::forms::component class.
Contains xtd::forms::dialog_closed_event_handler dialog.
Contains xtd::forms::dialog_result enum class.
Contains xtd::forms::dialog_style enum class.
event< exception_dialog, dialog_closed_event_handler > dialog_closed
Occurs when the user close an exception dialog box with dialog close button or other dialog buttons.
Definition: exception_dialog.h:89
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ e
The E key.
dialog_result
Specifies identifiers to indicate the return value of a dialog box.
Definition: dialog_result.h:39
dialog_style
Specifies the style of a dialog.
Definition: dialog_style.h:17
@ none
Nothing is returned from the dialog box. This means that the modal dialog continues running.
@ standard
Standard style dialog.
Contains xtd::drawing::icon class.
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::system_exception exception.
Contains xtd::version class.