comparison libgui/graphics/Figure.cc @ 18648:1f8ce7be9c00 gui-release

Add support for "windowbuttonmotionfcn" and "currentpoint" * Figure.cc (Figure::Figure): Enable mouse tracking if windowbuttonmotionfcn callback is defined. (Figure::update): Enable mouse tracking on canvas and all child widgets when windowbuttonmotionfcn is defined. * Panel.cc (Panel::Panel): Propagate mouse tracking to child widgets during initialization. * Container.h (Container::childEvent): New method. * Container.cc (Container::childEvent): Likewise. Propagate mouse tracking status to child widgets. * BaseControl.cc (BaseControl::eventFilter): Handle mouse move events and call figure's appropriate callback. * Canvas.h (Canvas::updateCurrentPoint): New method. * Canvas.cc (Canvas::updateCurrentPoint): Likewise. Update figure and child axes currentpoint property. (Canvas::canvasMouseMoveEvent): Update currentpoint properties and call windowbuttonmotionfcn callback. (Canvas::canvasMousePressEvent): Call updateCurrentPoint. (Canvas::canvasMouseReleaseEvent): Likewise.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 01 Apr 2014 20:57:08 -0400
parents fb96b7f55242
children 6113e0c6920b 709f3a77685d
comparison
equal deleted inserted replaced
18645:086093fbdc1a 18648:1f8ce7be9c00
139 eventMask |= Canvas::KeyPress; 139 eventMask |= Canvas::KeyPress;
140 if (! fp.get_keyreleasefcn ().is_empty ()) 140 if (! fp.get_keyreleasefcn ().is_empty ())
141 eventMask |= Canvas::KeyRelease; 141 eventMask |= Canvas::KeyRelease;
142 m_container->canvas (m_handle)->setEventMask (eventMask); 142 m_container->canvas (m_handle)->setEventMask (eventMask);
143 143
144 if (! fp.get_windowbuttonmotionfcn ().is_empty ())
145 {
146 m_container->setMouseTracking (true);
147 m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
148 }
149
144 connect (this, SIGNAL (asyncUpdate (void)), 150 connect (this, SIGNAL (asyncUpdate (void)),
145 this, SLOT (updateContainer (void))); 151 this, SLOT (updateContainer (void)));
146 152
147 if (fp.is_visible ()) 153 if (fp.is_visible ())
148 QTimer::singleShot (0, win, SLOT (show ())); 154 QTimer::singleShot (0, win, SLOT (show ()));
299 case figure::properties::ID_KEYRELEASEFCN: 305 case figure::properties::ID_KEYRELEASEFCN:
300 if (fp.get_keyreleasefcn ().is_empty ()) 306 if (fp.get_keyreleasefcn ().is_empty ())
301 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); 307 m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease);
302 else 308 else
303 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); 309 m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
310 break;
311 case figure::properties::ID_WINDOWBUTTONMOTIONFCN:
312 {
313 bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
314
315 m_container->setMouseTracking (hasCallback);
316 foreach (QWidget* w, m_container->findChildren<QWidget*> ())
317 { w->setMouseTracking (hasCallback); }
318 }
304 break; 319 break;
305 default: 320 default:
306 break; 321 break;
307 } 322 }
308 323