1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRealPoint
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
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 Converts the given wxPoint (with integer coordinates) to a wxRealPoint.
143 wxRealPoint(const wxPoint
& pt
);
146 @name Miscellaneous operators
148 Note that these operators are documented as class members
149 (to make them easier to find) but, as their prototype shows,
150 they are implemented as global operators; note that this is
151 transparent to the user but it helps to understand why the
152 following functions are documented to take the wxPoint they
153 operate on as an explicit argument.
156 wxRealPoint
& operator=(const wxRealPoint
& pt
);
158 bool operator ==(const wxRealPoint
& p1
, const wxRealPoint
& p2
);
159 bool operator !=(const wxRealPoint
& p1
, const wxRealPoint
& p2
);
161 wxRealPoint
operator +(const wxRealPoint
& p1
, const wxRealPoint
& p2
);
162 wxRealPoint
operator -(const wxRealPoint
& p1
, const wxRealPoint
& p2
);
164 wxRealPoint
& operator +=(const wxRealPoint
& pt
);
165 wxRealPoint
& operator -=(const wxRealPoint
& pt
);
167 wxRealPoint
operator +(const wxRealPoint
& pt
, const wxSize
& sz
);
168 wxRealPoint
operator -(const wxRealPoint
& pt
, const wxSize
& sz
);
169 wxRealPoint
operator +(const wxSize
& sz
, const wxRealPoint
& pt
);
170 wxRealPoint
operator -(const wxSize
& sz
, const wxRealPoint
& pt
);
172 wxRealPoint
& operator +=(const wxSize
& sz
);
173 wxRealPoint
& operator -=(const wxSize
& sz
);
175 wxSize
operator /(const wxRealPoint
& sz
, int factor
);
176 wxSize
operator *(const wxRealPoint
& sz
, int factor
);
177 wxSize
operator *(int factor
, const wxSize
& sz
);
178 wxSize
& operator /=(int factor
);
179 wxSize
& operator *=(int factor
);
183 X coordinate of this point.
188 Y coordinate of this point.
198 A class for manipulating rectangles.
200 Note that the x, y coordinates and the width and height stored inside a wxRect
201 object may be negative and that wxRect functions do not perform any check against
214 Initializes to zero the internal @a x, @a y, @a width and @a height members.
218 Creates a wxRect object from @a x, @a y, @a width and @a height values.
220 wxRect(int x
, int y
, int width
, int height
);
222 Creates a wxRect object from top-left and bottom-right points.
224 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
226 Creates a wxRect object from position @a pos and @a size values.
228 wxRect(const wxPoint
& pos
, const wxSize
& size
);
230 Creates a wxRect object from @a size values at the origin.
232 wxRect(const wxSize
& size
);
236 Returns the rectangle having the same size as this one but centered
237 relatively to the given rectangle @a r. By default, rectangle is
238 centred in both directions but if @a dir includes only @c wxVERTICAL or
239 only @c wxHORIZONTAL, then it is only centered in this direction while
240 the other component of its position remains unchanged.
242 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
243 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
247 Returns @true if the given point is inside the rectangle (or on its
248 boundary) and @false otherwise.
250 bool Contains(int x
, int y
) const;
252 Returns @true if the given point is inside the rectangle (or on its
253 boundary) and @false otherwise.
255 bool Contains(const wxPoint
& pt
) const;
257 Returns @true if the given rectangle is completely inside this
258 rectangle (or touches its boundary) and @false otherwise.
260 bool Contains(const wxRect
& rect
) const;
264 Decrease the rectangle size.
266 This method is the opposite from Inflate(): Deflate(a, b) is equivalent
267 to Inflate(-a, -b). Please refer to Inflate() for full description.
269 wxRect
& Deflate(wxCoord dx
, wxCoord dy
);
270 wxRect
& Deflate(const wxSize
& diff
);
271 wxRect
& Deflate(wxCoord diff
);
272 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
276 Gets the bottom point of the rectangle.
278 int GetBottom() const;
281 Gets the position of the bottom left corner.
283 wxPoint
GetBottomLeft() const;
286 Gets the position of the bottom right corner.
288 wxPoint
GetBottomRight() const;
291 Gets the height member.
293 int GetHeight() const;
296 Gets the left point of the rectangle (the same as GetX()).
303 wxPoint
GetPosition() const;
306 Gets the right point of the rectangle.
308 int GetRight() const;
315 wxSize
GetSize() const;
318 Gets the top point of the rectangle (the same as GetY()).
323 Gets the position of the top left corner of the rectangle, same as
326 wxPoint
GetTopLeft() const;
329 Gets the position of the top right corner.
331 wxPoint
GetTopRight() const;
334 Gets the width member.
336 int GetWidth() const;
350 Increases the size of the rectangle.
352 The left border is moved farther left and the right border is moved
353 farther right by @a dx. The upper border is moved farther up and the
354 bottom border is moved farther down by @a dy. (Note that the width and
355 height of the rectangle thus change by 2*dx and 2*dy, respectively.) If
356 one or both of @a dx and @a dy are negative, the opposite happens: the
357 rectangle size decreases in the respective direction.
359 Inflating and deflating behaves "naturally". Defined more precisely,
361 -# "Real" inflates (that is, @a dx and/or @a dy = 0) are not
362 constrained. Thus inflating a rectangle can cause its upper left
363 corner to move into the negative numbers. (2.5.4 and older forced
364 the top left coordinate to not fall below (0, 0), which implied a
365 forced move of the rectangle.)
366 -# Deflates are clamped to not reduce the width or height of the
367 rectangle below zero. In such cases, the top-left corner is
368 nonetheless handled properly. For example, a rectangle at (10, 10)
369 with size (20, 40) that is inflated by (-15, -15) will become
370 located at (20, 25) at size (0, 10). Finally, observe that the width
371 and height are treated independently. In the above example, the
372 width is reduced by 20, whereas the height is reduced by the full 30
373 (rather than also stopping at 20, when the width reached zero).
377 wxRect
& Inflate(wxCoord dx
, wxCoord dy
);
378 wxRect
& Inflate(const wxSize
& diff
);
379 wxRect
& Inflate(wxCoord diff
);
380 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
384 Modifies this rectangle to contain the overlapping portion of this rectangle
385 and the one passed in as parameter.
387 @return This rectangle, modified.
389 wxRect
& Intersect(const wxRect
& rect
);
392 Returns the overlapping portion of this rectangle and the one passed in as
395 wxRect
Intersect(const wxRect
& rect
) const;
398 Returns @true if this rectangle has a non-empty intersection with the
399 rectangle @a rect and @false otherwise.
401 bool Intersects(const wxRect
& rect
) const;
404 Returns @true if this rectangle has a width or height less than or
405 equal to 0 and @false otherwise.
407 bool IsEmpty() const;
411 Moves the rectangle by the specified offset. If @a dx is positive, the
412 rectangle is moved to the right, if @a dy is positive, it is moved to the
413 bottom, otherwise it is moved to the left or top respectively.
415 void Offset(wxCoord dx
, wxCoord dy
);
416 void Offset(const wxPoint
& pt
);
422 void SetHeight(int height
);
429 void SetSize(const wxSize
& s
);
434 void SetWidth(int width
);
448 Modifies the rectangle to contain the bounding box of this rectangle
449 and the one passed in as parameter.
451 wxRect
Union(const wxRect
& rect
) const;
452 wxRect
& Union(const wxRect
& rect
);
458 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
462 Like Union(), but doesn't treat empty rectangles specially.
464 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
465 wxRect
& operator +=(const wxRect
& r
);
470 Returns the intersection of two rectangles (which may be empty).
472 wxRect
operator *(const wxRect
& r1
, const wxRect
& r2
);
473 wxRect
& operator *=(const wxRect
& r
);
479 wxRect
& operator=(const wxRect
& rect
);
484 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
497 x coordinate of the top-level corner of the rectangle.
502 y coordinate of the top-level corner of the rectangle.
512 A wxPoint is a useful data structure for graphics operations.
514 It contains integer @e x and @e y members.
515 See wxRealPoint for a floating point version.
517 Note that the width and height stored inside a wxPoint object may be negative
518 and that wxPoint functions do not perform any check against negative values
519 (this is used to e.g. store the special -1 value in ::wxDefaultPosition instance).
534 Initializes the internal x and y coordinates to zero.
539 Initializes the point object with the given @a x and @a y coordinates.
541 wxPoint(int x
, int y
);
544 Converts the given wxRealPoint (with floating point coordinates) to a
547 wxPoint(const wxRealPoint
& pt
);
550 @name Miscellaneous operators
552 Note that these operators are documented as class members
553 (to make them easier to find) but, as their prototype shows,
554 they are implemented as global operators; note that this is
555 transparent to the user but it helps to understand why the
556 following functions are documented to take the wxPoint they
557 operate on as an explicit argument.
560 wxPoint
& operator=(const wxPoint
& pt
);
562 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
563 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
565 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
566 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
568 wxPoint
& operator +=(const wxPoint
& pt
);
569 wxPoint
& operator -=(const wxPoint
& pt
);
571 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
572 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
573 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
574 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
576 wxPoint
& operator +=(const wxSize
& sz
);
577 wxPoint
& operator -=(const wxSize
& sz
);
579 wxSize
operator /(const wxPoint
& sz
, int factor
);
580 wxSize
operator *(const wxPoint
& sz
, int factor
);
581 wxSize
operator *(int factor
, const wxSize
& sz
);
582 wxSize
& operator /=(int factor
);
583 wxSize
& operator *=(int factor
);
588 @name Defaults handling.
590 Test for and set non-specified wxPoint components.
592 Although a wxPoint is always initialized to (0, 0), wxWidgets commonly
593 uses wxDefaultCoord (defined as @c -1) to indicate that a point hasn't
594 been initialized or specified. In particular, ::wxDefaultPosition is
595 used in many places with this meaning.
600 Returns @true if neither of the point components is equal to
603 This method is typically used before calling SetDefaults().
607 bool IsFullySpecified() const;
610 Combine this object with another one replacing the uninitialized
613 It is typically used like this:
616 if ( !pos.IsFullySpecified() )
618 pos.SetDefaults(GetDefaultPosition());
622 @see IsFullySpecified()
626 void SetDefaults(const wxPoint
& pt
);
641 Global instance of a wxPoint initialized with values (-1,-1).
643 const wxPoint wxDefaultPosition
;
647 @class wxColourDatabase
649 wxWidgets maintains a database of standard RGB colours for a predefined
650 set of named colours. The application may add to this set if desired by
651 using AddColour() and may use it to look up colours by names using Find()
652 or find the names for the standard colour using FindName().
654 There is one predefined, global instance of this class called
655 ::wxTheColourDatabase.
657 The standard database contains at least the following colours:
702 @n MEDIUM SPRING GREEN
740 class wxColourDatabase
744 Constructs the colour database. It will be initialized at the first
750 Adds a colour to the database. If a colour with the same name already
751 exists, it is replaced.
753 void AddColour(const wxString
& colourName
, const wxColour
& colour
);
756 Finds a colour given the name. Returns an invalid colour object (that
757 is, wxColour::IsOk() will return @false) if the colour wasn't found in
760 wxColour
Find(const wxString
& colourName
) const;
763 Finds a colour name given the colour. Returns an empty string if the
764 colour is not found in the database.
766 wxString
FindName(const wxColour
& colour
) const;
771 Global instance of a wxColourDatabase.
773 wxColourDatabase
* wxTheColourDatabase
;
779 A wxSize is a useful data structure for graphics operations.
780 It simply contains integer @e width and @e height members.
782 Note that the width and height stored inside a wxSize object may be negative
783 and that wxSize functions do not perform any check against negative values
784 (this is used to e.g. store the special -1 value in ::wxDefaultSize instance).
785 See also IsFullySpecified() and SetDefaults() for utility functions regarding
786 the special -1 value.
788 wxSize is used throughout wxWidgets as well as wxPoint which, although
789 almost equivalent to wxSize, has a different meaning: wxPoint represents a
790 position while wxSize represents the size.
793 wxPython defines aliases for the @e x and @e y members named @e width and
794 @e height since it makes much more sense for sizes.
803 @see wxPoint, wxRealPoint
809 Initializes this size object with zero width and height.
814 Initializes this size object with the given @a width and @a height.
816 wxSize(int width
, int height
);
820 Decreases the size in both x and y directions.
824 void DecBy(const wxPoint
& pt
);
825 void DecBy(const wxSize
& size
);
826 void DecBy(int dx
, int dy
);
831 Decrements this object so that both of its dimensions are not greater
832 than the corresponding dimensions of the @a size.
836 void DecTo(const wxSize
& size
);
839 Gets the height member.
841 int GetHeight() const;
844 Gets the width member.
846 int GetWidth() const;
850 Increases the size in both x and y directions.
854 void IncBy(const wxPoint
& pt
);
855 void IncBy(const wxSize
& size
);
856 void IncBy(int dx
, int dy
);
861 Increments this object so that both of its dimensions are not less than
862 the corresponding dimensions of the @a size.
866 void IncTo(const wxSize
& size
);
869 Returns @true if neither of the size object components is equal to -1,
870 which is used as default for the size values in wxWidgets (hence the
871 predefined ::wxDefaultSize has both of its components equal to -1).
873 This method is typically used before calling SetDefaults().
875 bool IsFullySpecified() const;
878 Scales the dimensions of this object by the given factors. If you want
879 to scale both dimensions by the same factor you can also use
882 @return A reference to this object (so that you can concatenate other
883 operations in the same line).
885 wxSize
& Scale(float xscale
, float yscale
);
888 Sets the width and height members.
890 void Set(int width
, int height
);
893 Combine this size object with another one replacing the default (i.e.
894 equal to -1) components of this object with those of the other. It is
895 typically used like this:
898 if ( !size.IsFullySpecified() )
900 size.SetDefaults(GetDefaultSize());
904 @see IsFullySpecified()
906 void SetDefaults(const wxSize
& sizeDefault
);
911 void SetHeight(int height
);
916 void SetWidth(int width
);
920 @name Miscellaneous operators
922 Note that these operators are documented as class members
923 (to make them easier to find) but, as their prototype shows,
924 they are implemented as global operators; note that this is
925 transparent to the user but it helps to understand why the
926 following functions are documented to take the wxSize they
927 operate on as an explicit argument.
930 wxSize
& operator=(const wxSize
& sz
);
932 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
933 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
935 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
936 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
937 wxSize
& operator +=(const wxSize
& sz
);
938 wxSize
& operator -=(const wxSize
& sz
);
940 wxSize
operator /(const wxSize
& sz
, int factor
);
941 wxSize
operator *(const wxSize
& sz
, int factor
);
942 wxSize
operator *(int factor
, const wxSize
& sz
);
943 wxSize
& operator /=(int factor
);
944 wxSize
& operator *=(int factor
);
949 Global instance of a wxSize object initialized to (-1,-1).
951 const wxSize wxDefaultSize
;
956 // ============================================================================
957 // Global functions/macros
958 // ============================================================================
960 /** @addtogroup group_funcmacro_gdi */
964 This macro loads a bitmap from either application resources (on the
965 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
966 This can help to avoid using @ifdef_ when creating bitmaps.
968 @see @ref overview_bitmap, wxICON()
972 #define wxBITMAP(bitmapName)
975 This macro loads an icon from either application resources (on the
976 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
977 This can help to avoid using @ifdef_ when creating icons.
979 @see @ref overview_bitmap, wxBITMAP()
983 #define wxICON(iconName)
986 Returns @true if the display is colour, @false otherwise.
990 bool wxColourDisplay();
993 Returns the depth of the display (a value of 1 denotes a monochrome
998 int wxDisplayDepth();
1001 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
1002 should call this function with wxNullCursor to restore the system cursor.
1004 @see wxCursor, wxWindow::SetCursor()
1006 @header{wx/gdicmn.h}
1008 void wxSetCursor(const wxCursor
& cursor
);
1012 /** @addtogroup group_funcmacro_gdi */
1015 Returns the dimensions of the work area on the display. On Windows this
1016 means the area not covered by the taskbar, etc. Other platforms are
1017 currently defaulting to the whole display until a way is found to provide
1018 this info for all window managers, etc.
1020 @header{wx/gdicmn.h}
1022 void wxClientDisplayRect(int* x
, int* y
, int* width
, int* height
);
1023 wxRect
wxGetClientDisplayRect();
1026 /** @addtogroup group_funcmacro_gdi */
1029 Returns the display resolution in pixels per inch.
1031 The @c x component of the returned wxSize object contains the horizontal
1032 resolution and the @c y one -- the vertical resolution.
1034 @header{wx/gdicmn.h}
1038 wxSize
wxGetDisplayPPI();
1041 /** @addtogroup group_funcmacro_gdi */
1044 Returns the display size in pixels.
1046 For the version taking @a width and @a header arguments, either of them
1047 can be @NULL if the caller is not interested in the returned value.
1049 @header{wx/gdicmn.h}
1051 void wxDisplaySize(int* width
, int* height
);
1052 wxSize
wxGetDisplaySize();
1055 /** @addtogroup group_funcmacro_gdi */
1058 Returns the display size in millimeters.
1060 For the version taking @a width and @a header arguments, either of them
1061 can be @NULL if the caller is not interested in the returned value.
1063 @see wxGetDisplayPPI()
1065 @header{wx/gdicmn.h}
1067 void wxDisplaySizeMM(int* width
, int* height
);
1068 wxSize
wxGetDisplaySizeMM();