Button with both bitmap and text label? Topic is solved

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
theosib
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Nov 21, 2005 9:46 pm

Button with both bitmap and text label?

Post by theosib »

Another of my noob questions. I have been trying to search for this on google to no avail. Is there a way to have a button that has both a text label AND a bitmap/icon? I tried creating a wxBitmapButton and then using SetLabel, but all I saw was the bitmap.

Any suggestions?

Thanks!
sethjackson
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Wed Oct 05, 2005 1:19 am

Post by sethjackson »

I think to do that create a dialog then place the wxBitmapButton on it. Then set the label of the dialog. Or do you want text on the button itself?

http://www.wxwidgets.org/manuals/2.6.2/ ... tmapbutton
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 »

im working on the patch for it... I can't release it yet... but you can use Dave fileccia's first http://sourceforge.net/tracker/index.ph ... tid=309863
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

Meanwhile there are classes out in the wild, such as mmMultiButton from mmwx:
http://mindmatters.no/mmwx/

I recall that wxCode might have had something like that too, but not sure if that wasn't some other place...
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
BlowdyNose
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Sep 20, 2005 3:49 pm
Location: Konstanz, Germany

Post by BlowdyNose »

Hi

When you don't need to change or query the label on runtime, just write the label you want into the bitmap until the patch is released :twisted: .

- BlowdyNose
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 »

yea, but my patch is for MSW only, sorry ppl. And yes i use a wxWindowDC ;)
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

It is extremely trivial to do it in GTK+. No idea about Mac.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Post by Ksmith22 »

Could you overload the paint event of the button class to draw the image first and then draw text? I think that would work.
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

It will not, unless you are dealing with a wxUniversal port (and then it might not work either), or are lucky on a certain port.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
Post Reply