Ownerdrawn buttons

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply

does it work for you?

yes, under windows
5
29%
no, under windows
0
No votes
yes, linux
1
6%
no, linux
0
No votes
yes, other
0
No votes
no, other
0
No votes
not tested...french are bad programmers lol
11
65%
 
Total votes: 17

tom69
Earned a small fee
Earned a small fee
Posts: 14
Joined: Tue Nov 30, 2004 5:17 pm
Location: france

Ownerdrawn buttons

Post by tom69 » Mon Feb 07, 2005 11:53 pm

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

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Re: Ownerdrawn buttons

Post by gururamnath » Sun Feb 27, 2005 5:26 am

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

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Re: Ownerdrawn buttons

Post by gururamnath » Sun Feb 27, 2005 5:53 am

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) ]

tom69
Earned a small fee
Earned a small fee
Posts: 14
Joined: Tue Nov 30, 2004 5:17 pm
Location: france

Post by tom69 » Sun Feb 27, 2005 11:37 am

well i think i see what you mean :-o
well maybe using the wxBitmapButton class ??
i don't really know sorry
:-)

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Mon Jun 13, 2005 12:27 am

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

roboknight
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Feb 15, 2006 3:25 pm
Contact:

Tried in own program

Post by roboknight » Thu Feb 16, 2006 2:15 pm

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.

Post Reply