Inconsistent handling of textlabel background color in 3.0

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
p_lu
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Oct 25, 2018 2:04 pm

Inconsistent handling of textlabel background color in 3.0

Post by p_lu » Thu Nov 15, 2018 1:44 am

I'm having trouble with wxWidgets 3.0.4, running on Windows10 and Debian Linux.

In Windows, textlabel background take on the assigned color, as expected.
However, when the exact same set-up is used in Linux (Debian), the textlabel
background does not take on the assigned color (even with Refresh() performed).

I thought the problem was wxWidgets versions, being 3.0.4 on Windows and 3.0.2
on Debian, but building and using 3.0.4 on Debian made no difference.

I read somewhere that this might be a Gtk issue, where Linux textlabel background
meant only the borders and not the solid background itself. By comparison, buttons
do the same thing under Windows and Linux, having background doing a solid fill in
either environment.

I need the same project running on both Windows and Linux. I was hoping the same
features worked the same way on all platforms. The textlabel background color works
great on Windows for my needs. Why won't it do the same thing on Linux?

Any suggestions on how to fix this?

Thanks for all help.

User avatar
doublemax
Moderator
Moderator
Posts: 13565
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Inconsistent handling of textlabel background color in 3.0

Post by doublemax » Thu Nov 15, 2018 8:39 am

I assume you're talking about wxStaticText?

Try wxGenericStaticText instead:

Code: Select all

#include <wx/generic/stattextg.h>
...
wxGenericStaticText *gstc = new wxGenericStaticText( panel, wxID_ANY, "some text", wxPoint(10,90), wxSize(200,-1) );
gstc->SetBackgroundColour( *wxRED );
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3257
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Inconsistent handling of textlabel background color in 3.0

Post by ONEEYEMAN » Thu Nov 15, 2018 3:44 pm

HI,
To answer your question:

wxWidgets is known to be a native library. It means that it will use a native control implementation whenever possible.
So if *nix/GTK does not support something wxWidgets can't do anything. You have a choice of either use generic control, as doublemax suggested, or leave with it.

Thank you.

p_lu
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Oct 25, 2018 2:04 pm

Re: Inconsistent handling of textlabel background color in 3.0

Post by p_lu » Thu Nov 15, 2018 6:24 pm

Thanks for the wxGenericStaticText suggestion. Works great, as background colors
are showing.

I hand-edited the source and changed wxStaticText to wxGenericStaticText
where appropriate. I don't suppose it's easy to add this widget to the wxSmith/Codeblocks
IDE I'm using, since it's not included. (I know this belongs to a Codeblocks forums discussion,
but perhaps someone in this forum has done this before and can offer advice/insight).
Or, perhaps generic controls don't belong in wxSmith?

Also thanks for the clarification about the native library and generic controls.

Post Reply