I am attempting to create a magnifying glass cursor that floats above
a wxBitmap displayed in a wxScrolledWindow. The cursor displays an
enlarged view of a region from the bitmap below centered at the
current location. Nothing extraordinary about this, but I would
prefer to be able to use an irregularly shaped region for the
displayed image, and possibly a simple bitmap like a handle, or at
least a bounding circle or frame. This gets updated on every
wx.EVT_MOTION.
I have done this before in C++, (long ago) but I'm having difficulty
sorting it all out in wxPython. I began with the DragImage example
from the wxPython Demos. It has almost gotten me where I want to go.
Unlike that example, I don't want to just drag a simple static bitmap
around the screen, however. I need to be able to create the 'cursor'
bitmap by combining layers into a MemoryDC and finally blitting the
whole works to the screen.
My current code uses GetSubBitmap() to retrieve the region of the
original bitmap, and then attempts to composite it into a temporary
MemoryDC. Other components of the mask are created by drawing with
white and black brushes into the same DC. In my searches for a model
to follow I've gone back to Petzold's venerable 'Programming Windows'
and its discussion of creating irregular bitmaps.
In the example I have been following, he fills the rectangular area
using a black brush, then uses a white brush to create an ellipse to
contain the bitmap, then blits this against the desired image using a
SRCAND raster operation (rop). This zeros the are under the black
areas of the mask, and leaves the image areas that are exposed to the
white mask intact. So far, so good.
But the next action specified (in onpaint) is to blit the whole mask
onto the main (primary image) bitmap using an unnamed 0x220326 rop.
This is where I have a problem.
The 0x220326 rop is asid to be equivalent to a (Dest & (NOT Src))
operation, which is also not named in wxPython. And when I attempt to
force-feed this value as a HEX literal, wxPython tells me that this is
an invalid rop. It appears that wxPython does not accept any but the
sixteen named rops.
A final Blit of the image using a SRCPAINT rop finishes the sequence.
Can anyone suggest a way to accomplish what I'm trying to do or better
yet, point me to someone who has already done it? Failing that, can
anyone tell me that It cannot be done?
Thanks,
Dave W.