Version: 3.3.1
Loading...
Searching...
No Matches

#include <wx/gdicmn.h>

Detailed Description

A wxPoint is a useful data structure for graphics operations.

It contains integer x and y members. See wxRealPoint for a floating point version.

Note that the width and height stored inside a wxPoint object may be negative and that wxPoint functions do not perform any check against negative values (this is used to e.g. store the special -1 value in wxDefaultPosition instance).

Library:  wxCore
Category:  Data Structures

Predefined objects/pointers: wxDefaultPosition

See also
wxRealPoint

Miscellaneous operators

Note that binary operators are defined as friend functions inside this class, making them accessible via argument-dependent lookup, but hidden otherwise.

wxPointoperator= (const wxPoint &pt)
wxPointoperator+= (const wxPoint &pt)
wxPointoperator-= (const wxPoint &pt)
wxPointoperator+= (const wxSize &sz)
wxPointoperator-= (const wxSize &sz)
wxPoint operator- (const wxPoint &pt)
wxPointoperator/= (int divisor)
wxPointoperator*= (int factor)
wxPointoperator/= (double divisor)
wxPointoperator*= (double factor)
bool operator== (const wxPoint &p1, const wxPoint &p2)
bool operator!= (const wxPoint &p1, const wxPoint &p2)
wxPoint operator+ (const wxPoint &p1, const wxPoint &p2)
wxPoint operator- (const wxPoint &p1, const wxPoint &p2)
wxPoint operator+ (const wxPoint &pt, const wxSize &sz)
wxPoint operator- (const wxPoint &pt, const wxSize &sz)
wxPoint operator+ (const wxSize &sz, const wxPoint &pt)
wxPoint operator- (const wxSize &sz, const wxPoint &pt)
wxPoint operator/ (const wxPoint &sz, int divisor)
wxPoint operator* (const wxPoint &sz, int factor)
wxPoint operator* (int factor, const wxPoint &sz)
wxPoint operator/ (const wxPoint &pt, double divisor)
wxPoint operator* (const wxPoint &pt, double factor)
wxPoint operator* (double factor, const wxPoint &pt)

Public Member Functions

 wxPoint ()
 Constructs a point.
 wxPoint (int x, int y)
 Initializes the point object with the given x and y coordinates.
 wxPoint (const wxRealPoint &pt)
 Converts the given wxRealPoint (with floating point coordinates) to a wxPoint instance.
Defaults handling.

Test for and set non-specified wxPoint components.

Although a wxPoint is always initialized to (0, 0), wxWidgets commonly uses wxDefaultCoord (defined as -1) to indicate that a point hasn't been initialized or specified. In particular, wxDefaultPosition is used in many places with this meaning.

bool IsFullySpecified () const
 Returns true if neither of the point components is equal to wxDefaultCoord.
void SetDefaults (const wxPoint &pt)
 Combine this object with another one replacing the uninitialized values.

Static Public Member Functions

static wxPoint Round (const wxRealPoint &pt)
 Creates a wxPoint by rounding the coordinates of the given wxRealPoint.
static wxPoint Truncate (const wxRealPoint &pt)
 Creates a wxPoint by truncating the coordinates of the given wxRealPoint.

Public Attributes

int x
 x member.
int y
 y member.

Constructor & Destructor Documentation

◆ wxPoint() [1/3]

wxPoint::wxPoint ( )

Constructs a point.

Initializes the internal x and y coordinates to zero.

◆ wxPoint() [2/3]

wxPoint::wxPoint ( int x,
int y )

Initializes the point object with the given x and y coordinates.

◆ wxPoint() [3/3]

wxPoint::wxPoint ( const wxRealPoint & pt)

Converts the given wxRealPoint (with floating point coordinates) to a wxPoint instance.

Notice that since v3.1.2 the behaviour of this constructor has changed to round the floating point values of pt components, if you want to truncate them instead, please use wxPoint::Truncate().

Member Function Documentation

◆ IsFullySpecified()

bool wxPoint::IsFullySpecified ( ) const

Returns true if neither of the point components is equal to wxDefaultCoord.

This method is typically used before calling SetDefaults().

Since
2.9.2

◆ operator*=() [1/2]

wxPoint & wxPoint::operator*= ( double factor)

◆ operator*=() [2/2]

wxPoint & wxPoint::operator*= ( int factor)

◆ operator+=() [1/2]

wxPoint & wxPoint::operator+= ( const wxPoint & pt)

◆ operator+=() [2/2]

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

◆ operator-()

wxPoint wxPoint::operator- ( const wxPoint & pt)

◆ operator-=() [1/2]

wxPoint & wxPoint::operator-= ( const wxPoint & pt)

◆ operator-=() [2/2]

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

◆ operator/=() [1/2]

wxPoint & wxPoint::operator/= ( double divisor)

◆ operator/=() [2/2]

wxPoint & wxPoint::operator/= ( int divisor)

◆ operator=()

wxPoint & wxPoint::operator= ( const wxPoint & pt)

◆ Round()

wxPoint wxPoint::Round ( const wxRealPoint & pt)
static

Creates a wxPoint by rounding the coordinates of the given wxRealPoint.

This is equivalent to using the constructor taking wxRealPoint but is more explicit about the fact that rounding is performed.

Since
3.3.2

◆ SetDefaults()

void wxPoint::SetDefaults ( const wxPoint & pt)

Combine this object with another one replacing the uninitialized values.

It is typically used like this:

if ( !pos.IsFullySpecified() )
{
pos.SetDefaults(GetDefaultPosition());
}
See also
IsFullySpecified()
Since
2.9.2

◆ Truncate()

wxPoint wxPoint::Truncate ( const wxRealPoint & pt)
static

Creates a wxPoint by truncating the coordinates of the given wxRealPoint.

This is similar to Round() but instead of rounding the coordinates, they are simply truncated to integers.

Since
3.3.2

◆ operator!=

bool operator!= ( const wxPoint & p1,
const wxPoint & p2 )
friend

◆ operator* [1/4]

wxPoint operator* ( const wxPoint & pt,
double factor )
friend

◆ operator* [2/4]

wxPoint operator* ( const wxPoint & sz,
int factor )
friend

◆ operator* [3/4]

wxPoint operator* ( double factor,
const wxPoint & pt )
friend

◆ operator* [4/4]

wxPoint operator* ( int factor,
const wxPoint & sz )
friend

◆ operator+ [1/3]

wxPoint operator+ ( const wxPoint & p1,
const wxPoint & p2 )
friend

◆ operator+ [2/3]

wxPoint operator+ ( const wxPoint & pt,
const wxSize & sz )
friend

◆ operator+ [3/3]

wxPoint operator+ ( const wxSize & sz,
const wxPoint & pt )
friend

◆ operator- [1/3]

wxPoint operator- ( const wxPoint & p1,
const wxPoint & p2 )
friend

◆ operator- [2/3]

wxPoint operator- ( const wxPoint & pt,
const wxSize & sz )
friend

◆ operator- [3/3]

wxPoint operator- ( const wxSize & sz,
const wxPoint & pt )
friend

◆ operator/ [1/2]

wxPoint operator/ ( const wxPoint & pt,
double divisor )
friend

◆ operator/ [2/2]

wxPoint operator/ ( const wxPoint & sz,
int divisor )
friend

◆ operator==

bool operator== ( const wxPoint & p1,
const wxPoint & p2 )
friend

Member Data Documentation

◆ x

int wxPoint::x

x member.

◆ y

int wxPoint::y

y member.