2017-07-21 16:21:34 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskTextRenderer.h"
|
2017-10-23 05:46:46 +00:00
|
|
|
#include "QskRichTextRenderer.h"
|
|
|
|
#include "QskPlainTextRenderer.h"
|
|
|
|
#include "QskTextOptions.h"
|
2017-10-20 18:26:39 +00:00
|
|
|
|
2017-10-23 05:46:46 +00:00
|
|
|
#include <QRectF>
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2017-10-23 05:46:46 +00:00
|
|
|
QSizeF QskTextRenderer::textSize( const QString& text,
|
|
|
|
const QFont& font, const QskTextOptions& options )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2017-10-23 05:46:46 +00:00
|
|
|
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
|
|
|
return QskPlainTextRenderer::textSize( text, font, options );
|
|
|
|
else
|
|
|
|
return QskRichTextRenderer::textSize( text, font, options );
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
|
|
|
|
2017-10-23 05:46:46 +00:00
|
|
|
QSizeF QskTextRenderer::textSize( const QString& text,
|
|
|
|
const QFont& font, const QskTextOptions& options, const QSizeF& size )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2017-10-23 05:46:46 +00:00
|
|
|
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
|
|
|
return QskPlainTextRenderer::textRect( text, font, options, size ).size();
|
|
|
|
else
|
|
|
|
return QskRichTextRenderer::textRect( text, font, options, size ).size();
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 18:26:39 +00:00
|
|
|
void QskTextRenderer::updateNode( const QString& text,
|
2017-10-23 05:46:46 +00:00
|
|
|
const QFont& font, const QskTextOptions& options,
|
|
|
|
Qsk::TextStyle style, const QskTextColors& colors,
|
|
|
|
Qt::Alignment alignment, const QRectF& rect,
|
2017-10-20 18:26:39 +00:00
|
|
|
const QQuickItem* item, QSGTransformNode* node )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2017-10-23 05:46:46 +00:00
|
|
|
if ( options.format() == QskTextOptions::PlainText )
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
2017-10-23 05:46:46 +00:00
|
|
|
QskPlainTextRenderer::updateNode( text, font, options, style,
|
|
|
|
colors, alignment, rect, item, node );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QskRichTextRenderer::updateNode( text, font, options, style,
|
|
|
|
colors, alignment, rect, item, node );
|
2017-07-21 16:21:34 +00:00
|
|
|
}
|
2017-10-20 18:26:39 +00:00
|
|
|
}
|