How can I change the background color of a data window header that is on a tab page in a theme?
- You are here:
- Home
- Q&A
- Q&A
- PowerBuilder
- Themes: Changing the background color in a Datawindow header on a Tabpage
- Steffen Chrobok
- PowerBuilder
- Wednesday, 26 April 2023 07:28 AM UTC
- Wednesday, 26 April 2023 12:48 PM UTC
- PowerBuilder
- # 1
I don't believe that themes could help you.
First of all themes cannot apply to controls that were dynamically created. This means that if you are using opentab or openuserobject, themes are not a solution.
In case you aren't using opentab or openuserobject, you would have to create a custom json file and describe somehow which windows (or userobjects) should be affected by these json file. Such a file (in my case theme-0001.json) would look like:
{
"meta-info":
{
"version":"22.0.0.1900"
},
"w_main$commandbutton":
{
"drawing":true,
"normal-state":
{
"border-color":"#B3D7F3",
"background-color":"#AAAAAA",
"text-font":{"color":"#000000"}
},
"hover-state":
{
"border-color":"#3393DF",
"background-color":"#3393DF",
"text-font":{"color":"#FFFFFF"}
},
"pressed-state":
{
"border-color":"#0060AC",
"background-color":"#0060AC",
"text-font":{"color":"#FFFFFF"}
},
"focused-state":
{
"border-color":"#0078D7",
"background-color":"#0078D7",
"text-font":{"color":"#FFFFFF"}
},
"default-state":
{
"border-color":"#0078D7",
"background-color":"#0078D7",
"text-font":{"color":"#FFFFFF"}
},
"disabled-state":
{
"border-color":"#CCCCCC",
"background-color":"#CCCCCC",
"text-font":{"color":"#999999"}
}
},
"w_main.tab_1.tabpage_1.dw_1":
{
"drawing":true,
"background-color-enabled":true,
"background-color":"#FFFFFF",
"normal-state":
{
"border-color":"#CCCCCC"
},
[...]
"dwo-compute":
{
"border":2,
"border-color":"#CCCCCC",
"background-color":"#FFFFFF",
"text-font":{"color":"#000000"}
}
}
}
}
What is interesting is how you can define what that theme will affect. You can do it by:
- Name it with dot notation ("w_main.tab_1.tabpage_1.dw_1":)
- Specify how controls of a specific type should be affected in a specific window ("w_main$datawindow":)
- Specify how controls of a specific type should be affected in a specific user object ("uo_1$datawindow":)
From information you provided until now I conclude that you would have to go using method 1, which means you would have to know the "dot notation" path to your controls. Seems to be some work.
Even if you do that, the json file for let say 250 objects could be quite large (if this is the case I'm not sure how performance would be affected).
The advantage: you could easily change the appearance when needed without having to compile you application, simply by modifying your theme.
Andreas.
- Wednesday, 26 April 2023 12:14 PM UTC
- PowerBuilder
- # 2
How many windows do you have that have tab controls and contain datawindows?
Andreas.
- Steffen Chrobok
- Wednesday, 26 April 2023 12:24 PM UTC
-
Helpful Loading... Helpful 0
- Wednesday, 26 April 2023 10:55 AM UTC
- PowerBuilder
- # 3
- Andreas Mykonios
- Wednesday, 26 April 2023 11:35 AM UTC
Andreas.
-
Helpful Loading... Helpful 0
- Steffen Chrobok
- Wednesday, 26 April 2023 11:43 AM UTC
Does the version information in the json have any influence?
I never changed it.
-
Helpful Loading... Helpful 0
- Andreas Mykonios
- Wednesday, 26 April 2023 12:10 PM UTC
Andreas.
-
Helpful Loading... Helpful 0
- Wednesday, 26 April 2023 08:41 AM UTC
- PowerBuilder
- # 4
Hi.
What version of PB are you using?
Generally speaking, in PB 2022, you can use dot notation. Something like:
"<your window>.<your tab>.<your tabpage>.<your datawindow>":
{
... // Copy "datawindow" node from json and make your changes.
}
I haven't tested but it should be something like that.
Andreas.
- Steffen Chrobok
- Wednesday, 26 April 2023 09:53 AM UTC
https://github.com/Appeon/PowerBuilder-UI-Example/blob/main/Appeon.UIDemo/theme/Flat%20Design%20Blue/theme.json
-
Helpful Loading... Helpful 0
- Steffen Chrobok
- Wednesday, 26 April 2023 09:56 AM UTC
-
Helpful Loading... Helpful 0
- Andreas Mykonios
- Wednesday, 26 April 2023 10:36 AM UTC
Andreas.
-
Helpful Loading... Helpful 0
- Page :
- 1
However, you are not allowed to reply to this question.