Hi,
When selecting objects, I'd like to draw a rectangle over the area
selected (startpoint+moving point). On windows I create a wxClientDC
for the canvas and draw using an XOR pen. On a mac, it doesn't work.
Is there a simple fix, should I create some transparent window over my
canvas or can I draw to an OpenGL layer?
Thanks,
Henrik
> When selecting objects, I'd like to draw a rectangle over the area
> selected (startpoint+moving point). On windows I create a wxClientDC
> for the canvas and draw using an XOR pen. On a mac, it doesn't work.
On Mac using XOR pens doesn't work, whether you use them with wxGLCanvas
or not. See the new wxOverlay API in wx/overlay.h and example of its use in
the drawing sample for what does work.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Thanks Vadim!
I'll take a look at wxOverlay!
Best Regards,
Henrik Vallgren
PS
I found a sample that allowed use of OpenGL to solve this:
void drawInvertRectX(const wxRect &rect)
{
glDesignCanvas *pWnd=getGLWindow();
if (pWnd)
{
wxRect rectClient=pWnd->GetClientRect();
glDisable(GL_DEPTH_TEST);
glDrawBuffer(GL_FRONT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,rectClient.GetWidth(),0,rectClient.GetHeight(),-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glRecti(rect.GetLeft(), rectClient.GetHeight()-rect.GetBottom(),
rect.GetRight(), rectClient.GetHeight()-rect.GetTop());
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_COLOR_LOGIC_OP);
glFlush();
glDrawBuffer(GL_BACK);
glEnable(GL_DEPTH_TEST);
pWnd->reset_viewport(rectClient.GetWidth(),rectClient.GetHeight());