tooltip causing early redraws

James Bigler bigler at cs.utah.edu
Fri Nov 17 10:25:34 PST 2006


I have a toolbar that sits near a panel that has some custom drawing 
inside using an OpenProducer::RenderSurface.  When a tooltip occurs for 
the toolbar and overlays my custom panel, I see the first one just fine 
and my custom panel gets a refresh after the tool tip goes way (by 
moving my cursor).  If I move my cursor over to other items in the tool 
bar my custom panel gets a refresh event right away and I can't see the 
tool tip (as it gets painted over my tool tip).

I'm using wxWidgets 2.6.3
WinXP
VS 8 Express Edition

Thanks,
James

Here's the relevant bits of code:

BEGIN_EVENT_TABLE(MyCanvas, wxPanel)
     EVT_SIZE(wxPanel::OnSize)
     EVT_PAINT(MyCanvas::OnPaint)
     EVT_ERASE_BACKGROUND(MyCanvas::OnEraseBackground)
     EVT_KEY_DOWN( MyCanvas::OnKeyDown )
     EVT_KEY_UP( MyCanvas::OnKeyUp )
     EVT_ENTER_WINDOW( MyCanvas::OnEnterWindow )
     EVT_LEAVE_WINDOW( MyCanvas::OnExitWindow )
     EVT_LEFT_DOWN( MyCanvas::OnLeftDown )
     EVT_LEFT_DCLICK( MyCanvas::OnLeftDClick )
     EVT_LEFT_UP( MyCanvas::OnLeftUp )
     EVT_MIDDLE_DOWN( MyCanvas::OnMiddleDown )
     EVT_MIDDLE_UP( MyCanvas::OnMiddleUp )
     EVT_RIGHT_DOWN( MyCanvas::OnRightDown )
     EVT_RIGHT_UP( MyCanvas::OnRightUp )
     EVT_MOTION( MyCanvas::OnMotion )
     EVT_IDLE(MyCanvas::OnIdle )
     EVT_SET_FOCUS( MyCanvas::OnSetFocus )
     EVT_KILL_FOCUS( MyCanvas::OnKillFocus )
END_EVENT_TABLE()

MyCanvas::MyCanvas(wxWindow *parent, wxSizer* sizer,
                    wxWindowID id, const wxPoint& pos,
                    const wxSize& size, long style, const wxString& name)
     : wxPanel(parent,  id, pos, size, 
style|wxSIMPLE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxWANTS_CHARS , name )
{
   AddToolbar(parent, sizer);
   sizer->Add(this, 1, wxEXPAND|wxTOP, 7);
}

void FireSimCanvas::Render()
{
   // Do some drawing using the Producer::RenderSurface
}

void FireSimCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
     wxPaintDC dc(this);
     Render();
}

void MyCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
   // Do nothing, to avoid flashing.
}

void MyCanvas::AddToolbar(wxWindow* parent, wxSizer* sizer)
{
   wxToolBar* toolBar = new wxToolBar(parent, -1, wxDefaultPosition,
                                      wxDefaultSize, wxDOUBLE_BORDER);
   if (sizer) {
     sizer->Add(toolBar, 0, 0, 100);
   }

   wxBitmap* toolBarBitmaps[6];

   toolBarBitmaps[0] = new wxBitmap( back_xpm );
   toolBarBitmaps[1] = new wxBitmap( forward_xpm );
   toolBarBitmaps[2] = new wxBitmap( up_xpm );
   toolBarBitmaps[3] = new wxBitmap( down_xpm );
   toolBarBitmaps[4] = new wxBitmap( find_xpm );
   toolBarBitmaps[5] = new wxBitmap( findrepl_xpm );

   int bit = 0;
   if (mode == viewMode) {
     bit = TOOL_VIEW;
   }
   else {
     bit = TOOL_EDIT;
   }
   toolBar->AddTool(TOOL_PAN_LEFT|bit, "", *(toolBarBitmaps[0]), "Move 
Camera Left");
   toolBar->AddTool(TOOL_PAN_RIGHT|bit, "", *(toolBarBitmaps[1]), "Move 
Camera Right");
   toolBar->AddTool(TOOL_PAN_UP|bit, "", *(toolBarBitmaps[2]), "Move 
Camera Up");
   toolBar->AddTool(TOOL_PAN_DOWN|bit, "", *(toolBarBitmaps[3]), "Move 
Camera Down");
   toolBar->AddTool(TOOL_ZOOM_IN|bit, "", *(toolBarBitmaps[4]), "Zoom in");
   toolBar->AddTool(TOOL_ZOOM_OUT|bit, "", *(toolBarBitmaps[5]), "Zoom 
out");

   toolBar->Realize();

   int i;
   for (i = 0; i < 6; i++)
     delete toolBarBitmaps[i];

}

void FireSimCanvas::OnTool(wxCommandEvent &event)
{
   // Check what was pressed and do something
   Refresh();
}





More information about the wx-users mailing list