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 Standard cursors. See wxCursor.
57 wxCURSOR_ARROW
, ///< A standard arrow cursor.
58 wxCURSOR_RIGHT_ARROW
, ///< A standard arrow cursor pointing to the right.
59 wxCURSOR_BULLSEYE
, ///< Bullseye cursor.
60 wxCURSOR_CHAR
, ///< Rectangular character cursor.
61 wxCURSOR_CROSS
, ///< A cross cursor.
62 wxCURSOR_HAND
, ///< A hand cursor.
63 wxCURSOR_IBEAM
, ///< An I-beam cursor (vertical line).
64 wxCURSOR_LEFT_BUTTON
, ///< Represents a mouse with the left button depressed.
65 wxCURSOR_MAGNIFIER
, ///< A magnifier icon.
66 wxCURSOR_MIDDLE_BUTTON
, ///< Represents a mouse with the middle button depressed.
67 wxCURSOR_NO_ENTRY
, ///< A no-entry sign cursor.
68 wxCURSOR_PAINT_BRUSH
, ///< A paintbrush cursor.
69 wxCURSOR_PENCIL
, ///< A pencil cursor.
70 wxCURSOR_POINT_LEFT
, ///< A cursor that points left.
71 wxCURSOR_POINT_RIGHT
, ///< A cursor that points right.
72 wxCURSOR_QUESTION_ARROW
, ///< An arrow and question mark.
73 wxCURSOR_RIGHT_BUTTON
, ///< Represents a mouse with the right button depressed.
74 wxCURSOR_SIZENESW
, ///< A sizing cursor pointing NE-SW.
75 wxCURSOR_SIZENS
, ///< A sizing cursor pointing N-S.
76 wxCURSOR_SIZENWSE
, ///< A sizing cursor pointing NW-SE.
77 wxCURSOR_SIZEWE
, ///< A sizing cursor pointing W-E.
78 wxCURSOR_SIZING
, ///< A general sizing cursor.
79 wxCURSOR_SPRAYCAN
, ///< A spraycan cursor.
80 wxCURSOR_WAIT
, ///< A wait cursor.
81 wxCURSOR_WATCH
, ///< A watch cursor.
82 wxCURSOR_BLANK
, ///< Transparent cursor.
83 wxCURSOR_DEFAULT
, ///< Standard X11 cursor (only in wxGTK).
84 wxCURSOR_COPY_ARROW
, ///< MacOS Theme Plus arrow (only in wxMac).
85 wxCURSOR_CROSS_REVERSE
, ///< Only available on wxX11.
86 wxCURSOR_DOUBLE_ARROW
, ///< Only available on wxX11.
87 wxCURSOR_BASED_ARROW_UP
, ///< Only available on wxX11.
88 wxCURSOR_BASED_ARROW_DOWN
, ///< Only available on wxX11.
89 wxCURSOR_ARROWWAIT
, ///< A wait cursor with a standard arrow.
98 A wxRealPoint is a useful data structure for graphics operations.
100 It contains floating point @e x and @e y members. See wxPoint for an
114 Initializes the point with the given coordinates.
116 wxRealPoint(double x
, double y
);
119 X coordinate of this point.
124 Y coordinate of this point.
134 A class for manipulating rectangles.
149 Creates a wxRect object from @a x, @a y, @a width and @a height values.
151 wxRect(int x
, int y
, int width
, int height
);
153 Creates a wxRect object from top-left and bottom-right points.
155 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
157 Creates a wxRect object from position and @a size values.
159 wxRect(const wxPoint
& pos
, const wxSize
& size
);
161 Creates a wxRect object from @a size values at the origin.
163 wxRect(const wxSize
& size
);
167 Returns the rectangle having the same size as this one but centered
168 relatively to the given rectangle @a r. By default, rectangle is
169 centred in both directions but if @a dir includes only @c wxVERTICAL or
170 only @c wxHORIZONTAL, then it is only centered in this direction while
171 the other component of its position remains unchanged.
173 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
174 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
178 Returns @true if the given point is inside the rectangle (or on its
179 boundary) and @false otherwise.
181 bool Contains(int x
, int y
) const;
183 Returns @true if the given point is inside the rectangle (or on its
184 boundary) and @false otherwise.
186 bool Contains(const wxPoint
& pt
) const;
188 Returns @true if the given rectangle is completely inside this
189 rectangle (or touches its boundary) and @false otherwise.
191 bool Contains(const wxRect
& rect
) const;
195 Decrease the rectangle size.
197 This method is the opposite from Inflate(): Deflate(a, b) is equivalent
198 to Inflate(-a, -b). Please refer to Inflate() for full description.
200 void Deflate(wxCoord dx
, wxCoord dy
);
201 void Deflate(const wxSize
& diff
);
202 void Deflate(wxCoord diff
);
203 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
207 Gets the bottom point of the rectangle.
209 int GetBottom() const;
212 Gets the position of the bottom left corner.
214 wxPoint
GetBottomLeft() const;
217 Gets the position of the bottom right corner.
219 wxPoint
GetBottomRight() const;
222 Gets the height member.
224 int GetHeight() const;
227 Gets the left point of the rectangle (the same as GetX()).
234 wxPoint
GetPosition() const;
237 Gets the right point of the rectangle.
239 int GetRight() const;
246 wxSize
GetSize() const;
249 Gets the top point of the rectangle (the same as GetY()).
254 Gets the position of the top left corner of the rectangle, same as
257 wxPoint
GetTopLeft() const;
260 Gets the position of the top right corner.
262 wxPoint
GetTopRight() const;
265 Gets the width member.
267 int GetWidth() const;
281 Increases the size of the rectangle.
283 The left border is moved farther left and the right border is moved
284 farther right by @a dx. The upper border is moved farther up and the
285 bottom border is moved farther down by @a dy. (Note the the width and
286 height of the rectangle thus change by 2*dx and 2*dy, respectively.) If
287 one or both of @a dx and @a dy are negative, the opposite happens: the
288 rectangle size decreases in the respective direction.
290 Inflating and deflating behaves "naturally". Defined more precisely,
292 -# "Real" inflates (that is, @a dx and/or @a dy = 0) are not
293 constrained. Thus inflating a rectangle can cause its upper left
294 corner to move into the negative numbers. (2.5.4 and older forced
295 the top left coordinate to not fall below (0, 0), which implied a
296 forced move of the rectangle.)
297 -# Deflates are clamped to not reduce the width or height of the
298 rectangle below zero. In such cases, the top-left corner is
299 nonetheless handled properly. For example, a rectangle at (10, 10)
300 with size (20, 40) that is inflated by (-15, -15) will become
301 located at (20, 25) at size (0, 10). Finally, observe that the width
302 and height are treated independently. In the above example, the
303 width is reduced by 20, whereas the height is reduced by the full 30
304 (rather than also stopping at 20, when the width reached zero).
308 void Inflate(wxCoord dx
, wxCoord dy
);
309 void Inflate(const wxSize
& diff
);
310 void Inflate(wxCoord diff
);
311 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
316 Modifies the rectangle to contain the overlapping box of this rectangle
317 and the one passed in as parameter.
319 wxRect
Intersect(const wxRect
& rect
) const;
320 wxRect
& Intersect(const wxRect
& rect
);
324 Returns @true if this rectangle has a non-empty intersection with the
325 rectangle @a rect and @false otherwise.
327 bool Intersects(const wxRect
& rect
) const;
330 Returns @true if this rectangle has a width or height less than or
331 equal to 0 and @false otherwise.
333 bool IsEmpty() const;
337 Moves the rectangle by the specified offset. If @a dx is positive, the
338 rectangle is moved to the right, if @a dy is positive, it is moved to the
339 bottom, otherwise it is moved to the left or top respectively.
341 void Offset(wxCoord dx
, wxCoord dy
);
342 void Offset(const wxPoint
& pt
);
348 void SetHeight(int height
);
355 void SetSize(const wxSize
& s
);
360 void SetWidth(int width
);
374 Modifies the rectangle to contain the bounding box of this rectangle
375 and the one passed in as parameter.
377 wxRect
Union(const wxRect
& rect
) const;
378 wxRect
& Union(const wxRect
& rect
);
384 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
388 Like Union(), but doesn't treat empty rectangles specially.
390 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
391 wxRect
& operator +=(const wxRect
& r
);
396 Returns the intersection of two rectangles (which may be empty).
398 wxRect
operator *(const wxRect
& r1
, const wxRect
& r2
);
399 wxRect
& operator *=(const wxRect
& r
);
405 void operator =(const wxRect
& rect
);
410 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
423 x coordinate of the top-level corner of the rectangle.
428 y coordinate of the top-level corner of the rectangle.
438 A wxPoint is a useful data structure for graphics operations.
440 It contains integer @e x and @e y members. See wxRealPoint for a floating
459 wxPoint(int x
, int y
);
465 void operator =(const wxPoint
& pt
);
467 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
468 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
470 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
471 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
473 wxPoint
& operator +=(const wxPoint
& pt
);
474 wxPoint
& operator -=(const wxPoint
& pt
);
476 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
477 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
478 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
479 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
481 wxPoint
& operator +=(const wxSize
& sz
);
482 wxPoint
& operator -=(const wxSize
& sz
);
496 Global istance of a wxPoint initialized with values (-1,-1).
498 wxPoint wxDefaultPosition
;
502 @class wxColourDatabase
504 wxWidgets maintains a database of standard RGB colours for a predefined
505 set of named colours. The application may add to this set if desired by
506 using AddColour() and may use it to look up colours by names using Find()
507 or find the names for the standard colour using FindName().
509 There is one predefined, global instance of this class called
510 ::wxTheColourDatabase.
512 The standard database contains at least the following colours:
557 @n MEDIUM SPRING GREEN
595 class wxColourDatabase
599 Constructs the colour database. It will be initialized at the first
605 Adds a colour to the database. If a colour with the same name already
606 exists, it is replaced.
608 void AddColour(const wxString
& colourName
, const wxColour
& colour
);
611 Finds a colour given the name. Returns an invalid colour object (that
612 is, wxColour::IsOk() will return @false) if the colour wasn't found in
615 wxColour
Find(const wxString
& colourName
);
618 Finds a colour name given the colour. Returns an empty string if the
619 colour is not found in the database.
621 wxString
FindName(const wxColour
& colour
) const;
628 A wxSize is a useful data structure for graphics operations. It simply
629 contains integer @e width and @e height members.
631 wxSize is used throughout wxWidgets as well as wxPoint which, although
632 almost equivalent to wxSize, has a different meaning: wxPoint represents a
633 position while wxSize represents the size.
636 wxPython defines aliases for the @e x and @e y members named @e width and
637 @e height since it makes much more sense for sizes.
646 @see wxPoint, wxRealPoint
653 Creates a size object.
656 wxSize(int width
, int height
);
661 Decreases the size in both x and y directions.
665 void DecBy(const wxSize
& size
);
666 void DecBy(int dx
, int dy
);
671 Decrements this object so that both of its dimensions are not greater
672 than the corresponding dimensions of the @a size.
676 void DecTo(const wxSize
& size
);
679 Gets the height member.
681 int GetHeight() const;
684 Gets the width member.
686 int GetWidth() const;
690 Increases the size in both x and y directions.
694 void IncBy(const wxSize
& size
);
695 void IncBy(int dx
, int dy
);
700 Increments this object so that both of its dimensions are not less than
701 the corresponding dimensions of the @a size.
705 void IncTo(const wxSize
& size
);
708 Returns @true if neither of the size object components is equal to -1,
709 which is used as default for the size values in wxWidgets (hence the
710 predefined ::wxDefaultSize has both of its components equal to -1).
712 This method is typically used before calling SetDefaults().
714 bool IsFullySpecified() const;
717 Scales the dimensions of this object by the given factors. If you want
718 to scale both dimensions by the same factor you can also use
721 @return A reference to this object (so that you can concatenate other
722 operations in the same line).
724 wxSize
& Scale(float xscale
, float yscale
);
727 Sets the width and height members.
729 void Set(int width
, int height
);
732 Combine this size object with another one replacing the default (i.e.
733 equal to -1) components of this object with those of the other. It is
734 typically used like this:
737 if ( !size.IsFullySpecified() )
739 size.SetDefaults(GetDefaultSize());
743 @see IsFullySpecified()
745 void SetDefaults(const wxSize
& sizeDefault
);
750 void SetHeight(int height
);
755 void SetWidth(int width
);
760 void operator =(const wxSize
& sz
);
762 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
763 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
765 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
766 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
767 wxSize
& operator +=(const wxSize
& sz
);
768 wxSize
& operator -=(const wxSize
& sz
);
770 wxSize
operator /(const wxSize
& sz
, int factor
);
771 wxSize
operator *(const wxSize
& sz
, int factor
);
772 wxSize
operator *(int factor
, const wxSize
& sz
);
773 wxSize
& operator /=(int factor
);
774 wxSize
& operator *=(int factor
);
778 Global instance of a wxSize object initialized to (-1,-1).
780 wxSize wxDefaultSize
;
785 // ============================================================================
786 // Global functions/macros
787 // ============================================================================
789 /** @ingroup group_funcmacro_gdi */
793 This macro loads a bitmap from either application resources (on the
794 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
795 This can help to avoid using @ifdef_ when creating bitmaps.
797 @see @ref overview_bitmap, wxICON()
801 #define wxBITMAP(bitmapName)
804 This macro loads an icon from either application resources (on the
805 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
806 This can help to avoid using @ifdef_ when creating icons.
808 @see @ref overview_bitmap, wxBITMAP()
815 Returns @true if the display is colour, @false otherwise.
819 bool wxColourDisplay();
822 Returns the depth of the display (a value of 1 denotes a monochrome
827 int wxDisplayDepth();
830 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
831 should call this function with wxNullCursor to restore the system cursor.
833 @see wxCursor, wxWindow::SetCursor()
837 void wxSetCursor(const wxCursor
& cursor
);
841 /** @ingroup group_funcmacro_gdi */
844 Returns the dimensions of the work area on the display. On Windows this
845 means the area not covered by the taskbar, etc. Other platforms are
846 currently defaulting to the whole display until a way is found to provide
847 this info for all window managers, etc.
851 void wxClientDisplayRect(int* x
, int* y
, int* width
, int* height
);
852 wxRect
wxGetClientDisplayRect();
855 /** @ingroup group_funcmacro_gdi */
858 Returns the display resolution in pixels per inch.
860 The @c x component of the returned wxSize object contains the horizontal
861 resolution and the @c y one -- the vertical resolution.
867 wxSize
wxGetDisplayPPI();
870 /** @ingroup group_funcmacro_gdi */
873 Returns the display size in pixels.
875 For the version taking @a width and @a header arguments, either of them
876 can be @NULL if the caller is not interested in the returned value.
880 void wxDisplaySize(int* width
, int* height
);
881 wxSize
wxGetDisplaySize();
884 /** @ingroup group_funcmacro_gdi */
887 Returns the display size in millimeters.
889 For the version taking @a width and @a header arguments, either of them
890 can be @NULL if the caller is not interested in the returned value.
892 @see wxGetDisplayPPI()
896 void wxDisplaySizeMM(int* width
, int* height
);
897 wxSize
wxGetDisplaySizeMM();