Bug #13872 » wt_Composite_Impl_Style.patch
| src/Wt/WBootstrap2Theme.C | ||
|---|---|---|
|
#include "Wt/WAbstractSpinBox.h"
|
||
|
#include "Wt/WApplication.h"
|
||
|
#include "Wt/WCheckBox.h"
|
||
|
#include "Wt/WCompositeWidget.h"
|
||
|
#include "Wt/WDateEdit.h"
|
||
|
#include "Wt/WDatePicker.h"
|
||
|
#include "Wt/WDialog.h"
|
||
| ... | ... | |
|
if (!widget->isThemeStyleEnabled())
|
||
|
return;
|
||
|
|
||
|
Wt::WCompositeWidget *composite = dynamic_cast<WCompositeWidget*>(widget);
|
||
|
|
||
|
{
|
||
|
WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
|
||
|
if (popup) {
|
||
| ... | ... | |
|
case DomElementType::DIV:
|
||
|
{
|
||
|
WDialog *dialog = dynamic_cast<WDialog *>(widget);
|
||
|
if (dialog) {
|
||
|
if (dialog || (composite && composite->canCastTo<WDialog*>())) {
|
||
|
element.addPropertyWord(Property::Class, "modal");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WPanel *panel = dynamic_cast<WPanel *>(widget);
|
||
|
if (panel) {
|
||
|
if (panel || (composite && composite->canCastTo<WPanel*>())) {
|
||
|
element.addPropertyWord(Property::Class, "accordion-group");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
|
||
|
if (bar) {
|
||
|
if (bar || (composite && composite->canCastTo<WProgressBar*>())) {
|
||
|
switch (elementRole) {
|
||
|
case MainElement:
|
||
|
element.addPropertyWord(Property::Class, "progress");
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
|
||
|
if (map) {
|
||
|
if (map || (composite && composite->canCastTo<WGoogleMap*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-googlemap");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget);
|
||
|
if (itemView) {
|
||
|
if (itemView || (composite && composite->canCastTo<WAbstractItemView*>())) {
|
||
|
element.addPropertyWord(Property::Class, "form-inline");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WNavigationBar *navBar = dynamic_cast<WNavigationBar *>(widget);
|
||
|
if (navBar) {
|
||
|
if (navBar || (composite && composite->canCastTo<WNavigationBar*>())) {
|
||
|
element.addPropertyWord(Property::Class, "navbar");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
case DomElementType::INPUT:
|
||
|
{
|
||
|
WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
|
||
|
if (spinBox) {
|
||
|
if (spinBox || (composite && composite->canCastTo<WAbstractSpinBox*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-spinbox");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
|
||
|
if (dateEdit) {
|
||
|
if (dateEdit || (composite && composite->canCastTo<WDateEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-dateedit");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WTimeEdit *timeEdit = dynamic_cast<WTimeEdit *>(widget);
|
||
|
if (timeEdit) {
|
||
|
if (timeEdit || (composite && composite->canCastTo<WTimeEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-timeedit");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
WInPlaceEdit *inPlaceEdit
|
||
|
= dynamic_cast<WInPlaceEdit *>(widget);
|
||
|
if (inPlaceEdit)
|
||
|
if (inPlaceEdit || (composite && composite->canCastTo<WInPlaceEdit*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-in-place-edit");
|
||
|
else {
|
||
|
WDatePicker *picker
|
||
|
= dynamic_cast<WDatePicker *>(widget);
|
||
|
if (picker)
|
||
|
if (picker || (composite && composite->canCastTo<WDatePicker*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-datepicker");
|
||
|
}
|
||
|
|
||
| src/Wt/WBootstrap3Theme.C | ||
|---|---|---|
|
#include "Wt/WBootstrapTheme.h"
|
||
|
#include "Wt/WCheckBox.h"
|
||
|
#include "Wt/WComboBox.h"
|
||
|
#include "Wt/WCompositeWidget.h"
|
||
|
#include "Wt/WDateEdit.h"
|
||
|
#include "Wt/WDatePicker.h"
|
||
|
#include "Wt/WLinkedCssStyleSheet.h"
|
||
| ... | ... | |
|
if (!widget->isThemeStyleEnabled())
|
||
|
return;
|
||
|
|
||
|
Wt::WCompositeWidget *composite = dynamic_cast<WCompositeWidget*>(widget);
|
||
|
|
||
|
{
|
||
|
WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
|
||
|
if (popup) {
|
||
| ... | ... | |
|
case DomElementType::DIV:
|
||
|
{
|
||
|
WDialog *dialog = dynamic_cast<WDialog *>(widget);
|
||
|
if (dialog) {
|
||
|
if (dialog || (composite && composite->canCastTo<WDialog*>())) {
|
||
|
element.addPropertyWord(Property::Class, "modal-dialog Wt-dialog");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WPanel *panel = dynamic_cast<WPanel *>(widget);
|
||
|
if (panel) {
|
||
|
if (panel || (composite && composite->canCastTo<WPanel*>())) {
|
||
|
element.addPropertyWord(Property::Class, "panel panel-default");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
|
||
|
if (bar) {
|
||
|
if (bar || (composite && composite->canCastTo<WProgressBar*>())) {
|
||
|
switch (elementRole) {
|
||
|
case MainElement:
|
||
|
element.addPropertyWord(Property::Class, "progress");
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
|
||
|
if (map) {
|
||
|
if (map || (composite && composite->canCastTo<WGoogleMap*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-googlemap");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget);
|
||
|
if (itemView) {
|
||
|
if (itemView || (composite && composite->canCastTo<WAbstractItemView*>())) {
|
||
|
element.addPropertyWord(Property::Class, "form-inline");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WNavigationBar *navBar = dynamic_cast<WNavigationBar *>(widget);
|
||
|
if (navBar) {
|
||
|
if (navBar || (composite && composite->canCastTo<WNavigationBar*>())) {
|
||
|
element.addPropertyWord(Property::Class, "navbar navbar-default");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
|
||
|
if (spinBox) {
|
||
|
if (spinBox || (composite && composite->canCastTo<WAbstractSpinBox*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-spinbox");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
|
||
|
if (dateEdit) {
|
||
|
if (dateEdit || (composite && composite->canCastTo<WDateEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-dateedit");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WTimeEdit *timeEdit = dynamic_cast<WTimeEdit *>(widget);
|
||
|
if (timeEdit) {
|
||
|
if (timeEdit || (composite && composite->canCastTo<WTimeEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-timeedit");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
WInPlaceEdit *inPlaceEdit
|
||
|
= dynamic_cast<WInPlaceEdit *>(widget);
|
||
|
if (inPlaceEdit)
|
||
|
if (inPlaceEdit || (composite && composite->canCastTo<WInPlaceEdit*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-in-place-edit");
|
||
|
else {
|
||
|
WDatePicker *picker
|
||
|
= dynamic_cast<WDatePicker *>(widget);
|
||
|
if (picker)
|
||
|
if (picker || (composite && composite->canCastTo<WDatePicker*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-datepicker");
|
||
|
}
|
||
|
}
|
||
| src/Wt/WBootstrap5Theme.C | ||
|---|---|---|
|
#include "Wt/WAbstractSpinBox.h"
|
||
|
#include "Wt/WApplication.h"
|
||
|
#include "Wt/WCheckBox.h"
|
||
|
#include "Wt/WCompositeWidget.h"
|
||
|
#include "Wt/WDateEdit.h"
|
||
|
#include "Wt/WDatePicker.h"
|
||
|
#include "Wt/WLinkedCssStyleSheet.h"
|
||
| ... | ... | |
|
if (!widget->isThemeStyleEnabled())
|
||
|
return;
|
||
|
|
||
|
|
||
|
Wt::WCompositeWidget *composite = dynamic_cast<WCompositeWidget*>(widget);
|
||
|
|
||
|
{
|
||
|
auto popup = dynamic_cast<WPopupWidget *>(widget);
|
||
|
if (popup) {
|
||
| ... | ... | |
|
|
||
|
case DomElementType::DIV: {
|
||
|
auto dialog = dynamic_cast<WDialog *>(widget);
|
||
|
if (dialog) {
|
||
|
if (dialog || (composite && composite->canCastTo<WDialog*>())) {
|
||
|
element.addPropertyWord(Property::Class, "modal Wt-dialog");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
auto panel = dynamic_cast<WPanel *>(widget);
|
||
|
if (panel) {
|
||
|
if (panel || (composite && composite->canCastTo<WPanel*>())) {
|
||
|
element.addPropertyWord(Property::Class, "card Wt-panel");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
auto bar = dynamic_cast<WProgressBar *>(widget);
|
||
|
if (bar) {
|
||
|
if (bar || (composite && composite->canCastTo<WProgressBar*>())) {
|
||
|
switch (elementRole) {
|
||
|
case MainElement:
|
||
|
element.addPropertyWord(Property::Class, "progress");
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
auto map = dynamic_cast<WGoogleMap *>(widget);
|
||
|
if (map) {
|
||
|
if (map || (composite && composite->canCastTo<WGoogleMap*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-googlemap");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
|
||
|
auto spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
|
||
|
if (spinBox) {
|
||
|
if (spinBox || (composite && composite->canCastTo<WAbstractSpinBox*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-spinbox");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
auto dateEdit = dynamic_cast<WDateEdit *>(widget);
|
||
|
if (dateEdit) {
|
||
|
if (dateEdit || (composite && composite->canCastTo<WDateEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-dateedit");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
auto timeEdit = dynamic_cast<WTimeEdit *>(widget);
|
||
|
if (timeEdit) {
|
||
|
if (timeEdit || (composite && composite->canCastTo<WTimeEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-timeedit");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
element.addPropertyWord(Property::Class, "form-file-button");
|
||
|
|
||
|
auto inPlaceEdit = dynamic_cast<WInPlaceEdit *>(widget);
|
||
|
if (inPlaceEdit)
|
||
|
if (inPlaceEdit || (composite && composite->canCastTo<WInPlaceEdit*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-in-place-edit");
|
||
|
else {
|
||
|
auto picker = dynamic_cast<WDatePicker *>(widget);
|
||
|
if (picker)
|
||
|
if (picker || (composite && composite->canCastTo<WDatePicker*>()))
|
||
|
element.addPropertyWord(Property::Class, "Wt-datepicker");
|
||
|
}
|
||
|
}
|
||
| src/Wt/WCompositeWidget.h | ||
|---|---|---|
|
|
||
|
#include <Wt/WWidget.h>
|
||
|
|
||
|
// Conditionally include <concepts> ONLY IF the compiler supports C++20 Concepts
|
||
|
#ifdef __cpp_concepts
|
||
|
#include <concepts>
|
||
|
#endif
|
||
|
|
||
|
namespace Wt {
|
||
|
|
||
|
/*! \class WCompositeWidget Wt/WCompositeWidget.h Wt/WCompositeWidget.h
|
||
| ... | ... | |
|
|
||
|
~WCompositeWidget();
|
||
|
|
||
|
/**
|
||
|
* @brief helper Function for Theme::apply to check if underlying impl can be cast to predefined Widgets
|
||
|
* \warning Not Every Widget is Supported!
|
||
|
*/
|
||
|
template <typename T>
|
||
|
#ifdef __cpp_concepts
|
||
|
// Constraint 1: T must be a pointer type
|
||
|
// Constraint 2: The type T points to (std::remove_pointer_t<T>) must be WWidget or derived from it.
|
||
|
requires std::is_pointer_v<T> && (std::derived_from<std::remove_pointer_t<T>, WWidget> || std::same_as<std::remove_pointer_t<T>, WWidget>)
|
||
|
#endif
|
||
|
bool canCastTo() const {
|
||
|
// Fallback static_assert for older compilers
|
||
|
#ifndef __cpp_concepts
|
||
|
// Ensure T is a pointer type
|
||
|
static_assert(std::is_pointer<T>::value,
|
||
|
"Template argument T must be a pointer type (e.g., WPanel*).");
|
||
|
|
||
|
// Ensure the pointed-to type is derived from WWidget
|
||
|
static_assert(std::is_base_of<WWidget, std::remove_pointer_t<T>>::value,
|
||
|
"The type pointed to by T must be a WWidget or derived from WWidget.");
|
||
|
#endif
|
||
|
|
||
|
if (!impl_) {
|
||
|
return false; // Cannot cast if no implementation widget exists
|
||
|
}
|
||
|
|
||
|
// Perform the dynamic_cast and check if it succeeds
|
||
|
return dynamic_cast<T>(impl_.get()) != nullptr;
|
||
|
}
|
||
|
|
||
|
virtual std::vector<WWidget *> children() const override;
|
||
|
using WWidget::removeWidget;
|
||
|
virtual std::unique_ptr<WWidget> removeWidget(WWidget *widget) override;
|
||
| src/Wt/WCssTheme.C | ||
|---|---|---|
|
#include "Wt/WApplication.h"
|
||
|
#include "Wt/WCalendar.h"
|
||
|
#include "Wt/WCssTheme.h"
|
||
|
#include "Wt/WCompositeWidget.h"
|
||
|
#include "Wt/WDateEdit.h"
|
||
|
#include "Wt/WDialog.h"
|
||
|
#include "Wt/WEnvironment.h"
|
||
| ... | ... | |
|
element.addPropertyWord(Property::Class, "Wt-outset");
|
||
|
}
|
||
|
|
||
|
Wt::WCompositeWidget *composite = dynamic_cast<WCompositeWidget*>(widget);
|
||
|
|
||
|
switch (element.type()) {
|
||
|
case DomElementType::BUTTON:
|
||
|
if (creating) {
|
||
| ... | ... | |
|
case DomElementType::DIV:
|
||
|
{
|
||
|
WDialog *dialog = dynamic_cast<WDialog *>(widget);
|
||
|
if (dialog) {
|
||
|
if (dialog || (composite && composite->canCastTo<WDialog*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-dialog");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WPanel *panel = dynamic_cast<WPanel *>(widget);
|
||
|
if (panel) {
|
||
|
if (panel || (composite && composite->canCastTo<WPanel*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-panel Wt-outset");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
|
||
|
if (bar) {
|
||
|
if (bar || (composite && composite->canCastTo<WProgressBar*>())) {
|
||
|
switch (elementRole) {
|
||
|
case MainElement:
|
||
|
element.addPropertyWord(Property::Class, "Wt-progressbar");
|
||
| ... | ... | |
|
case DomElementType::INPUT:
|
||
|
{
|
||
|
WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
|
||
|
if (spinBox) {
|
||
|
if (spinBox || (composite && composite->canCastTo<WAbstractSpinBox*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-spinbox");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
|
||
|
if (dateEdit) {
|
||
|
if (dateEdit || (composite && composite->canCastTo<WDateEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-dateedit");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WTimeEdit *timeEdit = dynamic_cast<WTimeEdit *>(widget);
|
||
|
if (timeEdit) {
|
||
|
if (timeEdit || (composite && composite->canCastTo<WTimeEdit*>())) {
|
||
|
element.addPropertyWord(Property::Class, "Wt-timeedit");
|
||
|
return;
|
||
|
}
|
||