///////////////////////////////////////////////////////////////////////////// // Name: gdicmn.h // Purpose: interface of wxRealPoint // Author: wxWidgets team // RCS-ID: $Id$ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** Bitmap type flags. See wxBitmap and wxImage classes. */ enum wxBitmapType { wxBITMAP_TYPE_INVALID, wxBITMAP_TYPE_BMP, wxBITMAP_TYPE_BMP_RESOURCE, wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE, wxBITMAP_TYPE_ICO, wxBITMAP_TYPE_ICO_RESOURCE, wxBITMAP_TYPE_CUR, wxBITMAP_TYPE_CUR_RESOURCE, wxBITMAP_TYPE_XBM, wxBITMAP_TYPE_XBM_DATA, wxBITMAP_TYPE_XPM, wxBITMAP_TYPE_XPM_DATA, wxBITMAP_TYPE_TIF, wxBITMAP_TYPE_TIF_RESOURCE, wxBITMAP_TYPE_GIF, wxBITMAP_TYPE_GIF_RESOURCE, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_PNG_RESOURCE, wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_JPEG_RESOURCE, wxBITMAP_TYPE_PNM, wxBITMAP_TYPE_PNM_RESOURCE, wxBITMAP_TYPE_PCX, wxBITMAP_TYPE_PCX_RESOURCE, wxBITMAP_TYPE_PICT, wxBITMAP_TYPE_PICT_RESOURCE, wxBITMAP_TYPE_ICON, wxBITMAP_TYPE_ICON_RESOURCE, wxBITMAP_TYPE_ANI, wxBITMAP_TYPE_IFF, wxBITMAP_TYPE_TGA, wxBITMAP_TYPE_MACCURSOR, wxBITMAP_TYPE_MACCURSOR_RESOURCE, wxBITMAP_TYPE_ANY = 50 }; /** Polygon filling mode. See wxDC::DrawPolygon. */ enum wxPolygonFillMode { wxODDEVEN_RULE = 1, wxWINDING_RULE }; /** Standard cursors. Notice that under wxMSW some of these cursors are defined in @c wx.rc file and not by the system itself so you should include this file from your own resource file (possibly creating a trivial resource file just containing a single include line if you don't need it otherwise) to be able to use them. See wxCursor. */ enum wxStockCursor { wxCURSOR_NONE, wxCURSOR_ARROW, ///< A standard arrow cursor. wxCURSOR_RIGHT_ARROW, ///< A standard arrow cursor pointing to the right. wxCURSOR_BULLSEYE, ///< Bullseye cursor. wxCURSOR_CHAR, ///< Rectangular character cursor. wxCURSOR_CROSS, ///< A cross cursor. wxCURSOR_HAND, ///< A hand cursor. wxCURSOR_IBEAM, ///< An I-beam cursor (vertical line). wxCURSOR_LEFT_BUTTON, ///< Represents a mouse with the left button depressed. wxCURSOR_MAGNIFIER, ///< A magnifier icon. wxCURSOR_MIDDLE_BUTTON, ///< Represents a mouse with the middle button depressed. wxCURSOR_NO_ENTRY, ///< A no-entry sign cursor. wxCURSOR_PAINT_BRUSH, ///< A paintbrush cursor. wxCURSOR_PENCIL, ///< A pencil cursor. wxCURSOR_POINT_LEFT, ///< A cursor that points left. wxCURSOR_POINT_RIGHT, ///< A cursor that points right. wxCURSOR_QUESTION_ARROW, ///< An arrow and question mark. wxCURSOR_RIGHT_BUTTON, ///< Represents a mouse with the right button depressed. wxCURSOR_SIZENESW, ///< A sizing cursor pointing NE-SW. wxCURSOR_SIZENS, ///< A sizing cursor pointing N-S. wxCURSOR_SIZENWSE, ///< A sizing cursor pointing NW-SE. wxCURSOR_SIZEWE, ///< A sizing cursor pointing W-E. wxCURSOR_SIZING, ///< A general sizing cursor. wxCURSOR_SPRAYCAN, ///< A spraycan cursor. wxCURSOR_WAIT, ///< A wait cursor. wxCURSOR_WATCH, ///< A watch cursor. wxCURSOR_BLANK, ///< Transparent cursor. wxCURSOR_DEFAULT, ///< Standard X11 cursor (only in wxGTK). wxCURSOR_COPY_ARROW , ///< MacOS Theme Plus arrow (only in wxMac). wxCURSOR_CROSS_REVERSE, ///< Only available on wxX11. wxCURSOR_DOUBLE_ARROW, ///< Only available on wxX11. wxCURSOR_BASED_ARROW_UP, ///< Only available on wxX11. wxCURSOR_BASED_ARROW_DOWN, ///< Only available on wxX11. wxCURSOR_ARROWWAIT, ///< A wait cursor with a standard arrow. wxCURSOR_MAX }; /** @class wxRealPoint A wxRealPoint is a useful data structure for graphics operations. It contains floating point @e x and @e y members. See wxPoint for an integer version. Note that the coordinates stored inside a wxRealPoint object may be negative and that wxRealPoint functions do not perform any check against negative values. @library{wxcore} @category{data} @see wxPoint */ class wxRealPoint { public: /** Initializes to zero the x and y members. */ wxRealPoint(); /** Initializes the point with the given coordinates. */ wxRealPoint(double x, double y); /** Converts the given wxPoint (with integer coordinates) to a wxRealPoint. */ wxRealPoint(const wxPoint& pt); /** @name 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. */ //@{ wxRealPoint& operator=(const wxRealPoint& pt); bool operator ==(const wxRealPoint& p1, const wxRealPoint& p2); bool operator !=(const wxRealPoint& p1, const wxRealPoint& p2); wxRealPoint operator +(const wxRealPoint& p1, const wxRealPoint& p2); wxRealPoint operator -(const wxRealPoint& p1, const wxRealPoint& p2); wxRealPoint& operator +=(const wxRealPoint& pt); wxRealPoint& operator -=(const wxRealPoint& pt); wxRealPoint operator +(const wxRealPoint& pt, const wxSize& sz); wxRealPoint operator -(const wxRealPoint& pt, const wxSize& sz); wxRealPoint operator +(const wxSize& sz, const wxRealPoint& pt); wxRealPoint operator -(const wxSize& sz, const wxRealPoint& pt); wxRealPoint& operator +=(const wxSize& sz); wxRealPoint& operator -=(const wxSize& sz); wxSize operator /(const wxRealPoint& sz, int factor); wxSize operator *(const wxRealPoint& sz, int factor); wxSize operator *(int factor, const wxSize& sz); wxSize& operator /=(int factor); wxSize& operator *=(int factor); //@} /** X coordinate of this point. */ double x; /** Y coordinate of this point. */ double y; }; /** @class wxRect A class for manipulating rectangles. Note that the x, y coordinates and the width and height stored inside a wxRect object may be negative and that wxRect functions do not perform any check against negative values. @library{wxcore} @category{data} @see wxPoint, wxSize */ class wxRect { public: /** Default constructor. Initializes to zero the internal @a x, @a y, @a width and @a height members. */ wxRect(); /** Creates a wxRect object from @a x, @a y, @a width and @a height values. */ wxRect(int x, int y, int width, int height); /** Creates a wxRect object from top-left and bottom-right points. */ wxRect(const wxPoint& topLeft, const wxPoint& bottomRight); /** Creates a wxRect object from position @a pos and @a size values. */ wxRect(const wxPoint& pos, const wxSize& size); /** Creates a wxRect object from @a size values at the origin. */ wxRect(const wxSize& size); //@{ /** Returns the rectangle having the same size as this one but centered relatively to the given rectangle @a r. By default, rectangle is centred in both directions but if @a dir includes only @c wxVERTICAL or only @c wxHORIZONTAL, then it is only centered in this direction while the other component of its position remains unchanged. */ wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const; wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const; //@} /** Returns @true if the given point is inside the rectangle (or on its boundary) and @false otherwise. */ bool Contains(int x, int y) const; /** Returns @true if the given point is inside the rectangle (or on its boundary) and @false otherwise. */ bool Contains(const wxPoint& pt) const; /** Returns @true if the given rectangle is completely inside this rectangle (or touches its boundary) and @false otherwise. */ bool Contains(const wxRect& rect) const; //@{ /** Decrease the rectangle size. This method is the opposite from Inflate(): Deflate(a, b) is equivalent to Inflate(-a, -b). Please refer to Inflate() for full description. */ wxRect& Deflate(wxCoord dx, wxCoord dy); wxRect& Deflate(const wxSize& diff); wxRect& Deflate(wxCoord diff); wxRect Deflate(wxCoord dx, wxCoord dy) const; //@} /** Gets the bottom point of the rectangle. */ int GetBottom() const; /** Gets the position of the bottom left corner. */ wxPoint GetBottomLeft() const; /** Gets the position of the bottom right corner. */ wxPoint GetBottomRight() const; /** Gets the height member. */ int GetHeight() const; /** Gets the left point of the rectangle (the same as GetX()). */ int GetLeft() const; /** Gets the position. */ wxPoint GetPosition() const; /** Gets the right point of the rectangle. */ int GetRight() const; /** Gets the size. @see SetSize() */ wxSize GetSize() const; /** Gets the top point of the rectangle (the same as GetY()). */ int GetTop() const; /** Gets the position of the top left corner of the rectangle, same as GetPosition(). */ wxPoint GetTopLeft() const; /** Gets the position of the top right corner. */ wxPoint GetTopRight() const; /** Gets the width member. */ int GetWidth() const; /** Gets the x member. */ int GetX() const; /** Gets the y member. */ int GetY() const; //@{ /** Increases the size of the rectangle. The left border is moved farther left and the right border is moved farther right by @a dx. The upper border is moved farther up and the bottom border is moved farther down by @a dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of @a dx and @a dy are negative, the opposite happens: the rectangle size decreases in the respective direction. Inflating and deflating behaves "naturally". Defined more precisely, that means: -# "Real" inflates (that is, @a dx and/or @a dy = 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (2.5.4 and older forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.) -# Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero). @see Deflate() */ wxRect& Inflate(wxCoord dx, wxCoord dy); wxRect& Inflate(const wxSize& diff); wxRect& Inflate(wxCoord diff); wxRect Inflate(wxCoord dx, wxCoord dy) const; //@} /** Modifies this rectangle to contain the overlapping portion of this rectangle and the one passed in as parameter. @return This rectangle, modified. */ wxRect& Intersect(const wxRect& rect); /** Returns the overlapping portion of this rectangle and the one passed in as parameter. */ wxRect Intersect(const wxRect& rect) const; /** Returns @true if this rectangle has a non-empty intersection with the rectangle @a rect and @false otherwise. */ bool Intersects(const wxRect& rect) const; /** Returns @true if this rectangle has a width or height less than or equal to 0 and @false otherwise. */ bool IsEmpty() const; //@{ /** Moves the rectangle by the specified offset. If @a dx is positive, the rectangle is moved to the right, if @a dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively. */ void Offset(wxCoord dx, wxCoord dy); void Offset(const wxPoint& pt); //@} /** Sets the height. */ void SetHeight(int height); /** Sets the size. @see GetSize() */ void SetSize(const wxSize& s); /** Sets the width. */ void SetWidth(int width); /** Sets the x position. */ void SetX(int x); /** Sets the y position. */ void SetY(int y); //@{ /** Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. */ wxRect Union(const wxRect& rect) const; wxRect& Union(const wxRect& rect); //@} /** Inequality operator. */ bool operator !=(const wxRect& r1, const wxRect& r2); //@{ /** Like Union(), but doesn't treat empty rectangles specially. */ wxRect operator +(const wxRect& r1, const wxRect& r2); wxRect& operator +=(const wxRect& r); //@} //@{ /** Returns the intersection of two rectangles (which may be empty). */ wxRect operator *(const wxRect& r1, const wxRect& r2); wxRect& operator *=(const wxRect& r); //@} /** Assignment operator. */ wxRect& operator=(const wxRect& rect); /** Equality operator. */ bool operator ==(const wxRect& r1, const wxRect& r2); /** Height member. */ int height; /** Width member. */ int width; /** x coordinate of the top-level corner of the rectangle. */ int x; /** y coordinate of the top-level corner of the rectangle. */ int y; }; /** @class wxPoint A wxPoint is a useful data structure for graphics operations. It contains integer @e x and @e 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} @stdobjects ::wxDefaultPosition @see wxRealPoint */ class wxPoint { public: /** Constructs a point. Initializes the internal x and y coordinates to zero. */ wxPoint(); /** Initializes the point object with the given @a x and @a y coordinates. */ wxPoint(int x, int y); /** Converts the given wxRealPoint (with floating point coordinates) to a wxPoint instance. */ wxPoint(const wxRealPoint& pt); /** @name 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); //@} /** @name 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 @c -1) to indicate that a point hasn't been initialized or specified. In particular, ::wxDefaultPosition is used in many places with this meaning. */ //@{ /** Returns @true if neither of the point components is equal to wxDefaultCoord. This method is typically used before calling SetDefaults(). @since 2.9.2 */ bool IsFullySpecified() const; /** Combine this object with another one replacing the uninitialized values. It is typically used like this: @code if ( !pos.IsFullySpecified() ) { pos.SetDefaults(GetDefaultPosition()); } @endcode @see IsFullySpecified() @since 2.9.2 */ void SetDefaults(const wxPoint& pt); //@} /** x member. */ int x; /** y member. */ int y; }; /** Global instance of a wxPoint initialized with values (-1,-1). */ const wxPoint wxDefaultPosition; /** @class wxColourDatabase wxWidgets maintains a database of standard RGB colours for a predefined set of named colours. The application may add to this set if desired by using AddColour() and may use it to look up colours by names using Find() or find the names for the standard colour using FindName(). There is one predefined, global instance of this class called ::wxTheColourDatabase. The standard database contains at least the following colours: @beginTable