1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRealPoint
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 See wxBitmap and wxImage classes.
17 wxBITMAP_TYPE_INVALID
,
19 wxBITMAP_TYPE_BMP_RESOURCE
,
20 wxBITMAP_TYPE_RESOURCE
= wxBITMAP_TYPE_BMP_RESOURCE
,
22 wxBITMAP_TYPE_ICO_RESOURCE
,
24 wxBITMAP_TYPE_CUR_RESOURCE
,
26 wxBITMAP_TYPE_XBM_DATA
,
28 wxBITMAP_TYPE_XPM_DATA
,
30 wxBITMAP_TYPE_TIF_RESOURCE
,
32 wxBITMAP_TYPE_GIF_RESOURCE
,
34 wxBITMAP_TYPE_PNG_RESOURCE
,
36 wxBITMAP_TYPE_JPEG_RESOURCE
,
38 wxBITMAP_TYPE_PNM_RESOURCE
,
40 wxBITMAP_TYPE_PCX_RESOURCE
,
42 wxBITMAP_TYPE_PICT_RESOURCE
,
44 wxBITMAP_TYPE_ICON_RESOURCE
,
48 wxBITMAP_TYPE_MACCURSOR
,
49 wxBITMAP_TYPE_MACCURSOR_RESOURCE
,
50 wxBITMAP_TYPE_ANY
= 50
70 wxCURSOR_MIDDLE_BUTTON
,
76 wxCURSOR_QUESTION_ARROW
,
77 wxCURSOR_RIGHT_BUTTON
,
87 wxCURSOR_DEFAULT
, //!< standard X11 cursor
88 wxCURSOR_COPY_ARROW
, //!< MacOS Theme Plus arrow
89 // Not yet implemented for Windows
90 wxCURSOR_CROSS_REVERSE
,
91 wxCURSOR_DOUBLE_ARROW
,
92 wxCURSOR_BASED_ARROW_UP
,
93 wxCURSOR_BASED_ARROW_DOWN
,
104 A @b wxRealPoint is a useful data structure for graphics operations.
106 It contains floating point @e x and @e y members.
107 See also wxPoint for an integer version.
120 Initializes the point with the given coordinates.
122 wxRealPoint(double x
, double y
);
125 X coordinate of this point.
130 Y coordinate of this point.
141 A class for manipulating rectangles.
153 Creates a wxRect object from size values at the origin.
156 wxRect(int x
, int y
, int width
, int height
);
157 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
158 wxRect(const wxPoint
& pos
, const wxSize
& size
);
159 wxRect(const wxSize
& size
);
164 Returns the rectangle having the same size as this one but centered relatively
165 to the given rectangle @e r. By default, rectangle is centred in both
166 directions but if @a dir includes only @c wxVERTICAL or only
167 @c wxHORIZONTAL flag, then it is only centered in this direction while
168 the other component of its position remains unchanged.
170 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
171 const wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
176 Returns @true if the given rectangle is completely inside this rectangle
177 (or touches its boundary) and @false otherwise.
179 bool Contains(int x
, int y
) const;
180 const bool Contains(const wxPoint
& pt
) const;
181 const bool Contains(const wxRect
& rect
) const;
186 Decrease the rectangle size.
187 This method is the opposite from Inflate():
188 Deflate(a, b) is equivalent to Inflate(-a, -b).
189 Please refer to Inflate() for full description.
193 void Deflate(wxCoord dx
, wxCoord dy
) const;
194 void Deflate(const wxSize
& diff
) const;
195 void Deflate(wxCoord diff
) const;
196 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
200 Gets the bottom point of the rectangle.
202 int GetBottom() const;
205 Gets the position of the bottom left corner.
207 wxPoint
GetBottomLeft() const;
210 Gets the position of the bottom right corner.
212 wxPoint
GetBottomRight() const;
215 Gets the height member.
217 int GetHeight() const;
220 Gets the left point of the rectangle (the same as wxRect::GetX).
227 wxPoint
GetPosition() const;
230 Gets the right point of the rectangle.
232 int GetRight() const;
239 wxSize
GetSize() const;
242 Gets the top point of the rectangle (the same as wxRect::GetY).
247 Gets the position of the top left corner of the rectangle, same as
250 wxPoint
GetTopLeft() const;
253 Gets the position of the top right corner.
255 wxPoint
GetTopRight() const;
258 Gets the width member.
260 int GetWidth() const;
274 Increases the size of the rectangle.
275 The second form uses the same @a diff for both @a dx and @e dy.
276 The first two versions modify the rectangle in place, the last one returns a
277 new rectangle leaving this one unchanged.
278 The left border is moved farther left and the right border is moved farther
279 right by @e dx. The upper border is moved farther up and the bottom border
280 is moved farther down by @e dy. (Note the the width and height of the
281 rectangle thus change by 2*@a dx and 2*@e dy, respectively.) If one or
282 both of @a dx and @a dy are negative, the opposite happens: the rectangle
283 size decreases in the respective direction.
284 Inflating and deflating behaves "naturally". Defined more precisely, that
286 "Real" inflates (that is, @a dx and/or @a dy = 0) are not
287 constrained. Thus inflating a rectangle can cause its upper left corner
288 to move into the negative numbers. (the versions prior to 2.5.4 forced
289 the top left coordinate to not fall below (0, 0), which implied a
290 forced move of the rectangle.)
291 Deflates are clamped to not reduce the width or height of the
292 rectangle below zero. In such cases, the top-left corner is nonetheless
293 handled properly. For example, a rectangle at (10, 10) with size (20,
294 40) that is inflated by (-15, -15) will become located at (20, 25) at
295 size (0, 10). Finally, observe that the width and height are treated
296 independently. In the above example, the width is reduced by 20,
297 whereas the height is reduced by the full 30 (rather than also stopping
298 at 20, when the width reached zero).
302 void Inflate(wxCoord dx
, wxCoord dy
) const;
303 void Inflate(const wxSize
& diff
) const;
304 void Inflate(wxCoord diff
) const;
305 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
310 Modifies the rectangle to contain the overlapping box of this rectangle and the
311 one passed in as parameter. The const version returns the new rectangle, the
312 other one modifies this rectangle in place.
314 wxRect
Intersect(const wxRect
& rect
);
315 const wxRect
& Intersect(const wxRect
& rect
);
319 Returns @true if this rectangle has a non-empty intersection with the
320 rectangle @a rect and @false otherwise.
322 bool Intersects(const wxRect
& rect
) const;
325 Returns @true if this rectangle has a width or height less than or equal to
326 0 and @false otherwise.
328 bool IsEmpty() const;
332 Moves the rectangle by the specified offset. If @a dx is positive, the
333 rectangle is moved to the right, if @a dy is positive, it is moved to the
334 bottom, otherwise it is moved to the left or top respectively.
336 void Offset(wxCoord dx
, wxCoord dy
);
337 void Offset(const wxPoint
& pt
);
343 void SetHeight(int height
);
350 void SetSize(const wxSize
& s
);
355 void SetWidth(int width
);
369 Modifies the rectangle to contain the bounding box of this rectangle and the
370 one passed in as parameter. The const version returns the new rectangle, the
371 other one modifies this rectangle in place.
373 wxRect
Union(const wxRect
& rect
);
374 const wxRect
& Union(const wxRect
& rect
);
385 Returns the intersection of two rectangles (which may be empty).
387 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
388 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
389 wxRect
operator +=(const wxRect
& r
);
390 See also wxRect
operator *(const wxRect
& r1
,
392 wxRect
operator *=(const wxRect
& r
);
398 void operator =(const wxRect
& rect
);
403 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
413 x coordinate of the top-level corner of the rectangle.
419 y coordinate of the top-level corner of the rectangle.
429 A @b wxPoint is a useful data structure for graphics operations.
430 It simply contains integer @e x and @e y members.
432 See also wxRealPoint for a floating point version.
450 wxPoint(int x
, int y
);
455 Operators for sum and subtraction between a wxPoint object and a
458 void operator =(const wxPoint
& pt
);
459 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
460 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
461 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
462 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
463 wxPoint
operator +=(const wxPoint
& pt
);
464 wxPoint
operator -=(const wxPoint
& pt
);
465 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
466 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
467 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
468 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
469 wxPoint
operator +=(const wxSize
& sz
);
470 wxPoint
operator -=(const wxSize
& sz
);
486 Global istance of a wxPoint initialized with values -1;-1.
488 wxPoint wxDefaultPosition
;
492 @class wxColourDatabase
495 wxWidgets maintains a database of standard RGB colours for a predefined
496 set of named colours (such as "BLACK", "LIGHT GREY"). The
497 application may add to this set if desired by using
498 wxColourDatabase::AddColour and may use it to look up
499 colours by names using wxColourDatabase::Find or find the names
500 for the standard colour suing wxColourDatabase::FindName.
502 There is one predefined instance of this class called
503 @b wxTheColourDatabase.
510 class wxColourDatabase
514 Constructs the colour database. It will be initialized at the first use.
520 Adds a colour to the database. If a colour with the same name already exists,
522 Please note that the overload taking a pointer is deprecated and will be
523 removed in the next wxWidgets version, please don't use it.
525 void AddColour(const wxString
& colourName
,
526 const wxColour
& colour
);
527 void AddColour(const wxString
& colourName
, wxColour
* colour
);
531 Finds a colour given the name. Returns an invalid colour object (that is, such
532 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
533 found in the database.
535 wxColour
Find(const wxString
& colourName
);
538 Finds a colour name given the colour. Returns an empty string if the colour is
539 not found in the database.
541 wxString
FindName(const wxColour
& colour
) const;
549 A @b wxSize is a useful data structure for graphics operations.
550 It simply contains integer @e width and @e height members.
552 wxSize is used throughout wxWidgets as well as wxPoint which, although almost
553 equivalent to wxSize, has a different meaning: wxPoint represents a position
554 while wxSize - the size.
556 @b wxPython note: wxPython defines aliases for the @c x and @c y members
557 named @c width and @c height since it makes much more sense for
566 @see wxPoint, wxRealPoint
573 Creates a size object.
576 wxSize(int width
, int height
);
581 Decreases the size in x- and y- directions
582 By @e size.x and @e size.y for the first overload
583 By @a dx and @a dy for the second one
584 By @a d and @a d for the third one
588 void DecBy(const wxSize
& size
);
589 void DecBy(int dx
, int dy
);
594 Decrements this object so that both of its dimensions are not greater than the
595 corresponding dimensions of the @e size.
599 void DecTo(const wxSize
& size
);
602 Gets the height member.
604 int GetHeight() const;
607 Gets the width member.
609 int GetWidth() const;
613 Increases the size in x- and y- directions
614 By @e size.x and @e size.y for the first overload
615 By @a dx and @a dy for the second one
616 By @a d and @a d for the third one
620 void IncBy(const wxSize
& size
);
621 void IncBy(int dx
, int dy
);
626 Increments this object so that both of its dimensions are not less than the
627 corresponding dimensions of the @e size.
631 void IncTo(const wxSize
& size
);
634 Returns @true if neither of the size object components is equal to -1, which
635 is used as default for the size values in wxWidgets (hence the predefined
636 @c wxDefaultSize has both of its components equal to -1).
637 This method is typically used before calling
640 bool IsFullySpecified() const;
644 Operators for division and multiplication between a wxSize object and an
647 void operator =(const wxSize
& sz
);
648 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
649 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
650 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
651 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
652 wxSize
operator +=(const wxSize
& sz
);
653 wxSize
operator -=(const wxSize
& sz
);
654 wxSize
operator /(const wxSize
& sz
, int factor
);
655 wxSize
operator *(const wxSize
& sz
, int factor
);
656 wxSize
operator *(int factor
, const wxSize
& sz
);
657 wxSize
operator /=(int factor
);
658 wxSize
operator *=(int factor
);
662 Scales the dimensions of this object by the given factors.
663 If you want to scale both dimensions by the same factor you can also use
664 the @ref operators() "operator *="
665 Returns a reference to this object (so that you can concatenate other
666 operations in the same line).
668 wxSize
Scale(float xscale
, float yscale
);
671 Sets the width and height members.
673 void Set(int width
, int height
);
676 Combine this size object with another one replacing the default (i.e. equal
677 to -1) components of this object with those of the other. It is typically
680 @see IsFullySpecified()
682 void SetDefaults(const wxSize
& sizeDefault
);
687 void SetHeight(int height
);
692 void SetWidth(int width
);
696 Global instance of a wxSize object initialized with values -1;-1.
698 wxSize wxDefaultSize
;
703 // ============================================================================
704 // Global functions/macros
705 // ============================================================================
707 /** @ingroup group_funcmacro_gdi */
711 This macro loads a bitmap from either application resources (on the
712 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
713 This can help to avoid using @ifdef_ when creating bitmaps.
715 @see @ref overview_bitmap, wxICON()
719 #define wxBITMAP(bitmapName)
722 This macro loads an icon from either application resources (on the
723 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
724 This can help to avoid using @ifdef_ when creating icons.
726 @see @ref overview_bitmap, wxBITMAP()
733 Returns @true if the display is colour, @false otherwise.
737 bool wxColourDisplay();
740 Returns the depth of the display (a value of 1 denotes a monochrome
745 int wxDisplayDepth();
748 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
749 should call this function with wxNullCursor to restore the system cursor.
751 @see wxCursor, wxWindow::SetCursor()
755 void wxSetCursor(const wxCursor
& cursor
);
759 /** @ingroup group_funcmacro_gdi */
762 Returns the dimensions of the work area on the display. On Windows this
763 means the area not covered by the taskbar, etc. Other platforms are
764 currently defaulting to the whole display until a way is found to provide
765 this info for all window managers, etc.
769 void wxClientDisplayRect(int* x
, int* y
, int* width
, int* height
);
770 wxRect
wxGetClientDisplayRect();
773 /** @ingroup group_funcmacro_gdi */
776 Returns the display size in pixels.
780 void wxDisplaySize(int* width
, int* height
);
781 wxSize
wxGetDisplaySize();
784 /** @ingroup group_funcmacro_gdi */
787 Returns the display size in millimeters.
791 void wxDisplaySizeMM(int* width
, int* height
);
792 wxSize
wxGetDisplaySizeMM();