1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRealPoint
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 Bitmap type flags. See wxBitmap and wxImage classes.
15 wxBITMAP_TYPE_INVALID
,
17 wxBITMAP_TYPE_BMP_RESOURCE
,
18 wxBITMAP_TYPE_RESOURCE
= wxBITMAP_TYPE_BMP_RESOURCE
,
20 wxBITMAP_TYPE_ICO_RESOURCE
,
22 wxBITMAP_TYPE_CUR_RESOURCE
,
24 wxBITMAP_TYPE_XBM_DATA
,
26 wxBITMAP_TYPE_XPM_DATA
,
28 wxBITMAP_TYPE_TIF_RESOURCE
,
30 wxBITMAP_TYPE_GIF_RESOURCE
,
32 wxBITMAP_TYPE_PNG_RESOURCE
,
34 wxBITMAP_TYPE_JPEG_RESOURCE
,
36 wxBITMAP_TYPE_PNM_RESOURCE
,
38 wxBITMAP_TYPE_PCX_RESOURCE
,
40 wxBITMAP_TYPE_PICT_RESOURCE
,
42 wxBITMAP_TYPE_ICON_RESOURCE
,
46 wxBITMAP_TYPE_MACCURSOR
,
47 wxBITMAP_TYPE_MACCURSOR_RESOURCE
,
48 wxBITMAP_TYPE_ANY
= 50
52 Polygon filling mode. See wxDC::DrawPolygon.
54 enum wxPolygonFillMode
63 Notice that under wxMSW some of these cursors are defined in @c wx.rc file
64 and not by the system itself so you should include this file from your own
65 resource file (possibly creating a trivial resource file just containing a
66 single include line if you don't need it otherwise) to be able to use them.
73 wxCURSOR_ARROW
, ///< A standard arrow cursor.
74 wxCURSOR_RIGHT_ARROW
, ///< A standard arrow cursor pointing to the right.
75 wxCURSOR_BULLSEYE
, ///< Bullseye cursor.
76 wxCURSOR_CHAR
, ///< Rectangular character cursor.
77 wxCURSOR_CROSS
, ///< A cross cursor.
78 wxCURSOR_HAND
, ///< A hand cursor.
79 wxCURSOR_IBEAM
, ///< An I-beam cursor (vertical line).
80 wxCURSOR_LEFT_BUTTON
, ///< Represents a mouse with the left button depressed.
81 wxCURSOR_MAGNIFIER
, ///< A magnifier icon.
82 wxCURSOR_MIDDLE_BUTTON
, ///< Represents a mouse with the middle button depressed.
83 wxCURSOR_NO_ENTRY
, ///< A no-entry sign cursor.
84 wxCURSOR_PAINT_BRUSH
, ///< A paintbrush cursor.
85 wxCURSOR_PENCIL
, ///< A pencil cursor.
86 wxCURSOR_POINT_LEFT
, ///< A cursor that points left.
87 wxCURSOR_POINT_RIGHT
, ///< A cursor that points right.
88 wxCURSOR_QUESTION_ARROW
, ///< An arrow and question mark.
89 wxCURSOR_RIGHT_BUTTON
, ///< Represents a mouse with the right button depressed.
90 wxCURSOR_SIZENESW
, ///< A sizing cursor pointing NE-SW.
91 wxCURSOR_SIZENS
, ///< A sizing cursor pointing N-S.
92 wxCURSOR_SIZENWSE
, ///< A sizing cursor pointing NW-SE.
93 wxCURSOR_SIZEWE
, ///< A sizing cursor pointing W-E.
94 wxCURSOR_SIZING
, ///< A general sizing cursor.
95 wxCURSOR_SPRAYCAN
, ///< A spraycan cursor.
96 wxCURSOR_WAIT
, ///< A wait cursor.
97 wxCURSOR_WATCH
, ///< A watch cursor.
98 wxCURSOR_BLANK
, ///< Transparent cursor.
99 wxCURSOR_DEFAULT
, ///< Standard X11 cursor (only in wxGTK).
100 wxCURSOR_COPY_ARROW
, ///< MacOS Theme Plus arrow (only in wxMac).
101 wxCURSOR_CROSS_REVERSE
, ///< Only available on wxX11.
102 wxCURSOR_DOUBLE_ARROW
, ///< Only available on wxX11.
103 wxCURSOR_BASED_ARROW_UP
, ///< Only available on wxX11.
104 wxCURSOR_BASED_ARROW_DOWN
, ///< Only available on wxX11.
105 wxCURSOR_ARROWWAIT
, ///< A wait cursor with a standard arrow.
114 A wxRealPoint is a useful data structure for graphics operations.
116 It contains floating point @e x and @e y members.
117 See wxPoint for an integer version.
119 Note that the coordinates stored inside a wxRealPoint object may be negative
120 and that wxRealPoint functions do not perform any check against negative values.
131 Initializes to zero the x and y members.
136 Initializes the point with the given coordinates.
138 wxRealPoint(double x
, double y
);
141 X coordinate of this point.
146 Y coordinate of this point.
156 A class for manipulating rectangles.
158 Note that the x, y coordinates and the width and height stored inside a wxRect
159 object may be negative and that wxRect functions do not perform any check against
172 Initializes to zero the internal @a x, @a y, @a width and @a height members.
176 Creates a wxRect object from @a x, @a y, @a width and @a height values.
178 wxRect(int x
, int y
, int width
, int height
);
180 Creates a wxRect object from top-left and bottom-right points.
182 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
184 Creates a wxRect object from position @a pos and @a size values.
186 wxRect(const wxPoint
& pos
, const wxSize
& size
);
188 Creates a wxRect object from @a size values at the origin.
190 wxRect(const wxSize
& size
);
194 Returns the rectangle having the same size as this one but centered
195 relatively to the given rectangle @a r. By default, rectangle is
196 centred in both directions but if @a dir includes only @c wxVERTICAL or
197 only @c wxHORIZONTAL, then it is only centered in this direction while
198 the other component of its position remains unchanged.
200 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
201 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
205 Returns @true if the given point is inside the rectangle (or on its
206 boundary) and @false otherwise.
208 bool Contains(int x
, int y
) const;
210 Returns @true if the given point is inside the rectangle (or on its
211 boundary) and @false otherwise.
213 bool Contains(const wxPoint
& pt
) const;
215 Returns @true if the given rectangle is completely inside this
216 rectangle (or touches its boundary) and @false otherwise.
218 bool Contains(const wxRect
& rect
) const;
222 Decrease the rectangle size.
224 This method is the opposite from Inflate(): Deflate(a, b) is equivalent
225 to Inflate(-a, -b). Please refer to Inflate() for full description.
227 void Deflate(wxCoord dx
, wxCoord dy
);
228 void Deflate(const wxSize
& diff
);
229 void Deflate(wxCoord diff
);
230 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
234 Gets the bottom point of the rectangle.
236 int GetBottom() const;
239 Gets the position of the bottom left corner.
241 wxPoint
GetBottomLeft() const;
244 Gets the position of the bottom right corner.
246 wxPoint
GetBottomRight() const;
249 Gets the height member.
251 int GetHeight() const;
254 Gets the left point of the rectangle (the same as GetX()).
261 wxPoint
GetPosition() const;
264 Gets the right point of the rectangle.
266 int GetRight() const;
273 wxSize
GetSize() const;
276 Gets the top point of the rectangle (the same as GetY()).
281 Gets the position of the top left corner of the rectangle, same as
284 wxPoint
GetTopLeft() const;
287 Gets the position of the top right corner.
289 wxPoint
GetTopRight() const;
292 Gets the width member.
294 int GetWidth() const;
308 Increases the size of the rectangle.
310 The left border is moved farther left and the right border is moved
311 farther right by @a dx. The upper border is moved farther up and the
312 bottom border is moved farther down by @a dy. (Note the the width and
313 height of the rectangle thus change by 2*dx and 2*dy, respectively.) If
314 one or both of @a dx and @a dy are negative, the opposite happens: the
315 rectangle size decreases in the respective direction.
317 Inflating and deflating behaves "naturally". Defined more precisely,
319 -# "Real" inflates (that is, @a dx and/or @a dy = 0) are not
320 constrained. Thus inflating a rectangle can cause its upper left
321 corner to move into the negative numbers. (2.5.4 and older forced
322 the top left coordinate to not fall below (0, 0), which implied a
323 forced move of the rectangle.)
324 -# Deflates are clamped to not reduce the width or height of the
325 rectangle below zero. In such cases, the top-left corner is
326 nonetheless handled properly. For example, a rectangle at (10, 10)
327 with size (20, 40) that is inflated by (-15, -15) will become
328 located at (20, 25) at size (0, 10). Finally, observe that the width
329 and height are treated independently. In the above example, the
330 width is reduced by 20, whereas the height is reduced by the full 30
331 (rather than also stopping at 20, when the width reached zero).
335 void Inflate(wxCoord dx
, wxCoord dy
);
336 void Inflate(const wxSize
& diff
);
337 void Inflate(wxCoord diff
);
338 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
342 Modifies this rectangle to contain the overlapping portion of this rectangle
343 and the one passed in as parameter.
345 @return This rectangle, modified.
347 wxRect
& Intersect(const wxRect
& rect
);
350 Returns the overlapping portion of this rectangle and the one passed in as
353 wxRect
Intersect(const wxRect
& rect
) const;
356 Returns @true if this rectangle has a non-empty intersection with the
357 rectangle @a rect and @false otherwise.
359 bool Intersects(const wxRect
& rect
) const;
362 Returns @true if this rectangle has a width or height less than or
363 equal to 0 and @false otherwise.
365 bool IsEmpty() const;
369 Moves the rectangle by the specified offset. If @a dx is positive, the
370 rectangle is moved to the right, if @a dy is positive, it is moved to the
371 bottom, otherwise it is moved to the left or top respectively.
373 void Offset(wxCoord dx
, wxCoord dy
);
374 void Offset(const wxPoint
& pt
);
380 void SetHeight(int height
);
387 void SetSize(const wxSize
& s
);
392 void SetWidth(int width
);
406 Modifies the rectangle to contain the bounding box of this rectangle
407 and the one passed in as parameter.
409 wxRect
Union(const wxRect
& rect
) const;
410 wxRect
& Union(const wxRect
& rect
);
416 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
420 Like Union(), but doesn't treat empty rectangles specially.
422 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
423 wxRect
& operator +=(const wxRect
& r
);
428 Returns the intersection of two rectangles (which may be empty).
430 wxRect
operator *(const wxRect
& r1
, const wxRect
& r2
);
431 wxRect
& operator *=(const wxRect
& r
);
437 wxRect
& operator=(const wxRect
& rect
);
442 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
455 x coordinate of the top-level corner of the rectangle.
460 y coordinate of the top-level corner of the rectangle.
470 A wxPoint is a useful data structure for graphics operations.
472 It contains integer @e x and @e y members.
473 See wxRealPoint for a floating point version.
475 Note that the width and height stored inside a wxPoint object may be negative
476 and that wxPoint functions do not perform any check against negative values
477 (this is used to e.g. store the special -1 value in ::wxDefaultPosition instance).
492 Initializes the internal x and y coordinates to zero.
497 Initializes the point object with the given @a x and @a y coordinates.
499 wxPoint(int x
, int y
);
502 @name Miscellaneous operators
505 wxPoint
& operator=(const wxPoint
& pt
);
507 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
508 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
510 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
511 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
513 wxPoint
& operator +=(const wxPoint
& pt
);
514 wxPoint
& operator -=(const wxPoint
& pt
);
516 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
517 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
518 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
519 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
521 wxPoint
& operator +=(const wxSize
& sz
);
522 wxPoint
& operator -=(const wxSize
& sz
);
537 Global istance of a wxPoint initialized with values (-1,-1).
539 wxPoint wxDefaultPosition
;
543 @class wxColourDatabase
545 wxWidgets maintains a database of standard RGB colours for a predefined
546 set of named colours. The application may add to this set if desired by
547 using AddColour() and may use it to look up colours by names using Find()
548 or find the names for the standard colour using FindName().
550 There is one predefined, global instance of this class called
551 ::wxTheColourDatabase.
553 The standard database contains at least the following colours:
598 @n MEDIUM SPRING GREEN
636 class wxColourDatabase
640 Constructs the colour database. It will be initialized at the first
646 Adds a colour to the database. If a colour with the same name already
647 exists, it is replaced.
649 void AddColour(const wxString
& colourName
, const wxColour
& colour
);
652 Finds a colour given the name. Returns an invalid colour object (that
653 is, wxColour::IsOk() will return @false) if the colour wasn't found in
656 wxColour
Find(const wxString
& colourName
) const;
659 Finds a colour name given the colour. Returns an empty string if the
660 colour is not found in the database.
662 wxString
FindName(const wxColour
& colour
) const;
669 A wxSize is a useful data structure for graphics operations.
670 It simply contains integer @e width and @e height members.
672 Note that the width and height stored inside a wxSize object may be negative
673 and that wxSize functions do not perform any check against negative values
674 (this is used to e.g. store the special -1 value in ::wxDefaultSize instance).
675 See also IsFullySpecified() and SetDefaults() for utility functions regarding
676 the special -1 value.
678 wxSize is used throughout wxWidgets as well as wxPoint which, although
679 almost equivalent to wxSize, has a different meaning: wxPoint represents a
680 position while wxSize represents the size.
683 wxPython defines aliases for the @e x and @e y members named @e width and
684 @e height since it makes much more sense for sizes.
693 @see wxPoint, wxRealPoint
699 Initializes this size object with zero width and height.
704 Initializes this size object with the given @a width and @a height.
706 wxSize(int width
, int height
);
710 Decreases the size in both x and y directions.
714 void DecBy(const wxSize
& size
);
715 void DecBy(int dx
, int dy
);
720 Decrements this object so that both of its dimensions are not greater
721 than the corresponding dimensions of the @a size.
725 void DecTo(const wxSize
& size
);
728 Gets the height member.
730 int GetHeight() const;
733 Gets the width member.
735 int GetWidth() const;
739 Increases the size in both x and y directions.
743 void IncBy(const wxSize
& size
);
744 void IncBy(int dx
, int dy
);
749 Increments this object so that both of its dimensions are not less than
750 the corresponding dimensions of the @a size.
754 void IncTo(const wxSize
& size
);
757 Returns @true if neither of the size object components is equal to -1,
758 which is used as default for the size values in wxWidgets (hence the
759 predefined ::wxDefaultSize has both of its components equal to -1).
761 This method is typically used before calling SetDefaults().
763 bool IsFullySpecified() const;
766 Scales the dimensions of this object by the given factors. If you want
767 to scale both dimensions by the same factor you can also use
770 @return A reference to this object (so that you can concatenate other
771 operations in the same line).
773 wxSize
& Scale(float xscale
, float yscale
);
776 Sets the width and height members.
778 void Set(int width
, int height
);
781 Combine this size object with another one replacing the default (i.e.
782 equal to -1) components of this object with those of the other. It is
783 typically used like this:
786 if ( !size.IsFullySpecified() )
788 size.SetDefaults(GetDefaultSize());
792 @see IsFullySpecified()
794 void SetDefaults(const wxSize
& sizeDefault
);
799 void SetHeight(int height
);
804 void SetWidth(int width
);
808 @name Miscellaneous operators
811 wxSize
& operator=(const wxSize
& sz
);
813 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
814 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
816 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
817 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
818 wxSize
& operator +=(const wxSize
& sz
);
819 wxSize
& operator -=(const wxSize
& sz
);
821 wxSize
operator /(const wxSize
& sz
, int factor
);
822 wxSize
operator *(const wxSize
& sz
, int factor
);
823 wxSize
operator *(int factor
, const wxSize
& sz
);
824 wxSize
& operator /=(int factor
);
825 wxSize
& operator *=(int factor
);
830 Global instance of a wxSize object initialized to (-1,-1).
832 wxSize wxDefaultSize
;
837 // ============================================================================
838 // Global functions/macros
839 // ============================================================================
841 /** @addtogroup group_funcmacro_gdi */
845 This macro loads a bitmap from either application resources (on the
846 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
847 This can help to avoid using @ifdef_ when creating bitmaps.
849 @see @ref overview_bitmap, wxICON()
853 #define wxBITMAP(bitmapName)
856 This macro loads an icon from either application resources (on the
857 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
858 This can help to avoid using @ifdef_ when creating icons.
860 @see @ref overview_bitmap, wxBITMAP()
864 #define wxICON(iconName)
867 Returns @true if the display is colour, @false otherwise.
871 bool wxColourDisplay();
874 Returns the depth of the display (a value of 1 denotes a monochrome
879 int wxDisplayDepth();
882 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
883 should call this function with wxNullCursor to restore the system cursor.
885 @see wxCursor, wxWindow::SetCursor()
889 void wxSetCursor(const wxCursor
& cursor
);
893 /** @addtogroup group_funcmacro_gdi */
896 Returns the dimensions of the work area on the display. On Windows this
897 means the area not covered by the taskbar, etc. Other platforms are
898 currently defaulting to the whole display until a way is found to provide
899 this info for all window managers, etc.
903 void wxClientDisplayRect(int* x
, int* y
, int* width
, int* height
);
904 wxRect
wxGetClientDisplayRect();
907 /** @addtogroup group_funcmacro_gdi */
910 Returns the display resolution in pixels per inch.
912 The @c x component of the returned wxSize object contains the horizontal
913 resolution and the @c y one -- the vertical resolution.
919 wxSize
wxGetDisplayPPI();
922 /** @addtogroup group_funcmacro_gdi */
925 Returns the display size in pixels.
927 For the version taking @a width and @a header arguments, either of them
928 can be @NULL if the caller is not interested in the returned value.
932 void wxDisplaySize(int* width
, int* height
);
933 wxSize
wxGetDisplaySize();
936 /** @addtogroup group_funcmacro_gdi */
939 Returns the display size in millimeters.
941 For the version taking @a width and @a header arguments, either of them
942 can be @NULL if the caller is not interested in the returned value.
944 @see wxGetDisplayPPI()
948 void wxDisplaySizeMM(int* width
, int* height
);
949 wxSize
wxGetDisplaySizeMM();