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 : std::size_t
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 MAX_BUTTONS = 3;
148 using FButtons = std::array<std::unique_ptr<FButton>, MAX_BUTTONS>;
149 using FButtonsDigit = std::array<ButtonType, MAX_BUTTONS>;
154 void initCallbacks();
155 void calculateDimensions();
156 void draw()
override;
157 auto getButtonLengthArray()
const -> std::array<std::size_t, MAX_BUTTONS>;
158 auto calculateMaxButtonSize()
const -> std::size_t;
159 void resizeButtons()
const;
160 void adjustButtons();
165 FStringList text_components{};
167 std::size_t max_line_width{0};
168 FColor emphasis_color{getColorTheme()->dialog.emphasis_fg};
169 ButtonType result_code{ButtonType::Reject};
170 FButtonsDigit button_digit{};
171 std::size_t num_buttons{0};
172 std::size_t text_num_lines{0};
173 bool center_text{
false};
179 inline auto FMessageBox::getClassName()
const ->
FString 180 {
return "FMessageBox"; }
183 inline auto FMessageBox::getTitlebarText()
const ->
FString 185 const FString& title = FDialog::getText();
190 inline auto FMessageBox::getHeadline()
const ->
FString 191 {
return headline_text; }
194 inline auto FMessageBox::getText()
const ->
FString 198 inline void FMessageBox::setTitlebarText (
const FString& txt)
199 {
return FDialog::setText(txt); }
202 inline void FMessageBox::setCenterText (
bool enable)
203 { center_text = enable; }
206 inline void FMessageBox::unsetCenterText()
207 { setCenterText(
false); }
210 template <
typename messageType>
211 auto FMessageBox::info (
FWidget* parent
213 ,
const messageType& message
216 , ButtonType button2 ) -> ButtonType
219 , std::move(
FString() << message)
220 , button0, button1, button2
222 const ButtonType reply = mbox.exec();
227 template <
typename messageType>
228 auto FMessageBox::error (
FWidget* parent
229 ,
const messageType& message
232 , ButtonType button2 ) -> ButtonType
234 const FString caption{
"Error message"};
237 , std::move(
FString() << message)
238 , button0, button1, button2
240 FVTerm::getFOutput()->beep();
241 mbox.setHeadline(
"Warning:");
242 mbox.setCenterText();
243 const auto& wc = getColorTheme();
244 mbox.setForegroundColor(wc->error_box.fg);
245 mbox.setBackgroundColor(wc->error_box.bg);
246 mbox.emphasis_color = wc->error_box.emphasis_fg;
247 const ButtonType reply = mbox.exec();
253 #endif // FMESSAGEBOX_H Definition: class_template.cpp:25
Definition: fmessagebox.h:79