当前位置: 首页>>代码示例>>C++>>正文


C++ ToggleButton::getToggleState方法代码示例

本文整理汇总了C++中ToggleButton::getToggleState方法的典型用法代码示例。如果您正苦于以下问题:C++ ToggleButton::getToggleState方法的具体用法?C++ ToggleButton::getToggleState怎么用?C++ ToggleButton::getToggleState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ToggleButton的用法示例。


在下文中一共展示了ToggleButton::getToggleState方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawToggleButton

//==============================================================================
void JuceticeLookAndFeel::drawToggleButton (Graphics& g,
                                            ToggleButton& button,
                                            bool isMouseOverButton,
                                            bool isButtonDown)
{
    const int tickWidth = jmin (20, button.getHeight() - 4);

    drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
                 tickWidth, tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);

    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (jmin (15.0f, button.getHeight() * 0.6f));

    if (! button.isEnabled())
        g.setOpacity (0.5f);

    const int textX = tickWidth + 5;

    g.drawFittedText (button.getButtonText(),
                      textX, 4,
                      button.getWidth() - textX - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
开发者ID:dennyabrain,项目名称:DISTRHO,代码行数:28,代码来源:jucetice_JuceticeLookAndFeel.cpp

示例2: drawToggleButton

void OldSchoolLookAndFeel::drawToggleButton (Graphics& g,
                                             ToggleButton& button,
                                             bool isMouseOverButton,
                                             bool isButtonDown)
{
    if (button.hasKeyboardFocus (true))
    {
        g.setColour (button.findColour (TextEditor::focusedOutlineColourId));
        g.drawRect (0, 0, button.getWidth(), button.getHeight());
    }

    const int tickWidth = jmin (20, button.getHeight() - 4);

    drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
                 (float) tickWidth, (float) tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);

    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (jmin (15.0f, button.getHeight() * 0.6f));

    if (! button.isEnabled())
        g.setOpacity (0.5f);

    const int textX = tickWidth + 5;

    g.drawFittedText (button.getButtonText(),
                      textX, 4,
                      button.getWidth() - textX - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
开发者ID:randi2kewl,项目名称:ShoutOut,代码行数:33,代码来源:juce_OldSchoolLookAndFeel.cpp

示例3: drawToggleButton

void NTLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown){
    
    float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
    const int tickWidth = fontSize * 1.6f;
    
    drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
                 tickWidth, tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);
    
    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (fontSize);
    
    if (! button.isEnabled())
        g.setOpacity (0.5f);
    
    const int textX = (int) tickWidth + 10;
    
    g.drawFittedText (button.getButtonText(),
                      textX, 0,
                      button.getWidth() - textX - 2, button.getHeight(),
                      Justification::centredLeft, 10);
}
开发者ID:Besegra-Mjolnir,项目名称:TopologyOptimization-1,代码行数:25,代码来源:NTLookAndFeel.cpp

示例4: drawToggleButton

void mlrVSTLookAndFeel::drawToggleButton (Graphics& g,
                                             ToggleButton& button,
                                             bool /*isMouseOverButton*/,
                                             bool /*isButtonDown*/)
{
    if (button.getToggleState())
    {
        g.setColour(button.findColour(ToggleButton::textColourId));
        g.fillRect(0, 0, button.getWidth(), button.getHeight());
        g.setColour(Colours::white);
    }
    else
    {
        g.setColour(Colours::white);
        g.fillRect(0, 0, button.getWidth(), button.getHeight());
        g.setColour(button.findColour(ToggleButton::textColourId));
    }

    g.setFont(defaultFont);

    if (! button.isEnabled()) g.setOpacity (0.5f);

    g.drawFittedText (button.getButtonText(), 4, 4,
                      button.getWidth() - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
开发者ID:grimtraveller,项目名称:mlrVST,代码行数:26,代码来源:mlrVSTLookAndFeel.cpp

示例5: updatePreviewBoxText

    void updatePreviewBoxText()
    {
        Font* f = fonts [listBox->getSelectedRow()];

        if (f != 0)
        {
            Font font (*f);

            font.setHeight ((float) sizeSlider->getValue());
            font.setBold (boldButton->getToggleState());
            font.setItalic (italicButton->getToggleState());
            font.setExtraKerningFactor ((float) kerningSlider->getValue());
            font.setHorizontalScale ((float) horizontalScaleSlider->getValue());

            textBox->applyFontToAllText (font);
        }
    }
开发者ID:harry-g,项目名称:juced,代码行数:17,代码来源:FontsAndTextDemo.cpp

示例6: buttonClicked

    void buttonClicked (Button* button) override
    {
        if (button == &nativeButton)
        {
            getLookAndFeel().setUsingNativeAlertWindows (nativeButton.getToggleState());

            return;
        }

        for (int i = windowButtons.size(); --i >= 0;)
            if (button == windowButtons.getUnchecked (i))
                return showWindow (*button, static_cast<DialogType> (i));
    }
开发者ID:mmgeddie,项目名称:seniordesign,代码行数:13,代码来源:DialogsDemo.cpp

示例7: refreshPreviewBoxFont

    void refreshPreviewBoxFont()
    {
        const bool bold = boldToggle.getToggleState();
        const bool italic = italicToggle.getToggleState();
        const bool useStyle = ! (bold || italic);

        Font font (fonts [listBox.getSelectedRow()]);

        font = font.withPointHeight ((float) heightSlider.getValue())
                   .withExtraKerningFactor ((float) kerningSlider.getValue())
                   .withHorizontalScale ((float) scaleSlider.getValue());

        if (bold)    font = font.boldened();
        if (italic)  font = font.italicised();

        updateStylesList (font);

        styleBox.setEnabled (useStyle);

        if (useStyle)
            font = font.withTypefaceStyle (styleBox.getText());

        demoTextBox.applyFontToAllText (font);
    }
开发者ID:ankuznetsov,项目名称:JUCE-3,代码行数:24,代码来源:FontsDemo.cpp

示例8: buttonClicked

 void buttonClicked (Button* buttonThatWasClicked) override
 {
     if (buttonThatWasClicked == &startStopButton)
     {
         if (transportSource.isPlaying())
         {
             transportSource.stop();
         }
         else
         {
             transportSource.setPosition (0);
             transportSource.start();
         }
     }
     else if (buttonThatWasClicked == &followTransportButton)
     {
         thumbnail->setFollowsTransport (followTransportButton.getToggleState());
     }
 }
开发者ID:AydinSakar,项目名称:JUCE,代码行数:19,代码来源:AudioPlaybackDemo.cpp

示例9: drawToggleButton

void ProjucerLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown)
{
    ignoreUnused (isMouseOverButton, isButtonDown);

    if (! button.isEnabled())
        g.setOpacity (0.5f);

    bool isTextEmpty = button.getButtonText().isEmpty();
    bool isPropertyComponentChild = (dynamic_cast<BooleanPropertyComponent*> (button.getParentComponent()) != nullptr);

    auto bounds = button.getLocalBounds();

    auto sideLength = isPropertyComponentChild ? 25 : bounds.getHeight();

    auto rectBounds = isTextEmpty ? bounds
                                  : bounds.removeFromLeft (jmin (sideLength, bounds.getWidth() / 3));

    rectBounds = rectBounds.withSizeKeepingCentre (sideLength, sideLength).reduced (4);

    g.setColour (button.findColour (ToggleButton::tickDisabledColourId));
    g.drawRoundedRectangle (rectBounds.toFloat(), 2.0f, 1.0f);

    if (button.getToggleState())
    {
        g.setColour (button.findColour (ToggleButton::tickColourId));
        const auto tick = getTickShape (0.75f);
        g.fillPath (tick, tick.getTransformToScaleToFit (rectBounds.reduced (2).toFloat(), false));
    }

    if (! isTextEmpty)
    {
        bounds.removeFromLeft (5);

        const auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);

        g.setFont (fontSize);
        g.setColour (isPropertyComponentChild ? findColour (widgetTextColourId)
                                              : button.findColour (ToggleButton::textColourId));

        g.drawFittedText (button.getButtonText(), bounds, Justification::centredLeft, 2);
    }
}
开发者ID:azeteg,项目名称:HISE,代码行数:42,代码来源:jucer_ProjucerLookAndFeel.cpp

示例10: drawToggleButton

void TextLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button,
                                       bool isMouseOverButton, bool isButtonDown) {
  if (button.getToggleState())
    g.setColour(Colour(0xffffc400));
  else
    g.setColour(Colour(0xff313131));
  g.fillRect(button.getLocalBounds());

  g.setColour(Colour(0xff565656));
  g.drawRect(button.getLocalBounds());

  if (isButtonDown) {
    g.setColour(Colour(0x11000000));
    g.fillRect(button.getLocalBounds());
  }
  else if (isMouseOverButton) {
    g.setColour(Colour(0x11ffffff));
    g.fillRect(button.getLocalBounds());
  }
}
开发者ID:hztirf,项目名称:helm,代码行数:20,代码来源:text_look_and_feel.cpp

示例11: drawToggleButton

void DefaultLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button,
                                          bool isMouseOverButton, bool isButtonDown) {
  static const DropShadow shadow(Colour(0x88000000), 1.0f, Point<int>(0, 0));
  static float stroke_percent = 0.1;
  static float padding = 3.0f;
  static float hover_padding = 1.0f;

  float full_radius = std::min(button.getWidth(), button.getHeight()) / 2.0;
  float stroke_width = 2.0f * full_radius * stroke_percent;
  PathStrokeType stroke_type(stroke_width, PathStrokeType::beveled, PathStrokeType::rounded);
  float outer_radius = full_radius - stroke_width - padding;
  Path outer;
  outer.addCentredArc(full_radius, full_radius, outer_radius, outer_radius,
                      mopo::PI, -POWER_ARC_ANGLE, POWER_ARC_ANGLE, true);

  Path shadow_path;
  stroke_type.createStrokedPath(shadow_path, outer);
  shadow.drawForPath(g, shadow_path);
  Rectangle<int> bar_shadow_rect(full_radius - 1.0f, padding, 2.0f, full_radius - padding);
  shadow.drawForRectangle(g, bar_shadow_rect);

  if (button.getToggleState())
    g.setColour(Colours::white);
  else
    g.setColour(Colours::grey);

  g.strokePath(outer, stroke_type);
  g.fillRoundedRectangle(full_radius - 1.0f, padding, 2.0f, full_radius - padding, 1.0f);

  if (isButtonDown) {
    g.setColour(Colour(0x11000000));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);
  }
  else if (isMouseOverButton) {
    g.setColour(Colour(0x11ffffff));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);  }
}
开发者ID:fdeste,项目名称:JuceStuff,代码行数:39,代码来源:default_look_and_feel.cpp

示例12: id

bool
SettingsWindow::fieldsAreValid(void)
{
    ODL_ENTER(); //####
    int    badCount = 0;
    String badArgs;
    String primaryChannel;

    // Counterintuitively, we check the values from the descriptors first, before checking the
    // endpoint, port or tag values.
    _argsToUse.clear();
    for (size_t ii = 0, maxf = _standardFields.size(); maxf > ii; ++ii)
    {
        FormField * aField = _standardFields[static_cast<int>(ii)];

        if (aField && (! aField->validateField(_argsToUse)))
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += aField->getName();
            ++badCount;
        }
    }
    if (0 == badCount)
    {
        // Add the extra arguments here.
        for (size_t ii = 0, maxf = _extraFields.size(); maxf > ii; ++ii)
        {
            FormField * aField = _extraFields[static_cast<int>(ii)];

            _argsToUse.add(aField->getText());
        }
    }
    if (_canSetEndpoint)
    {
        if (_endpointField->validateField())
        {
            _endpointToUse = _endpointField->getText();
        }
        else
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += "Endpoint";
            ++badCount;
        }
    }
    if (_canSetPort)
    {
        if (_portField->validateField())
        {
            _portToUse = _portField->getText();
        }
        else
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += "Port";
            ++badCount;
        }
    }
    if (_canSetTag)
    {
        _tagToUse = _tagField->getText();
    }
    if (_canUseModifier)
    {
        // Determine which of the radio buttons has been selected.
        for (int ii = 0, maxb = _tagModifierGroup->getNumChildComponents(); maxb > ii; ++ii)
        {
            ToggleButton * tb =
                        reinterpret_cast<ToggleButton *>(_tagModifierGroup->getChildComponent(ii));

            if (tb && tb->getToggleState())
            {
                string       id(tb->getComponentID().toStdString());
                const char * startPtr = id.c_str();
                char *       endPtr;
                int          intValue = static_cast<int>(strtol(startPtr, &endPtr, 10));

                if ((startPtr != endPtr) && (! *endPtr))
                {
                    _tagModifierCount = intValue;
                }
                else
                {
                    _tagModifierCount = 0;
                }
            }
        }
    }
    if (0 < badCount)
    {
        String message1((1 < badCount) ? "arguments are" : "argument is");
//.........这里部分代码省略.........
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:101,代码来源:m+mSettingsWindow.cpp

示例13: updateLayoutMode

 void updateLayoutMode()
 {
     multiDocumentPanel.setLayoutMode (showInTabsButton.getToggleState() ? MultiDocumentPanel::MaximisedWindowsWithTabs
                                                                         : MultiDocumentPanel::FloatingWindows);
 }
开发者ID:Xaetrz,项目名称:AddSyn,代码行数:5,代码来源:MDIDemo.cpp

示例14: showWindow

    void showWindow (Component& button, DialogType type)
    {
        if (type >= plainAlertWindow && type <= questionAlertWindow)
        {
            AlertWindow::AlertIconType icon = AlertWindow::NoIcon;

            switch (type)
            {
                case warningAlertWindow:    icon = AlertWindow::WarningIcon;    break;
                case infoAlertWindow:       icon = AlertWindow::InfoIcon;       break;
                case questionAlertWindow:   icon = AlertWindow::QuestionIcon;   break;
                default: break;
            }

            AlertWindow::showMessageBoxAsync (icon,
                                              "This is an AlertWindow",
                                              "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                              "ok");
        }
        else if (type == okCancelAlertWindow)
        {
            AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
                                          "This is an ok/cancel AlertWindow",
                                          "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                          String::empty,
                                          String::empty,
                                          0,
                                          ModalCallbackFunction::forComponent (alertBoxResultChosen, this));
        }
        else if (type == calloutBoxWindow)
        {
            ColourSelector* colourSelector = new ColourSelector();
            colourSelector->setName ("background");
            colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
            colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
            colourSelector->setSize (300, 400);

            CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);
        }
        else if (type == extraComponentsAlertWindow)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            AlertWindow w ("AlertWindow demo..",
                           "This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
                           AlertWindow::QuestionIcon);

            w.addTextEditor ("text", "enter some text here", "text field:");

            const char* options[] = { "option 1", "option 2", "option 3", "option 4", nullptr };
            w.addComboBox ("option", StringArray (options), "some options");

            w.addButton ("ok",     1, KeyPress (KeyPress::returnKey, 0, 0));
            w.addButton ("cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));

            if (w.runModalLoop() != 0) // is they picked 'ok'
            {
                // this is the item they chose in the drop-down list..
                const int optionIndexChosen = w.getComboBoxComponent ("option")->getSelectedItemIndex();
                (void) optionIndexChosen; // (just avoids a compiler warning about unused variables)


                // this is the text they entered..
                String text = w.getTextEditorContents ("text");
            }
           #endif
        }
        else if (type == progressWindow)
        {
            // This will launch our ThreadWithProgressWindow in a modal state. (Our subclass
            // will take care of deleting the object when the task has finished)
            (new DemoBackgroundThread())->launchThread();
        }
        else if (type >= loadChooser && type <= saveChooser)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            const bool useNativeVersion = nativeButton.getToggleState();

            if (type == loadChooser)
            {
                FileChooser fc ("Choose a file to open...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForMultipleFilesToOpen())
                {
                    String chosen;
                    for (int i = 0; i < fc.getResults().size(); ++i)
                        chosen << fc.getResults().getReference(i).getFullPathName() << "\n";

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosen);
                }
            }
            else if (type == loadWithPreviewChooser)
            {
                ImagePreviewComponent imagePreview;
                imagePreview.setSize (200, 200);

//.........这里部分代码省略.........
开发者ID:mmgeddie,项目名称:seniordesign,代码行数:101,代码来源:DialogsDemo.cpp


注:本文中的ToggleButton::getToggleState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。