Kaydet (Commit) 09bd5846 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#92982 vcl: move Invert() member functions from vcl::Window to OutputDevice

With this, vcl::Cursor will be able to paint to a vcl::RenderContext,
too; not just directly, which is needed for double-buffering.

Change-Id: I868f6cd9b08afe59611ef266911a894a26cacedc
üst 372d4166
......@@ -288,6 +288,18 @@ namespace o3tl
template<> struct typed_flags<GetDefaultFontFlags> : is_typed_flags<GetDefaultFontFlags, 0x01> {};
}
// Flags for Invert()
enum class InvertFlags
{
NONE = 0x0000,
Highlight = 0x0001,
N50 = 0x0002,
};
namespace o3tl
{
template<> struct typed_flags<InvertFlags> : is_typed_flags<InvertFlags, 0x0003> {};
}
enum OutDevType { OUTDEV_DONTKNOW, OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV };
enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OUTDEV_VIEWTYPE_SLIDESHOW };
......@@ -753,6 +765,13 @@ public:
///@}
/** @name Invert functions
*/
///@{
public:
void Invert( const Rectangle& rRect, InvertFlags nFlags = InvertFlags::NONE );
void Invert( const Polygon& rPoly, InvertFlags nFlags = InvertFlags::NONE );
///@}
/** @name Line functions
*/
......
......@@ -280,18 +280,6 @@ namespace o3tl
template<> struct typed_flags<ParentClipMode> : is_typed_flags<ParentClipMode, 0x0003> {};
}
// Flags for Invert()
enum class InvertFlags
{
NONE = 0x0000,
Highlight = 0x0001,
N50 = 0x0002,
};
namespace o3tl
{
template<> struct typed_flags<InvertFlags> : is_typed_flags<InvertFlags, 0x0003> {};
}
// Flags for ShowTracking()
#define SHOWTRACK_SMALL ((sal_uInt16)0x0001)
#define SHOWTRACK_BIG ((sal_uInt16)0x0002)
......@@ -1244,9 +1232,6 @@ public:
virtual void ShowFocus(const Rectangle& rRect);
void HideFocus();
void Invert( const Rectangle& rRect, InvertFlags nFlags = InvertFlags::NONE );
void Invert( const Polygon& rPoly, InvertFlags nFlags = InvertFlags::NONE );
// transparent background for selected or checked items in toolboxes etc.
void DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly );
// support rounded edges in the selection rect
......
......@@ -129,6 +129,72 @@ void OutputDevice::DrawRect( const Rectangle& rRect,
mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound );
}
void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags )
{
if ( !IsDeviceOutputNecessary() )
return;
Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
if ( aRect.IsEmpty() )
return;
aRect.Justify();
// we need a graphics
if ( !mpGraphics )
{
if ( !AcquireGraphics() )
return;
}
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
SalInvert nSalFlags = 0;
if ( nFlags & InvertFlags::Highlight )
nSalFlags |= SAL_INVERT_HIGHLIGHT;
if ( nFlags & InvertFlags::N50 )
nSalFlags |= SAL_INVERT_50;
mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
}
void OutputDevice::Invert( const Polygon& rPoly, InvertFlags nFlags )
{
if ( !IsDeviceOutputNecessary() )
return;
sal_uInt16 nPoints = rPoly.GetSize();
if ( nPoints < 2 )
return;
Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
// we need a graphics
if ( !mpGraphics )
{
if ( !AcquireGraphics() )
return;
}
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
SalInvert nSalFlags = 0;
if ( nFlags & InvertFlags::Highlight )
nSalFlags |= SAL_INVERT_HIGHLIGHT;
if ( nFlags & InvertFlags::N50 )
nSalFlags |= SAL_INVERT_50;
const SalPoint* pPtAry = reinterpret_cast<const SalPoint*>(aPoly.GetConstPointAry());
mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
}
void OutputDevice::DrawCheckered(const Point& rPos, const Size& rSize, sal_uInt32 nLen, Color aStart, Color aEnd)
{
assert(!is_double_buffered_window());
......
......@@ -127,74 +127,6 @@ void Window::HideFocus()
mpWindowImpl->mbInHideFocus = false;
}
void Window::Invert( const Rectangle& rRect, InvertFlags nFlags )
{
if ( !IsDeviceOutputNecessary() )
return;
OutputDevice *pOutDev = GetOutDev();
Rectangle aRect( pOutDev->ImplLogicToDevicePixel( rRect ) );
if ( aRect.IsEmpty() )
return;
aRect.Justify();
// we need a graphics
if ( !mpGraphics )
{
if ( !pOutDev->AcquireGraphics() )
return;
}
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
SalInvert nSalFlags = 0;
if ( nFlags & InvertFlags::Highlight )
nSalFlags |= SAL_INVERT_HIGHLIGHT;
if ( nFlags & InvertFlags::N50 )
nSalFlags |= SAL_INVERT_50;
mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
}
void Window::Invert( const Polygon& rPoly, InvertFlags nFlags )
{
if ( !IsDeviceOutputNecessary() )
return;
sal_uInt16 nPoints = rPoly.GetSize();
if ( nPoints < 2 )
return;
OutputDevice *pOutDev = GetOutDev();
Polygon aPoly( pOutDev->ImplLogicToDevicePixel( rPoly ) );
// we need a graphics
if ( !mpGraphics )
{
if ( !pOutDev->AcquireGraphics() )
return;
}
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
SalInvert nSalFlags = 0;
if ( nFlags & InvertFlags::Highlight )
nSalFlags |= SAL_INVERT_HIGHLIGHT;
if ( nFlags & InvertFlags::N50 )
nSalFlags |= SAL_INVERT_50;
const SalPoint* pPtAry = reinterpret_cast<const SalPoint*>(aPoly.GetConstPointAry());
mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
}
void Window::ShowTracking( const Rectangle& rRect, sal_uInt16 nFlags )
{
ImplWinData* pWinData = ImplGetWinData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment