Esempio n. 1
0
    void DragContainer::onMouseMove(MouseEventArgs& e)
    {
        Window::onMouseMove(e);

        // get position of mouse as co-ordinates local to this window.
        Point localMousePos = (getMetricsMode() == Relative) ? 
            relativeToAbsolute(screenToWindow(e.position)) :
            screenToWindow(e.position);

        // handle dragging
        if (d_dragging)
        {
            doDragging(localMousePos);
       }
        // not dragging
        else
        {
            // if mouse button is down (but we're not yet being dragged)
            if (d_leftMouseDown)
            {
                if (isDraggingThresholdExceeded(localMousePos))
                {
                    // Trigger the event
                    WindowEventArgs args(this);
                    onDragStarted(args);
                }
            }
        }
    }
Esempio n. 2
0
void FalagardActionButton::onMouseMove(MouseEventArgs& e)
{
    FalagardButton::onMouseMove(e);

    if(isDraggingEnabled() && !d_dragging && !isEmpty())
    {
        // get position of mouse as co-ordinates local to this window.
        Point localMousePos = (getMetricsMode() == Relative) ?
                              relativeToAbsolute(screenToWindow(e.position)) :
                              screenToWindow(e.position);

        // if mouse button is down (but we're not yet being dragged)
        if (d_leftMouseDown)
        {
            if (isDraggingThresholdExceeded(localMousePos))
            {
                // Trigger the event
                WindowEventArgs args(this);
                d_dragging = true;
                releaseInput();

                fireEvent(EventDragStarted, e, EventNamespace);
            }
        }
    }
}
Esempio n. 3
0
	void FalagardDragTitle::onMouseButtonDown(MouseEventArgs& e)
	{
		// Base class processing
		Window::onMouseButtonDown(e);

		if (e.button == LeftButton)
		{
			if (d_dragTarget != NULL)
			{
				// we want all mouse inputs from now on
				if (captureInput())
				{
					// initialise the dragging state
					d_dragging = true;
					d_dragPoint = screenToWindow(e.position);

					if (getMetricsMode() == Relative)
					{
						d_dragPoint = relativeToAbsolute(d_dragPoint);
					}
				}
			}
		}

		e.handled = true;
	}
Esempio n. 4
0
void FalagardActionButton::onMouseButtonDown(MouseEventArgs& e)
{
    //        FalagardButton::onMouseButtonDown(e);下面就是pushbutton中的部分
    // default processing
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton || e.button == RightButton)
    {
        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            requestRedraw();
        }

        // event was handled by us.
        e.handled = true;
    }
    /////////////////////////////////////////////////////////
    if (e.button == LeftButton && isDraggingEnabled())
    {
        if(!d_dragging)
        {
            // get position of mouse as co-ordinates local to this window.
            Point localPos = (getMetricsMode() == Relative) ?
                             relativeToAbsolute(screenToWindow(e.position)) :
                             screenToWindow(e.position);

            // store drag point for possible sizing or moving operation.
            d_dragPoint = localPos;
            d_leftMouseDown = true;

        }

        e.handled = true;
    }

    if (e.button == RightButton && isDraggingEnabled())
    {
        e.handled = true;
    }
}
Esempio n. 5
0
/*************************************************************************
	Handler for when mouse button is pressed
*************************************************************************/
void Listbox::onMouseButtonDown(MouseEventArgs& e)
{
	// base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		bool modified = false;

		// clear old selections if no control key is pressed or if multi-select is off
		if (!(e.sysKeys & Control) || !d_multiselect)
		{
			modified = clearAllSelections_impl();
		}

		Point localPos(screenToWindow(e.position));

		if (getMetricsMode() == Relative)
		{
			localPos = relativeToAbsolute(localPos);
		}

		ListboxItem* item = getItemAtPoint(localPos);

		if (item != NULL)
		{
			modified = true;

			// select range or item, depending upon keys and last selected item
			if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect)
			{
				selectRange(getItemIndex(item), getItemIndex(d_lastSelected));
			}
			else
			{
				item->setSelected(item->isSelected() ^ true);
			}

			// update last selected item
			d_lastSelected = item->isSelected() ? item : NULL;
		}

		// fire event if needed
		if (modified)
		{
			WindowEventArgs args(this);
			onSelectionChanged(args);
		}
		
		e.handled = true;
	}

}
Esempio n. 6
0
    void DragContainer::onMouseButtonDown(MouseEventArgs& e)
    {
        Window::onMouseButtonDown(e);

        if (e.button == LeftButton)
        {
            // ensure all inputs come to us for now
            if (captureInput())
            {
                // get position of mouse as co-ordinates local to this window.
                Point localPos = (getMetricsMode() == Relative) ? 
                    relativeToAbsolute(screenToWindow(e.position)) :
                    screenToWindow(e.position);

                // store drag point for possible sizing or moving operation.
                d_dragPoint = localPos;
                d_leftMouseDown = true;
            }

            e.handled = true;
        }

    }
Esempio n. 7
0
/*************************************************************************
	Handler for mouse button press events
*************************************************************************/
void Titlebar::onMouseButtonDown(MouseEventArgs& e)
{
	// Base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		if ((d_parent != NULL) && d_dragEnabled)
		{
			// we want all mouse inputs from now on
			if (captureInput())
			{
				// initialise the dragging state
				d_dragging = true;
				d_dragPoint = screenToWindow(e.position);

				if (getMetricsMode() == Relative)
				{
					d_dragPoint = relativeToAbsolute(d_dragPoint);
				}

				// store old constraint area
				d_oldCursorArea = MouseCursor::getSingleton().getConstraintArea();

				// setup new constraint area to be the intersection of the old area and our grand-parent's clipped inner-area
				Rect constrainArea;

				if ((d_parent == NULL) || (d_parent->getParent() == NULL))
				{
					constrainArea = System::getSingleton().getRenderer()->getRect().getIntersection(d_oldCursorArea);
				}
				else 
				{
					constrainArea = d_parent->getParent()->getInnerRect().getIntersection(d_oldCursorArea);
				}

				MouseCursor::getSingleton().setConstraintArea(&constrainArea);
			}

		}

		e.handled = true;
	}
}
Esempio n. 8
0
/*************************************************************************
	Return the text code point index that is rendered closest to screen
	position 'pt'.	
*************************************************************************/
size_t MultiLineEditbox::getTextIndexFromPosition(const Point& pt) const
{
	//
	// calculate final window position to be checked
	//
	Point wndPt = screenToWindow(pt);

	if (getMetricsMode() == Relative)
	{
		wndPt = relativeToAbsolute(wndPt);
	}

	Rect textArea(getTextRenderArea());

	wndPt.d_x -= textArea.d_left;
	wndPt.d_y -= textArea.d_top;

	// factor in scroll bar values
	if( d_horzScrollbar )
		wndPt.d_x += d_horzScrollbar->getScrollPosition();
	if( d_vertScrollbar )
		wndPt.d_y += d_vertScrollbar->getScrollPosition();

	size_t lineNumber = static_cast<size_t>(wndPt.d_y / getFont()->getLineSpacing());

	if (lineNumber >= d_lines.size())
	{
		lineNumber = d_lines.size() - 1;
	}

	String lineText(d_text.substr(d_lines[lineNumber].d_startIdx, d_lines[lineNumber].d_length));

	size_t lineIdx = getFont()->getCharAtPixel(lineText, wndPt.d_x);

	if (lineIdx >= lineText.length() - 1)
	{
		lineIdx = lineText.length() - 1;
	}

	return d_lines[lineNumber].d_startIdx + lineIdx;
}
Esempio n. 9
0
	void FalagardDragTitle::onMouseMove(MouseEventArgs& e)
	{
		// Base class processing.
		Window::onMouseMove(e);

		if (d_dragging && (d_dragTarget != NULL))
		{
			Vector2 delta(screenToWindow(e.position));

			if (getMetricsMode() == Relative)
			{
				delta = relativeToAbsolute(delta);
			}

			// calculate amount that window has been moved
			delta -= d_dragPoint;

			// move the window.  *** Again: Titlebar objects should only be attached to FrameWindow derived classes. ***
			((FalagardBoundWindow*)d_dragTarget)->offsetPixelPosition(delta);

			e.handled = true;
		}
	}
Esempio n. 10
0
/*************************************************************************
	Handler for mouse button down events
*************************************************************************/
void Thumb::onMouseButtonDown(MouseEventArgs& e)
{
	// default processing
	PushButton::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		// initialise the dragging state
		d_beingDragged = true;
		d_dragPoint = screenToWindow(e.position);

		if (getMetricsMode() == Relative)
		{
			d_dragPoint = relativeToAbsolute(d_dragPoint);
		}

		// trigger tracking started event
		WindowEventArgs args(this);
		onThumbTrackStarted(args);

		e.handled = true;
	}

}
Esempio n. 11
0
/*************************************************************************
    Handler for mouse movement
*************************************************************************/
void Listbox::onMouseMove(MouseEventArgs& e)
{
    if (d_itemTooltips)
    {
        static ListboxItem* lastItem = NULL;

        Point posi = relativeToAbsolute(screenToWindow(e.position));
        ListboxItem* item = getItemAtPoint(posi);
        if (item != lastItem)
        {
            if (item != NULL)
            {
                setTooltipText(item->getTooltipText());
            }
            else
            {
                setTooltipText("");
            }
            lastItem = item;
        }

        // must check the result from getTooltip(), as the tooltip object could
        // be 0 at any time for various reasons.
        Tooltip* tooltip = getTooltip();

        if (tooltip)
        {
            if (tooltip->getTargetWindow() != this)
                tooltip->setTargetWindow(this);
            else
                tooltip->positionSelf();
        }
    }

    Window::onMouseMove(e);
}
Esempio n. 12
0
/*************************************************************************
	Handler for mouse movement events
*************************************************************************/
void Thumb::onMouseMove(MouseEventArgs& e)
{
	// default processing
	PushButton::onMouseMove(e);

	// only react if we are being dragged
	if (d_beingDragged)
	{
		Vector2 delta;
		float hmin, hmax, vmin, vmax;

		// get some values as absolute pixel offsets
		if (getMetricsMode() == Relative)
		{
			delta = relativeToAbsolute(screenToWindow(e.position));

			hmax = relativeToAbsoluteX_impl(d_parent, d_horzMax);
			hmin = relativeToAbsoluteX_impl(d_parent, d_horzMin);
			vmax = relativeToAbsoluteY_impl(d_parent, d_vertMax);
			vmin = relativeToAbsoluteY_impl(d_parent, d_vertMin);
		}
		else
		{
			delta = screenToWindow(e.position);

			hmin = d_horzMin;
			hmax = d_horzMax;
			vmin = d_vertMin;
			vmax = d_vertMax;
		}

		// calculate amount of movement in pixels
		delta -= d_dragPoint;

		//
		// Calculate new (pixel) position for thumb
		//
		Point newPos(getAbsolutePosition());

		if (d_horzFree)
		{
			newPos.d_x += delta.d_x;

			// limit value to within currently set range
			newPos.d_x = (newPos.d_x < hmin) ? hmin : (newPos.d_x > hmax) ? hmax : newPos.d_x;
		}

		if (d_vertFree)
		{
			newPos.d_y += delta.d_y;

			// limit new position to within currently set range
			newPos.d_y = (newPos.d_y < vmin) ? vmin : (newPos.d_y > vmax) ? vmax : newPos.d_y;
		}

		// update thumb position if needed
		if (newPos != getAbsolutePosition())
		{
			if (getMetricsMode() == Relative)
			{
				newPos = absoluteToRelative_impl(d_parent, newPos);
			}

			setPosition(newPos);

			// send notification as required
			if (d_hotTrack)
			{
				WindowEventArgs args(this);
				onThumbPositionChanged(args);
			}

		}

	}

	e.handled = true;
}