qskinny/src/common/QskFunctions.h

59 lines
1.7 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_FUNCTIONS_H
#define QSK_FUNCTIONS_H
#include "QskGlobal.h"
2018-07-19 14:10:48 +02:00
#include <qmargins.h>
#include <qrect.h>
2017-07-21 18:21:34 +02:00
class QScreen;
2020-03-13 13:32:22 +01:00
class QFont;
class QFontMetricsF;
class QString;
2017-07-21 18:21:34 +02:00
QSK_EXPORT qreal qskDpiScaled( qreal value );
QSK_EXPORT bool qskHasPlatformWindowManagement();
QSK_EXPORT QRect qskPlatformScreenGeometry( const QScreen* );
2017-07-21 18:21:34 +02:00
QSK_EXPORT QRect qskAlignedRect( const QRect& outerRect,
int width, int height, Qt::Alignment alignment );
QSK_EXPORT QRectF qskAlignedRectF( const QRectF& outerRect,
qreal width, qreal height, Qt::Alignment alignment );
QSK_EXPORT QRect qskInnerRect( const QRectF& rect );
2019-04-10 19:37:59 +02:00
QSK_EXPORT QRectF qskInnerRectF( const QRectF& rect );
2017-07-21 18:21:34 +02:00
QSK_EXPORT QRectF qskValidOrEmptyInnerRect(
const QRectF& rect, const QMarginsF& margins );
2020-03-13 13:32:22 +01:00
QSK_EXPORT qreal qskHorizontalAdvance( const QFont&, const QString& );
QSK_EXPORT qreal qskHorizontalAdvance( const QFontMetricsF&, const QString& );
2017-07-21 18:21:34 +02:00
inline bool qskFuzzyCompare( qreal value1, qreal value2 )
{
if ( qFuzzyIsNull( value1 ) )
return qFuzzyIsNull( value2 );
if ( qFuzzyIsNull( value2 ) )
return false;
return qFuzzyCompare( value1, value2 );
}
inline QMarginsF qskMargins( const QRectF& rect, const QRectF& innerRect )
{
return QMarginsF(
innerRect.left() - rect.left(),
innerRect.top() - rect.top(),
rect.right() - innerRect.right(),
2018-08-03 08:15:28 +02:00
rect.bottom() - innerRect.bottom() );
2017-07-21 18:21:34 +02:00
}
#endif