void ScrollArea::mousePress(int x, int y, int button) { if (getUpButtonDimension().isPointInRect(x, y)) { setVerticalScrollAmount(getVerticalScrollAmount() - 10); mUpButtonPressed = true; } else if (getDownButtonDimension().isPointInRect(x, y)) { setVerticalScrollAmount(getVerticalScrollAmount() + 10); mDownButtonPressed = true; } else if (getLeftButtonDimension().isPointInRect(x, y)) { setHorizontalScrollAmount(getHorizontalScrollAmount() - 10); mLeftButtonPressed = true; } else if (getRightButtonDimension().isPointInRect(x, y)) { setHorizontalScrollAmount(getHorizontalScrollAmount() + 10); mRightButtonPressed = true; } else if (getVerticalMarkerDimension().isPointInRect(x, y)) { mVerticalMarkerPressed = true; mVerticalMarkerMousePosition = y - getVerticalMarkerDimension().y; } else if (getHorizontalMarkerDimension().isPointInRect(x, y)) { mHorizontalMarkerPressed = true; mHorizontalMarkerMousePosition = x - getHorizontalMarkerDimension().x; } }
void ScrollArea::drawVMarker(Graphics* graphics) { Rectangle dim = getVerticalMarkerDimension(); graphics->pushClipArea(dim); int alpha = getBaseColor().a; Color faceColor = getBaseColor(); faceColor.a = alpha; Color highlightColor = faceColor + 0x303030; highlightColor.a = alpha; Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; graphics->setColor(faceColor); graphics->fillRectangle(Rectangle(1, 1, dim.width - 1, dim.height - 1)); graphics->setColor(highlightColor); graphics->drawLine(0, 0, dim.width - 1, 0); graphics->drawLine(0, 1, 0, dim.height - 1); graphics->setColor(shadowColor); graphics->drawLine(1, dim.height - 1, dim.width - 1, dim.height - 1); graphics->drawLine(dim.width - 1, 0, dim.width - 1, dim.height - 1); graphics->popClipArea(); }
void ScrollArea::drawVMarker(gcn::Graphics *graphics) { gcn::Rectangle dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (getWidth() - getScrollbarWidth()))) static_cast<Graphics*>(graphics)-> drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi); else static_cast<Graphics*>(graphics)-> drawImageRect(dim.x, dim.y, dim.width, dim.height,vMarker); }
void ScrollArea::mouseDragged(MouseEvent& mouseEvent) { if (mIsVerticalMarkerDragged) { int pos = mouseEvent.getY() - getVerticalBarDimension().y - mVerticalMarkerDragOffset; int length = getVerticalMarkerDimension().height; Rectangle barDim = getVerticalBarDimension(); if ((barDim.height - length) > 0) { setVerticalScrollAmount((getVerticalMaxScroll() * pos) / (barDim.height - length)); } else { setVerticalScrollAmount(0); } } if (mIsHorizontalMarkerDragged) { int pos = mouseEvent.getX() - getHorizontalBarDimension().x - mHorizontalMarkerDragOffset; int length = getHorizontalMarkerDimension().width; Rectangle barDim = getHorizontalBarDimension(); if ((barDim.width - length) > 0) { setHorizontalScrollAmount((getHorizontalMaxScroll() * pos) / (barDim.width - length)); } else { setHorizontalScrollAmount(0); } } mouseEvent.consume(); }
void ScrollArea::mouseMotion(int x, int y) { if (mVerticalMarkerPressed) { int pos = y - getVerticalBarDimension().y - mVerticalMarkerMousePosition; int length = getVerticalMarkerDimension().height; Rectangle barDim = getVerticalBarDimension(); if ((barDim.height - length) > 0) { setVerticalScrollAmount((getVerticalMaxScroll() * pos) / (barDim.height - length)); } else { setVerticalScrollAmount(0); } } if (mHorizontalMarkerPressed) { int pos = x - getHorizontalBarDimension().x - mHorizontalMarkerMousePosition; int length = getHorizontalMarkerDimension().width; Rectangle barDim = getHorizontalBarDimension(); if ((barDim.width - length) > 0) { setHorizontalScrollAmount((getHorizontalMaxScroll() * pos) / (barDim.width - length)); } else { setHorizontalScrollAmount(0); } } }
void ScrollArea::mousePressed(MouseEvent& mouseEvent) { int x = mouseEvent.getX(); int y = mouseEvent.getY(); if (getUpButtonDimension().isPointInRect(x, y)) { setVerticalScrollAmount(getVerticalScrollAmount() - mUpButtonScrollAmount); mUpButtonPressed = true; } else if (getDownButtonDimension().isPointInRect(x, y)) { setVerticalScrollAmount(getVerticalScrollAmount() + mDownButtonScrollAmount); mDownButtonPressed = true; } else if (getLeftButtonDimension().isPointInRect(x, y)) { setHorizontalScrollAmount(getHorizontalScrollAmount() - mLeftButtonScrollAmount); mLeftButtonPressed = true; } else if (getRightButtonDimension().isPointInRect(x, y)) { setHorizontalScrollAmount(getHorizontalScrollAmount() + mRightButtonScrollAmount); mRightButtonPressed = true; } else if (getVerticalMarkerDimension().isPointInRect(x, y)) { mIsHorizontalMarkerDragged = false; mIsVerticalMarkerDragged = true; mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y; } else if (getVerticalBarDimension().isPointInRect(x,y)) { if (y < getVerticalMarkerDimension().y) { setVerticalScrollAmount(getVerticalScrollAmount() - (int)(getChildrenArea().height * 0.95)); } else { setVerticalScrollAmount(getVerticalScrollAmount() + (int)(getChildrenArea().height * 0.95)); } } else if (getHorizontalMarkerDimension().isPointInRect(x, y)) { mIsHorizontalMarkerDragged = true; mIsVerticalMarkerDragged = false; mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x; } else if (getHorizontalBarDimension().isPointInRect(x,y)) { if (x < getHorizontalMarkerDimension().x) { setHorizontalScrollAmount(getHorizontalScrollAmount() - (int)(getChildrenArea().width * 0.95)); } else { setHorizontalScrollAmount(getHorizontalScrollAmount() + (int)(getChildrenArea().width * 0.95)); } } // Eat the mouse mouseEvent.consume(); }