Page 1 of 1

Ownerdrawn buttons

Posted: Mon Feb 07, 2005 11:53 pm
by tom69
hi,
first of all i would like to precise that i only tested this code under Windows platform, but as it's enough short, i logically think it works under linux or other platforms (if someone could test and say yes or no at this question... it could be grate)

then i precise that the image i loaded are in PNG format, but logically you could use another format.... well i've note worked about this question...

third the ownerdrawn buttons act like a square! i mean that if your image is a circle, it would act like a square corresponding to the wxButton shape because my class of ownerdrawn button is a wxButton inherited class.

sorry for some text that is in French lol...

here is the h file (class declaration)



Code: Select all

class CBouton : public wxButton
{
public:
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // constructeur
	CBouton(wxWindow *parent, wxWindowID id, int indexBtn, int x, int y);
    // destructeur
	virtual ~CBouton();

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Gestion des

Re: Ownerdrawn buttons

Posted: Sun Feb 27, 2005 5:26 am
by gururamnath
Hi,
How does this button look in WinXP ? Does it support WinXP themeing like the wxButton component ? If so, may be we can request the wx Developers to add a refined version of your code to their codebase.

-Guru Kathiresan

Re: Ownerdrawn buttons

Posted: Sun Feb 27, 2005 5:53 am
by gururamnath
After some edits, I was able to make the code work . Since I was using one bitmap for all the states, the button was displayed like a Image control. Is there any way you can make this control look like a wxbutton button with a bitmap ?
-Guru Kathiresan
[I was about the click the last answer in the poll but the code seems to work after a tweak; so I'm not going with the my answers now ;o) ]

Posted: Sun Feb 27, 2005 11:37 am
by tom69
well i think i see what you mean :-o
well maybe using the wxBitmapButton class ??
i don't really know sorry
:-)

Posted: Mon Jun 13, 2005 12:27 am
by Tyler
Does your EVT_ENTER_WINDOW or EVT_LEAVE_WINDOW still work with wx 2.6? My owner drawn button class died after an upgrade, was wondering if you had any better luck with this one.

Thanks,

-Tyler

Tried in own program

Posted: Thu Feb 16, 2006 2:15 pm
by roboknight
I tried this technique in my own software. It worked very well for transparent bitmaps of a dial, a handle, a status light, and a special text box. I wish I knew a way of clipping the background behind a control into a bitmap instead, but this will suffice for now. Being able to clip the background behind the control would make the control more universal. As it is, I have to pass in the background bitmap to the control so it can find its background region and paint it as the background. Thanks for giving me an idea of how to do it.