void TextDomArea::mouseDragged(MouseEventDetails* const details) { if(_IsMousePressed && details->getButton() == MouseEventDetails::BUTTON1) { getLayoutManager()->calculateCaretPosition(DrawingSurfaceToComponent(details->getLocation(), TextDomAreaRefPtr(this)) , true); } }
bool Component::isContained(const Pnt2f& p, bool TestAgainstClipBounds) const { if(!getVisible()) { return false; } Pnt2f PointInCompSpace(DrawingSurfaceToComponent(p,this)); Border* DrawnBorder(getDrawnBorder()); Pnt2f TopLeft, BottomRight; if(TestAgainstClipBounds && getClipping()) { TopLeft = getClipTopLeft(); BottomRight = getClipBottomRight(); } else { TopLeft.setValues(0,0); BottomRight = Pnt2f(getSize()); } if(DrawnBorder == NULL) { return isContainedBounds(PointInCompSpace, TopLeft, BottomRight); } else { return isContainedBounds(PointInCompSpace, TopLeft, BottomRight) && DrawnBorder->isContained(PointInCompSpace,0,0,getSize().x(),getSize().y()); } }
void TextDomArea::mousePressed(MouseEventDetails* const details) { _IsMousePressed = true; if(details->getButton() == details->BUTTON1) { //set caret position to proper place getLayoutManager()->calculateCaretPosition(DrawingSurfaceToComponent(details->getLocation(), TextDomAreaRefPtr(this)),false); } Inherited::mousePressed(details); }
void TextField::mousePressed(MouseEventDetails* const e) { Pnt2f TopLeftText, BottomRightText, TempPos; Pnt2f TopLeftText1, BottomRightText1; Pnt2f TopLeft, BottomRight; getFont()->getBounds(getDrawnText(), TopLeftText, BottomRightText); getInsideBorderBounds(TopLeft, BottomRight); TempPos = calculateAlignment(TopLeft, BottomRight-TopLeft, BottomRightText-TopLeftText, getAlignment().y(), getAlignment().x()); if(e->getButton() == MouseEventDetails::BUTTON1) { //set caret position to proper place //if the mouse is to the left of the text, set it to the begining. Pnt2f temp = DrawingSurfaceToComponent(e->getLocation(), this); if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= TempPos.x()) { setCaretPosition(0); } //if the mouse is to the right of the text, set it to the end else if(DrawingSurfaceToComponent(e->getLocation(), this).x() >= TempPos.x()+BottomRightText.x()) { setCaretPosition(getDrawnText().size()); } else { for(UInt32 i = 0; i <getDrawnText().size(); i++) { calculateTextBounds(0,i, TopLeftText, BottomRightText); calculateTextBounds(0,i+1, TopLeftText1, BottomRightText1); if(DrawingSurfaceToComponent(e->getLocation(), this).x()>BottomRightText.x() && DrawingSurfaceToComponent(e->getLocation(), this).x() <= BottomRightText1.x())//check to see if it's in the right spot { if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= (BottomRightText1.x()-BottomRightText.x())/2.0+0.5 + BottomRightText.x()) { setCaretPosition(i); break; } else { setCaretPosition(i+1); break; } } } } _TextSelectionEnd = getCaretPosition(); _TextSelectionStart = getCaretPosition(); } if(getParentWindow() != NULL && getParentWindow()->getParentDrawingSurface()!=NULL&& getParentWindow()->getParentDrawingSurface()->getEventProducer() != NULL) { _MouseDownKeyTypedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectKeyTyped(boost::bind(&TextField::handleMouseDownKeyTyped, this, _1)); _MouseDownMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&TextField::handleMouseDownMouseReleased, this, _1)); _MouseDownMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&TextField::handleMouseDownMouseDragged, this, _1)); } Inherited::mousePressed(e); }
void TextDomArea::mouseClicked(MouseEventDetails* const details) { getLayoutManager()->calculateCaretPosition(DrawingSurfaceToComponent(details->getLocation(), TextDomAreaRefPtr(this)),false); if(details->getButton() == details->BUTTON1) { if(details->getClickCount() >= 2) { getLayoutManager()->doubleClickHandler(); } } Inherited::mouseClicked(details); }
void Label::mousePressed(MouseEventDetails* const e) { if(getTextSelectable()) { Pnt2f TopLeftText, BottomRightText, TempPos; Pnt2f TopLeftText1, BottomRightText1; Pnt2f TopLeft, BottomRight; getFont()->getBounds(getText(), TopLeftText, BottomRightText); getInsideBorderBounds(TopLeft, BottomRight); TempPos = calculateAlignment(TopLeft, BottomRight-TopLeft, BottomRightText-TopLeftText, getAlignment().y(), getAlignment().x()); if(e->getButton() == MouseEventDetails::BUTTON1) { //set caret position to proper place //if the mouse is to the left of the text, set it to the begining. Pnt2f temp = DrawingSurfaceToComponent(e->getLocation(), this); if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= TempPos.x()) { setCaretPosition(0); } //if the mouse is to the right of the text, set it to the end else if(DrawingSurfaceToComponent(e->getLocation(), this).x() >= TempPos.x()+BottomRightText.x()) { setCaretPosition(getText().size()); } else { for(UInt32 i = 0; i <getText().size(); i++) { calculateTextBounds(0,i, TopLeftText, BottomRightText); calculateTextBounds(0,i+1, TopLeftText1, BottomRightText1); if(DrawingSurfaceToComponent(e->getLocation(), this).x()>BottomRightText.x() && DrawingSurfaceToComponent(e->getLocation(), this).x() <= BottomRightText1.x())//check to see if it's in the right spot { if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= (BottomRightText1.x()-BottomRightText.x())/2.0+0.5 + BottomRightText.x()) { setCaretPosition(i); break; } else { setCaretPosition(i+1); break; } } } } _TextSelectionEnd = getCaretPosition(); _TextSelectionStart = getCaretPosition(); } } Inherited::mousePressed(e); }
void Component::handleToolTipActivateUpdate(UpdateEventDetails* const e) { _TimeSinceMouseEntered += e->getElapsedTime(); if(!isToolTipActive() && _TimeSinceMouseEntered >= LookAndFeelManager::the()->getLookAndFeel()->getToolTipPopupTime()) { Pnt2f Location(0.0f,0.0f); if(getParentWindow() != NULL && getParentWindow()->getParentDrawingSurface() != NULL) { //TODO: Make this configurable Vec2f DefaultToolTipOffset(5,18); Location = DrawingSurfaceToComponent(getParentWindow()->getParentDrawingSurface()->getMousePosition(),this) + DefaultToolTipOffset; } setToolTipLocation(Location); activateToolTip(); } }
void ScrollBar::ScrollFieldListener::actionPerformed(const ActionEventUnrecPtr e) { if(_ScrollBar->getEnabled()) { UInt32 AxisIndex(0); if(_ScrollBar->getOrientation() == ScrollBar::HORIZONTAL_ORIENTATION ) AxisIndex = 0; else AxisIndex = 1; Pnt2f ComponentMousePosition(DrawingSurfaceToComponent(_ScrollBar->getParentWindow()->getDrawingSurface()->getMousePosition(), _ScrollBar)); //Is Mouse Major axis on the min or max side of the scroll bar if(ComponentMousePosition[AxisIndex] < _ScrollBar->editScrollBar()->getPosition()[AxisIndex]) { //Move the Bounded range model one block in the Min direction _ScrollBar->scrollBlock(-1); } else if(ComponentMousePosition[AxisIndex] > (_ScrollBar->editScrollBar()->getPosition()[AxisIndex] + _ScrollBar->editScrollBar()->getSize()[AxisIndex])) { //Move the Bounded range model one block in the Max direction _ScrollBar->scrollBlock(1); } } }
void ScrollBar::handleScrollFieldAction(ActionEventDetails* const e) { if(getEnabled()) { UInt32 AxisIndex(0); if(getOrientation() == ScrollBar::HORIZONTAL_ORIENTATION ) AxisIndex = 0; else AxisIndex = 1; Pnt2f ComponentMousePosition(DrawingSurfaceToComponent(getParentWindow()->getParentDrawingSurface()->getMousePosition(), this)); //Is Mouse Major axis on the min or max side of the scroll bar if(ComponentMousePosition[AxisIndex] < getScrollBar()->getPosition()[AxisIndex]) { //Move the Bounded range model one block in the Min direction scrollBlock(-1); } else if(ComponentMousePosition[AxisIndex] > (getScrollBar()->getPosition()[AxisIndex] + getScrollBar()->getSize()[AxisIndex])) { //Move the Bounded range model one block in the Max direction scrollBlock(1); } } }
InternalWindow::WindowArea InternalWindow::getCursurArea(const Pnt2f& DrawingSurfaceLocation) const { Pnt2f LocationInWindow(DrawingSurfaceToComponent(DrawingSurfaceLocation, this)); if(LocationInWindow.x() < 0 || LocationInWindow.x() > getSize().x() || LocationInWindow.y() < 0 || LocationInWindow.y() > getSize().y()) { return WINDOW_OUTSIDE; } else { if(getDrawDecorations()) { Pnt2f TitlebarTopLeft, TitlebarBottomRight; getTitlebarBounds(TitlebarTopLeft, TitlebarBottomRight); //Borders if(LocationInWindow.x() < getResizeModifyCursorWidth() || LocationInWindow.y() < getResizeModifyCursorWidth() || LocationInWindow.x() > (getSize().x() - getResizeModifyCursorWidth()) || LocationInWindow.y() > (getSize().y() - getResizeModifyCursorWidth())) { //Top Left if(LocationInWindow.x() >= 0 && LocationInWindow.x() < getResizeModifyCursorWidth() && LocationInWindow.y() >= 0 && LocationInWindow.y() < getResizeModifyCursorWidth()) { return WINDOW_TOP_LEFT_BORDER; } //Bottom Right else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() && LocationInWindow.x() < getSize().x() && LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() && LocationInWindow.y() < getSize().y()) { return WINDOW_BOTTOM_RIGHT_BORDER; } //Top Right else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() && LocationInWindow.x() < getSize().x() && LocationInWindow.y() >= 0 && LocationInWindow.y() < getResizeModifyCursorWidth()) { return WINDOW_TOP_RIGHT_BORDER; } //Bottom Left else if(LocationInWindow.x() >= 0 && LocationInWindow.x() < getResizeModifyCursorWidth() && LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() && LocationInWindow.y() < getSize().y()) { return WINDOW_BOTTOM_LEFT_BORDER; } //Left else if(LocationInWindow.x() >= 0 && LocationInWindow.x() < getResizeModifyCursorWidth() && LocationInWindow.y() >= getResizeModifyCursorWidth() && LocationInWindow.y() < getSize().y() - getResizeModifyCursorWidth()) { return WINDOW_LEFT_BORDER; } //Right else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() && LocationInWindow.x() < getSize().x() && LocationInWindow.y() >= getResizeModifyCursorWidth() && LocationInWindow.y() < getSize().y() - getResizeModifyCursorWidth()) { return WINDOW_RIGHT_BORDER; } //Top else if(LocationInWindow.x() >= getResizeModifyCursorWidth() && LocationInWindow.x() < getSize().x() - getResizeModifyCursorWidth() && LocationInWindow.y() >= 0 && LocationInWindow.y() < getResizeModifyCursorWidth()) { return WINDOW_TOP_BORDER; } //Bottom else if( (LocationInWindow.x() >= getResizeModifyCursorWidth() && LocationInWindow.x() < getSize().x() - getResizeModifyCursorWidth() && LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() && LocationInWindow.y() < getSize().y())) { return WINDOW_BOTTOM_BORDER; } } //Title bar else if(getDrawTitlebar() && isContainedBounds(LocationInWindow, TitlebarTopLeft, TitlebarBottomRight)) { return WINDOW_TITLE_BAR; } //Main Panel else { return WINDOW_MAIN_PANEL; } } else { return WINDOW_MAIN_PANEL; } } }
void Label::mouseClicked(MouseEventDetails* const e) { if(getTextSelectable()) { Int32 Position(0); Int32 BeginWord = 0; Int32 EndWord = getText().size(); if(e->getButton() == MouseEventDetails::BUTTON1) { if(e->getClickCount() == 2) { Pnt2f TopLeftText, BottomRightText, TempPos; Pnt2f TopLeftText1, BottomRightText1; Pnt2f TopLeft, BottomRight; getFont()->getBounds(getText(), TopLeftText, BottomRightText); getInsideBorderBounds(TopLeft, BottomRight); TempPos = calculateAlignment(TopLeft, BottomRight-TopLeft, BottomRightText-TopLeftText, getAlignment().y(), getAlignment().x()); //set caret position to proper place //if the mouse is to the left of the text, set it to the begining. Pnt2f temp = DrawingSurfaceToComponent(e->getLocation(), this); if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= TempPos.x()) { Position = 0; }//if the mouse is to the right of the text, set it to the end else if(DrawingSurfaceToComponent(e->getLocation(), this).x() >= TempPos.x()+BottomRightText.x()) { Position = getText().size(); } else { for(UInt32 i = 0; i <getText().size(); i++) { calculateTextBounds(0,i, TopLeftText, BottomRightText); calculateTextBounds(0,i+1, TopLeftText1, BottomRightText1); if(DrawingSurfaceToComponent(e->getLocation(), this).x()>BottomRightText.x() && DrawingSurfaceToComponent(e->getLocation(), this).x() <= BottomRightText1.x())//check to see if it's in the right spot { Position = i; break; } } } if(isPunctuationChar(getText()[Position])) { EndWord = Position + 1; BeginWord = Position; } else{ for(Int32 i = Position; i < getText().size(); i++) { if(!isWordChar(getText()[i])) { EndWord = i; break; } } for(Int32 i = Position; i >= 0; i--) { if(!isWordChar(getText()[i])) { BeginWord = i + 1; break; } } } _TextSelectionEnd = EndWord; _TextSelectionStart = BeginWord; setCaretPosition(EndWord); } } } Inherited::mouseClicked(e); }
void TextField::handleMouseDownMouseDragged(MouseEventDetails* const e) { Pnt2f TopLeftText, BottomRightText, TempPos; Pnt2f TopLeftText1, BottomRightText1; Pnt2f TopLeft, BottomRight; Int32 OriginalPosition = getCaretPosition(); getFont()->getBounds(getDrawnText(), TopLeftText, BottomRightText); getInsideBorderBounds(TopLeft, BottomRight); TempPos = calculateAlignment(TopLeft, BottomRight-TopLeft, BottomRightText-TopLeftText, getAlignment().y(), getAlignment().x()); if(e->getButton() == MouseEventDetails::BUTTON1) { //set caret position to proper place //if the mouse is to the left of the text, set it to the begining. Pnt2f temp = DrawingSurfaceToComponent(e->getLocation(), this); if(DrawingSurfaceToComponent(e->getLocation(), this).x() <= TempPos.x()) { setCaretPosition(0); } //if the mouse is to the right of the text, set it to the end else if(DrawingSurfaceToComponent(e->getLocation(), this).x() >= TempPos.x()+BottomRightText.x()) { setCaretPosition(getDrawnText().size()); } else { //check letter by letter for the mouse's position for(UInt32 i = 0; i <getDrawnText().size(); i++) { calculateTextBounds(0,i, TopLeftText, BottomRightText); calculateTextBounds(0,i+1, TopLeftText1, BottomRightText1); if(DrawingSurfaceToComponent(e->getLocation(), this).x()>BottomRightText.x() && DrawingSurfaceToComponent(e->getLocation(), this).x() <= BottomRightText1.x())//check to see if it's in the right spot { if(DrawingSurfaceToComponent(e->getLocation(), this).x() < (BottomRightText1.x()-BottomRightText.x())/2.0 + BottomRightText.x()) { setCaretPosition(i); break; } else { setCaretPosition(i+1); break; } } } } if(getCaretPosition() < OriginalPosition) { if(getCaretPosition() < _TextSelectionStart) { _TextSelectionStart = getCaretPosition(); } else { _TextSelectionEnd = getCaretPosition(); } } else if(getCaretPosition() > OriginalPosition) { if(getCaretPosition() > _TextSelectionEnd) { _TextSelectionEnd = getCaretPosition(); } else { _TextSelectionStart = getCaretPosition(); } } } }