コード例 #1
0
void WeatherPlugin::updateButton()
{
    if ((getTime() == 0) || (m_bar == NULL))
        return;
    const char **xpm = xpms[getIcon()];
    if (xpm){
        IconDef icon;
        icon.name = "weather";
        icon.xpm  = xpm;
        Event eIcon(EventAddIcon, &icon);
        eIcon.process();
    }
    QString text = unquoteText(getButtonText());
    QString tip = getTipText();
    text = replace(text);
    tip  = replace(tip);
    Command cmd;
    cmd->id		= CmdWeather;
    cmd->param	= m_bar;
    Event e(EventCommandWidget, cmd);
    CToolButton *btn = (CToolButton*)e.process();
    if (btn == NULL)
        return;
    btn->setTextLabel(text);
    btn->repaint();
    QToolTip::add(btn, tip);
}
コード例 #2
0
void DrawableButton::paintButton (Graphics& g,
                                  bool isMouseOverButton,
                                  bool isButtonDown)
{
    if (style == ImageOnButtonBackground)
    {
        getLookAndFeel().drawButtonBackground (g, *this,
                                               getBackgroundColour(),
                                               isMouseOverButton,
                                               isButtonDown);
    }
    else
    {
        g.fillAll (getBackgroundColour());

        const int textH = (style == ImageAboveTextLabel)
                            ? jmin (16, proportionOfHeight (0.25f))
                            : 0;

        if (textH > 0)
        {
            g.setFont ((float) textH);

            g.setColour (findColour (DrawableButton::textColourId)
                            .withMultipliedAlpha (isEnabled() ? 1.0f : 0.4f));

            g.drawFittedText (getButtonText(),
                              2, getHeight() - textH - 1,
                              getWidth() - 4, textH,
                              Justification::centred, 1);
        }
    }
}
コード例 #3
0
void ToolbarItemComponent::paintButton (Graphics& g, const bool over, const bool down)
{
    if (isBeingUsedAsAButton)
        getLookAndFeel().paintToolbarButtonBackground (g, getWidth(), getHeight(),
                                                       over, down, *this);

    if (toolbarStyle != Toolbar::iconsOnly)
    {
        const int indent = contentArea.getX();
        int y = indent;
        int h = getHeight() - indent * 2;

        if (toolbarStyle == Toolbar::iconsWithText)
        {
            y = contentArea.getBottom() + indent / 2;
            h -= contentArea.getHeight();
        }

        getLookAndFeel().paintToolbarButtonLabel (g, indent, y, getWidth() - indent * 2, h,
                                                  getButtonText(), *this);
    }

    if (! contentArea.isEmpty())
    {
        Graphics::ScopedSaveState ss (g);

        g.reduceClipRegion (contentArea);
        g.setOrigin (contentArea.getX(), contentArea.getY());

        paintButtonArea (g, contentArea.getWidth(), contentArea.getHeight(), over, down);
    }
}
コード例 #4
0
ファイル: ElectrodeButtons.cpp プロジェクト: AGenews/GUI
void ElectrodeButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
{
    if (getToggleState() == true)
        g.setColour(Colours::orange);
    else
        g.setColour(Colours::darkgrey);

    if (isMouseOver)
        g.setColour(Colours::white);

	if (!isEnabled())
		g.setColour(Colours::black);

    g.fillRect(0,0,getWidth(),getHeight());

    // g.setFont(buttonFont);
    g.setColour(Colours::black);

    g.drawRect(0,0,getWidth(),getHeight(),1.0);

	if (!isEnabled())
	{
		g.setColour(Colours::grey);
	}

    if (chan >= 0)
		g.drawText(getButtonText(),0,0,getWidth(),getHeight(),Justification::centred,true);
}
コード例 #5
0
void TabBarButton::clicked (const ModifierKeys& mods)
{
    if (mods.isPopupMenu())
        owner.popupMenuClickOnTab (getIndex(), getButtonText());
    else
        owner.setCurrentTabIndex (getIndex());
}
コード例 #6
0
bool TabBarButton::hitTest (int mx, int my)
{
    const Rectangle<int> area (getActiveArea());

    if (owner.getOrientation() == TabbedButtonBar::TabsAtLeft
         || owner.getOrientation() == TabbedButtonBar::TabsAtRight)
    {
        if (isPositiveAndBelow (mx, getWidth())
             && my >= area.getY() + overlapPixels
             && my < area.getBottom() - overlapPixels)
            return true;
    }
    else
    {
        if (mx >= area.getX() + overlapPixels && mx < area.getRight() - overlapPixels
             && isPositiveAndBelow (my, getHeight()))
            return true;
    }

    Path p;
    getLookAndFeel()
        .createTabButtonShape (p, area.getWidth(), area.getHeight(), getIndex(), getButtonText(), *this,
                               owner.getOrientation(), false, false, getToggleState());

    return p.contains ((float) (mx - area.getX()),
                       (float) (my - area.getY()));
}
コード例 #7
0
bool TabBarButton::hitTest (int mx, int my)
{
    int x, y, w, h;
    getActiveArea (x, y, w, h);

    if (owner->getOrientation() == TabbedButtonBar::TabsAtLeft
         || owner->getOrientation() == TabbedButtonBar::TabsAtRight)
    {
        if (((unsigned int) mx) < (unsigned int) getWidth()
             && my >= y + overlapPixels
             && my < y + h - overlapPixels)
            return true;
    }
    else
    {
        if (mx >= x + overlapPixels && mx < x + w - overlapPixels
             && ((unsigned int) my) < (unsigned int) getHeight())
            return true;
    }

    Path p;
    getLookAndFeel()
        .createTabButtonShape (p, w, h, tabIndex, getButtonText(), *this,
                               owner->getOrientation(),
                               false, false, getToggleState());

    return p.contains ((float) (mx - x),
                       (float) (my - y));
}
コード例 #8
0
void TextButton::changeWidthToFitText (const int newHeight)
{
    if (newHeight >= 0)
        setSize (jmax (1, getWidth()), newHeight);

    setSize (getFont().getStringWidth (getButtonText()) + getHeight(),
             getHeight());
}
コード例 #9
0
void WeatherPlugin::updateButton()
{
    if ((getTime() == 0) || (m_bar == NULL))
        return;
    const char **xpm = xpms[getIcon()];
    if (xpm){
        IconDef icon;
        icon.name = "weather";
        icon.xpm  = xpm;
        Event eIcon(EventAddIcon, &icon);
        eIcon.process();
    }
    QString text = unquoteText(getButtonText());
    QString tip = getTipText();
    QString ftip = getForecastText();
    text = replace(text);
    tip  = replace(tip);
	if (getForecast())
		tip = QString("<table><tr><td>") + tip + "</td><td>";
	unsigned n = (getForecast() + 1) / 2;
	if (n < 3)
		n = getForecast();
	for (m_day = 1; m_day <= getForecast(); m_day++){
		tip += forecastReplace(ftip);
	    const char **xpm = xpms[atol(getDayIcon(m_day))];
		if (xpm){
			string url = "weather";
			url += number(m_day);
			IconDef icon;
			icon.name = url.c_str();
			icon.xpm  = xpm;
			Event eIcon(EventAddIcon, &icon);
			eIcon.process();
		}
		if (--n == 0){
			tip += "</td><td>";
			n = (getForecast() + 1) / 2;
		}
	}
	if (getForecast())
		tip += "</td></tr></table>";
	tip += "<br>\nWeather data provided by weather.com";
	tip += QChar((unsigned short)176);
    Command cmd;
    cmd->id		= CmdWeather;
    cmd->param	= m_bar;
    Event e(EventCommandWidget, cmd);
    CToolButton *btn = (CToolButton*)e.process();
    if (btn == NULL)
        return;
    btn->setTextLabel(text);
    btn->repaint();
    QToolTip::add(btn, tip);
}
コード例 #10
0
void TabBarButton::paintButton (Graphics& g,
                                bool isMouseOverButton,
                                bool isButtonDown)
{
    const Rectangle<int> area (getActiveArea());
    g.setOrigin (area.getX(), area.getY());

    getLookAndFeel()
        .drawTabButton (g, area.getWidth(), area.getHeight(),
                        owner.getTabBackgroundColour (getIndex()),
                        getIndex(), getButtonText(), *this,
                        owner.getOrientation(),
                        isMouseOverButton, isButtonDown,
                        getToggleState());
}
コード例 #11
0
void WeatherPlugin::updateButton()
{
    if ((getTime() == 0) || (m_bar == NULL))
        return;
    weather_icon = "weather";
    weather_icon += number(getIcon());
    Command cmd;
    cmd->id      = CmdWeather;
    cmd->text    = I18N_NOOP("Not connected");
    cmd->icon    = weather_icon.c_str();
    cmd->bar_id  = BarWeather;
    cmd->bar_grp = 0x1000;
    cmd->flags   = BTN_PICT | BTN_DIV;
    Event eCmd(EventCommandChange, cmd);
    eCmd.process();

    QString text = unquoteText(getButtonText());
    QString tip = getTipText();
    QString ftip = getForecastText();
    text = replace(text);
    tip  = replace(tip);
    if (getForecast())
        tip = QString("<table><tr><td>") + tip + "</td><td>";
    unsigned n = (getForecast() + 1) / 2;
    if (n < 3)
        n = getForecast();
    for (m_day = 1; m_day <= getForecast(); m_day++){
        tip += forecastReplace(ftip);
        if (--n == 0){
            tip += "</td><td>";
            n = (getForecast() + 1) / 2;
        }
    }
    if (getForecast())
        tip += "</td></tr></table>";
    tip += "<br>\nWeather data provided by weather.com";
    tip += QChar((unsigned short)174);
    Command cmdw;
    cmdw->id	= CmdWeather;
    cmdw->param	= m_bar;
    Event e(EventCommandWidget, cmdw);
    CToolButton *btn = (CToolButton*)e.process();
    if (btn == NULL)
        return;
    btn->setTextLabel(text);
    btn->repaint();
    QToolTip::add(btn, tip);
}
コード例 #12
0
void TabBarButton::paintButton (Graphics& g,
                                bool isMouseOverButton,
                                bool isButtonDown)
{
    int x, y, w, h;
    getActiveArea (x, y, w, h);

    g.setOrigin (x, y);

    getLookAndFeel()
        .drawTabButton (g, w, h,
                        owner->getTabBackgroundColour (tabIndex),
                        tabIndex, getButtonText(), *this,
                        owner->getOrientation(),
                        isMouseOverButton, isButtonDown,
                        getToggleState());
}
コード例 #13
0
void WeatherPlugin::updateButton()
{
    if ((getTime() == 0) || (m_bar == NULL))
        return;
    const char **xpm = NULL;
    QString conditions(getConditions());
    if (conditions == "Overcast"){
        xpm = overcast;
    }else if (conditions == "Fog"){
        xpm = fog;
    }else if (conditions == "Storm"){
        xpm = storm;
    }else if (conditions == "Rain"){
        xpm = rain;
    }else if (conditions == "Snow"){
        xpm = snow;
    }else if (conditions == "Cloudy"){
        xpm = snow;
    }else if (conditions == "Clear"){
        xpm = isDay() ? day : night;
    }else if (conditions == "Partial cloudy"){
        xpm = isDay() ? day_cloudy : night_cloudy;
    }
    if (xpm){
        IconDef icon;
        icon.name = "weather";
        icon.xpm  = xpm;
        Event eIcon(EventAddIcon, &icon);
        eIcon.process();
    }
    QString text = unquoteText(getButtonText());
    QString tip = getTipText();
    text = replace(text);
    tip  = replace(tip);
    Command cmd;
    cmd->id		= CmdWeather;
    cmd->param	= m_bar;
    Event e(EventCommandWidget, cmd);
    CToolButton *btn = (CToolButton*)e.process();
    if (btn == NULL)
        return;
    btn->setTextLabel(text);
    btn->repaint();
    QToolTip::add(btn, tip);
}
コード例 #14
0
ファイル: juce_HyperlinkButton.cpp プロジェクト: AGenews/GUI
void HyperlinkButton::paintButton (Graphics& g,
                                   bool isMouseOverButton,
                                   bool isButtonDown)
{
    const Colour textColour (findColour (textColourId));

    if (isEnabled())
        g.setColour ((isMouseOverButton) ? textColour.darker ((isButtonDown) ? 1.3f : 0.4f)
                                         : textColour);
    else
        g.setColour (textColour.withMultipliedAlpha (0.4f));

    g.setFont (getFontToUse());

    g.drawText (getButtonText(), getLocalBounds().reduced (1, 0),
                justification.getOnlyHorizontalFlags() | Justification::verticallyCentred,
                true);
}
コード例 #15
0
void SharedMediaWidget::refreshButton(MediaOverviewType type) {
	int count = _history->overviewCount(type), migrated = _migrated ? _migrated->overviewCount(type) : 0;
	int finalCount = (count >= 0 && migrated >= 0) ? (count + migrated) : -1;
	auto text = getButtonText(type, finalCount);
	if (text.isEmpty()) {
		if (_mediaButtons[type]) {
			delete _mediaButtons[type];
			_mediaButtons[type] = nullptr;
		}
	} else {
		if (_mediaButtons[type]) {
			_mediaButtons[type]->setText(text);
		} else {
			_mediaButtons[type] = new Ui::LeftOutlineButton(this, text, st::defaultLeftOutlineButton);
			_mediaButtons[type]->show();
			connect(_mediaButtons[type], SIGNAL(clicked()), this, SLOT(onMediaChosen()));
		}
	}
}
コード例 #16
0
void WebDB::setButtonText(uint _id, char *text)
{
	if (_id < getDBButtonMaxRecords())
	{
		recordButton = &m_button;
		getButtonText(_id);
		contador = 0;
		for (unsigned i = 0; i < TEXT_MAX; i++) recordButton->text[i] = 0;
		for (unsigned i = 0; i < TEXT_MAX; i++) {
			recordButton->text[i] = text[i];
			if (text[i] <= 0) break;
		}
		for( int j = getDBButtonStart() + (sizeof(DBButtonRecord) * _id);
			j < getDBButtonStart() + ((sizeof(DBButtonRecord) * _id) + sizeof(DBButtonRecord)); j++)
		{
			EEPROM.write(j, ((uchar*)recordButton)[contador]);
			contador++;
		}
	}
}
コード例 #17
0
void CtrlrCustomButtonInternal::drawTextBoxText(Graphics &g, const Rectangle<int> &frameRect, const Rectangle<int> &totalAreaToDraw)
{
	RectangleList<int> list;
	list.add (totalAreaToDraw);
	list.subtract (frameRect);
	Rectangle<int> destination = list.getBounds();

	const int destinationWidth = (int)owner.getProperty(::Ids::uiImageButtonTextWidth)  ? (int)owner.getProperty(::Ids::uiImageButtonTextWidth)  : destination.getWidth();
	const int destinatioHeight = (int)owner.getProperty(::Ids::uiImageButtonTextHeight) ? (int)owner.getProperty(::Ids::uiImageButtonTextHeight) : destination.getHeight();

	destination.setSize (destinationWidth, destinatioHeight);

	g.setColour (VAR2COLOUR(owner.getProperty(::Ids::uiImageButtonTextColour)));
	g.setFont (owner.getOwner().getOwnerPanel().getCtrlrManagerOwner().getFontManager().getFontFromString(owner.getProperty(::Ids::uiButtonTextFont)));

	g.drawFittedText (getButtonText(),
							destination.getX(),
							destination.getY(),
							destination.getWidth(),
							destination.getHeight(),
							justificationFromProperty (owner.getProperty(::Ids::uiButtonTextJustification)),
							2);
}
コード例 #18
0
void WebDB::deleteButton(uint _id)
{
	if (_id < getDBButtonMaxRecords())
	{
		recordButton = &m_button;
		getButtonText(_id);

		recordButton->id = -1;
		recordButton->type = -1;
		recordButton->state = false;
		for (unsigned i = 0; i < TEXT_MAX; i++) recordButton->text[i] = 0;
		recordButton->step = -1;
		recordButton->value = 0;

		contador = 0;
		for( int j = getDBButtonStart() + (sizeof(DBButtonRecord) * _id);
			j < getDBButtonStart() + ((sizeof(DBButtonRecord) * _id) + sizeof(DBButtonRecord)); j++)
		{
			EEPROM.write(j, ((uchar*)recordButton)[contador]);
			contador++;
		}
	}
}
コード例 #19
0
ファイル: juce_HyperlinkButton.cpp プロジェクト: 0x4d52/JUCE
void HyperlinkButton::changeWidthToFitText()
{
    setSize (getFontToUse().getStringWidth (getButtonText()) + 6, getHeight());
}
コード例 #20
0
int TabBarButton::getBestTabLength (const int depth)
{
    return jlimit (depth * 2,
                   depth * 7,
                   getLookAndFeel().getTabButtonBestWidth (getIndex(), getButtonText(), depth, *this));
}
コード例 #21
0
void DrawableButton::paintButton (Graphics& g,
                                  bool isMouseOverButton,
                                  bool isButtonDown)
{
    Rectangle imageSpace;

    if (style == ImageOnButtonBackground)
    {
        const int insetX = getWidth() / 4;
        const int insetY = getHeight() / 4;

        imageSpace.setBounds (insetX, insetY, getWidth() - insetX * 2, getHeight() - insetY * 2);

        getLookAndFeel().drawButtonBackground (g, *this,
                                               getBackgroundColour(),
                                               isMouseOverButton,
                                               isButtonDown);
    }
    else
    {
        g.fillAll (getBackgroundColour());

        const int textH = (style == ImageAboveTextLabel)
                            ? jmin (16, proportionOfHeight (0.25f))
                            : 0;

        const int indentX = jmin (edgeIndent, proportionOfWidth (0.3f));
        const int indentY = jmin (edgeIndent, proportionOfHeight (0.3f));

        imageSpace.setBounds (indentX, indentY,
                              getWidth() - indentX * 2,
                              getHeight() - indentY * 2 - textH);

        if (textH > 0)
        {
            g.setFont ((float) textH);

            g.setColour (Colours::black.withAlpha (isEnabled() ? 1.0f : 0.4f));
            g.drawFittedText (getButtonText(),
                              2, getHeight() - textH - 1,
                              getWidth() - 4, textH,
                              Justification::centred, 1);
        }
    }

    g.setImageResamplingQuality (Graphics::mediumResamplingQuality);
    g.setOpacity (1.0f);

    const Drawable* imageToDraw = 0;

    if (isEnabled())
    {
        imageToDraw = getCurrentImage();
    }
    else
    {
        imageToDraw = getToggleState() ? disabledImageOn
                                       : disabledImage;

        if (imageToDraw == 0)
        {
            g.setOpacity (0.4f);
            imageToDraw = getNormalImage();
        }
    }

    if (imageToDraw != 0)
    {
        if (style == ImageRaw)
        {
            imageToDraw->draw (g, 1.0f);
        }
        else
        {
            imageToDraw->drawWithin (g,
                                     imageSpace.getX(),
                                     imageSpace.getY(),
                                     imageSpace.getWidth(),
                                     imageSpace.getHeight(),
                                     RectanglePlacement::centred,
                                     1.0f);
        }
    }
}
コード例 #22
0
void ButtonPropertyComponent::refresh()
{
    button.setButtonText (getButtonText());
}