.. include:: headings.inc .. _Size: ========================================================================================================================================== |phoenix_title| **Size** ========================================================================================================================================== A :ref:`Size` is a useful data structure for graphics operations. It simply contains integer `width` and `height` members. Note that the width and height stored inside a :ref:`Size` object may be negative and that :ref:`Size` functions do not perform any check against negative values (this is used to e.g. store the special -1 value in ``DefaultSize`` instance). See also :meth:`~Size.IsFullySpecified` and :meth:`~Size.SetDefaults` for utility functions regarding the special -1 value. :ref:`Size` is used throughout wxWidgets as well as :ref:`Point` which, although almost equivalent to :ref:`Size`, has a different meaning: :ref:`Point` represents a position while :ref:`Size` represents the size. .. seealso:: :ref:`Point`, :ref:`RealPoint` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **Size** .. raw:: html

Inheritance diagram of Size

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~Size.__init__` Initializes this size object with zero width and height. :meth:`~Size.DecBy` Decreases the size in both x and y directions. :meth:`~Size.DecTo` Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the `size`. :meth:`~Size.Get` Return the width and height properties as a tuple. :meth:`~Size.GetHeight` Gets the height member. :meth:`~Size.GetWidth` Gets the width member. :meth:`~Size.IncBy` Increases the size in both x and y directions. :meth:`~Size.IncTo` Increments this object so that both of its dimensions are not less than the corresponding dimensions of the `size`. :meth:`~Size.IsFullySpecified` Returns ``True`` if neither of the size object components is equal to -1, which is used as default for the size values in wxWidgets (hence the predefined ``DefaultSize`` has both of its components equal to -1). :meth:`~Size.Scale` Scales the dimensions of this object by the given factors. :meth:`~Size.Set` Sets the width and height members. :meth:`~Size.SetDefaults` Combine this size object with another one replacing the default (i.e. :meth:`~Size.SetHeight` Sets the height. :meth:`~Size.SetWidth` Sets the width. :meth:`~Size.__getitem__` :meth:`~Size.__len__` :meth:`~Size.__nonzero__` :meth:`~Size.__reduce__` :meth:`~Size.__repr__` :meth:`~Size.__setitem__` :meth:`~Size.__str__` :meth:`~Size.__imul__` :meth:`~Size.__iadd__` :meth:`~Size.__isub__` :meth:`~Size.__idiv__` ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~Size.Height` See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight` :attr:`~Size.Width` See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` :attr:`~Size.height` See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight` :attr:`~Size.width` See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` :attr:`~Size.x` See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` :attr:`~Size.y` See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: Size(object) A Size is a useful data structure for graphics operations. **Possible constructors**:: Size() Size(width, height) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Initializes this size object with zero width and height. **~~~** **__init__** `(self, width, height)` Initializes this size object with the given `width` and `height`. :param `width`: :type `width`: int :param `height`: :type `height`: int **~~~** .. method:: DecBy(self, *args, **kw) Decreases the size in both x and y directions. .. seealso:: :meth:`IncBy` |overload| **Overloaded Implementations**: **~~~** **DecBy** `(self, pt)` :param `pt`: :type `pt`: Point **~~~** **DecBy** `(self, size)` :param `size`: :type `size`: Size **~~~** **DecBy** `(self, dx, dy)` :param `dx`: :type `dx`: int :param `dy`: :type `dy`: int **~~~** **DecBy** `(self, d)` :param `d`: :type `d`: int **~~~** .. method:: DecTo(self, size) Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the `size`. :param `size`: :type `size`: Size .. seealso:: :meth:`IncTo` .. method:: Get(self) Return the width and height properties as a tuple. :rtype: `tuple` :returns: ( `width`, `height` ) .. method:: GetHeight(self) Gets the height member. :rtype: `int` .. method:: GetWidth(self) Gets the width member. :rtype: `int` .. method:: IncBy(self, *args, **kw) Increases the size in both x and y directions. .. seealso:: :meth:`DecBy` |overload| **Overloaded Implementations**: **~~~** **IncBy** `(self, pt)` :param `pt`: :type `pt`: Point **~~~** **IncBy** `(self, size)` :param `size`: :type `size`: Size **~~~** **IncBy** `(self, dx, dy)` :param `dx`: :type `dx`: int :param `dy`: :type `dy`: int **~~~** **IncBy** `(self, d)` :param `d`: :type `d`: int **~~~** .. method:: IncTo(self, size) Increments this object so that both of its dimensions are not less than the corresponding dimensions of the `size`. :param `size`: :type `size`: Size .. seealso:: :meth:`DecTo` .. method:: IsFullySpecified(self) Returns ``True`` if neither of the size object components is equal to -1, which is used as default for the size values in wxWidgets (hence the predefined ``DefaultSize`` has both of its components equal to -1). This method is typically used before calling :meth:`SetDefaults` . :rtype: `bool` .. method:: Scale(self, xscale, yscale) Scales the dimensions of this object by the given factors. If you want to scale both dimensions by the same factor you can also use :meth:`operator*=` . :param `xscale`: :type `xscale`: float :param `yscale`: :type `yscale`: float :rtype: :ref:`Size` :returns: A reference to this object (so that you can concatenate other operations in the same line). .. method:: Set(self, width, height) Sets the width and height members. :param `width`: :type `width`: int :param `height`: :type `height`: int .. method:: SetDefaults(self, sizeDefault) Combine this size object with another one replacing the default (i.e. equal to -1) components of this object with those of the other. It is typically used like this: :: if not size.IsFullySpecified(): size.SetDefaults(GetDefaultSize()) :param `sizeDefault`: :type `sizeDefault`: Size .. seealso:: :meth:`IsFullySpecified` .. method:: SetHeight(self, height) Sets the height. :param `height`: :type `height`: int .. method:: SetWidth(self, width) Sets the width. :param `width`: :type `width`: int .. method:: __getitem__(self, idx) .. method:: __len__(self) .. method:: __nonzero__(self) .. method:: __reduce__(self) .. method:: __repr__(self) .. method:: __setitem__(self, idx, val) .. method:: __str__(self) .. method:: __imul__(self) :param `factor`: :type `factor`: int .. method:: __iadd__(self) :param `sz`: :type `sz`: Size .. method:: __isub__(self) :param `sz`: :type `sz`: Size .. method:: __idiv__(self) :param `factor`: :type `factor`: int .. attribute:: Height See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight` .. attribute:: Width See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` .. attribute:: height See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight` .. attribute:: width See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` .. attribute:: x See :meth:`~Size.GetWidth` and :meth:`~Size.SetWidth` .. attribute:: y See :meth:`~Size.GetHeight` and :meth:`~Size.SetHeight`