/* -*- 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 .
*/
namespace svt::table
{ using ::css::uno::Any; using ::css::uno::Reference; using ::css::uno::UNO_QUERY; using ::css::uno::XInterface; using ::css::uno::TypeClass_INTERFACE; using ::css::graphic::XGraphic; using ::css::style::HorizontalAlignment; using ::css::style::HorizontalAlignment_CENTER; using ::css::style::HorizontalAlignment_RIGHT; using ::css::style::VerticalAlignment; using ::css::style::VerticalAlignment_MIDDLE; using ::css::style::VerticalAlignment_BOTTOM;
// draw sort indicator if the model data is sorted by the given column
ITableDataSort const * pSortAdapter = m_pImpl->rModel.getSortAdapter();
ColumnSort aCurrentSortOrder; if ( pSortAdapter != nullptr )
aCurrentSortOrder = pSortAdapter->getCurrentSortOrder(); if ( aCurrentSortOrder.nColumnPos == _nCol )
{
tools::Longconst nHeaderHeight( _rArea.GetHeight() );
BitmapEx const aIndicatorBitmap = m_pImpl->aSortIndicator.getBitmapFor(rRenderContext, nHeaderHeight, _rStyle,
aCurrentSortOrder.eSortDirection == ColumnSortAscending);
Size const aBitmapSize( aIndicatorBitmap.GetSizePixel() );
tools::Longconst nSortIndicatorPaddingX = 2;
tools::Longconst nSortIndicatorPaddingY = ( nHeaderHeight - aBitmapSize.Height() ) / 2;
if ( nDrawTextFlags & DrawTextFlags::Right )
{ // text is right aligned => draw the sort indicator at the left hand side
rRenderContext.DrawBitmapEx(Point(_rArea.Left() + nSortIndicatorPaddingX, _rArea.Top() + nSortIndicatorPaddingY),
aIndicatorBitmap);
} else
{ // text is left-aligned or centered => draw the sort indicator at the right hand side
rRenderContext.DrawBitmapEx(Point(_rArea.Right() - nSortIndicatorPaddingX - aBitmapSize.Width(), nSortIndicatorPaddingY),
aIndicatorBitmap);
}
}
rRenderContext.Pop();
}
void GridTableRenderer::PrepareRow(RowPos _nRow, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRowArea, const StyleSettings& _rStyle)
{ // remember the row for subsequent calls to the other ->ITableRenderer methods
m_pImpl->nCurrentRow = _nRow;
Any const rowHeading( m_pImpl->rModel.getRowHeading( m_pImpl->nCurrentRow ) );
OUString const rowTitle( m_pImpl->aStringConverter.convertToString( rowHeading ) ); if (!rowTitle.isEmpty())
{
Color const textColor = lcl_getEffectiveColor(m_pImpl->rModel.getHeaderTextColor(),
_rStyle, &StyleSettings::GetFieldTextColor);
rRenderContext.SetTextColor(textColor);
tools::Rectangle const aTextRect(lcl_getTextRenderingArea(lcl_getContentArea(*m_pImpl, _rArea)));
DrawTextFlags nDrawTextFlags = lcl_getAlignmentTextDrawFlags(*m_pImpl, 0) | DrawTextFlags::Clip; if (!m_pImpl->rModel.isEnabled())
nDrawTextFlags |= DrawTextFlags::Disable; // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitrary ..
rRenderContext.DrawText(aTextRect, rowTitle, nDrawTextFlags);
}
if ( _bSelected && !aLineColor )
{ // if no line color is specified by the model, use the usual selection color for lines in selected cells
lineColor = i_hasControlFocus
? lcl_getEffectiveColor( m_pImpl->rModel.getActiveSelectionBackColor(), _rStyle, &StyleSettings::GetHighlightColor )
: lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor );
}
bool GridTableRenderer::FitsIntoCell( Any const & i_cellContent,
OutputDevice& i_targetDevice, tools::Rectangle const & i_targetArea ) const
{ if ( !i_cellContent.hasValue() ) returntrue;
if ( i_cellContent.getValueTypeClass() == TypeClass_INTERFACE )
{
Reference< XInterface > const xContentInterface( i_cellContent, UNO_QUERY ); if ( !xContentInterface.is() ) returntrue;
Reference< XGraphic > const xGraphic( i_cellContent, UNO_QUERY ); if ( xGraphic.is() ) // for the moment, assume it fits. We can always scale it down during painting ... returntrue;
OSL_ENSURE( false, "GridTableRenderer::FitsIntoCell: only XGraphic interfaces (or NULL) are supported for painting." ); returntrue;
}
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.