56 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 57 #error "Only <final/final.h> can be included directly." 65 #include "final/dialog/fdialog.h" 66 #include "final/fwidgetcolors.h" 67 #include "final/widget/fbutton.h" 83 enum class ButtonType : uInt8
99 , ButtonType, ButtonType, ButtonType
106 auto getClassName()
const ->
FString override;
107 auto getTitleBarText()
const ->
FString;
108 auto getHeadline()
const ->
FString;
109 auto getText()
const ->
FString override;
112 void setTitleBarText (
const FString&);
113 void setHeadline (
const FString&);
114 void setCenterText (
bool =
true);
115 void unsetCenterText();
116 void setText (
const FString&)
override;
119 auto exec() -> ButtonType;
120 template <
typename messageType>
124 , ButtonType = ButtonType::Ok
125 , ButtonType = ButtonType::Reject
126 , ButtonType = ButtonType::Reject ) -> ButtonType;
128 template <
typename messageType>
131 , ButtonType = ButtonType::Ok
132 , ButtonType = ButtonType::Reject
133 , ButtonType = ButtonType::Reject ) -> ButtonType;
136 void initLayout()
override;
137 void adjustSize()
override;
138 void done (ButtonType);
141 void cb_processClick (ButtonType);
145 static constexpr std::size_t GAP = 4;
146 static constexpr std::size_t MAX_BUTTONS = 3;
147 static constexpr std::size_t PADDING = 5;
150 using FButtons = std::array<std::unique_ptr<FButton>, MAX_BUTTONS>;
151 using FButtonsDigit = std::array<ButtonType, MAX_BUTTONS>;
156 void initCallbacks();
157 void calculateDimensions();
158 void draw()
override;
159 auto getButtonLengthArray()
const -> std::array<std::size_t, MAX_BUTTONS>;
160 auto calculateMaxButtonSize()
const -> std::size_t;
161 void resizeButtons()
const;
162 void adjustButtons();
163 auto calculateTotalButtonWidth()
const -> std::size_t;
164 void adjustWindowSize (std::size_t);
165 void setButtonPositions (std::size_t);
170 FStringList text_components{};
172 std::size_t max_line_width{0};
173 FColor emphasis_color{getColorTheme()->dialog.emphasis_fg};
174 ButtonType result_code{ButtonType::Reject};
175 FButtonsDigit button_digit{};
176 std::size_t num_buttons{0};
177 std::size_t text_num_lines{0};
178 bool center_text{
false};
184 inline auto FMessageBox::getClassName()
const ->
FString 185 {
return "FMessageBox"; }
188 inline auto FMessageBox::getTitleBarText()
const ->
FString 190 const FString& title = FDialog::getText();
195 inline auto FMessageBox::getHeadline()
const ->
FString 196 {
return headline_text; }
199 inline auto FMessageBox::getText()
const ->
FString 203 inline void FMessageBox::setTitleBarText (
const FString& txt)
204 {
return FDialog::setText(txt); }
207 inline void FMessageBox::setCenterText (
bool enable)
208 { center_text = enable; }
211 inline void FMessageBox::unsetCenterText()
212 { setCenterText(
false); }
215 template <
typename messageType>
216 auto FMessageBox::info (
FWidget* parent
218 ,
const messageType& message
221 , ButtonType button2 ) -> ButtonType
224 , std::move(
FString() << message)
225 , button0, button1, button2
227 const ButtonType reply = mbox.exec();
232 template <
typename messageType>
233 auto FMessageBox::error (
FWidget* parent
234 ,
const messageType& message
237 , ButtonType button2 ) -> ButtonType
239 const FString caption{
"Error message"};
242 , std::move(
FString() << message)
243 , button0, button1, button2
245 FVTerm::getFOutput()->beep();
246 mbox.setHeadline(
"Warning:");
247 mbox.setCenterText();
248 const auto& wc_error_box = getColorTheme()->error_box;
249 mbox.setForegroundColor(wc_error_box.fg);
250 mbox.setBackgroundColor(wc_error_box.bg);
251 mbox.emphasis_color = wc_error_box.emphasis_fg;
252 const ButtonType reply = mbox.exec();
258 #endif // FMESSAGEBOX_H Definition: class_template.cpp:25
Definition: fmessagebox.h:79