generate bitmap for state "current" of bitmapButton

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Nonox
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 25, 2013 2:59 pm

generate bitmap for state "current" of bitmapButton

Post by Nonox » Mon Nov 25, 2013 4:31 pm

Hello everyone,

I am using the method SetBitmapCurrent on all my wxBitmapButtons, so their look change when the mouse is over the button.

But it takes me a lot of time, because I am making the bitmap of the state "current" in the software Gimp for each bitmapButton.
Is there a way to generate a bitmap for the state "current" automatically?
For example, the program copies the original bitmap, adds some brightness and uses it as bitmap for the state "current".

It would save me a lot of time!

It seems that the wxBitmapButtons should already do it automatically, as i read the following quote in the description of its constructor, but the bitmaps are always the same in my program.
The bitmap parameter is normally the only bitmap you need to provide, and wxWidgets will draw the button correctly in its different states.
I am on windows 7, with wxWidget 2.9.5.

Thanks,
Nonox

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

Re: generate bitmap for state "current" of bitmapButton

Post by doublemax » Mon Nov 25, 2013 11:17 pm

The bitmap parameter is normally the only bitmap you need to provide, and wxWidgets will draw the button correctly in its different states.
This seems to be partly wrong. In the wx source i only found code to generate a bitmap for the "disabled" state.

If you want to change a bitmap programmatically, the only useful methods i could think of, are:
wxImage::RotateHue(double angle)
and
wxImage::ConvertToDisabled(unsigned char brightness)

http://docs.wxwidgets.org/trunk/classwx_image.html
Use the source, Luke!

fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

Re: generate bitmap for state "current" of bitmapButton

Post by fancyivan » Tue Nov 26, 2013 3:00 am

I think it is not job of wxWidgets itself.
I created a template (106*26) for generating Bitmap (wxBitmapButton: 26 * 26) in GIMP.
There are totally 8 layers in it. 4 different backgrounds(layers) for each state of BitmapButton. and 4 layers for foreground of button.
If you want to create new bitmap for new button, you just need to replace 4 foreground by using your single bitmap of normal state(26*26).
If you have many many bitmaps to generate, may be you can create a very small application for this.

Template file is in attachment.

Tao
Attachments
tpl_btn_26.rar
gimp template file for button
(6.15 KiB) Downloaded 54 times
gimp.png
screenshot
gimp.png (19.4 KiB) Viewed 1585 times
OS: Win7 Ultimate SP1 x64(Windows XP Pro SP3 in VirtualBox)
Compiler: MinGW32 (gcc4.8.1 + gdb7.6.1)
IDE: Code::Blocks 12.11
Lib: wxWidgets3.0.0

Nonox
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 25, 2013 2:59 pm

Re: generate bitmap for state "current" of bitmapButton

Post by Nonox » Tue Nov 26, 2013 5:44 pm

Thank you for your .rar, fancyivan, but I do not like the manual way. wxWidget changes the look of the bitmapButtons of the AuiToolBar, of the checkBoxes, of the radioButtons, with a different style depending of the OS. So why not the bitmapButtons?
Besides, we change the graphical theme from time to time. It is much faster to change it with the automatic way.

Thank you, doublemax, I am using your ConvertToDisabled!
The best solution for me would be to have the same buttons as the ones of AuiToolbar, so everything would be homogeneous, but it seems to be impossible.
If anyone knows how to do it, I am interested!

Post Reply