Project

General

Profile

Actions

Bug #13872

open
CM RM

WCompositeWidget does not Apply Style classes from Implementation class

Bug #13872: WCompositeWidget does not Apply Style classes from Implementation class

Added by Christian Meyer about 1 year ago. Updated 1 day ago.

Status:
Review
Priority:
Normal
Target version:
Start date:
07/28/2025
Due date:
% Done:

0%

Estimated time:

Description

Only Tested with WPanel implementation so far.

Making a WCompositeWidget implement a WPanel, the Panel Specific style classes are not added.

Making it collapsible: it works, but there is no indicator: the Collapse Button is not visible.

It does not even look like a WPanel or "card" at all.

Unless this is desired behaviour, but I do not think so

Sample Code WCompositeWidget


Sample Code WPanel in Contrast


Files

wt_Composite_Impl_Style.patch (1.31 KB) wt_Composite_Impl_Style.patch Patching WCompositeWidget and Bootstrap5Theme for implementation Styles Christian Meyer, 07/28/2025 05:10 PM
wt_Composite_Impl_Style.patch (15.8 KB) wt_Composite_Impl_Style.patch Updated Patch v1 Christian Meyer, 08/01/2025 04:50 PM
wt_Composite_Impl_Style.patch (15.4 KB) wt_Composite_Impl_Style.patch v1 with LF Format Christian Meyer, 08/06/2025 01:13 PM
wt_Composite_Impl_Style.patch (13.4 KB) wt_Composite_Impl_Style.patch v1 adapted for 4.12.0 Christian Meyer, 08/09/2025 02:42 PM

MV Updated by Matthias Van Ceulebroeck about 1 year ago Actions #1

  • Assignee set to Matthias Van Ceulebroeck
  • Target version set to 4.12.3

Hello Christian,

this is a VERY good catch. No theming is ever applied to the WPanel.

This could be the case for any widget that is set as the WCompositeWidget's implementation. I am however sure I have seen this work for certain other widgets, and am curious as to what the discrepancy is.

CM Updated by Christian Meyer about 1 year ago Actions #2

Hi Matthias

The Wt- Internal Composite Widgets (like WPanel) work as expected. Because they are a Special Type that is handled in the Theme.

It is different for User Generated Composites.

From what I could figure out, I wrote a Patch, but it really is not a longterm, global solution.

It just targets WBootstrap5Theme, making its apply() function a friend of WCompositeWidget, and in the apply() function, change the widget to the implementation() of the composite Widget.

Breaking Solution

CM Updated by Christian Meyer about 1 year ago Actions #3

I made a way better patch...

I added a function to WCompositeWidget to check if the impl_ widget can be cast to a Type:

template <typename T>
bool canCastTo() const {

  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; 
}

There are concepts for the future, and also static_asserts to make sure the type fits. (left out here)

Within the ::apply() functions of the Bootstrap and Css Theme Classes, I added a check to see if it is a composite:

WCompositeWidget *composite = dynamic_cast<WCompositeWidget*>(widget);

auto panel = dynami_cast<WPanel*>(widget);

if(panel || (composite && composite->canCastTo<WPanel*>()))
{
... // Apply Style
}

Updated the ::apply() Function for WCSSTheme as well as Bootstrap 2, 3 & 5

CM Updated by Christian Meyer about 1 year ago Actions #4

Aparrently my last Patch had Windows Line Endings (CRLF), which failed my own patching...

converting to Linux Line Endings (LF) fixed that ...

CM Updated by Christian Meyer about 1 year ago Actions #5

Fixed Patch for 4.12.0

With the support for native Style classes, my proposed solution does not work for DateEdit and TimeEdit Implementations anymore

RM Updated by Romain Mardulyn 7 months ago Actions #6

  • Target version changed from 4.12.3 to 4.12.4

RM Updated by Romain Mardulyn 6 months ago Actions #7

  • Target version changed from 4.12.4 to 4.12.6

RM Updated by Romain Mardulyn 6 months ago Actions #8

  • Target version changed from 4.12.6 to 4.13.0

RM Updated by Romain Mardulyn 5 months ago Actions #9

  • Target version changed from 4.13.0 to 4.14.0

RM Updated by Romain Mardulyn about 2 months ago Actions #10

  • Target version changed from 4.14.0 to 4.15.0

ED Updated by emil de keyser 29 days ago Actions #11

  • Assignee deleted (Matthias Van Ceulebroeck)

ED Updated by emil de keyser 21 days ago Actions #12

  • Status changed from New to InProgress
  • Assignee set to emil de keyser

ED Updated by emil de keyser 21 days ago Actions #13

  • Status changed from InProgress to Review
  • Assignee deleted (emil de keyser)

RM Updated by Romain Mardulyn 21 days ago Actions #14

  • Assignee set to Romain Mardulyn

RM Updated by Romain Mardulyn 1 day ago Actions #15

  • Status changed from Review to Resolved
  • Assignee changed from Romain Mardulyn to emil de keyser

RM Updated by Romain Mardulyn 1 day ago Actions #16

  • Status changed from Resolved to InProgress

RM Updated by Romain Mardulyn 1 day ago Actions #17

  • Status changed from InProgress to Review
  • Assignee changed from emil de keyser to Romain Mardulyn
Actions

Also available in: PDF Atom