Listbox colours

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
clp1000
Posts: 14
Joined: Wed Jan 04, 2023 2:18 am

Listbox colours

#1 Post by clp1000 »

Hello

I'm trying to change the colour of a highlighted item in a XbpListbox() but for the life of me I've no idea where the colours are coming from
Currently the highlight bar is blue with white text, and when the box is disabled it's blue with a grey text ( very hard to see )
None of these attributes, below, seem to change anything

Alternatively, has anyone got an example of a CSS sheet for a Listbox, with various defined colours for highlighted items whilst the box is active or disabled ?

Thanks for any help
Chris

PUBLIC app10lbox := {{ XBP_PP_COMPOUNDNAME , "9.Courier" },;
{ XBP_PP_ACTIVE_CLR , GRA_CLR_RED },;
{ XBP_PP_INACTIVE_CLR , GRA_CLR_RED },;
{ XBP_PP_ACTIVETEXT_FGCLR , GRA_CLR_RED },;
{ XBP_PP_ACTIVETEXT_BGCLR , GRA_CLR_RED },;
{ XBP_PP_INACTIVETEXT_FGCLR , GRA_CLR_RED },;
{ XBP_PP_INACTIVETEXT_BGCLR , GRA_CLR_RED },;
{ XBP_PP_FGCLR , GRA_CLR_BLACK },;
{ XBP_PP_BGCLR , GRA_CLR_WHITE },;
{ XBP_PP_DISABLED_FGCLR , GRA_CLR_RED },;
{ XBP_PP_DISABLED_BGCLR , GRA_CLR_PALEGRAY }}

clp1000
Posts: 14
Joined: Wed Jan 04, 2023 2:18 am

Re: Listbox colours

#2 Post by clp1000 »

Anyone ?
Just to confirm, I can't seem to change the colour blue/white on the left box ( enabled - left box) and blue/Grey ( disabled - right box )
Thanks
Chris
Listbox.jpg
Listbox.jpg (71.69 KiB) Viewed 503 times

User avatar
SlavkoDam
Posts: 85
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Listbox colours

#3 Post by SlavkoDam »

Hi,

This is not the way to change font and colors in a XbpListBox, with the XBP_PP_* parameters. You can do that with the XbpListBox owner-draw option, setting :drawMode = XBP_DRAW_OWNER, and using :drawItem() and :measureItem() methods.

To create a CSS sheet for a XbpListBox, use XbpListBox:visualStyle propery and XbpHTMLStyle() class. You have an example for that in the description of XbpComboBox:visualStyle property.

Slavko
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

k-insis
Posts: 99
Joined: Fri Jan 28, 2011 4:07 am

Re: Listbox colours

#4 Post by k-insis »

Slavko,

it would probably be easier to replace xbplistbox with xpbbrowse or xbpquickbrowse object on array than going through all the hassle of ownedraw


SlavkoDam wrote: Mon Mar 11, 2024 12:57 am Hi,

This is not the way to change font and colors in a XbpListBox, with the XBP_PP_* parameters. You can do that with the XbpListBox owner-draw option, setting :drawMode = XBP_DRAW_OWNER, and using :drawItem() and :measureItem() methods.

To create a CSS sheet for a XbpListBox, use XbpListBox:visualStyle propery and XbpHTMLStyle() class. You have an example for that in the description of XbpComboBox:visualStyle property.

Slavko

User avatar
SlavkoDam
Posts: 85
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Listbox colours

#5 Post by SlavkoDam »

I don't agree with you. You cannot compare XbpListBox with XbpBrowse and XbpQuickBrowse. You cannot use XbpBrowse and XbpQuickBrowse as GET elements. XbpBrowse don't have :dataLink property, and in XbpQuickBrowse :dataLink property and :getData() method have different purposes. They also don't have :markMode and :multiColumn properties of XbpListBox, and you cannot define colors for disabled items. Besides, XbpBrowse and XbpQuickBrowse is much more complex to create than XbpListBox.

Owner-draw is not very hard to implement. You have examples in Xbase++ samples. Its not the point what is easier to achieve but what do you want to achieve. For advanced options you have to do advanced programming.
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

User avatar
Tom
Posts: 1170
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Listbox colours

#6 Post by Tom »

Roger implemented the "COMBO" clause for DCSAY ... GET, which uses a popup button beside a get field to show a browse for value selections. Maybe this will do the job.
But I also agree with Slavko. Ownerdrawing is no magic, and there are samples for that, even in your eXpress++-installation.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
SlavkoDam
Posts: 85
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Listbox colours

#7 Post by SlavkoDam »

Tom,
Yes, its a fine option in eXpress++ and I implemented a similar one in my PowerWin. But, its only a help to select a value into a get field when you press a popup button, and not a direct get select as XbpListBox. To return to the beginning, the initial request was to change font and colors of active, selected and disabled items of XbpListBox, and that can be only done with owner-draw or HTML CSS style.

Slavko
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

User avatar
Tom
Posts: 1170
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Listbox colours

#8 Post by Tom »

Slavko, I know it's not the same. ;) But maybe it helps Chris to do what he wants to do.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

clp1000
Posts: 14
Joined: Wed Jan 04, 2023 2:18 am

Re: Listbox colours

#9 Post by clp1000 »

Thanks for the replies, I've worked out what was needed and used the DrawMode option
The Owner draw example worked well, once I'd stripped out all the code I wanted
Thanks once again
Chris
LB2.jpg
LB2.jpg (32.75 KiB) Viewed 441 times

Post Reply