Skip to content

Commit

Permalink
Expose some more classes to Python, but mark as unstable API
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 12, 2020
1 parent 0e13999 commit cb1e844
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 4 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_additions/qgstextcharacterformat.py
@@ -0,0 +1,7 @@
# The following has been generated automatically from src/core/textrenderer/qgstextcharacterformat.h
# monkey patching scoped based enum
QgsTextCharacterFormat.BooleanValue.NotSet.__doc__ = "Property is not set"
QgsTextCharacterFormat.BooleanValue.True.__doc__ = "Property is set and ``True``"
QgsTextCharacterFormat.BooleanValue.False.__doc__ = "Property is set and ``False``"
QgsTextCharacterFormat.BooleanValue.__doc__ = 'Status values for boolean format properties\n\n' + '* ``NotSet``: ' + QgsTextCharacterFormat.BooleanValue.NotSet.__doc__ + '\n' + '* ``True``: ' + QgsTextCharacterFormat.BooleanValue.True.__doc__ + '\n' + '* ``False``: ' + QgsTextCharacterFormat.BooleanValue.False.__doc__
# --
122 changes: 122 additions & 0 deletions python/core/auto_generated/textrenderer/qgstextcharacterformat.sip.in
@@ -0,0 +1,122 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/textrenderer/qgstextcharacterformat.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsTextCharacterFormat
{
%Docstring
Stores information relating to individual character formatting.

These options encapsulate formatting options which override the default
settings from a QgsTextFormat for individual characters (or sets of characters).

.. warning::

This API is not considered stable and may change in future QGIS versions.

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgstextcharacterformat.h"
%End
public:

QgsTextCharacterFormat();

QgsTextCharacterFormat( const QTextCharFormat &format );
%Docstring
Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat ``format``.
%End

enum class BooleanValue
{
NotSet,
True,
False,
};

QColor textColor() const;
%Docstring
Returns the character's text color, or an invalid color if no color override
is set and the default format color should be used.

.. seealso:: :py:func:`setTextColor`
%End

void setTextColor( const QColor &textColor );
%Docstring
Sets the character's text ``color``.

Set ``color`` to an invalid color if no color override
is desired and the default format color should be used.

.. seealso:: :py:func:`textColor`
%End


BooleanValue strikeOut() const;
%Docstring
Returns whether the format has strikethrough enabled.

.. seealso:: :py:func:`setStrikeOut`
%End

void setStrikeOut( BooleanValue enabled );
%Docstring
Sets whether the format has strikethrough ``enabled``.

.. seealso:: :py:func:`strikeOut`
%End

BooleanValue underline() const;
%Docstring
Returns whether the format has underline enabled.

.. seealso:: :py:func:`setUnderline`
%End

void setUnderline( BooleanValue enabled );
%Docstring
Sets whether the format has underline ``enabled``.

.. seealso:: :py:func:`underline`
%End

BooleanValue overline() const;
%Docstring
Returns whether the format has overline enabled.

.. seealso:: :py:func:`setUnderline`
%End

void setOverline( BooleanValue enabled );
%Docstring
Sets whether the format has overline ``enabled``.

.. seealso:: :py:func:`overline`
%End

void updateFontForFormat( QFont &font ) const;
%Docstring
Updates the specified ``font`` in place, applying character formatting options which
are applicable on a font level.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/textrenderer/qgstextcharacterformat.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
84 changes: 84 additions & 0 deletions python/core/auto_generated/textrenderer/qgstextfragment.sip.in
@@ -0,0 +1,84 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/textrenderer/qgstextfragment.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsTextFragment
{
%Docstring
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.

.. warning::

This API is not considered stable and may change in future QGIS versions.

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgstextfragment.h"
%End
public:

explicit QgsTextFragment( const QString &text, const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
%Docstring
Constructor for QgsTextFragment, with the specified ``text`` and optional character ``format``.
%End

explicit QgsTextFragment( const QTextFragment &fragment );
%Docstring
Constructor for QgsTextFragment, based on the specified QTextFragment ``fragment``.
%End

QString text() const;
%Docstring
Returns the text content of the fragment.

.. seealso:: :py:func:`setText`
%End

void setText( const QString &text );
%Docstring
Sets the ``text`` content of the fragment.

.. seealso:: :py:func:`text`
%End

const QgsTextCharacterFormat &characterFormat() const;
%Docstring
Returns the character formatting for the fragment.

.. seealso:: :py:func:`setCharacterFormat`
%End

void setCharacterFormat( const QgsTextCharacterFormat &format );
%Docstring
Sets the character ``format`` for the fragment.

.. seealso:: :py:func:`characterFormat`
%End

double horizontalAdvance( const QFont &font, bool fontHasBeenUpdatedForFragment = false ) const;
%Docstring
Returns the horizontal advance associated with this fragment, when rendered using
the specified base ``font``.

Set ``fontHasBeenUpdatedForFragment`` to ``True`` if ``font`` already represents the character
format for this fragment.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/textrenderer/qgstextfragment.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions python/core/core_auto.sip
Expand Up @@ -548,8 +548,10 @@
%Include auto_generated/textrenderer/qgstextbackgroundsettings.sip
%Include auto_generated/textrenderer/qgstextblock.sip
%Include auto_generated/textrenderer/qgstextbuffersettings.sip
%Include auto_generated/textrenderer/qgstextcharacterformat.sip
%Include auto_generated/textrenderer/qgstextdocument.sip
%Include auto_generated/textrenderer/qgstextformat.sip
%Include auto_generated/textrenderer/qgstextfragment.sip
%Include auto_generated/textrenderer/qgstextmasksettings.sip
%Include auto_generated/textrenderer/qgstextrenderer.sip
%Include auto_generated/textrenderer/qgstextrendererutils.sip
Expand Down
4 changes: 2 additions & 2 deletions src/core/textrenderer/qgstextcharacterformat.h
Expand Up @@ -24,8 +24,6 @@

class QTextCharFormat;

#define SIP_NO_FILE

/**
* \class QgsTextCharacterFormat
* \ingroup core
Expand All @@ -34,6 +32,8 @@ class QTextCharFormat;
* These options encapsulate formatting options which override the default
* settings from a QgsTextFormat for individual characters (or sets of characters).
*
* \warning This API is not considered stable and may change in future QGIS versions.
*
* \since QGIS 3.14
*/
class CORE_EXPORT QgsTextCharacterFormat
Expand Down
4 changes: 2 additions & 2 deletions src/core/textrenderer/qgstextfragment.h
Expand Up @@ -22,13 +22,13 @@

class QTextFragment;

#define SIP_NO_FILE

/**
* \class QgsTextFragment
* \ingroup core
* Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
*
* \warning This API is not considered stable and may change in future QGIS versions.
*
* \since QGIS 3.14
*/
class CORE_EXPORT QgsTextFragment
Expand Down

0 comments on commit cb1e844

Please sign in to comment.