Fun with wxDC and wxBitmapButton =)

Hi all,

I need a 'color picker' button for my wxPython app, but ColourChooser acts pretty funky on Mac (because the buttons are standard Aqua buttons and can't be colored), so I thought I'd write something similar that was Mac-friendly. =) What I thought I'd do is draw a rectangle inside of a bitmap button that represented the currently selected color. Being new to wxDCs, I checked out the Wiki and I played around with Chris Barker's DoubleBuffered DC example and used it to make a sub-class of wxBitmapButton which I'm calling wxColorButton. On Windows, it works pretty much as desired, but on Mac it has one little glitch - the 'drawing' of the color rectangle is animated! =) That is, the color rectangle moves diagonally from the top left corner to the place where it needs to go. It's kinda cool, actually, but it's not what I want it to do. :wink:

I'm assuming this is because there's a Blit call happening, and there's something going on with the source/dest DC origins, but being new to working with DCs I'm not sure if all my origins are in the right place or if I'm trying to do something I shouldn't be able to. <G> I'm also not sure if this is a Mac-specific bug or if drawing is happening faster on my PC so I just don't see it (?). I've tried both with and without the double-buffering enabled, and I get the same results. A text version of the code is available here:

http://www.theolliviers.com/python/dctest2.txt

If anyone could offer pointers as to what is going on here, or advice on a better way to go about this, I'd greatly appreciate it! BTW, the code isn't finished yet (no Getters!), but if I can get it working (and Chris isn't mad at me for using his code =) I'll be happy to make it available, or contribute it to wxPython if there's interest.

Thanks,

Kevin