示例#1
0
bool ResizableWindow::restoreWindowStateFromString (const String& s)
{
    StringArray tokens;
    tokens.addTokens (s, false);
    tokens.removeEmptyStrings();
    tokens.trim();

    const bool fs = tokens[0].startsWithIgnoreCase ("fs");
    const int firstCoord = fs ? 1 : 0;

    if (tokens.size() != firstCoord + 4)
        return false;

    Rectangle<int> newPos (tokens[firstCoord].getIntValue(),
                           tokens[firstCoord + 1].getIntValue(),
                           tokens[firstCoord + 2].getIntValue(),
                           tokens[firstCoord + 3].getIntValue());

    if (newPos.isEmpty())
        return false;

    ComponentPeer* const peer = isOnDesktop() ? getPeer() : nullptr;
    if (peer != nullptr)
        peer->getFrameSize().addTo (newPos);

    {
        Desktop& desktop = Desktop::getInstance();
        RectangleList allMonitors (desktop.getDisplays().getRectangleList (true));
        allMonitors.clipTo (newPos);
        const Rectangle<int> onScreenArea (allMonitors.getBounds());

        if (onScreenArea.getWidth() * onScreenArea.getHeight() < 32 * 32)
        {
            const Rectangle<int> screen (desktop.getDisplays().getDisplayContaining (newPos.getCentre()).userArea);

            newPos.setSize (jmin (newPos.getWidth(),  screen.getWidth()),
                            jmin (newPos.getHeight(), screen.getHeight()));

            newPos.setPosition (jlimit (screen.getX(), screen.getRight()  - newPos.getWidth(),  newPos.getX()),
                                jlimit (screen.getY(), screen.getBottom() - newPos.getHeight(), newPos.getY()));
        }
    }

    if (peer != nullptr)
    {
        peer->getFrameSize().subtractFrom (newPos);
        peer->setNonFullScreenBounds (newPos);
    }

    lastNonFullScreenPos = newPos;
    setFullScreen (fs);

    if (! fs)
        setBoundsConstrained (newPos);

    return true;
}
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);
}