void InternalWindow::mouseDragged(MouseEventDetails* const e) { if(getMenuBar() != NULL) { bool isContained; isContained = getMenuBar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getMenuBar(),isContained,e->getViewport()); if(isContained) { getMenuBar()->mouseDragged(e); Component::mouseDragged(e); return; } } if(getTitlebar() != NULL) { bool isContained; isContained = getTitlebar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTitlebar(),isContained,e->getViewport()); if(isContained) { getTitlebar()->mouseDragged(e); Component::mouseDragged(e); return; } } if(!getLockInput()) { ComponentContainer::mouseDragged(e); } }
void TabPanel::mousePressed(MouseEventDetails* const e) { bool isContained; for(Int32 i(getMFTabs()->size()-1) ; i>=0 ; --i) { // going backwards through through elements, so only top button is pressed isContained = getTabs(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabs(i),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getTabs(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getTabs(i)->takeFocus(); } getTabs(i)->mousePressed(e); break; } } if(isContained) { //Remove my temporary focus giveFocus(NULL, false); } else { //Give myself permanant focus takeFocus(); } // now do it for the content tab isContained = getTabContents(getSelectedIndex())->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabContents(getSelectedIndex()),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getTabContents(getSelectedIndex())->getType().isDerivedFrom(ComponentContainer::getClassType())) { getTabContents(getSelectedIndex())->takeFocus(); } getTabContents(getSelectedIndex())->mousePressed(e); giveFocus(NULL, false); } else { //Give myself permanent focus takeFocus(); } Component::mousePressed(e); }
void RotatedComponent::mousePressed(MouseEventDetails* const e) { bool isContained(false); for(Int32 i(getMFChildren()->size()-1) ; i>=0 ; --i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getChildren(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getChildren(i)->takeFocus(); } getChildren(i)->mousePressed(e); break; } } if(isContained) { //Remove my temporary focus giveFocus(NULL, false); } else { //Give myself permenant focus takeFocus(); } Component::mousePressed(e); }
void InternalWindow::mouseEntered(const MouseEventUnrecPtr e) { if(getMenuBar() != NULL) { bool isContained; isContained = getMenuBar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getMenuBar(),isContained,e->getViewport()); } if(getTitlebar() != NULL) { bool isContained; isContained = getTitlebar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTitlebar(),isContained,e->getViewport()); } if(!getLockInput()) { ComponentContainer::mouseEntered(e); } }
void RotatedComponent::mouseExited(MouseEventDetails* const e) { bool isContained; for(Int32 i(0) ; i<getMFChildren()->size() ; ++i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); } Component::mouseExited(e); }
void InternalWindow::popupMenuMouseDragged(MouseEventDetails* const e) { for(Int32 i(getMFActivePopupMenus()->size()-1) ; i>=0 ; --i) { bool isContained = getActivePopupMenus(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getActivePopupMenus(i),isContained,e->getViewport()); if(isContained) { getActivePopupMenus(i)->mouseDragged(e); return; } } }
void TabPanel::mouseWheelMoved(MouseWheelEventDetails* const e) { bool isContained; for(UInt32 i(0) ; i<getMFTabs()->size() ; ++i) { isContained = getTabs(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabs(i),isContained,e->getViewport()); if(isContained) { getTabs(i)->mouseWheelMoved(e); } } isContained = getTabContents(getSelectedIndex())->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabContents(getSelectedIndex()),isContained,e->getViewport()); if(isContained) { getTabContents(getSelectedIndex())->mouseWheelMoved(e); } Component::mouseWheelMoved(e); }
void InternalWindow::mouseExited(MouseEventDetails* const e) { if(getMenuBar() != NULL) { bool isContained; isContained = getMenuBar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getMenuBar(),isContained,e->getViewport()); } if(getTitlebar() != NULL) { bool isContained; isContained = getTitlebar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTitlebar(),isContained,e->getViewport()); } if(!getLockInput()) { if(getParentDrawingSurface() != NULL && getParentDrawingSurface()->getEventProducer() != NULL) { getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_POINTER); } ComponentContainer::mouseExited(e); } }
void RotatedComponent::mouseReleased(MouseEventDetails* const e) { bool isContained; for(Int32 i(getMFChildren()->size()-1) ; i>=0 ; --i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); if(isContained) { getChildren(i)->mouseReleased(e); break; } } Component::mouseReleased(e); }
void InternalWindow::mousePressed(MouseEventDetails* const e) { if(!getLockInput()) { //Check if the Mouse is whithin the resize border width if(getResizable()) { WindowArea TheArea(getCursurArea(e->getLocation())); switch(TheArea) { case WINDOW_LEFT_BORDER: case WINDOW_RIGHT_BORDER: case WINDOW_TOP_BORDER: case WINDOW_BOTTOM_BORDER: case WINDOW_TOP_LEFT_BORDER: case WINDOW_BOTTOM_RIGHT_BORDER: case WINDOW_TOP_RIGHT_BORDER: case WINDOW_BOTTOM_LEFT_BORDER: setLockInput(true); _WindowStartPosition = getPosition(); _WindowStartSize = getSize(); _MouseStartPosition = e->getLocation(); _BorderDragged = TheArea; _BorderDragMouseDraggedConnection = getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&InternalWindow::borderDragMouseDragged, this, _1)); _BorderDragMouseReleasedConnection = getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&InternalWindow::borderDragMouseReleased, this, _1)); _BorderDragKeyPressedConnection = getParentDrawingSurface()->getEventProducer()->connectKeyPressed(boost::bind(&InternalWindow::borderDragKeyPressed, this, _1)); break; } } if(getMenuBar() != NULL) { bool isContained; isContained = getMenuBar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getMenuBar(),isContained,e->getViewport()); if(isContained) { getMenuBar()->mousePressed(e); if(e->isConsumed()) return; Component::mousePressed(e); return; } } if(getTitlebar() != NULL) { bool isContained; isContained = getTitlebar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTitlebar(),isContained,e->getViewport()); if(isContained) { getTitlebar()->mousePressed(e); if(e->isConsumed()) return; Component::mousePressed(e); return; } } //ComponentContainer MousePressed Handling bool isContained(false); for(Int32 i(getMFChildren()->size()-1) ; i>=0 ; --i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); if(isContained) { takeFocus(); if(!getChildren(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getChildren(i)->takeFocus(); } getChildren(i)->mousePressed(e); if(e->isConsumed()) return; break; } } Component::mousePressed(e); } }
void InternalWindow::mousePressed(const MouseEventUnrecPtr e) { if(!getLockInput()) { //Check if the Mouse is whithin the resize border width if(getResizable()) { WindowArea TheArea(getCursurArea(e->getLocation())); switch(TheArea) { case WINDOW_LEFT_BORDER: case WINDOW_RIGHT_BORDER: case WINDOW_TOP_BORDER: case WINDOW_BOTTOM_BORDER: case WINDOW_TOP_LEFT_BORDER: case WINDOW_BOTTOM_RIGHT_BORDER: case WINDOW_TOP_RIGHT_BORDER: case WINDOW_BOTTOM_LEFT_BORDER: setLockInput(true); _BorderDraggedListener.setWindowStartPosition(getPosition()); _BorderDraggedListener.setWindowStartSize(getSize()); _BorderDraggedListener.setMouseStartPosition(e->getLocation()); _BorderDraggedListener.setBorderDragged(TheArea); getDrawingSurface()->getEventProducer()->addMouseMotionListener(&_BorderDraggedListener); getDrawingSurface()->getEventProducer()->addMouseListener(&_BorderDraggedListener); getDrawingSurface()->getEventProducer()->addKeyListener(&_BorderDraggedListener); break; } } if(getMenuBar() != NULL) { bool isContained; isContained = getMenuBar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getMenuBar(),isContained,e->getViewport()); if(isContained) { getMenuBar()->mousePressed(e); Component::mousePressed(e); return; } } if(getTitlebar() != NULL) { bool isContained; isContained = getTitlebar()->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTitlebar(),isContained,e->getViewport()); if(isContained) { getTitlebar()->mousePressed(e); Component::mousePressed(e); return; } } //ComponentContainer MousePressed Handling bool isContained(false); for(Int32 i(getMFChildren()->size()-1) ; i>=0 ; --i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); if(isContained) { takeFocus(); if(!getChildren(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getChildren(i)->takeFocus(); } getChildren(i)->mousePressed(e); break; } } Component::mousePressed(e); } }
void RotatedComponent::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); //Do not respond to changes that have a Sync origin if(origin & ChangedOrigin::Sync) { return; } if(whichField & InternalComponentFieldMask) { clearChildren(); if(getInternalComponent() != NULL) { pushToChildren(getInternalComponent()); } } if((whichField & InternalComponentFieldMask) || (whichField & AngleFieldMask) || (whichField & ResizePolicyFieldMask)) { if(getInternalComponent() != NULL) { Vec2f Size; switch (static_cast<ResizePolicy>(getResizePolicy())) { case RESIZE_TO_MIN: { //Treat TopLeft as 0,0 //Get the Rotated Bounds of the Internal Component Pnt2f p1,p2,p3,p4; Pnt2f ComponentCenter(static_cast<Real32>(getInternalComponent()->getSize().x())/2.0, static_cast<Real32>(getInternalComponent()->getSize().y())/2.0); p1 = -ComponentCenter; p2.setValues(ComponentCenter.x(),-ComponentCenter.y()); p3 = ComponentCenter; p4.setValues(-ComponentCenter.x(),ComponentCenter.y()); //Rotate them p1 = Rotate(p1, -getAngle()); p2 = Rotate(p2, -getAngle()); p3 = Rotate(p3, -getAngle()); p4 = Rotate(p4, -getAngle()); //Get their min and max Pnt2f Min(osgMin(osgMin(osgMin(p1.x(),p2.x()),p3.x()),p4.x()), osgMin(osgMin(osgMin(p1.y(),p2.y()),p3.y()),p4.y())); Pnt2f Max(osgMax(osgMax(osgMax(p1.x(),p2.x()),p3.x()),p4.x()), osgMax(osgMax(osgMax(p1.y(),p2.y()),p3.y()),p4.y())); Pnt2f BorderTopLeft, BorderBottomRight; getInsideInsetsBounds(BorderTopLeft, BorderBottomRight); Pnt2f TopLeft, BottomRight; getBounds(TopLeft, BottomRight); setPreferredSize(Vec2f(Max.x() - Min.x() + (BorderTopLeft.x() - TopLeft.x()) + (BottomRight.x() - BorderBottomRight.x()), Max.y() - Min.y() + (BorderTopLeft.y() - TopLeft.y()) + (BottomRight.y() - BorderBottomRight.y()))); break; } case RESIZE_TO_MAX: { //Get the Internal Components Center Pnt2f ComponentCenter(static_cast<Real32>(getInternalComponent()->getSize().x())/2.0, static_cast<Real32>(getInternalComponent()->getSize().y())/2.0); //Get the distance from the Center to one of the TopLeft Corner Real32 Length = 2*ComponentCenter.dist(Pnt2f(0,0)); setPreferredSize(Vec2f(Length,Length)); break; } case NO_RESIZING: default: break; } getInternalComponent()->updateClipBounds(); //Check the Mouse if( getParentWindow() != NULL && getParentWindow()->getParentDrawingSurface() != NULL && getParentWindow()->getParentDrawingSurface()->getEventProducer() != NULL) { Pnt2f MouseLoc(getParentWindow()->getParentDrawingSurface()->getEventProducer()->getMousePosition()); MouseEventDetailsUnrecPtr e = MouseEventDetails::create(getParentWindow()->getParentDrawingSurface()->getEventProducer(),getSystemTime(),MouseEventDetails::NO_BUTTON,0,MouseLoc, NULL); checkMouseEnterExit(e,e->getLocation(),getInternalComponent(),getInternalComponent()->isContained(MouseLoc, true),e->getViewport()); } } } }