C

QSafeLayout Class

class SafeRenderer::QSafeLayout

The QSafeLayout class provides an abstract class for accessing the Qt Safe Renderer layout data. More...

Header: #include <QSafeLayout>
Since: QtSafeRenderer 1.0
Inherited By:

SafeRenderer::QSafeLayoutFileReader and SafeRenderer::QSafeLayoutResourceReader

This class was introduced in QtSafeRenderer 1.0.

Public Types

enum LayoutException { UnknownBitmapId, UnknownItem, ItemOutOfBounds, SizeErrorWidth, SizeErrorHeight, …, InvalidLayoutType }
enum LayoutParserState { INVALID, OK }

Public Functions

QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader)
virtual ~QSafeLayout()
void advanceAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)
const SafeRenderer::QSafeBitmap *bitmapForItem(const SafeRenderer::quint32 id) const
SafeRenderer::quint32 count() const
virtual SafeRenderer::QSafeFontCache *fontCache() const = 0
const SafeRenderer::LayoutData &getLayoutItem(const SafeRenderer::quint32 id) const
const SafeRenderer::QSafeStateTransition &getStateTransition(const SafeRenderer::quint32 indexArg)
SafeRenderer::LayoutData &item(const SafeRenderer::quint32 idx)
bool itemIndex(const SafeRenderer::quint32 idArg, SafeRenderer::quint32 &indexArg) const
SafeRenderer::quint32 layoutId() const
SafeRenderer::QSafeLayout::LayoutParserState parserState() const
SafeRenderer::QSafePoint position() const
virtual const SafeRenderer::QSafeByteArray readDataFromFile(const SafeRenderer::qchar *const filenameArg) = 0
void restartAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)
void setAlphaForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint8 alphaArg)
void setBitmapForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint32 bitmapIdArg)
void setColorForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::ARGB colorArg)
void setLayoutId(const SafeRenderer::quint32 &layoutIdArg)
void setPositionForItem(const SafeRenderer::qchar *const name, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y)
void setPositionForItem(const SafeRenderer::quint32 id, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y)
void setTextForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::qchar *const textArg)
SafeRenderer::QSafeSize size() const
SafeRenderer::quint32 stateTransitionsCount() const

Detailed Description

The QSafeLayout class provides an abstract class for accessing the Qt Safe Renderer layout data.

Member Type Documentation

enum QSafeLayout::LayoutException

This enum describes the exception values in the QSafeLayout class.

ConstantValueDescription
SafeRenderer::QSafeLayout::UnknownBitmapId0The bitmap ID is not found from layout.
SafeRenderer::QSafeLayout::UnknownItem1The item is not found.
SafeRenderer::QSafeLayout::ItemOutOfBounds2The item's new position is out of bounds.
SafeRenderer::QSafeLayout::SizeErrorWidth4The width of the layout size too long.
SafeRenderer::QSafeLayout::SizeErrorHeight5The height of the layout size too long.
SafeRenderer::QSafeLayout::DataSizeMismatch3The layout file size is not multiple of the layout data size, or the layout data size is too small.
SafeRenderer::QSafeLayout::InvalidLayoutVersion6Layout version is not supported.
SafeRenderer::QSafeLayout::CheckSumFailed7Layout file checksum fails
SafeRenderer::QSafeLayout::TooLongFilename8Bitmap's filename is too long to fit in temporary buffer.
SafeRenderer::QSafeLayout::InvalidLayoutType9The layout type is Invalid.

enum QSafeLayout::LayoutParserState

This enum describes the status values in the QSafeLayout class.

ConstantValueDescription
SafeRenderer::QSafeLayout::INVALID0The layout data is invalid.
SafeRenderer::QSafeLayout::OK1Layout data read and validated.

Member Function Documentation

QSafeLayout::QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader)

Constructs a safe layout object using a bitmapReader instance to access the bitmap data.

[virtual] QSafeLayout::~QSafeLayout()

Destroys the safe layout object.

void QSafeLayout::advanceAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)

Advances the stateIndexArg at transitionIndexArg.

const SafeRenderer::QSafeBitmap *QSafeLayout::bitmapForItem(const SafeRenderer::quint32 id) const

Returns the bitmap object of the layout item identified by id. Returns NULL if bitmaps is not found.

See also setBitmapForItem().

SafeRenderer::quint32 QSafeLayout::count() const

Returns the count of the layout items.

[pure virtual] SafeRenderer::QSafeFontCache *QSafeLayout::fontCache() const

Returns a pointer to the font cache. This function is implemented in the inherited classes.

const SafeRenderer::LayoutData &QSafeLayout::getLayoutItem(const SafeRenderer::quint32 id) const

Returns SafeRenderer::LayoutData item idenfified by id.

The id value is the hash of the safe item's objectName in a QML UI Form file. In case of a item is not found, an exception will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item is not found.

For example:

SafePicture {
    objectName: "iconCoolant"
    width: 64
    height: 64
    color: "#e41e25"
    source: "qrc:/iso-icons/iso_grs_7000_4_2426.dat"
}

The ID value can be calculated as follows:

quint32 id = qt_hash("iconCoolant", safe_strlen("iconCoolant");

const SafeRenderer::QSafeStateTransition &QSafeLayout::getStateTransition(const SafeRenderer::quint32 indexArg)

Returns the QSafeStateTransition at indexArg

In case the indexArg is greater than the count of states SafeRenderer::QSafeStates::StatesException::IndexOutOfBounds is thrown.

SafeRenderer::LayoutData &QSafeLayout::item(const SafeRenderer::quint32 idx)

Returns the reference to LayoutData at idx.

bool QSafeLayout::itemIndex(const SafeRenderer::quint32 idArg, SafeRenderer::quint32 &indexArg) const

Returns true if idArg is found; otherwise returns false. The index of the layout item is identified by idArg. The index is set to indexArg.

SafeRenderer::quint32 QSafeLayout::layoutId() const

Getter function for the layout id.

LayoutId is a unique id for each layout instances. By default layoutId is the hash value of the layout filename.

See also setLayoutId().

SafeRenderer::QSafeLayout::LayoutParserState QSafeLayout::parserState() const

Returns the state of the parser.

SafeRenderer::QSafePoint QSafeLayout::position() const

Returns the position of the layout.

[pure virtual] const SafeRenderer::QSafeByteArray QSafeLayout::readDataFromFile(const SafeRenderer::qchar *const filenameArg)

Reads a file with filenameArg. Returns the reference to the read data. This function is implemented in the inherited classes.

void QSafeLayout::restartAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)

Restarts the stateIndexArg at transitionIndexArg.

void QSafeLayout::setAlphaForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint8 alphaArg)

Sets the alphaArg alpha value to the object identified by idArg.

In case of a failure, the following exceptions will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item idArg does not exist.

void QSafeLayout::setBitmapForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint32 bitmapIdArg)

Sets the bitmapIdArg value to the object identified by idArg.

In case of a failure, one of the following exceptions will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item idArg does not exist.
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapIdThe bitmap bitmapIdArg does not exist.
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBoundsThe bitmap goes outside the window boundaries

See also bitmapForItem().

void QSafeLayout::setColorForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::ARGB colorArg)

Sets the colorArg color to the object identified by idArg.

This method allows to change mutable objects' like picture's color.

In case of a failure, one of the following exceptions will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item idArg does not exist.

void QSafeLayout::setLayoutId(const SafeRenderer::quint32 &layoutIdArg)

Sets the layout id to the value layoutIdArg.

See also layoutId().

void QSafeLayout::setPositionForItem(const SafeRenderer::qchar *const name, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y)

Sets the x and y positions to the object named name.

In case of a failure, one of the following exceptions will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBoundsThe item's new position is outside the window boundaries.
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item name does not exist.
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapIdThe bitmap that is associated with the layout item is not found.

void QSafeLayout::setPositionForItem(const SafeRenderer::quint32 id, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y)

Sets the x and y positions to the object identified by id.

In case of a failure, one of the following exceptions will be thrown:

ConstantDescription
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBoundsThe bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS.
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBoundsThe item's new position is outside the window boundaries.
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item id does not exist.
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapIdThe bitmap that is associated with the layout item is not found.

void QSafeLayout::setTextForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::qchar *const textArg)

Sets the textArg text to the object identified by idArg.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item idArg does not exist.

SafeRenderer::QSafeSize QSafeLayout::size() const

Returns the size of the layout.

SafeRenderer::quint32 QSafeLayout::stateTransitionsCount() const

Returns the count of the states.

Available under certain Qt licenses.
Find out more.