ANN: wxGradientButton - Simple Owner-Drawn Gradient Button

Do you like to promote your wxWidgets based application or component!? Post it here and let's see what the critics have to say. Also, if you found that ONE wx component the world needs to know about, put it here for future reference.
Post Reply
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

ANN: wxGradientButton - Simple Owner-Drawn Gradient Button

Post by T-Rex »

I created the owner-drawn gradient button control and want to share its source code with other developers here.

Here you can download the source code and sample application for Windows Mobile 6 and Win32 platforms

Image
orbitcowboy
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Mon Jul 23, 2007 9:01 am

Tested on Ubuntu 8.04

Post by orbitcowboy »

Hi,

i've tested the gradient buttons on ubuntu. It works great :-)

GCC-Version: g++-4.3.1
wxWidgets: wxGTK-2.8.8

Here a makefile, and the sample app.

Regards

Orbitcowboy
Attachments
screenshot on an Linux OS (Ubuntu 'Hardy')
screenshot on an Linux OS (Ubuntu 'Hardy')
Bildschirmfoto-wxTestMainFrame.png (11.67 KiB) Viewed 3873 times
wxGradientButton.tar.gz
tarball of the sample source, including a linux makefile
(96.29 KiB) Downloaded 221 times
User avatar
silver.moon
Experienced Solver
Experienced Solver
Posts: 67
Joined: Fri Feb 20, 2015 6:13 am

Re: ANN: wxGradientButton - Simple Owner-Drawn Gradient Button

Post by silver.moon »

Hi

Thanks, its a great example to begin with making custom buttons.
However there is one small issue, that is if you click the button again and again rapidly, then some of the clicks are missed
This can be observed with the change of the visual appearance which does not happen that often as the number of clicks.

Is there a way to fix this and the make the button as responsive as a native control ?
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: ANN: wxGradientButton - Simple Owner-Drawn Gradient Button

Post by T-Rex »

The control uses EVT_LEFT_UP for sending the command events. You can change this logic and send on mouse down if you want.
Also the control is derived from wxWindow because (as far as I remember) there is no way to sking the wxButton under wxGTK. If you are going to use this only under Windows and OS X, you ,probably, could subclass from wxButton and then there will be no need to send the command event manually I think.
User avatar
silver.moon
Experienced Solver
Experienced Solver
Posts: 67
Joined: Fri Feb 20, 2015 6:13 am

Re: ANN: wxGradientButton - Simple Owner-Drawn Gradient Button

Post by silver.moon »

T-Rex wrote:The control uses EVT_LEFT_UP for sending the command events. You can change this logic and send on mouse down if you want.
Also the control is derived from wxWindow because (as far as I remember) there is no way to sking the wxButton under wxGTK. If you are going to use this only under Windows and OS X, you ,probably, could subclass from wxButton and then there will be no need to send the command event manually I think.
Hi, thanks for the reply.

Indeed deriving from wxButton gives a more native behavior and all clicks are detected no matter how fast they are done. And there is no need to generate click events like with wxWindow. I have checked only on Windows 7.

However, I seem to have found another trick to make it work with wxWindow. When deriving from wxWindow,
do not call ReleaseMouse in wxEVT_LEFT_UP (mouse up) event, instead call ReleaseMouse inside wxEVT_LEAVE_WINDOW (mouse out) event handler. Then also the "rapid click" problem is solved. Not sure if this is a good way to do it.
Post Reply