qskinny/src/layouts/QskGridBox.h

135 lines
4.5 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_GRID_BOX_H
#define QSK_GRID_BOX_H
2019-04-08 13:08:58 +02:00
#include "QskLayoutBox.h"
2017-07-21 18:21:34 +02:00
2019-04-08 13:08:58 +02:00
class QSK_EXPORT QskGridBox : public QskLayoutBox
2017-07-21 18:21:34 +02:00
{
Q_OBJECT
Q_PROPERTY( qreal horizontalSpacing READ horizontalSpacing
WRITE setHorizontalSpacing RESET resetHorizontalSpacing
NOTIFY horizontalSpacingChanged )
Q_PROPERTY( qreal verticalSpacing READ verticalSpacing
WRITE setVerticalSpacing RESET resetVerticalSpacing
NOTIFY verticalSpacingChanged )
2019-04-08 13:08:58 +02:00
using Inherited = QskLayoutBox;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
explicit QskGridBox( QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskGridBox() override;
2017-07-21 18:21:34 +02:00
Q_INVOKABLE void addItem(
QQuickItem*, int row, int column, int rowSpan, int columnSpan,
Qt::Alignment alignment = Qt::Alignment() );
Q_INVOKABLE void addItem(
QQuickItem*, int row, int column,
Qt::Alignment alignment = Qt::Alignment() );
Q_INVOKABLE int rowCount() const;
Q_INVOKABLE int columnCount() const;
Q_INVOKABLE QQuickItem* itemAt( int row, int column ) const;
Q_INVOKABLE int indexAt( int row, int column ) const;
Q_INVOKABLE int rowOfIndex( int index ) const;
Q_INVOKABLE int rowSpanOfIndex( int index ) const;
Q_INVOKABLE int columnOfIndex( int index ) const;
Q_INVOKABLE int columnSpanOfIndex( int index ) const;
// spacings
void setSpacing( qreal spacing );
void setHorizontalSpacing( qreal spacing );
void resetHorizontalSpacing();
2017-12-07 17:04:05 +01:00
qreal horizontalSpacing() const;
2017-07-21 18:21:34 +02:00
void setVerticalSpacing( qreal spacing );
void resetVerticalSpacing();
2017-12-07 17:04:05 +01:00
qreal verticalSpacing() const;
2017-07-21 18:21:34 +02:00
Q_INVOKABLE void setRowSpacing( int row, qreal spacing );
Q_INVOKABLE qreal rowSpacing( int row ) const;
Q_INVOKABLE void setColumnSpacing( int column, qreal spacing );
Q_INVOKABLE qreal columnSpacing( int column ) const;
// stretch factors
Q_INVOKABLE void setRowStretchFactor( int row, int stretch );
Q_INVOKABLE int rowStretchFactor( int row ) const;
Q_INVOKABLE void setColumnStretchFactor( int column, int stretch );
Q_INVOKABLE int columnStretchFactor( int column ) const;
// row/column size hints
Q_INVOKABLE void setRowMinimumHeight( int row, qreal height );
Q_INVOKABLE qreal rowMinimumHeight( int row ) const;
Q_INVOKABLE void setRowPreferredHeight( int row, qreal height );
Q_INVOKABLE qreal rowPreferredHeight( int row ) const;
Q_INVOKABLE void setRowMaximumHeight( int row, qreal height );
Q_INVOKABLE qreal rowMaximumHeight( int row ) const;
Q_INVOKABLE void setRowFixedHeight( int row, qreal height );
Q_INVOKABLE void setColumnMinimumWidth( int column, qreal width );
Q_INVOKABLE qreal columnMinimumWidth( int column ) const;
Q_INVOKABLE void setColumnPreferredWidth( int column, qreal width );
Q_INVOKABLE qreal columnPreferredWidth( int column ) const;
Q_INVOKABLE void setColumnMaximumWidth( int column, qreal width );
Q_INVOKABLE qreal columnMaximumWidth( int column ) const;
Q_INVOKABLE void setColumnFixedWidth( int column, qreal width );
// alignments
Q_INVOKABLE void setRowAlignment( int row, Qt::Alignment alignment );
Q_INVOKABLE Qt::Alignment rowAlignment( int row ) const;
Q_INVOKABLE void setColumnAlignment( int column, Qt::Alignment alignment );
Q_INVOKABLE Qt::Alignment columnAlignment( int column ) const;
void setAlignment( const QQuickItem* item, Qt::Alignment alignment );
Qt::Alignment alignment( const QQuickItem* item ) const;
bool retainSizeWhenHidden( const QQuickItem* ) const;
void setRetainSizeWhenHidden( const QQuickItem*, bool on );
2018-08-03 08:15:28 +02:00
Q_SIGNALS:
2017-07-21 18:21:34 +02:00
void verticalSpacingChanged();
void horizontalSpacingChanged();
2018-08-03 08:15:28 +02:00
protected:
2018-07-31 17:32:25 +02:00
void setupLayoutItem( QskLayoutItem*, int index ) override;
void layoutItemInserted( QskLayoutItem*, int index ) override;
void layoutItemRemoved( QskLayoutItem*, int index ) override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
void setRowSizeHint(
Qt::SizeHint which, int row, qreal size,
Qt::Orientation orientation );
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
inline void QskGridBox::addItem(
QQuickItem* item, int row, int column, Qt::Alignment alignment )
{
addItem( item, row, column, 1, 1, alignment );
}
#endif