Пример #1
0
bool CCControl::init()
{
    if (CCNode::init())
    {
        //this->setTouchEnabled(true);
        //m_bIsTouchEnabled=true;
        // Initialise instance variables
        m_eState=CCControlStateNormal;
        setCascadeOpacityEnabled(true);
        setCascadeColorEnabled(true);
        setEnabled(true);
        setSelected(false);
        setHighlighted(false);

        // Initialise the tables
        m_pDispatchTable = new CCDictionary(); 
        // Initialise the mapHandleOfControlEvents
        m_mapHandleOfControlEvent.clear();
        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #2
0
bool Control::init()
{
    if (Layer::init())
    {
        // Initialise instance variables
        _state=Control::State::NORMAL;
        setEnabled(true);
        setSelected(false);
        setHighlighted(false);

        // x-studio365 spec
        setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
        setTouchEnabled(true);

        /*auto dispatcher = Director::getInstance()->getEventDispatcher();
        auto touchListener = EventListenerTouchOneByOne::create();
        touchListener->setSwallowTouches(true);
        touchListener->onTouchBegan = CC_CALLBACK_2(Control::onTouchBegan, this);
        touchListener->onTouchMoved = CC_CALLBACK_2(Control::onTouchMoved, this);
        touchListener->onTouchEnded = CC_CALLBACK_2(Control::onTouchEnded, this);
        touchListener->onTouchCancelled = CC_CALLBACK_2(Control::onTouchCancelled, this);
        
        dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);*/
        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #3
0
void BoardTable::sortEvent(int c)
{
    //qDebug()<<c;
    //return;d
    if (Global::alreadyJudging) return;
    
    if (preHeaderClicked!=c)
    {
        clearHighlighted(preHeaderClicked);
        setHighlighted(c);
    }
    
    this->horizontalHeader()->setSortIndicatorShown(true);
    if (preHeaderClicked!=c&&c) this->horizontalHeader()->setSortIndicator(c,Qt::DescendingOrder);
    Global::preSortOrder=this->horizontalHeader()->sortIndicatorOrder();
    
    if (!c) sortByName();
    else if (c==1) sortBySumScore();
    else sortByProblem(c-2);
    
    int k=0;
    for (auto&i:Global::players)
    {
        this->item(i.id,c)->setData(Qt::DisplayRole,k);
        i.id=Global::logicalRow(k);//
        k++;
    }
    this->sortByColumn(c);
    this->verticalScrollBar()->setValue(0);
  //  for (int i=0; i<playerNum; i++) qDebug()<<ui->tableWidget->item(i,c)->data(Qt::DisplayRole);
    
    preHeaderClicked=c;
}
Пример #4
0
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
{
    _hitted = false;
    if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) )
    {
        _touchBeganPosition = touch->getLocation();
        auto camera = Camera::getVisitingCamera();
        if(hitTest(_touchBeganPosition, camera, nullptr))
        {
            _hittedByCamera = camera;
            if (isClippingParentContainsPoint(_touchBeganPosition)) {
                _hitted = true;
            }
        }
    }
    if (!_hitted)
    {
        return false;
    }
    setHighlighted(true);

    /*
     * Propagate touch events to its parents
     */
    if (_propagateTouchEvents)
    {
        this->propagateTouchEvent(TouchEventType::BEGAN, this, touch);
    }

    pushDownEvent();
    return true;
}
Пример #5
0
	bool HudItemButton::onInput(const InputEvent &event) {
		bool is_mouse_over = isMouseOver(event);
		if(event.isMouseOverEvent()) {
			setHighlighted(is_mouse_over);
			if(is_mouse_over && isVisible())
				handleEvent(this, HudEvent::item_focused);


		}
		if(event.mouseButtonDown(InputButton::left) && is_mouse_over)
			handleEvent(this, isEnabled()? HudEvent::item_unequip : HudEvent::item_equip);

		if(event.mouseButtonDown(InputButton::right) && is_mouse_over) {
			if(isEnabled()) {
				handleEvent(this, HudEvent::item_unequip);
			}
			else {
				m_drop_count = 1.0;
				m_drop_start_pos = (float2)event.mousePos();
			}
		}

		if(event.mouseButtonPressed(InputButton::right) && isDropping())
			m_drop_diff = (event.mousePos().y - m_drop_start_pos.y) / 20.0f;
		if(event.mouseButtonUp(InputButton::right) && isDropping()) {
			if(dropCount() > 0)
				handleEvent(this, HudEvent::item_drop, dropCount());
			m_drop_count = -1.0f;
		}

		return false;
	}
Пример #6
0
bool Control::init()
{
    if (Layer::init())
    {
        // Initialise instance variables
        m_eState=Control::State::NORMAL;
        setEnabled(true);
        setSelected(false);
        setHighlighted(false);

        // Initialise the tables
        m_pDispatchTable = new Dictionary();
        m_pDispatchTable->init();
        
        auto dispatcher = Director::getInstance()->getEventDispatcher();
        auto touchListener = EventListenerTouchOneByOne::create();
        touchListener->onTouchBegan = CC_CALLBACK_2(Control::onTouchBegan, this);
        touchListener->onTouchMoved = CC_CALLBACK_2(Control::onTouchMoved, this);
        touchListener->onTouchEnded = CC_CALLBACK_2(Control::onTouchEnded, this);
        touchListener->onTouchCancelled = CC_CALLBACK_2(Control::onTouchCancelled, this);
        
        dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #7
0
void MainWindow::handleCookieAdded(const QNetworkCookie &cookie)
{
    // only new cookies
    if (containsCookie(cookie))
        return;

    CookieWidget *widget = new CookieWidget(cookie);
    widget->setHighlighted(m_cookies.count() % 2);
    m_cookies.append(cookie);
    m_layout->insertWidget(0,widget);

    connect(widget, &CookieWidget::deleteClicked, [this, cookie, widget]() {
        m_store->deleteCookie(cookie);
        delete widget;
        m_cookies.removeOne(cookie);
        for (int i = 0; i < m_layout->count() - 1; i++) {
            // fix background colors
            auto widget = qobject_cast<CookieWidget*>(m_layout->itemAt(i)->widget());
            widget->setHighlighted(i % 2);
        }
    });

    connect(widget, &CookieWidget::viewClicked, [cookie]() {
        CookieDialog dialog(cookie);
        dialog.exec();
    });
}
Пример #8
0
bool CCControl::init()
{
    if (CCLayer::init())
    {
        //this->setTouchEnabled(true);
        //m_bIsTouchEnabled=true;
        // Initialise instance variables
        m_eState=CCControlStateNormal;
        setEnabled(true);
        setSelected(false);
        setHighlighted(false);

        // Set the touch dispatcher priority by default to 1
        setDefaultTouchPriority(1);
        this->setDefaultTouchPriority(m_nDefaultTouchPriority);
        // Initialise the tables
        m_pDispatchTable = new CCDictionary(); 

        return true;
    }
    else
    {
        return false;
    }
}
Пример #9
0
bool Control::init()
{
    if (Layer::init())
    {
        //this->setTouchEnabled(true);
        //_isTouchEnabled=true;
        // Initialise instance variables
        _state=Control::State::NORMAL;
        setEnabled(true);
        setSelected(false);
        setHighlighted(false);

        // Set the touch dispatcher priority by default to 1
        this->setTouchPriority(1);
        // Initialise the tables
        _dispatchTable = new Dictionary();
        _dispatchTable->init();
        
        return true;
    }
    else
    {
        return false;
    }
}
Пример #10
0
 void clearHighlighting() {
     ensureInitialized();
     for (int row = 0; row < gState.rowCount; row++) {
         for (int col = 0; col < gState.columnCount; col++) {
             setHighlighted(row, col, false);
         }
     }
 }
Пример #11
0
void ButtonWrap::onTouchEnded(Touch* touch, Event* event)
{
	bool highLight = _isHighLight;
 	setHighlighted(false);
	if (highLight && !_touchDown)
	{
		onConfirmHandle();
	}
}
Пример #12
0
void SessionChildItem::receiveMessage(IrcMessage* message)
{
    AbstractSessionItem::receiveMessage(message);
    if (message->type() == IrcMessage::Private)
    {
        IrcPrivateMessage* privMsg = static_cast<IrcPrivateMessage*>(message);

        QString alertText;
        if (isChannel())
        {
            if (privMsg->message().contains(m_parent->session()->nickName(), Qt::CaseInsensitive))
            {
                setHighlighted(true);
                if (!isCurrent())
                    alertText = tr("%1 on %2:\n%3").arg(privMsg->sender().name()).arg(title()).arg(privMsg->message());
            }
        }
        else
        {
            setHighlighted(true);
            if (!isCurrent())
                alertText = tr("%1 in private:\n%2").arg(privMsg->sender().name()).arg(privMsg->message());
        }

        if (!alertText.isEmpty())
        {
            setAlertText(alertText);
            emit alert(this);
        }

        if (!isCurrent())
            setUnreadCount(unreadCount() + 1);
    }
    else if (message->type() == IrcMessage::Numeric)
    {
        IrcNumericMessage* numMsg = static_cast<IrcNumericMessage*>(message);
        if (isChannel() && numMsg->code() == Irc::RPL_TOPIC)
            setSubtitle(numMsg->parameters().value(2));
        else if (!isChannel() && numMsg->code() == Irc::RPL_WHOISUSER)
            setSubtitle(numMsg->parameters().value(5));
    }
}
Пример #13
0
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent)
{
    _touchMovePosition = touch->getLocation();
    setHighlighted(hitTest(_touchMovePosition));
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->interceptTouchEvent(TouchEventType::MOVED, this, touch);
    }
    moveEvent();
}
Пример #14
0
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent)
{
    _touchMovePos = touch->getLocation();
    setHighlighted(hitTest(_touchMovePos));
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(1,this,_touchMovePos);
    }
    moveEvent();
}
Пример #15
0
void AnchorHandleItem::setHandlePath(const AnchorHandlePathData  &pathData)
{
    m_beginArrowPoint = pathData.beginArrowPoint;
    m_endArrowPoint = pathData.endArrowPoint;
    m_arrowPathItem->setPath(pathData.arrowPath);
    m_sourceAnchorLinePathItem->setPath(pathData.sourceAnchorLinePath);
    m_targetAnchorLinePathItem->setPath(pathData.targetAnchorLinePath);
    m_targetNamePathItem->setPath(pathData.targetNamePath);

    setHighlighted(false);
}
Пример #16
0
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent)
{
    _touchMovePosition = touch->getLocation();

    setHighlighted(hitTest(_touchMovePosition, _hittedByCamera, nullptr));

    /*
     * Propagate touch events to its parents
     */
    if (_propagateTouchEvents)
    {
        this->propagateTouchEvent(TouchEventType::MOVED, this, touch);
    }

    moveEvent();
}
Пример #17
0
void RUser::assignIcon() {
    struct stat fileinfo;

    usercol = colourHash(name);

    bool image_assigned = false;

    if(gGourceSettings.user_image_dir.size() > 0) {

        //try thier username
        // TODO: replace with map of name -> image of all pngs and jpgs in directory
        //gGourceSettings.user_image_dir + name + std::string(".jpg");

        std::map<std::string, std::string>::iterator findimage;

        findimage = gGourceSettings.user_image_map.find(name);

        //do we have this image
        if(findimage != gGourceSettings.user_image_map.end()) {
            std::string imagefile = findimage->second;

            if(!gGourceSettings.colour_user_images) usercol = vec3f(1.0, 1.0, 1.0);

            icon = texturemanager.grabFile(imagefile);

            setHighlighted(true);

            image_assigned = true;
        }
    }

    //nope
    if(!image_assigned) {
        if(gGourceSettings.default_user_image.size() > 0) {
            if(!gGourceSettings.colour_user_images) usercol = vec3f(1.0, 1.0, 1.0);
            icon = texturemanager.grabFile(gGourceSettings.default_user_image);
        } else {
            icon = texturemanager.grab("no_photo.png");
        }
    }

    usercol = usercol * 0.6 + vec3f(1.0, 1.0, 1.0) * 0.4;
    usercol *= 0.9;
}
Пример #18
0
void Widget::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPos = touch->getLocation();
    bool highlight = _highlight;
    setHighlighted(false);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(2,this,_touchEndPos);
    }
    if (highlight)
    {
        releaseUpEvent();
    }
    else
    {
        cancelUpEvent();
    }
}
Пример #19
0
    void labelCube(int row, int col, char letter, bool highlighted) {
        ensureInitialized();
        if (row < 0 || row >= gState.rowCount || col < 0 || col >= gState.columnCount) {
            error(string("labelCube called with invalid row, col arguments.  Must be between (0, 0) and (")
                  + integerToString(gState.rowCount) + ", " + integerToString(gState.columnCount) + ")");
        }
        if (!isalpha(letter) && letter != ' ') {
            error(string("labelCube called with non-alphabetic character: '") + letter);
        }

        setHighlighted(row, col, highlighted);

        GLabel* label = letterCubes[row][col].label;
        label->setLabel(string(1, letter));
        if (isalpha(letter)) {
            label->setLocation(
                    letterCubes[row][col].rect->getX() + gState.cubeSize/2 - 0.45 * label->getWidth(),
                    letterCubes[row][col].rect->getY() + gState.cubeSize/2 + 0.36 * gState.fontSize);
        }
    }
ChatLine::ChatLine(int row, QAbstractItemModel *model, const qreal &width, const qreal &firstWidth, const qreal &secondWidth, const qreal &thirdWidth, const QPointF &secondPos, const QPointF &thirdPos, QGraphicsItem *parent) :
    QGraphicsItem(parent),
    _row(row), // needs to be set before the items
    _model(model),
    _contentsItem(secondPos, secondWidth, this),
    _senderItem(QRectF(0, 0, firstWidth, _contentsItem.height()), this),
    _timestampItem(QRectF(thirdPos, QSizeF(thirdWidth, _contentsItem.height())), this),
    _width(width),
    _height(_contentsItem.height()),
    _selection(0),
    _mouseGrabberItem(0),
    _hoverItem(0)
{
    Q_ASSERT(model);
    setZValue(0);
    setAcceptHoverEvents(true);

    QModelIndex index = model->index(row, MessageModel::ContentsColumn);
    setHighlighted(index.data(MessageModel::FlagsRole).toInt() & Message::Highlight);
}
Пример #21
0
void Widget::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPosition = touch->getLocation();
    
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->interceptTouchEvent(TouchEventType::ENDED, this, touch);
    }
    
    bool highlight = _highlight;
    setHighlighted(false);
    
    if (highlight)
    {
        releaseUpEvent();
    }
    else
    {
        cancelUpEvent();
    }
}
Пример #22
0
void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPos = touch->getLocation();
    if (_highlight)
    {
        releaseUpEvent();
        if (_isSelected){
            setSelectedState(false);
            unSelectedEvent();
        }
        else
        {
            setSelectedState(true);
            selectedEvent();
        }
    }
    setHighlighted(false);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(2,this,_touchEndPos);
    }
}
Пример #23
0
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
{
    _hitted = false;
    if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) )
    {
        _touchBeganPosition = touch->getLocation();
        if(hitTest(_touchBeganPosition) && isClippingParentContainsPoint(_touchBeganPosition))
        {
            _hitted = true;
        }
    }
    if (!_hitted)
    {
        return false;
    }
    setHighlighted(true);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->interceptTouchEvent(TouchEventType::BEGAN, this, touch);
    }
    pushDownEvent();
    return true;
}
Пример #24
0
bool ButtonWrap::onTouchBegan(Touch* touch, Event* event)
{
	bool hitted = false;
	if (this->isVisible() && _btnEnable)
	{
		_touchPosition = touch->getLocation();
		if (hitTest(_touchPosition))
		{
			hitted = true;
		}
	}
	if (!hitted)
	{
		return false;
	}
	setHighlighted(true);

	if (_touchDown)
	{
		onConfirmHandle();
	}

	return true;
}
Пример #25
0
void Widget::onTouchEnded(Touch *touch, Event *unusedEvent)
{
    _touchEndPosition = touch->getLocation();

    /*
     * Propagate touch events to its parents
     */
    if (_propagateTouchEvents)
    {
        this->propagateTouchEvent(TouchEventType::ENDED, this, touch);
    }

    bool highlight = _highlight;
    setHighlighted(false);

    if (highlight)
    {
        releaseUpEvent();
    }
    else
    {
        cancelUpEvent();
    }
}
Пример #26
0
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent)
{
    _hitted = false;
    if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) )
    {
        _touchStartPos = touch->getLocation();
        if(hitTest(_touchStartPos) && clippingParentAreaContainPoint(_touchStartPos))
        {
            _hitted = true;
        }
    }
    if (!_hitted)
    {
        return false;
    }
    setHighlighted(true);
    Widget* widgetParent = getWidgetParent();
    if (widgetParent)
    {
        widgetParent->checkChildInfo(0,this,_touchStartPos);
    }
    pushDownEvent();
    return true;
}
Пример #27
0
void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
{
    // Trim whitespace
    trim(line);

    if (line.empty())
        return;

    CHATLOG tmp;
    tmp.own = own;
    tmp.nick = "";
    tmp.text = line;

    std::string::size_type pos = line.find(" : ");
    if (pos != std::string::npos)
    {
        tmp.nick = line.substr(0, pos);
        tmp.text = line.substr(pos + 3);
    }
    else
    {
        // Fix the owner of welcome message.
        if (line.substr(0, 7) == "Welcome")
        {
            own = BY_SERVER;
        }
    }

    // *implements actions in a backwards compatible way*
    if ((own == BY_PLAYER || own == BY_OTHER) &&
        tmp.text.at(0) == '*' &&
        tmp.text.at(tmp.text.length()-1) == '*')
    {
        tmp.text[0] = ' ';
        tmp.text.erase(tmp.text.length() - 1);
        own = ACT_IS;
    }

    std::string lineColor = "##C";
    switch (own)
    {
        case BY_GM:
            if (tmp.nick.empty())
            {
                tmp.nick = std::string(_("Global announcement:"));
                tmp.nick += " ";
                lineColor = "##G";
            }
            else
            {
                tmp.nick = strprintf(_("Global announcement from %s:"),
                                     tmp.nick.c_str());
                tmp.nick += " ";
                lineColor = "##1"; // Equiv. to BrowserBox::RED
            }
            break;
        case BY_PLAYER:
            tmp.nick += ": ";
            lineColor = "##Y";
            break;
        case BY_OTHER:
            tmp.nick += ": ";
            lineColor = "##C";
            break;
        case BY_SERVER:
            tmp.nick = _("Server:");
            tmp.nick += " ";
            tmp.text = line;
            lineColor = "##S";
            break;
        case BY_CHANNEL:
            tmp.nick = "";
            // TODO: Use a predefined color
            lineColor = "##2"; // Equiv. to BrowserBox::GREEN
            break;
        case ACT_WHISPER:
            tmp.nick = strprintf(_("%s whispers: "), tmp.nick.c_str());
            lineColor = "##W";
            break;
        case ACT_IS:
            lineColor = "##I";
            break;
        case BY_LOGGER:
            tmp.nick = "";
            tmp.text = line;
            lineColor = "##L";
            break;
    }

    if (tmp.nick == ": ")
    {
        tmp.nick = "";
        lineColor = "##S";
    }

    // Get the current system time
    time_t t;
    time(&t);

    // Format the time string properly
    std::stringstream timeStr;
    timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
        << (int) (((t / 60) / 60) % 24)
        << ":" << (((t / 60) % 60 < 10) ? "0" : "")
        << (int) ((t / 60) % 60)
        << "] ";

    line = lineColor + timeStr.str() + tmp.nick + tmp.text;

    // We look if the Vertical Scroll Bar is set at the max before
    // adding a row, otherwise the max will always be a row higher
    // at comparison.
    if (mScrollArea->getVerticalScrollAmount() >= mScrollArea->getVerticalMaxScroll())
    {
        mTextOutput->addRow(line);
        mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
    }
    else
    {
        mTextOutput->addRow(line);
    }

    mScrollArea->logic();
    chatWindow->mRecorder->record(line.substr(3));
    if (this != getTabbedArea()->getSelectedTab() &&
        own != BY_PLAYER)
        setHighlighted(true);
}
Пример #28
0
GcScopeBar::GcScopeBar(Context *context) : QWidget(context->mainWindow), context(context)
{

    setFixedHeight(23);
    setContentsMargins(10,0,10,0);
    layout = new QHBoxLayout(this);
    layout->setSpacing(2);
    layout->setContentsMargins(0,0,0,0);

    searchLabel = new GcLabel(tr("Search/Filter:"));
    searchLabel->setYOff(1);
    searchLabel->setFixedHeight(20);
    searchLabel->setHighlighted(true);
    QFont font;

    font.setPointSize(10);
    font.setWeight(QFont::Black);
    searchLabel->setFont(font);
    layout->addWidget(searchLabel);
    searchLabel->hide();

#ifdef GC_HAVE_LUCENE
    connect(context, SIGNAL(filterChanged()), this, SLOT(setHighlighted()));
#endif
    connect(context, SIGNAL(compareIntervalsStateChanged(bool)), this, SLOT(setCompare()));
    connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(setCompare()));

    // Mac uses QtMacButton - recessed etc
#ifdef Q_OS_MAC
    home = new QtMacButton(this, QtMacButton::Recessed);
#ifdef GC_HAVE_ICAL
    diary = new QtMacButton(this, QtMacButton::Recessed);
#endif
    anal = new QtMacButton(this, QtMacButton::Recessed);
#ifdef GC_HAVE_INTERVALS
    interval = new QtMacButton(this, QtMacButton::Recessed);
#endif
    train = new QtMacButton(this, QtMacButton::Recessed);
#else
    // Windows / Linux uses GcScopeButton - pushbutton
    home = new GcScopeButton(this);
#ifdef GC_HAVE_ICAL
    diary = new GcScopeButton(this);
#endif
    anal = new GcScopeButton(this);
#ifdef GC_HAVE_INTERVALS
    interval = new GcScopeButton(this);
#endif
    train = new GcScopeButton(this);
#endif

    // now set the text for each one
    home->setText(tr("Trends"));
    layout->addWidget(home);
    connect(home, SIGNAL(clicked(bool)), this, SLOT(clickedHome()));

#ifdef GC_HAVE_ICAL
    diary->setText(tr("Diary"));
    layout->addWidget(diary);
    connect(diary, SIGNAL(clicked(bool)), this, SLOT(clickedDiary()));
#endif

    anal->setText(tr("Rides"));
    anal->setWidth(70);
    anal->setChecked(true);
    layout->addWidget(anal);
    connect(anal, SIGNAL(clicked(bool)), this, SLOT(clickedAnal()));

#ifdef GC_HAVE_INTERVALS
    interval->setText(tr("Intervals"));
    interval->setWidth(70);
    layout->addWidget(interval);
    connect(interval, SIGNAL(clicked(bool)), this, SLOT(clickedInterval()));
#endif

    train->setText(tr("Train"));
    layout->addWidget(train);
    connect(train, SIGNAL(clicked(bool)), this, SLOT(clickedTrain()));

    //layout->addWidget(traintool); //XXX!!! eek

    // we now need to adjust the buttons according to their text size
    // this is particularly bad for German's who, as a nation, must
    // suffer from RSI from typing and writing more than any other nation ;)
    QFontMetrics fontMetric(font);
    int width = fontMetric.width(tr("Trends"));
    home->setWidth(width+20);

    width = fontMetric.width(tr("Rides"));
    anal->setWidth(width+20);

    width = fontMetric.width(tr("Train"));
    train->setWidth(width+20);

#ifdef GC_HAVE_ICAL
    width = fontMetric.width(tr("Diary"));
    diary->setWidth(width+20);
#endif
}
Пример #29
0
bool ark_SwallowButton::init()
{
	if (Layer::init())
	{
		// Initialise instance variables
		_state=Control::State::NORMAL;
		setEnabled(true);
		setSelected(false);
		setHighlighted(false);

		auto dispatcher = Director::getInstance()->getEventDispatcher();
		auto touchListener = EventListenerTouchOneByOne::create();
		touchListener->setSwallowTouches(true);

		touchListener->onTouchBegan = CC_CALLBACK_2(Control::onTouchBegan, this);
		touchListener->onTouchMoved = CC_CALLBACK_2(Control::onTouchMoved, this);
		touchListener->onTouchEnded = CC_CALLBACK_2(Control::onTouchEnded, this);
		touchListener->onTouchCancelled = CC_CALLBACK_2(Control::onTouchCancelled, this);

		dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);

		Scale9Sprite * backgroundSprite = Scale9Sprite::create();
		Label *node = Label::createWithSystemFont("", "Helvetica", 12);
		CCASSERT(node != nullptr, "Label must not be nil.");
		LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
		CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil.");
		CCASSERT(label != nullptr || backgroundSprite != nullptr, "");

		_parentInited = true;

		_isPushed = false;

		// Adjust the background image by default
		setAdjustBackgroundImage(true);
		setPreferredSize(Size::ZERO);
		// Zooming button by default
		_zoomOnTouchDown = true;
		_scaleRatio = 1.1f;

		// Set the default anchor point
		ignoreAnchorPointForPosition(false);
		setAnchorPoint(Point(0.5f, 0.5f));

		// Set the nodes
		setTitleLabel(node);
		setBackgroundSprite(backgroundSprite);

		// Set the default color and opacity
		setColor(Color3B(255.0f, 255.0f, 255.0f));
		setOpacity(255.0f);
		setOpacityModifyRGB(true);

		// Initialize the dispatch table

		setTitleForState(label->getString(), Control::State::NORMAL);
		setTitleColorForState(node->getColor(), Control::State::NORMAL);
		setTitleLabelForState(node, Control::State::NORMAL);
		setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);

		setLabelAnchorPoint(Point(0.5f, 0.5f));

		// Layout update
		needsLayout();

		return true;
	}
	else
	{
		return false;
	}
}
Пример #30
0
void Widget::onTouchCancelled(Touch *touch, Event *unusedEvent)
{
    setHighlighted(false);
    cancelUpEvent();
}