Table Of Contents

Previous topic

SingleInstanceChecker

Next topic

SizeEvent

This Page

phoenix_title Size

A 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 Size object may be negative and that 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 IsFullySpecified and SetDefaults for utility functions regarding the special -1 value.

Size is used throughout wxWidgets as well as Point which, although almost equivalent to Size, has a different meaning: Point represents a position while Size represents the size.

See also

Point, RealPoint


class_hierarchy Inheritance Diagram

Inheritance diagram for class Size

Inheritance diagram of Size


method_summary Methods Summary

__init__ Initializes this size object with zero width and height.
DecBy Decreases the size in both x and y directions.
DecTo Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.
Get Return the width and height properties as a tuple.
GetHeight Gets the height member.
GetWidth Gets the width member.
IncBy Increases the size in both x and y directions.
IncTo Increments this object so that both of its dimensions are not less than the corresponding dimensions of the 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).
Scale Scales the dimensions of this object by the given factors.
Set Sets the width and height members.
SetDefaults Combine this size object with another one replacing the default (i.e.
SetHeight Sets the height.
SetWidth Sets the width.
__getitem__  
__len__  
__nonzero__  
__reduce__  
__repr__  
__setitem__  
__str__  
__imul__  
__iadd__  
__isub__  
__idiv__  

property_summary Properties Summary

Height See GetHeight and SetHeight
Width See GetWidth and SetWidth
height See GetHeight and SetHeight
width See GetWidth and SetWidth
x See GetWidth and SetWidth
y See GetHeight and SetHeight

api Class API



class Size(object)

A Size is a useful data structure for graphics operations.

Possible constructors:

Size()

Size(width, height)

Methods



__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.

Parameters:
  • width (int) –
  • height (int) –





DecBy(self, *args, **kw)

Decreases the size in both x and y directions.

See also

IncBy


overload Overloaded Implementations:



DecBy (self, pt)

Parameters:pt (Point) –



DecBy (self, size)

Parameters:size (Size) –



DecBy (self, dx, dy)

Parameters:
  • dx (int) –
  • dy (int) –



DecBy (self, d)

Parameters:d (int) –





DecTo(self, size)

Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.

Parameters:size (Size) –

See also

IncTo



Get(self)

Return the width and height properties as a tuple.

Return type:tuple
Returns:( width, height )


GetHeight(self)

Gets the height member.

Return type:int


GetWidth(self)

Gets the width member.

Return type:int


IncBy(self, *args, **kw)

Increases the size in both x and y directions.

See also

DecBy


overload Overloaded Implementations:



IncBy (self, pt)

Parameters:pt (Point) –



IncBy (self, size)

Parameters:size (Size) –



IncBy (self, dx, dy)

Parameters:
  • dx (int) –
  • dy (int) –



IncBy (self, d)

Parameters:d (int) –





IncTo(self, size)

Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size.

Parameters:size (Size) –

See also

DecTo



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 SetDefaults .

Return type:bool


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 operator*= .

Parameters:
  • xscale (float) –
  • yscale (float) –
Return type:

Size

Returns:

A reference to this object (so that you can concatenate other operations in the same line).



Set(self, width, height)

Sets the width and height members.

Parameters:
  • width (int) –
  • height (int) –


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())
Parameters:sizeDefault (Size) –

See also

IsFullySpecified



SetHeight(self, height)

Sets the height.

Parameters:height (int) –


SetWidth(self, width)

Sets the width.

Parameters:width (int) –


__getitem__(self, idx)


__len__(self)


__nonzero__(self)


__reduce__(self)


__repr__(self)


__setitem__(self, idx, val)


__str__(self)


__imul__(self)
Parameters:factor (int) –


__iadd__(self)
Parameters:sz (Size) –


__isub__(self)
Parameters:sz (Size) –


__idiv__(self)
Parameters:factor (int) –

Properties



Height

See GetHeight and SetHeight



Width

See GetWidth and SetWidth



height

See GetHeight and SetHeight



width

See GetWidth and SetWidth



x

See GetWidth and SetWidth



y

See GetHeight and SetHeight