wxWidgets: wxSize Class Reference

| Version: 3.0.2

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
wxSize Class Reference
Data Structures

`#include <wx/gdicmn.h>`

## Detailed Description

A wxSize 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 wxSize object may be negative and that wxSize functions do not perform any check against negative values (this is used to e.g. store the special -1 value in wxDefaultSize instance). See also IsFullySpecified() and SetDefaults() for utility functions regarding the special -1 value.

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

##

Library: wxCore
Category: Data Structures

Predefined objects/pointers: wxDefaultSize

See Also
  wxPoint, wxRealPoint

## Public Member Functions
| wxSize ()
| Initializes this size object with zero width and height.
| wxSize (int width, int height)
| Initializes this size object with the given width and height.
void | DecTo (const wxSize &size)
| Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.
void | DecToIfSpecified (const wxSize &size)
| Decrements this object to be not bigger than the given size ignoring non-specified components.
int | GetHeight () const
| Gets the height member.
int | GetWidth () const
| Gets the width member.
void | IncTo (const wxSize &size)
| Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size.
bool | IsFullySpecified () const
| 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 wxDefaultSize has both of its components equal to -1).
wxSize & | Scale (float xscale, float yscale)
| Scales the dimensions of this object by the given factors.
void | Set (int width, int height)
| Sets the width and height members.
void | SetDefaults (const wxSize &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.
void | SetHeight (int height)
| Sets the height.
void | SetWidth (int width)
| Sets the width.
void | DecBy (const wxPoint &pt)
| Decreases the size in both x and y directions.
void | DecBy (const wxSize &size)
| Decreases the size in both x and y directions.
void | DecBy (int dx, int dy)
| Decreases the size in both x and y directions.
void | DecBy (int d)
| Decreases the size in both x and y directions.
void | IncBy (const wxPoint &pt)
| Increases the size in both x and y directions.
void | IncBy (const wxSize &size)
| Increases the size in both x and y directions.
void | IncBy (int dx, int dy)
| Increases the size in both x and y directions.
void | IncBy (int d)
| Increases the size in both x and y directions.
Miscellaneous operators
Note that these operators are documented as class members (to make them easier to find) but, as their prototype shows, they are implemented as global operators; note that this is transparent to the user but it helps to understand why the following functions are documented to take the wxSize they operate on as an explicit argument.
wxSize & | operator= (const wxSize &sz)
bool | operator== (const wxSize &s1, const wxSize &s2)
bool | operator!= (const wxSize &s1, const wxSize &s2)
wxSize | operator+ (const wxSize &s1, const wxSize &s2)
wxSize | operator- (const wxSize &s1, const wxSize &s2)
wxSize & | operator+= (const wxSize &sz)
wxSize & | operator-= (const wxSize &sz)
wxSize | operator/ (const wxSize &sz, int factor)
wxSize | operator* (const wxSize &sz, int factor)
wxSize | operator* (int factor, const wxSize &sz)
wxSize & | operator/= (int factor)
wxSize & | operator*= (int factor)

## Constructor & Destructor Documentation

wxSize::wxSize | ( |  | ) |

Initializes this size object with zero width and height.

wxSize::wxSize | ( | int | width,
|  | int | height
| ) |  |

Initializes this size object with the given width and height.

## Member Function Documentation

void wxSize::DecBy | ( | const wxPoint & | pt | ) |

Decreases the size in both x and y directions.

See Also
  IncBy()

void wxSize::DecBy | ( | const wxSize & | size | ) |

Decreases the size in both x and y directions.

See Also
  IncBy()

void wxSize::DecBy | ( | int | dx,
|  | int | dy
| ) |  |

Decreases the size in both x and y directions.

See Also
  IncBy()

void wxSize::DecBy | ( | int | d | ) |

Decreases the size in both x and y directions.

See Also
  IncBy()

void wxSize::DecTo | ( | const wxSize & | size | ) |

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

See Also
  IncTo()

void wxSize::DecToIfSpecified | ( | const wxSize & | size | ) |

Decrements this object to be not bigger than the given size ignoring non-specified components.

This is similar to DecTo() but doesn't do anything for x or y component if the same component of size is not specified, i.e. set to wxDefaultCoord.

Since
  2.9.5

int wxSize::GetHeight | ( |  | ) | const

Gets the height member.

int wxSize::GetWidth | ( |  | ) | const

Gets the width member.

void wxSize::IncBy | ( | const wxPoint & | pt | ) |

Increases the size in both x and y directions.

See Also
  DecBy()

void wxSize::IncBy | ( | const wxSize & | size | ) |

Increases the size in both x and y directions.

See Also
  DecBy()

void wxSize::IncBy | ( | int | dx,
|  | int | dy
| ) |  |

Increases the size in both x and y directions.

See Also
  DecBy()

void wxSize::IncBy | ( | int | d | ) |

Increases the size in both x and y directions.

See Also
  DecBy()

void wxSize::IncTo | ( | const wxSize & | size | ) |

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

See Also
  DecTo()

bool wxSize::IsFullySpecified | ( |  | ) | const

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 wxDefaultSize has both of its components equal to -1).

This method is typically used before calling SetDefaults().

bool wxSize::operator!= | ( | const wxSize & | s1,
|  | const wxSize & | s2
| ) |  |

wxSize wxSize::operator* | ( | const wxSize & | sz,
|  | int | factor
| ) |  |

wxSize wxSize::operator* | ( | int | factor,
|  | const wxSize & | sz
| ) |  |

wxSize& wxSize::operator*= | ( | int | factor | ) |

wxSize wxSize::operator+ | ( | const wxSize & | s1,
|  | const wxSize & | s2
| ) |  |

wxSize& wxSize::operator+= | ( | const wxSize & | sz | ) |

wxSize wxSize::operator- | ( | const wxSize & | s1,
|  | const wxSize & | s2
| ) |  |

wxSize& wxSize::operator-= | ( | const wxSize & | sz | ) |

wxSize wxSize::operator/ | ( | const wxSize & | sz,
|  | int | factor
| ) |  |

wxSize& wxSize::operator/= | ( | int | factor | ) |

wxSize& wxSize::operator= | ( | const wxSize & | sz | ) |

bool wxSize::operator== | ( | const wxSize & | s1,
|  | const wxSize & | s2
| ) |  |

wxSize& wxSize::Scale | ( | float | xscale,
|  | float | 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*=().

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

void wxSize::Set | ( | int | width,
|  | int | height
| ) |  |

Sets the width and height members.

void wxSize::SetDefaults | ( | const wxSize & | 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 ( !size.IsFullySpecified() )
{
size.SetDefaults(GetDefaultSize());
}

See Also
  IsFullySpecified()

void wxSize::SetHeight | ( | int | height | ) |

Sets the height.

void wxSize::SetWidth | ( | int | width | ) |

Sets the width.