Rounded rectangular button

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
Raghu
Experienced Solver
Experienced Solver
Posts: 79
Joined: Wed Oct 19, 2005 11:33 am

Rounded rectangular button

Post by Raghu »

How to make the rectangular button look like rounded rectangular?
phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 »

You should try to make your own Buttonclass,
an do the drawing there. wxWindow offers no SetShape
like wxTopLevelWindow does.
BlowdyNose
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Sep 20, 2005 3:49 pm
Location: Konstanz, Germany

Post by BlowdyNose »

Raghu... you are opening Pandora's Box... 8)
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 »

How rounded...? :lol:
My wxButton's are rounded rectangles, for example - as I use a theme that draws buttons as slighly rounded rectangles (for the outline).
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 »

:wink:

In fact you have to assign a wxBitmap to your custom wxBitmapButton with transparent borders.

Problem. To get a transparent wxBitmap I would do the following.

1)Get some tool to convert your *.png ( I prefer to work with png) to a *.cpp. I use the "bin2c.c". But ImageMagick could also do it. Convert!

2)Include the "yourImage.cpp" to your project. And generate a wxBitmap. Inside of the cpp-File you will find a array holding your picture informations. For this I use some code I found:

Code: Select all

inline wxBitmap _wxGetBitmapFromMemory(unsigned char *data, int length) {
           wxMemoryInputStream is(data, length);
           return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
           }
ahh, you have to include -wx/image.h- and -wx/mstream.h-

3)Assign your new wxBitmap to your own wxBitmapButton

That's all...

But attention!! Make sure you don't use a backgroundimage inside the window you are adding the bitmap. Because the transparent regions of your bitmap don't know that there is a bitmap. And so they will show the systembackground of the window they have been added to.

Have fun :D
Post Reply