/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if (rRenderContext.IsNativeControlSupported(ControlType::Spinbox, ControlPart::Entire) && // there is just no useful native support for spinfields with dropdown
!(pWin->GetStyle() & WB_DROPDOWN))
{ if (rRenderContext.IsNativeControlSupported(ControlType::Spinbox, rSpinbuttonValue.mnUpperPart) &&
rRenderContext.IsNativeControlSupported(ControlType::Spinbox, rSpinbuttonValue.mnLowerPart))
{ // only paint the embedded spin buttons, all buttons are painted at once
tools::Rectangle aUpperAndLowerButtons( rSpinbuttonValue.maUpperRect.GetUnion( rSpinbuttonValue.maLowerRect ) );
bNativeOK = rRenderContext.DrawNativeControl(ControlType::Spinbox, ControlPart::AllButtons, aUpperAndLowerButtons,
ControlState::ENABLED, rSpinbuttonValue, OUString());
} else
{ // paint the spinbox as a whole, use borderwindow to have proper clipping
vcl::Window* pBorder = pWin->GetWindow(GetWindowType::Border);
// to not overwrite everything, set the button region as clipregion to the border window
tools::Rectangle aClipRect(rSpinbuttonValue.maLowerRect);
aClipRect.Union(rSpinbuttonValue.maUpperRect);
vcl::RenderContext* pContext = &rRenderContext;
vcl::Region oldRgn;
Point aPt;
Size aSize(pBorder->GetOutputSizePixel()); // the size of the border window, i.e., the whole control
tools::Rectangle aNatRgn(aPt, aSize);
if (!pWin->SupportsDoubleBuffering())
{ // convert from screen space to borderwin space
aClipRect.SetPos(pBorder->ScreenToOutputPixel(pWin->OutputToScreenPixel(aClipRect.TopLeft())));
tools::Rectangle aRgn(aPt, aSize); if (pWin->SupportsDoubleBuffering())
{ // convert from borderwin space, to the pWin's space
aRgn.SetPos(pWin->ScreenToOutputPixel(pBorder->OutputToScreenPixel(aRgn.TopLeft())));
}
if (rRenderContext.IsNativeControlSupported(ControlType::SpinButtons, ControlPart::Entire))
{
tools::Rectangle aArea = rSpinbuttonValue.maUpperRect.GetUnion(rSpinbuttonValue.maLowerRect); // only paint the standalone spin buttons, all buttons are painted at once
bNativeOK = rRenderContext.DrawNativeControl(ControlType::SpinButtons, ControlPart::AllButtons, aArea,
ControlState::ENABLED, rSpinbuttonValue, OUString());
} return bNativeOK;
}
if (pWindow)
{ // are we drawing standalone spin buttons or members of a spinfield ?
ControlType aControl = ControlType::SpinButtons; switch (pWindow->GetType())
{ case WindowType::EDIT: case WindowType::MULTILINEEDIT: case WindowType::PATTERNFIELD: case WindowType::METRICFIELD: case WindowType::CURRENCYFIELD: case WindowType::DATEFIELD: case WindowType::TIMEFIELD: case WindowType::SPINFIELD: case WindowType::FORMATTEDFIELD:
aControl = ControlType::Spinbox; break; default:
aControl = ControlType::SpinButtons; break;
}
// draw into the edge, so that something is visible if the rectangle is too small if (aUpRect.GetHeight() < 4)
{
aUpRect.AdjustRight( 1 );
aUpRect.AdjustBottom( 1 );
aLowRect.AdjustRight( 1 );
aLowRect.AdjustBottom( 1 );
}
if (!(nWinStyle & (WB_SPIN | WB_DROPDOWN))) return;
mbSpin = true;
// Some themes want external spin buttons, therefore the main // spinfield should not overdraw the border between its encapsulated // edit field and the spin buttons if ((nWinStyle & WB_SPIN) && ImplUseNativeBorder(*GetOutDev(), nWinStyle))
{
SetBackground();
mpEdit.reset(VclPtr<Edit>::Create(this, WB_NOBORDER));
mpEdit->SetBackground();
} else
mpEdit.reset(VclPtr<Edit>::Create(this, WB_NOBORDER));
if ((pDev->GetOutDevType() == OUTDEV_WINDOW) && // there is just no useful native support for spinfields with dropdown
! (GetStyle() & WB_DROPDOWN) &&
IsNativeControlSupported(ControlType::Spinbox, ControlPart::Entire))
{
vcl::Window *pWin = pDev->GetOwnerWindow();
vcl::Window *pBorder = pWin->GetWindow( GetWindowType::Border );
// get the system's spin button size
ImplControlValue aControlValue;
tools::Rectangle aBound;
Point aPoint;
// use the full extent of the control
tools::Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
if (bNativeRegionOK)
{ // convert back from border space to local coordinates
aPoint = pBorder->ScreenToOutputPixel( pWin->OutputToScreenPixel( aPoint ) );
aContentUp.Move(-aPoint.X(), -aPoint.Y());
aContentDown.Move(-aPoint.X(), -aPoint.Y());
}
}
ImplControlValue aControlValue;
Point aPoint;
tools::Rectangle aContent, aBound;
// use the full extent of the control
vcl::Window *pBorder = GetWindow( GetWindowType::Border );
tools::Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
// adjust position and size of the edit field if (GetNativeControlRegion(ControlType::Spinbox, ControlPart::SubEdit, aArea, ControlState::NONE,
aControlValue, aBound, aContent) && // there is just no useful native support for spinfields with dropdown
!(GetStyle() & WB_DROPDOWN))
{ // convert back from border space to local coordinates
aPoint = pBorder->ScreenToOutputPixel(OutputToScreenPixel(aPoint));
aContent.Move(-aPoint.X(), -aPoint.Y());
// use the themes drop down size
mpEdit->SetPosPixel( aContent.TopLeft() );
bSubEditPositioned = true;
aSize = aContent.GetSize();
} else
{ if (maUpperRect.IsEmpty())
{
SAL_WARN_IF( maDropDownRect.IsEmpty(), "vcl", "SpinField::Resize: SPIN && DROPDOWN, but all empty rects?" );
aSize.setWidth( maDropDownRect.Left() );
} else
aSize.setWidth( maUpperRect.Left() );
}
}
if (!bSubEditPositioned)
{ // this moves our sub edit if RTL gets switched
mpEdit->SetPosPixel(Point());
}
mpEdit->SetSizePixel(aSize);
if (GetStyle() & WB_SPIN)
Invalidate(tools::Rectangle(maUpperRect.TopLeft(), maLowerRect.BottomRight())); if (GetStyle() & WB_DROPDOWN)
Invalidate(maDropDownRect);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.