/* -*- 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 .
*/
tools::Rectangle aRect( Point(0,0), GetOutputSizePixel() ); if ( bVertical )
{
aRect.SetTop( GetScrPos( nStart )-nLayoutSign ); // extra pixel for line at top of selection
aRect.SetBottom( GetScrPos( nEnd+1 )-nLayoutSign );
} else
{
aRect.SetLeft( GetScrPos( nStart )-nLayoutSign ); // extra pixel for line left of selection
aRect.SetRight( GetScrPos( nEnd+1 )-nLayoutSign );
}
Invalidate(aRect);
}
void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect )
{ // It is important for VCL to have few calls, that is why the outer lines are // grouped together
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); bool bHighContrast = rStyleSettings.GetHighContrastMode(); bool bDark = rStyleSettings.GetFaceColor().IsDark(); // Use the same distinction for bDark as in Window::DrawSelectionBackground
Color aTextColor = rStyleSettings.GetButtonTextColor();
Color aSelTextColor = rStyleSettings.GetHighlightTextColor();
Color aAFilterTextColor = rStyleSettings.GetButtonTextColor();
aAFilterTextColor.Merge(COL_LIGHTBLUE, bDark ? 150 : 10); // color of filtered row numbers
aNormFont.SetColor( aTextColor );
aAutoFilterFont.SetColor(aAFilterTextColor); if ( bHighContrast )
aBoldFont.SetColor( aTextColor ); else
aBoldFont.SetColor( aSelTextColor );
ScModule* mod = ScModule::get();
Color aSelLineColor = mod->GetColorConfig().GetColorValue(svtools::CALCCELLFOCUS).nColor;
aSelLineColor.Merge( COL_BLACK, 0xe0 ); // darken just a little bit
if ( bHighContrast )
{ if ( bDark )
{ // solid grey background for dark face color is drawn before lines
GetOutDev()->SetLineColor();
GetOutDev()->SetFillColor( COL_LIGHTGRAY );
GetOutDev()->DrawRect( aFillRect );
}
} else
{ // background for selection
GetOutDev()->SetLineColor();
Color aColor = mod->GetColorConfig().GetColorValue(svtools::CALCCELLFOCUS).nColor; // merging the highlightcolor (which is used if accent does not exist) with the background // fails in many cases such as Breeze Dark (highlight is too close to background) and // Breeze Light (font color is white and not readable anymore) #ifdef MACOSX
aColor.Merge( rStyleSettings.GetFaceColor(), 80 ); #endif
GetOutDev()->SetFillColor( aColor );
GetOutDev()->DrawRect( aFillRect );
}
}
// loop through entries several times to avoid changing the line color too often // and to allow merging of lines
ScGridMerger aGrid( GetOutDev(), 1, 1 );
// start at SC_HDRPAINT_BOTTOM instead of 0 - selection doesn't get different // borders, light border at top isn't used anymore // use SC_HDRPAINT_SEL_BOTTOM for different color
for (sal_uInt16 nPass = SC_HDRPAINT_SEL_BOTTOM; nPass < SC_HDRPAINT_COUNT; nPass++)
{ // set line color etc. before entry loop switch ( nPass )
{ case SC_HDRPAINT_SEL_BOTTOM: // same as non-selected for high contrast
GetOutDev()->SetLineColor( bHighContrast ? rStyleSettings.GetShadowColor() : aSelLineColor ); break; case SC_HDRPAINT_BOTTOM:
GetOutDev()->SetLineColor( rStyleSettings.GetShadowColor() ); break; case SC_HDRPAINT_TEXT: // DrawSelectionBackground is used only for high contrast on light background if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && bHighContrast && !bDark )
{ // Transparent selection background is drawn after lines, before text. // Use DrawSelectionBackground to make sure there is a visible // difference. The case of a dark face color, where DrawSelectionBackground // would just paint over the lines, is handled separately (bDark). // Otherwise, GetHighlightColor is used with 80% transparency. // The window's background color (SetBackground) has to be the background // of the cell area, for the contrast comparison in DrawSelectionBackground.
switch ( nPass )
{ case SC_HDRPAINT_SEL_BOTTOM: case SC_HDRPAINT_BOTTOM: if ( nPass == ( bNextToMark ? SC_HDRPAINT_SEL_BOTTOM : SC_HDRPAINT_BOTTOM ) )
{ if (bVertical)
aGrid.AddHorLine(/* here we work in pixels */ true, aScrPos.X(), aEndPos.X(), aEndPos.Y()); else
aGrid.AddVerLine(/* here we work in pixels */ true, aEndPos.X(), aScrPos.Y(), aEndPos.Y());
// thick bottom for hidden rows // (drawn directly, without aGrid) if ( nEntryNo+1 < nSize ) if ( GetEntrySize(nEntryNo+1)==0 )
{ if (bVertical)
GetOutDev()->DrawLine( Point(aScrPos.X(),aEndPos.Y()-nLayoutSign),
Point(aEndPos.X(),aEndPos.Y()-nLayoutSign) ); else
GetOutDev()->DrawLine( Point(aEndPos.X()-nLayoutSign,aScrPos.Y()),
Point(aEndPos.X()-nLayoutSign,aEndPos.Y()) );
}
} break;
case SC_HDRPAINT_TEXT: if ( nSizePix > 1 ) // minimal check for small columns/rows
{ if (bVertical)
{ bool bAutoFilterPos = false; for (constauto& rSpan : aSpans)
{ if (nEntryNo >= rSpan.mnStart && nEntryNo <= rSpan.mnEnd)
{
bAutoFilterPos = true; break;
}
}
Point aTxtPos(aScrPos); if (bVertical)
{
aTxtPos.AdjustX((nBarSize-aTextSize.Width())/2 );
aTxtPos.AdjustY((nSizePix*nLayoutSign-aTextSize.Height())/2 ); if ( bMirrored )
aTxtPos.AdjustX(1 ); // dark border is left instead of right
} else
{
aTxtPos.AdjustX((nSizePix*nLayoutSign-aTextSize.Width()+1)/2 );
aTxtPos.AdjustY((nBarSize-aTextSize.Height())/2 );
}
GetOutDev()->DrawText( aTxtPos, aString );
} break;
}
// when selecting the complete row/column: // InvertRect( Rectangle( aScrPos, aEndPos ) );
}
nScrPos += nSizePix * nLayoutSign; // also if before the visible area
}
++nCount;
} while ( nScrPos * nLayoutSign <= nPEnd * nLayoutSign );
SetMarking( true ); // must precede SelMouseButtonDown
pSelEngine->SelMouseButtonDown( rMEvt );
// In column/row headers a simple click already is a selection. // -> Call SelMouseMove to ensure CreateAnchor is called (and DestroyAnchor // if the next click is somewhere else with Control key).
pSelEngine->SelMouseMove( rMEvt );
if (IsMouseCaptured())
{ // tracking instead of CaptureMouse, so it can be cancelled cleanly //! someday SelectionEngine itself should call StartTracking!?!
ReleaseMouse();
StartTracking();
}
}
}
if (!bIgnoreMove)
pSelEngine->SelMouseMove( rMEvt );
}
}
void ScHeaderControl::Tracking( const TrackingEvent& rTEvt )
{ // Distribute the tracking events to the various MouseEvents, because // SelectionEngine does not know anything about Tracking
ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() ); if ( pViewSh )
{ if ( rCEvt.IsMouseEvent() )
{ // #i18735# select the column/row under the mouse pointer
ScViewData& rViewData = pViewSh->GetViewData();
SelectWindow(); // also deselects drawing objects, stops draw text edit if ( rViewData.HasEditView( rViewData.GetActivePart() ) )
ScModule::get()->InputEnterHandler(); // always end edit mode
bool bBorder;
SCCOLROW nPos = GetMousePos(rCEvt.GetMousePosPixel(), bBorder ); if (!IsSelectionAllowed(nPos)) // Selecting this cell is not allowed, neither is context menu. return;
// see if any part of the range is already selected
ScRangeList aRanges;
rViewData.GetMarkData().FillRangeListWithMarks( &aRanges, false ); bool bSelected = aRanges.Intersects(aNewRange);
// select the range if no part of it was selected if ( !bSelected )
pViewSh->MarkRange( aNewRange );
}
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.