1/* 2 * Copyright 2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 * 8 * Corresponds to: 9 * headers/os/interface/Point.h hrev47234 10 * src/kits/interface/Point.cpp hrev47234 11 */ 12 13 14/*! 15 \file Point.h 16 \ingroup interface 17 \ingroup libbe 18 \brief BPoint class definition. 19*/ 20 21 22/*! 23 \var B_ORIGIN 24 \brief The origin point, equivalent to BPoint(0, 0). 25 26 \since BeOS R5 27*/ 28 29 30/*! 31 \class BPoint 32 \ingroup interface 33 \ingroup libbe 34 \brief A point on a two-dimensional Cartesian coordinate system. 35 36 \since BeOS R3 37*/ 38 39 40/*! 41 \var BPoint::x 42 \brief The horizontal coordinate. 43 44 \since BeOS R3 45*/ 46 47 48/*! 49 \var BPoint::y 50 \brief The vertical coordinate. 51 52 \since BeOS R3 53*/ 54 55 56/*! 57 \fn inline BPoint::BPoint() 58 \brief Initializes a BPoint object at the origin, (0, 0). 59 60 \see BPoint::Set() 61 62 \since BeOS R3 63*/ 64 65 66/*! 67 \fn inline BPoint::BPoint(float x, float y) 68 \brief Initializes a BPoint object at the specified \a x and 69 \a y coordinates. 70 71 \param x The \a x coordinate. 72 \param y The \a y coordinate. 73 74 \since BeOS R3 75*/ 76 77 78/*! 79 \fn inline BPoint::BPoint(const BPoint& other) 80 \brief Initializes a BPoint object from another BPoint. 81 82 \param other The BPoint object to copy from. 83 84 \since BeOS R3 85*/ 86 87 88/*! 89 \fn inline void BPoint::Set(float x, float y) 90 \brief Sets the \a x and \a y coordinates of a BPoint object. 91 92 \param x The \a x coordinate to set. 93 \param y The \a y coordinate to set. 94 95 \since BeOS R3 96*/ 97 98 99/*! 100 \fn void BPoint::ConstrainTo(BRect rect) 101 \brief Moves the BPoint so that it is contained within \a rect. 102 103 If the BPoint is already contained within \a rect this method has no 104 effect. 105 106 \param rect The BRect to constrain the BPoint within. 107 108 \since BeOS R3 109*/ 110 111 112/*! 113 \fn void BPoint::PrintToStream() const 114 \brief Print the x and y coordinates to standard output. 115 116 Prints in the following format: 117 118\verbatim 119BPoint(x:%.0f, y:%.0f) 120\endverbatim 121 122 \since BeOS R3 123*/ 124 125 126/*! 127 \name Operators 128*/ 129 130 131//! @{ 132 133 134/*! 135 \fn inline BPoint& BPoint::operator=(const BPoint& other) 136 \brief Initializes a BPoint object from another BPoint by overloading 137 the = operator. 138 139 \param other The BPoint object to copy from. 140 141 \since BeOS R3 142*/ 143 144 145/*! 146 \fn BPoint BPoint::operator-() const 147 \brief Returns a BPoint object with the x and y coordinates negated. 148 149 \return A new BPoint object. 150 151 \since BeOS R3 152*/ 153 154 155/*! 156 \fn BPoint BPoint::operator+(const BPoint& other) const 157 \brief Returns a BPoint where the x-coordinate is the sum of the x values 158 and the y-coordinate is the sum of the y values. 159 160 \param other The BPoint object to use in the addition. 161 162 \return A new BPoint object. 163 164 \since BeOS R3 165*/ 166 167 168/*! 169 \fn BPoint BPoint::operator-(const BPoint& other) const 170 \brief Returns a BPoint where the x-coordinate is the difference of the 171 x values and the y-coordinate is the difference of the y values. 172 173 \param other The BPoint object to use in the subtraction. 174 175 \return A new BPoint object. 176 177 \since BeOS R3 178*/ 179 180 181/*! 182 \fn BPoint& BPoint::operator+=(const BPoint& other) 183 \brief Uses the BPoint as an accumulator storing the sum of the x values 184 and the sum of the y values. 185 186 \param other The BPoint object to use in the addition. 187 188 \return The address of the BPoint object. 189 190 \since BeOS R3 191*/ 192 193 194/*! 195 \fn BPoint& BPoint::operator-=(const BPoint& other) 196 \brief Uses the BPoint as an accumulator storing the difference of the x 197 values and the difference of the y values. 198 199 \param other The BPoint object to use in the subtraction. 200 201 \return The address of the BPoint object. 202 203 \since BeOS R3 204*/ 205 206 207/*! 208 \fn bool BPoint::operator!=(const BPoint& other) const 209 \brief Returns whether or not the x and y coordinates of the BPoint 210 objects differ. 211 212 \return \c true if the x or y coordinates differ, \c false otherwise. 213 214 \since BeOS R3 215*/ 216 217 218/*! 219 \fn bool BPoint::operator==(const BPoint& other) const 220 \brief Returns whether or not the x and y coordinates of the BPoint 221 objects are equal. 222 223 \return \c true if the x and y coordinates are equal, \c false otherwise. 224 225 \since BeOS R3 226*/ 227 228 229//! @} 230