extending DragImage/DragCanvas

James Morgan wrote:

I figure, the first thing that needs to be done is to add attributes
to DragImage that hold the Hover image(s), and then methods to switch
between those and the default bitmaps.

I'm hung up on the event handling part. Should the DragImage be a
subclass of some event-handler like wx.Window so it can catch a
EVT_ENTER/LEAVE_WINDOW and call its own Draw( )s for each of them?
What's also getting me is that I'm not sure what might trip up the DCs
that are getting tossed around here........

That is one option, but I suspect that it may not work quite right, particularly if you want it to be possible to have the images overlap -- wx doesn't handle overlapping Windows well.

so then, the other option I see is: stick to using DragCanvas as the
event handler (as the demo does), and have it tell DragImage when its
being hovered over to switch its bitmaps and Draw( ). .

yup -- that will work, and as long as your images are rectangles, it's pretty easy to know when it' being hit.

You could also use wx.lib.floatcanvas:

http://trac.paulmcnett.com/floatcanvas

I don't think there is any dragging code in the main demo, but there is here:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/

see: MovingElements.py

FloatCanvas supports full zooming and panning, but if you use a raw FloatCanvas, rather than a NavCanvas, you can fix the scale, and jsut use pixel coordinates.

There aren't any demos of having the bitmap (or anything else) change on Mouse-over, but the events are there, so it shouldn't be hard to do. I'd probably subclass the FloatCanvas.Bitmap object to have multiple bitmaps and switch between them.

HTH,

-Chris

ยทยทยท

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov