wxBitmapButton and Windows XP Themes

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
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

wxBitmapButton and Windows XP Themes

Post by ddaeschl »

Is there a reason why wxbitmapbutton looks like it does under Windows XP? From looking at the code, the face is owner drawn with no attention to the current theme except for the background color. Is there a technical or other reason why the theme isn't there, or has no one gotten around to it yet? Would wxw want a patch for it?
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

See here:

http://sourceforge.net/tracker/?group_i ... id=1098555

Not finished yet as I had to fix other things first to get this to work correctly, however I will try and get this done before 2.5.5.
Stefan
Experienced Solver
Experienced Solver
Posts: 57
Joined: Mon Feb 28, 2005 10:17 pm

Post by Stefan »

Hm, the standard button, when changing the foreground or background colour has the same problem. Any work on this?
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

Why? If you override the theme by setting custom foreground/background colours then the button becomes ownerdrawn.
Stefan
Experienced Solver
Experienced Solver
Posts: 57
Joined: Mon Feb 28, 2005 10:17 pm

Post by Stefan »

Exactly that is the problem. Imagine a Win95-Button (but now with read label;)) in WinXP with luna stype... So the style change is wrong. Can WinXP natively draw coloured buttons? If yes the change would be easy, just set the colour and don't let the button be ownerdrawn. But if not one has to draw the other style button like qt...
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

I assume you mean a standard themed button with red label, correct? This might look fine if using Luna, but what if a user was using a different theme? The ones that look like Aqua would not look good with a red label. Have a look at wxWindow::SetForegroundColour in the docs for an explanation.
I haven't used QT much, what other style button?
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

Post by ddaeschl »

"Can WinXP natively draw coloured buttons? If yes the change would be easy, just set the colour and don't let the button be ownerdrawn."

I'm not entirely sure this can be done with the native Windows XP themeing API anyhow. If you look at the DrawThemeBackground API Call, there is only a spot to specify the part you want to draw (aka, a button) and the state (disabled, enabled, pressed) the options for a button appear to be:

PART
BP_PUSHBUTTON

STATES
PBS_DEFAULTED, PBS_DISABLED, PBS_HOT, PBS_NORMAL, PBS_PRESSED

You could probably modify the DC after you draw the theme, but there would be no guarentee your color would match the current theme.
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

You could use GetThemeBackgroundContentRect and then draw the content area with the custom background colour, but just because it would look good on one theme doesn't mean it will on another.
Stefan
Experienced Solver
Experienced Solver
Posts: 57
Joined: Mon Feb 28, 2005 10:17 pm

Post by Stefan »

OK, maybe changing the colours of a button is not possible without potentially destroying the button's theme.
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

OK this is real REAL late but well.... thats exactly why im posting here... (2.6.2 CVS source)

the patch provided... seems to crash the program after applying it. it seems perfect without it, but after applying it and rebuilding the libraries, it crashes on exit

i can have a look at the source, but so far... i cant find anything wrong.
Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank »

I Created my own Button some Time ago. I derived it from wxButton and used UXTheme to paint it themed (and also to allow a bitmap and text on the same Button), cause I found both wxBitmapButton and a normal wxButton with colored label rather ugly and unprofessional (I'm using a different label-color and Icon to indicate a button, wich opens a dialog wich has data in the database, so the user can see without clicking if any data is available).

Looks like this:

Code: Select all

   wxUxThemeEngine *pTheme = wxUxThemeEngine::Get();
   if (pTheme && !pTheme->IsAppThemed()) pTheme = NULL;

   if (pTheme) {
      wxUxThemeHandle hTheme(this, L"BUTTON");
      if (hTheme) {
         long flags = PBS_NORMAL;
         if (state & ODS_DISABLED) flags = PBS_DISABLED;
         else if (pushed) flags = PBS_PRESSED;
         else if (m_mouseOver) flags = PBS_HOT;
         else if (selected) flags = PBS_DEFAULTED;

         pTheme->DrawThemeBackground(hTheme, (HDC)dc.GetHDC(), BP_PUSHBUTTON, flags, &lpDIS->rcItem, NULL);
      }
   }
   else {
      // Copy from wxButton.
   }

   // Paint Bitmap and Text
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

is it a patch in any right? :S

EDIT: somehow after rebuilding my libraries, it works... doesnt crash no more... but i just wonder why it still crashed the previous time even after a rebuild ? ](*,)
Post Reply