Example #1
0
bool WindowManager::_handleMousePushed(float x, float y, bool& down) {
    down = true;

    Event ev(this, EVENT_MOUSE_PUSH);

    WidgetList widgetList;

    if(!pickAtXY(x, y, widgetList)) return false;

    ev.makeMouse(x, y);

    _lastPush = getFirstEventInterface(widgetList, ev);

    if(!_lastPush) return false;

    // TODO: This is the old way; it didn't allow Event handler code to call grabFocus().
    // bool handled = _lastPush->callMethodAndCallbacks(ev);

    if(_focusMode != PFM_SLOPPY) {
        if(ev._window) {
            Window* topmostWindow = ev._window->getTopmostParent();

            setFocused(topmostWindow);

            if(ev._widget) topmostWindow->setFocused(ev._widget);
        }

        // If the user wants to be able to "unfocus" the last Window.
        else if(_focusMode == PFM_UNFOCUS) setFocused(0);
    }

    return _lastPush->callMethodAndCallbacks(ev);
}
Example #2
0
void phdPopupMenu::updateHitTestInfo(float _x, float _y) {
    hitTestInfo.infoType = pphOutside;
    hitTestInfo.focusedIndex = -1;
    if(_x >= x && _x <= x+colWidth*nCols && _y >= y && _y <= y+menuHeight) {
        hitTestInfo.infoType = pphInside;
        if(items.size() == 0) {
            hitTestInfo.focusedIndex = -1;
            setFocused(NULL);
        } else {
            //hitTestInfo.focusedIndex = ((_y-y) / h) * items.size();

            int _r = (int)((_y-y) / menuItemHeight);
            int _c = (int)((_x-x) / colWidth);

            hitTestInfo.focusedIndex = _c * nRows + _r;

            if(hitTestInfo.focusedIndex > -1 && hitTestInfo.focusedIndex < items.size()) {
                setFocused(items[hitTestInfo.focusedIndex]);
            } else {
                hitTestInfo.focusedIndex = -1;
                setFocused(NULL);
            }
        }
    } else {
        setFocused(NULL);
    }
}
Example #3
0
bool InternalWindow::takeFocus(bool Temporary)
{

    if(getFocused() &&
       getParentDrawingSurface() != NULL &&
       getParentDrawingSurface()->getFocusedWindow() == this)
    {
        return true;
    }
    setFocused(true);
    if(Temporary || getParentDrawingSurface() == NULL)
    {
        FocusEventDetailsUnrecPtr Details(FocusEventDetails::create(this,getSystemTime(),Temporary, NULL));

        focusGained(Details);
    }
    else
    {
        if(getParentDrawingSurface()->getFocusedWindow() != NULL)
        {
            getParentDrawingSurface()->getFocusedWindow()->giveFocus(this);
        }
        getParentDrawingSurface()->setFocusedWindow(this);
        FocusEventDetailsUnrecPtr Details(FocusEventDetails::create(this,getSystemTime(),Temporary, getParentDrawingSurface()->getFocusedWindow()));
        focusGained(Details);
    }
    return true;
}
void phdShapeGroup::onMouseMoved(ofMouseEventArgs& args) {

	if(!visible)  return;

	// if popup has focus
	if(getPopupMenu() != NULL && getPopupMenu()->getVisible()) {
		ofMouseEventArgs _args = args; _args.x = ofGetMouseX(); _args.y = ofGetMouseY();
		getPopupMenu()->onMouseMoved(_args);
		return;
	}

	if(focused != NULL && focused->updateHitTestInfo(args.x, args.y)) return;

	phdShapeBase * _shape = NULL;
	for(int i = 0; i < shapes.size(); i++) {
		if(shapes[i] != NULL && shapes[i]->updateHitTestInfo(args.x, args.y)) {
			_shape = shapes[i];
			break;
		}
	}

	setFocused(_shape);

	if(focused != NULL) focused->onMouseMoved(args);
}
Example #5
0
void WindowManager::childInserted(unsigned int i) {
    Window* window = dynamic_cast<Window*>(getChild(i));

    if(!window) return;

    // Update Window's index
    for(Iterator w = begin(); w != end(); w++) {
        if(w->get()->_index >= i) w->get()->_index++;
    }

    _objects.push_back(window);

    window->_index = i;

    setFocused(window);

    window->setNodeMask(_nodeMask);
    window->managed(this);

    for(Window::Iterator w = window->begin(); w != window->end(); w++) if(w->valid()) {
        _styleManager->applyStyles(w->get());
    }

    _styleManager->applyStyles(window);
}
bool InternalWindow::takeFocus(bool Temporary)
{

    if(getFocused() &&
       getDrawingSurface() != NULL &&
       getDrawingSurface()->getFocusedWindow() == InternalWindowRefPtr(this))
    {
        return true;
    }
    setFocused(true);
    if(Temporary || getDrawingSurface() == NULL)
    {
        focusGained(FocusEvent::create(ComponentRefPtr(this),getSystemTime(),Temporary, NULL));
    }
    else
    {
        if(getDrawingSurface()->getFocusedWindow() != NULL)
        {
            getDrawingSurface()->getFocusedWindow()->giveFocus(this);
        }
        getDrawingSurface()->setFocusedWindow(this);
        focusGained(FocusEvent::create(ComponentRefPtr(this),getSystemTime(),Temporary, getDrawingSurface()->getFocusedWindow()));
    }
    return true;
}
Example #7
0
// This is called by a ViewerEventHandler/MouseHandler (or whatever) as the pointer moves
// around and intersects with objects. It also resets our state data (_widget, _leftDown,
// etc.) The return value of this method is mostly useless.
bool WindowManager::pointerMove(float x, float y) {
    WidgetList wl;
    Event      ev(this);

    if(!pickAtXY(x, y, wl)) {
        if(_lastEvent) {
            setEventFromInterface(ev.makeMouse(x, y, EVENT_MOUSE_LEAVE), _lastEvent);

            _lastEvent->callMethodAndCallbacks(ev);
        }

        if(_focusMode == PFM_SLOPPY) setFocused(0);

        _lastEvent  = 0;
        _leftDown   = 0;
        _middleDown = 0;
        _rightDown  = 0;

        return false;
    }

    EventInterface* ei = getFirstEventInterface(wl, ev.makeMouse(x, y, EVENT_MOUSE_OVER));

    if(!ei) return false;

    if(_lastEvent != ei) {
        if(_lastEvent) {
            Event evLeave(this);

            evLeave.makeMouse(x, y, EVENT_MOUSE_LEAVE);

            setEventFromInterface(evLeave, _lastEvent);

            _lastEvent->callMethodAndCallbacks(evLeave);
        }

        _lastEvent = ei;

        if(_focusMode == PFM_SLOPPY && ev._window) setFocused(ev._window);

        _lastEvent->callMethodAndCallbacks(ev.makeMouse(x, y, EVENT_MOUSE_ENTER));
    }

    ei->callMethodAndCallbacks(ev.makeMouse(x, y, EVENT_MOUSE_OVER));

    return true;
}
void phdShapeGroup::freeShapes() {
	setFocused(NULL);
	setSelected(NULL);
	for (vector<phdShapeBase*>::iterator i = shapes.begin(); i != shapes.end(); i++) {
		delete(*i); (*i) = NULL;
	}
	shapes.clear();
}
void phdShapeGroup::delShape(int _index) {
	if(_index > -1 && _index < shapes.size()) { 
		if(shapes[_index] == focused) setFocused(NULL);
		if(shapes[_index] == selected) setSelected(NULL);
		delete shapes[_index];
		shapes[_index] = NULL;
		shapes.erase(shapes.begin() + _index);
	}
}
Example #10
0
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent)
{
    _touchMovePos = touch->getLocation();
    setFocused(hitTest(_touchMovePos));
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(1,this,_touchMovePos);
    }
    moveEvent();
}
Example #11
0
void UIWidget::onTouchMoved(const CCPoint &touchPoint)
{
    m_touchMovePos.x = touchPoint.x;
    m_touchMovePos.y = touchPoint.y;
    setFocused(hitTest(touchPoint));
    if (m_pWidgetParent)
    {
        m_pWidgetParent->checkChildInfo(1,this,touchPoint);
    }
    moveEvent();
}
		bool DisplayBase::mouseClick(LPPOINT mousePos, ULONG ulButtons, USHORT usButtonData)
		{
			for(int i = 0; i < this->children.size(); i++)
				if(this->children[i]->isEnabled() && this->children[i]->mouseClick(mousePos, ulButtons, usButtonData))
					break;
			if(!this->isEnabled())
				return false;
			bool flag = isPointInDisplay(mousePos);
			if(flag && isFocusable)
				setFocused();
			return this->e_mouseClick(mousePos, ulButtons, usButtonData) || flag;
		}
Example #13
0
bool UIWidget::onTouchBegan(const CCPoint &touchPoint)
{
    setFocused(true);
    m_touchStartPos.x = touchPoint.x;
    m_touchStartPos.y = touchPoint.y;
    if (m_pWidgetParent)
    {
        m_pWidgetParent->checkChildInfo(0,this,touchPoint);
    }
    pushDownEvent();
    return m_bTouchPassedEnabled;
}
bool InternalWindow::giveFocus(ComponentRefPtr NewFocusedComponent, bool Temporary)
{
    if(ComponentRefPtr(this) == NewFocusedComponent)
    {
        return true;
    }
    else
    {
        setFocused(false);
        focusLost(FocusEvent::create(ComponentRefPtr(this),getSystemTime(),Temporary, NewFocusedComponent));
        return true;
    }
}
Example #15
0
bool InternalWindow::giveFocus(Component* const NewFocusedComponent, bool Temporary)
{
    if(this == NewFocusedComponent)
    {
        return true;
    }
    else
    {
        setFocused(false);
        FocusEventDetailsUnrecPtr Details(FocusEventDetails::create(this,getSystemTime(),Temporary, NewFocusedComponent));
        focusLost(Details);
        return true;
    }
}
Example #16
0
void LibraryManager::show() {
  if(slotLoad == false) {
    loaded.reset();
    requestedLoadType.reset();
    skipButton.setText("Cancel");
  } else {
    skipButton.setText("Skip");
  }

  setInformation(true);
  setVisible();
  setFocused();
  onChange();
}
Example #17
0
void Widget::processEvent(simplgui::Event event)
{
    sf::Transform globalTr = getGlobalTransform();
    sf::FloatRect widgetRect(sf::Vector2f(0.f, 0.f), getEffectiveSize());

    widgetRect = globalTr.transformRect(widgetRect);

    if(event.type == simplgui::Event::MouseButtonPressed)
    {
        if(widgetRect.contains(event.mouseButton.x, event.mouseButton.y))
        {
            setFocused(true);
            m_click = true;
        }
        else //TODO: Allow widgets to go outside their effective size rectangle (like combobox with their unfoldable list)
        {
            setFocused(false);
        }
    }
    else if(event.type == simplgui::Event::MouseButtonReleased)
    {
        m_click = false;
    }
    else if(event.type == simplgui::Event::MouseMoved)
    {
        if(widgetRect.contains(event.mouseMove.x, event.mouseMove.y))
        {
            
        }
        else //TODO: Allow widgets to go outside their effective size rectangle (like combobox with their unfoldable list)
        {
            m_click = false;
        }
    }

    doProcessEvent(event);
}
    //_____________________________________________
    void ScrolledWindowData::registerChild( GtkWidget* widget )
    {
        // make sure widget is not already in map
        if( _childrenData.find( widget ) == _childrenData.end() )
        {

            #if OXYGEN_DEBUG
            std::cerr
                << "Oxygen::ScrolledWindowData::registerChild -"
                << " " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")"
                << std::endl;
            #endif

            // adjust event mask
            gtk_widget_add_events( widget, GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK|GDK_FOCUS_CHANGE_MASK );

            // allocate new Hover data
            ChildData data;
            data._destroyId.connect( G_OBJECT(widget), "destroy", G_CALLBACK( childDestroyNotifyEvent ), this );
            data._enterId.connect( G_OBJECT(widget), "enter-notify-event", G_CALLBACK( enterNotifyEvent ), this );
            data._leaveId.connect( G_OBJECT(widget), "leave-notify-event", G_CALLBACK( leaveNotifyEvent ), this );
            data._focusInId.connect( G_OBJECT(widget), "focus-in-event", G_CALLBACK( focusInNotifyEvent ), this );
            data._focusOutId.connect( G_OBJECT(widget), "focus-out-event", G_CALLBACK( focusOutNotifyEvent ), this );

            // and insert in map
            _childrenData.insert( std::make_pair( widget, data ) );

            // set initial focus
            setFocused( widget, gtk_widget_has_focus( widget ) );

            // set initial hover
            const bool enabled( gtk_widget_get_state( widget ) != GTK_STATE_INSENSITIVE );

            // on connection, needs to check whether mouse pointer is in widget or not
            // to have the proper initial value of the hover flag
            if( enabled && gtk_widget_get_window( widget ) )
            {

                gint xPointer,yPointer;
                gdk_window_get_pointer( gtk_widget_get_window( widget ), &xPointer, &yPointer, 0L );
                const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( widget ) );
                const GdkRectangle rect( Gtk::gdk_rectangle( 0, 0, allocation.width, allocation.height ) );
                setHovered( widget, Gtk::gdk_rectangle_contains( &rect, xPointer, yPointer ) );

            } else setHovered( widget, false );

        }

    }
Example #19
0
void UIPageView::onTouchMoved(const CCPoint &touchPoint)
{
    m_touchMovePos.x = touchPoint.x;
    m_touchMovePos.y = touchPoint.y;
    handleMoveLogic(touchPoint);
    if (m_pWidgetParent)
    {
        m_pWidgetParent->checkChildInfo(1,this,touchPoint);
    }
    moveEvent();
    if (!hitTest(touchPoint))
    {
        setFocused(false);
        onTouchEnded(touchPoint);
    }
}
Example #20
0
bool UIImageView::onTouchBegan(const CCPoint &touchPoint)
{
    setFocused(true);
    m_touchStartPos.x = touchPoint.x;
    m_touchStartPos.y = touchPoint.y;
    m_pWidgetParent->checkChildInfo(0,this,touchPoint);
    pushDownEvent();
    
    if (m_bDoubleClickEnabled)
    {
        m_fClickTimeInterval = 0;
        m_bStartCheckDoubleClick = true;
        m_nClickCount++;
        m_touchRelease = false;
    }
    return m_bTouchPassedEnabled;
}
Example #21
0
bool UIImageView::onTouchBegan(const cocos2d::Point &touchPoint)
{
    setFocused(true);
    _touchStartPos.x = touchPoint.x;
    _touchStartPos.y = touchPoint.y;
    _widgetParent->checkChildInfo(0,this,touchPoint);
    pushDownEvent();
    
    if (_doubleClickEnabled)
    {
        _clickTimeInterval = 0;
        _startCheckDoubleClick = true;
        _clickCount++;
        _touchRelease = false;
    }
    return _touchPassedEnabled;
}
Example #22
0
void CImageDropTarget::filesDropped (const StringArray& files, int x, int y)
{
  if (files.size () == 1)
  {
    Image image = ImageFileFormat::loadFrom (File (files [0]));

    if (image.isValid ())
    {
      m_image = image;
      repaint ();

      vf::componentNotifyParent (this, &Listener::onImageDropTargetDrop, m_id, image);
    }
  }

  setFocused (false);
}
Example #23
0
void Cell::mousePressEvent(QMouseEvent * e)
{
    setFocused(this);

    if(e->button() == Qt::LeftButton)
	start(RotationToLeft);
    else if(e->button() == Qt::RightButton)
	start(RotationToRight);
    else if(e->button() == Qt::MidButton)
	start(LockUnlock);

#if defined(Q_OS_SYMBIAN)
    if (touchFeedback)
    {
        touchFeedback->InstantFeedback(ETouchFeedbackBasic);
    }
#endif
}
Example #24
0
void UICheckBox::onTouchEnded(const Point &touchPoint)
{
    if (_focus)
    {
        releaseUpEvent();
        if (_isSelected){
            setSelectedState(false);
            unSelectedEvent();
        }
        else
        {
            setSelectedState(true);
            selectedEvent();
        }
    }
    setFocused(false);
    _widgetParent->checkChildInfo(2,this,touchPoint);
}
Example #25
0
void UIWidget::onTouchEnded(const CCPoint &touchPoint)
{
    m_touchEndPos.x = touchPoint.x;
    m_touchEndPos.y = touchPoint.y;
    bool focus = m_bFocus;
    setFocused(false);
    if (m_pWidgetParent)
    {
        m_pWidgetParent->checkChildInfo(2,this,touchPoint);
    }
    if (focus)
    {
        releaseUpEvent();
    }
    else
    {
        cancelUpEvent();
    }
}
Example #26
0
void Widget::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPos = touch->getLocation();
    bool focus = _focus;
    setFocused(false);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(2,this,_touchEndPos);
    }
    if (focus)
    {
        releaseUpEvent();
    }
    else
    {
        cancelUpEvent();
    }
}
Example #27
0
void ContactWidget::setOpen(bool isOpen) {
    _open = isOpen;
    qApp->setStyleSheet(qApp->styleSheet());

    if (isOpen) {
        if (_actionWidget == NULL) {
            _actionWidget = new ContactActionWidget(this, _contact);
            _mainLayout->addWidget(_actionWidget);
        } else {
            if (!_actionWidget->isVisible())
                _actionWidget->show();
        }
    } else {
        if (_actionWidget != NULL) {
            _actionWidget->hide();
        }
    }

    setFocused(true);
}
Example #28
0
void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPos = touch->getLocation();
    if (_focus)
    {
        releaseUpEvent();
        if (_isSelected){
            setSelectedState(false);
            unSelectedEvent();
        }
        else
        {
            setSelectedState(true);
            selectedEvent();
        }
    }
    setFocused(false);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(2,this,_touchEndPos);
    }
}
Example #29
0
ContactWidget::ContactWidget(QWidget *parent, Contact *contact)
    : QFrame(parent)
{
    _contact = contact;

    setFrameStyle(QFrame::NoFrame | QFrame::Plain);
    setCursor(Qt::PointingHandCursor);

    _mainLayout = new QVBoxLayout;
    _mainLayout->setMargin(0);
    _mainLayout->setSpacing(0);
    setLayout(_mainLayout);

    QWidget *statusWidget = new QWidget;
    QGridLayout *statusLayout = new QGridLayout;
    statusLayout->setMargin(0);
    statusLayout->setSpacing(0);
    statusLayout->setColumnStretch(0, 1);
    statusLayout->setColumnStretch(1, 9);
    statusWidget->setLayout(statusLayout);
    _mainLayout->addWidget(statusWidget);

    _nameLabel = new QLabel(contact->name());
    _nameLabel->setObjectName("nameLabel");
    statusLayout->addWidget(_nameLabel, 0, 1, Qt::AlignLeft | Qt::AlignTop);

    QPixmap statusIcon;
    statusIcon.load(":/icons/status/available.png");
    _iconLabel = new QLabel;
    _iconLabel->setPixmap(statusIcon);
    statusLayout->addWidget(_iconLabel, 0, 0, Qt::AlignLeft | Qt::AlignTop);

    _actionWidget = NULL;

    setOpen(false);
    setFocused(false);
}
Example #30
0
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
{
    _hitted = false;
    if (isEnabled() && isTouchEnabled())
    {
        _touchStartPos = touch->getLocation();
        if(hitTest(_touchStartPos) && clippingParentAreaContainPoint(_touchStartPos))
        {
            _hitted = true;
        }
    }
    if (!_hitted)
    {
        return false;
    }
    setFocused(true);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(0,this,_touchStartPos);
    }
    pushDownEvent();
    return !_touchPassedEnabled;
}