wxWidgets: wxPoint Class Reference

| Version: 3.0.5

Public Member Functions | List of all members
wxPoint Class Reference
Class List by Category » Data Structures

`#include </home/Hamis/wxwidgets/wxWidgets3.0/wxWidgets3.0-3.0.5.1-2.i686/src/wxWidgets-3.0.5.1/interface/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

<>< =''>:</>&;&;< =''>\ </></>

Predefined objects/pointers: wxDefaultPosition

See also
  wxRealPoint

## 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.
int | x
| x member. More...
int | y
| y member. More...
bool | IsFullySpecified () const
| Returns true if neither of the point components is equal to wxDefaultCoord. More...
void | SetDefaults (const wxPoint &pt)
| Combine this object with another one replacing the uninitialized values. More...

## Public Member Functions
| wxPoint ()
| Constructs a point. More...
| wxPoint (int x, int y)
| Initializes the point object with the given x and y coordinates. More...
| wxPoint (const wxRealPoint &pt)
| Converts the given wxRealPoint (with floating point coordinates) to a wxPoint instance. More...
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 wxPoint they operate on as an explicit argument.
wxPoint & | operator= (const wxPoint &pt)
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)
wxPoint & | operator-= (const wxPoint &pt)
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 wxSize &sz)
wxPoint & | operator-= (const wxSize &sz)
wxSize | operator/ (const wxPoint &sz, int factor)
wxSize | operator* (const wxPoint &sz, int factor)
wxSize | operator* (int factor, const wxSize &sz)
wxSize & | operator/= (int factor)
wxSize & | operator*= (int factor)

## 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 this truncates the floating point values of pt components, if you want to round them instead you need to do it manually, e.g.

#include <wx/math.h> // for wxRound()
wxRealPoint rp = ...;
wxPoint p(wxRound(rp.x), wxRound(rp.y));
wxPoint
A wxPoint is a useful data structure for graphics operations.
Definition: gdicmn.h:591
wxRealPoint
A wxRealPoint is a useful data structure for graphics operations.
Definition: gdicmn.h:129
wxRealPoint::x
double x
X coordinate of this point.
Definition: gdicmn.h:186
wxRealPoint::y
double y
Y coordinate of this point.
Definition: gdicmn.h:191
math.h
wxRound
int wxRound(double x)
Small wrapper around round().

## 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!=()

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

## ◆ operator*() [1/2]

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

## ◆ operator*() [2/2]

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

## ◆ operator*=()

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

## ◆ operator+() [1/3]

wxPoint wxPoint::operator+ | ( | const wxPoint & | p1,
|  | const wxPoint & | p2
| ) |  |

## ◆ operator+() [2/3]

wxPoint wxPoint::operator+ | ( | const wxPoint & | pt,
|  | const wxSize & | sz
| ) |  |

## ◆ operator+() [3/3]

wxPoint wxPoint::operator+ | ( | const wxSize & | sz,
|  | const wxPoint & | pt
| ) |  |

## ◆ operator+=() [1/2]

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

## ◆ operator+=() [2/2]

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

## ◆ operator-() [1/3]

wxPoint wxPoint::operator- | ( | const wxPoint & | p1,
|  | const wxPoint & | p2
| ) |  |

## ◆ operator-() [2/3]

wxPoint wxPoint::operator- | ( | const wxPoint & | pt,
|  | const wxSize & | sz
| ) |  |

## ◆ operator-() [3/3]

wxPoint wxPoint::operator- | ( | const wxSize & | sz,
|  | const wxPoint & | pt
| ) |  |

## ◆ operator-=() [1/2]

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

## ◆ operator-=() [2/2]

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

## ◆ operator/()

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

## ◆ operator/=()

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

## ◆ operator=()

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

## ◆ operator==()

bool wxPoint::operator== | ( | const wxPoint & | p1,
|  | const wxPoint & | p2
| ) |  |

## ◆ 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

## Member Data Documentation

## ◆ x

int wxPoint::x

x member.

## ◆ y

int wxPoint::y

y member.