コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: 0x4d52/JUCE
    bool perform (const InvocationInfo& info) override
    {
        MainAppWindow* mainWindow = MainAppWindow::getMainAppWindow();

        if (mainWindow == nullptr)
            return true;

        switch (info.commandID)
        {
            case MainAppWindow::showPreviousDemo:   moveDemoPages (-1); break;
            case MainAppWindow::showNextDemo:       moveDemoPages ( 1); break;

            case MainAppWindow::welcome:
            case MainAppWindow::componentsAnimation:
            case MainAppWindow::componentsDialogBoxes:
            case MainAppWindow::componentsKeyMappings:
            case MainAppWindow::componentsMDI:
            case MainAppWindow::componentsPropertyEditors:
            case MainAppWindow::componentsTransforms:
            case MainAppWindow::componentsWebBrowsers:
            case MainAppWindow::componentsWidgets:
                demoList.selectRow (info.commandID - MainAppWindow::welcome);
                break;

            case MainAppWindow::renderingEngineOne:
            case MainAppWindow::renderingEngineTwo:
            case MainAppWindow::renderingEngineThree:
                mainWindow->setRenderingEngine (info.commandID - MainAppWindow::renderingEngineOne);
                break;

            case MainAppWindow::useLookAndFeelV1:  LookAndFeel::setDefaultLookAndFeel (&lookAndFeelV1); break;
            case MainAppWindow::useLookAndFeelV2:  LookAndFeel::setDefaultLookAndFeel (&lookAndFeelV2); break;
            case MainAppWindow::useLookAndFeelV3:  LookAndFeel::setDefaultLookAndFeel (&lookAndFeelV3); break;

            case MainAppWindow::toggleRepaintDebugging:
                juceDemoRepaintDebuggingActive = ! juceDemoRepaintDebuggingActive;
                mainWindow->repaint();
                break;

            case MainAppWindow::useNativeTitleBar:
                mainWindow->setUsingNativeTitleBar (! mainWindow->isUsingNativeTitleBar());
                break;

           #if ! JUCE_LINUX
            case MainAppWindow::goToKioskMode:
                {
                    Desktop& desktop = Desktop::getInstance();

                    if (desktop.getKioskModeComponent() == nullptr)
                        desktop.setKioskModeComponent (getTopLevelComponent());
                    else
                        desktop.setKioskModeComponent (nullptr);

                    break;
                }
           #endif

            default:
                return false;
        }

        return true;
    }
コード例 #2
0
ファイル: FontsAndTextDemo.cpp プロジェクト: harry-g/juced
    //==============================================================================
    FontsAndTextDemo()
    {
        setName (T("Fonts"));

        Font::findFonts (fonts);

        addAndMakeVisible (listBox = new ListBox (T("fonts"), this));
        listBox->setRowHeight (28);

        addAndMakeVisible (textBox = new TextEditor());

        textBox->setColour (TextEditor::backgroundColourId, Colours::white);
        textBox->setColour (TextEditor::outlineColourId, Colours::black.withAlpha (0.5f));

        textBox->setMultiLine (true, true);
        textBox->setReturnKeyStartsNewLine (true);
        textBox->setText (T("The Quick Brown Fox Jumps Over The Lazy Dog\n\nAa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz 0123456789"));

        addAndMakeVisible (boldButton = new ToggleButton (T("bold")));
        boldButton->addButtonListener (this);

        addAndMakeVisible (italicButton = new ToggleButton (T("italic")));
        italicButton->addButtonListener (this);

        addAndMakeVisible (sizeSlider = new Slider ("Size"));
        sizeSlider->setRange (3.0, 150.0, 0.1);
        sizeSlider->setValue (20.0);
        sizeSlider->addListener (this);
        (new Label (String::empty, sizeSlider->getName()))->attachToComponent (sizeSlider, true);

        addAndMakeVisible (kerningSlider = new Slider ("Kerning"));
        kerningSlider->setRange (-1.0, 1.0, 0.01);
        kerningSlider->setValue (0.0);
        kerningSlider->addListener (this);
        (new Label (String::empty, kerningSlider->getName()))->attachToComponent (kerningSlider, true);

        addAndMakeVisible (horizontalScaleSlider = new Slider ("Stretch"));
        horizontalScaleSlider->setRange (0.1, 4.0, 0.01);
        horizontalScaleSlider->setValue (1.0);
        horizontalScaleSlider->addListener (this);
        (new Label (String::empty, horizontalScaleSlider->getName()))->attachToComponent (horizontalScaleSlider, true);

        for (int i = 0; i < fonts.size(); ++i)
        {
            if (fonts[i]->getTypefaceName().startsWithIgnoreCase (T("Arial")))
            {
                listBox->selectRow (i);
                break;
            }
        }

        listBox->setColour (ListBox::outlineColourId, Colours::black.withAlpha (0.5f));
        listBox->setOutlineThickness (1);

        // set up the layout and resizer bars..

        verticalLayout.setItemLayout (0, -0.2, -0.8, -0.5);  // width of the font list must be
        // between 20% and 80%, preferably 50%
        verticalLayout.setItemLayout (1, 8, 8, 8);           // the vertical divider drag-bar thing is always 8 pixels wide
        verticalLayout.setItemLayout (2, 150, -1.0, -0.5);   // the components on the right must be
        // at least 150 pixels wide, preferably 50% of the total width

        verticalDividerBar = new StretchableLayoutResizerBar (&verticalLayout, 1, true);
        addAndMakeVisible (verticalDividerBar);

        horizontalLayout.setItemLayout (0, -0.2, -1.0, -0.4);  // height of the font text box must be
        // between 20% and 100%, preferably 40%
        horizontalLayout.setItemLayout (1, 8, 8, 8);           // the horizontal divider drag-bar thing is always 8 pixels high
        horizontalLayout.setItemLayout (2, 2, 5, 5);           // a gap between the controls
        horizontalLayout.setItemLayout (3, 15, 20, 20);        // the italic button would like to be 20 pixels high
        horizontalLayout.setItemLayout (4, 2, 5, 5);           // a gap between the controls
        horizontalLayout.setItemLayout (5, 15, 20, 20);        // the bold button would like to be 20 pixels high
        horizontalLayout.setItemLayout (6, 2, 5, 5);           // a gap between the controls
        horizontalLayout.setItemLayout (7, 15, 20, 20);        // the italic button would like to be 20 pixels high
        horizontalLayout.setItemLayout (8, 2, 5, 5);           // a gap between the controls
        horizontalLayout.setItemLayout (9, 15, 20, 20);        // the copy code button would like to be 20 pixels high
        horizontalLayout.setItemLayout (10, 5, -1.0, 5);        // add a gap at the bottom that will fill up any
        // space left over - this will stop the
        // sliders from always sticking to the
        // bottom of the window
    }