28 template <
typename ButtonInterface>
35 template <
typename ButtonInterface>
42 template <
typename ButtonInterface>
44 base_type{}, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aTexture, label_type::
MultiLine, aAlignment }
49 template <
typename ButtonInterface>
56 template <
typename ButtonInterface>
63 template <
typename ButtonInterface>
70 template <
typename ButtonInterface>
77 template <
typename ButtonInterface>
84 template <
typename ButtonInterface>
91 template <
typename ButtonInterface>
93 base_type{ aParent }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aImage, label_type::
MultiLine, aAlignment }
98 template <
typename ButtonInterface>
100 base_type{ aParent }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aText, aTexture, label_type::
MultiLine, aAlignment }
105 template <
typename ButtonInterface>
107 base_type{ aParent }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aText, aImage, label_type::
MultiLine, aAlignment }
112 template <
typename ButtonInterface>
119 template <
typename ButtonInterface>
126 template <
typename ButtonInterface>
128 base_type{ aLayout }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aTexture, label_type::
MultiLine, aAlignment }
133 template <
typename ButtonInterface>
135 base_type{ aLayout }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aImage, label_type::
MultiLine, aAlignment }
140 template <
typename ButtonInterface>
142 base_type{ aLayout }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aText, aTexture, label_type::
MultiLine, aAlignment }
147 template <
typename ButtonInterface>
149 base_type{ aLayout }, iPressed{ false }, iCheckable{
button_checkable::
NotCheckable }, iCheckedState{ false }, iLayout{ *this }, iLabel{ iLayout, aText, aImage, label_type::
MultiLine, aAlignment }
154 template <
typename ButtonInterface>
157 service<i_app>().remove_mnemonic(*
this);
160 template <
typename ButtonInterface>
163 if (base_type::has_size_policy())
164 return base_type::size_policy();
165 else if (base_type::has_fixed_size())
171 template <
typename ButtonInterface>
174 if (base_type::has_maximum_size())
175 return base_type::maximum_size();
176 auto result = base_type::maximum_size();
184 template <
typename ButtonInterface>
196 template <
typename ButtonInterface>
202 template <
typename ButtonInterface>
208 template <
typename ButtonInterface>
211 iCheckable = aCheckable;
214 template <
typename ButtonInterface>
217 return iCheckedState != std::nullopt && *iCheckedState ==
true;
220 template <
typename ButtonInterface>
223 return iCheckedState != std::nullopt && *iCheckedState ==
false;
226 template <
typename ButtonInterface>
229 return iCheckedState == std::nullopt;
232 template <
typename ButtonInterface>
235 set_checked_state(
true);
238 template <
typename ButtonInterface>
241 set_checked_state(
false);
244 template <
typename ButtonInterface>
247 set_checked_state(std::nullopt);
250 template <
typename ButtonInterface>
253 set_checked_state(aChecked);
256 template <
typename ButtonInterface>
261 if (is_checked() || is_indeterminate())
267 template <
typename ButtonInterface>
270 return label().text();
273 template <
typename ButtonInterface>
276 label().set_text(aText);
279 template <
typename ButtonInterface>
282 return label().image();
285 template <
typename ButtonInterface>
291 template <
typename ButtonInterface>
294 label().set_image(aImage);
297 template <
typename ButtonInterface>
300 label().set_image(aImage);
303 template <
typename ButtonInterface>
310 template <
typename ButtonInterface>
316 template <
typename ButtonInterface>
322 template <
typename ButtonInterface>
328 template <
typename ButtonInterface>
334 template <
typename ButtonInterface>
337 return label().image_widget();
340 template <
typename ButtonInterface>
343 return label().image_widget();
346 template <
typename ButtonInterface>
349 base_type::mouse_button_pressed(aButton, aPosition, aKeyModifiers);
352 as_widget().update();
358 template <
typename ButtonInterface>
361 base_type::mouse_button_double_clicked(aButton, aPosition, aKeyModifiers);
364 as_widget().update();
365 DoubleClicked.trigger();
369 template <
typename ButtonInterface>
372 bool wasCapturing = as_widget().capturing();
373 base_type::mouse_button_released(aButton, aPosition);
376 as_widget().update();
379 destroyed_flag destroyed{ *
this };
381 if (as_widget().client_rect().
contains(aPosition))
389 if (wasCapturing && as_widget().client_rect().
contains(aPosition))
390 RightClicked.trigger();
394 template <
typename ButtonInterface>
405 template <
typename ButtonInterface>
408 destroyed_flag destroyed{ *
this };
414 template <
typename ButtonInterface>
420 template <
typename ButtonInterface>
423 return iCheckedState;
426 template <
typename ButtonInterface>
429 if (iCheckedState == aCheckedState)
432 throw not_tri_state_checkable();
433 iCheckedState = aCheckedState;
434 as_widget().update();
438 else if (is_unchecked())
440 else if (is_indeterminate())
441 Indeterminate.trigger();
445 template <
typename ButtonInterface>
451 template <
typename ButtonInterface>
457 template <
typename ButtonInterface>
460 return label().text_widget();
463 template <
typename ButtonInterface>
466 Pressed.set_trigger_type(trigger_type::Asynchronous);
467 Clicked.set_trigger_type(trigger_type::Asynchronous);
468 DoubleClicked.set_trigger_type(trigger_type::Asynchronous);
469 RightClicked.set_trigger_type(trigger_type::Asynchronous);
470 Released.set_trigger_type(trigger_type::Asynchronous);
471 Toggled.set_trigger_type(trigger_type::Asynchronous);
472 Checked.set_trigger_type(trigger_type::Asynchronous);
473 Unchecked.set_trigger_type(trigger_type::Asynchronous);
474 Indeterminate.set_trigger_type(trigger_type::Asynchronous);
480 auto label_text_updated = [
this]()
484 service<i_app>().add_mnemonic(*
this);
486 service<i_app>().remove_mnemonic(*
this);
488 iSink = label().text_widget().TextChanged(label_text_updated);
489 label_text_updated();
static constexpr dimension_type max_dimension()
virtual void set_alignment(optional_alignment const &aAlignment, bool aUpdateLayout=true)=0
void set_fixed_size(optional_size const &aFixedSize, bool aUpdateLayout=true)
void set_size_policy(const optional_size_policy &aSizePolicy, bool aUpdateLayout=true) override
text_widget(std::string const &aText=std::string{}, text_widget_type aType=text_widget_type::SingleLine, text_widget_flags aFlags=text_widget_flags::None)
std::string mnemonic_from_text(std::string const &aText, char aMnemonicPrefix='&')
bool contains(item_selection const &aSelection, item_presentation_model_index aIndex)