1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRealPoint
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
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
66 wxCURSOR_MIDDLE_BUTTON
,
72 wxCURSOR_QUESTION_ARROW
,
73 wxCURSOR_RIGHT_BUTTON
,
83 wxCURSOR_DEFAULT
, //!< standard X11 cursor
84 wxCURSOR_COPY_ARROW
, //!< MacOS Theme Plus arrow
85 // Not yet implemented for Windows
86 wxCURSOR_CROSS_REVERSE
,
87 wxCURSOR_DOUBLE_ARROW
,
88 wxCURSOR_BASED_ARROW_UP
,
89 wxCURSOR_BASED_ARROW_DOWN
,
100 A @b wxRealPoint is a useful data structure for graphics operations.
101 It contains floating point @e x and @e y members.
102 See also wxPoint for an integer version.
117 Members of the @b wxRealPoint object.
120 wxRealPoint(double x
, double y
);
130 A class for manipulating rectangles.
142 Creates a wxRect object from size values at the origin.
145 wxRect(int x
, int y
, int width
, int height
);
146 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
147 wxRect(const wxPoint
& pos
, const wxSize
& size
);
148 wxRect(const wxSize
& size
);
153 Returns the rectangle having the same size as this one but centered relatively
154 to the given rectangle @e r. By default, rectangle is centred in both
155 directions but if @a dir includes only @c wxVERTICAL or only
156 @c wxHORIZONTAL flag, then it is only centered in this direction while
157 the other component of its position remains unchanged.
159 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
160 const wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
165 Returns @true if the given rectangle is completely inside this rectangle
166 (or touches its boundary) and @false otherwise.
168 bool Contains(int x
, int y
) const;
169 const bool Contains(const wxPoint
& pt
) const;
170 const bool Contains(const wxRect
& rect
) const;
175 Decrease the rectangle size.
176 This method is the opposite from Inflate():
177 Deflate(a, b) is equivalent to Inflate(-a, -b).
178 Please refer to Inflate() for full description.
182 void Deflate(wxCoord dx
, wxCoord dy
) const;
183 void Deflate(const wxSize
& diff
) const;
184 void Deflate(wxCoord diff
) const;
185 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
189 Gets the bottom point of the rectangle.
191 int GetBottom() const;
194 Gets the position of the bottom left corner.
196 wxPoint
GetBottomLeft() const;
199 Gets the position of the bottom right corner.
201 wxPoint
GetBottomRight() const;
204 Gets the height member.
206 int GetHeight() const;
209 Gets the left point of the rectangle (the same as wxRect::GetX).
216 wxPoint
GetPosition() const;
219 Gets the right point of the rectangle.
221 int GetRight() const;
228 wxSize
GetSize() const;
231 Gets the top point of the rectangle (the same as wxRect::GetY).
236 Gets the position of the top left corner of the rectangle, same as
239 wxPoint
GetTopLeft() const;
242 Gets the position of the top right corner.
244 wxPoint
GetTopRight() const;
247 Gets the width member.
249 int GetWidth() const;
263 Increases the size of the rectangle.
264 The second form uses the same @a diff for both @a dx and @e dy.
265 The first two versions modify the rectangle in place, the last one returns a
266 new rectangle leaving this one unchanged.
267 The left border is moved farther left and the right border is moved farther
268 right by @e dx. The upper border is moved farther up and the bottom border
269 is moved farther down by @e dy. (Note the the width and height of the
270 rectangle thus change by 2*@a dx and 2*@e dy, respectively.) If one or
271 both of @a dx and @a dy are negative, the opposite happens: the rectangle
272 size decreases in the respective direction.
273 Inflating and deflating behaves "naturally''. Defined more precisely, that
275 "Real'' inflates (that is, @a dx and/or @a dy = 0) are not
276 constrained. Thus inflating a rectangle can cause its upper left corner
277 to move into the negative numbers. (the versions prior to 2.5.4 forced
278 the top left coordinate to not fall below (0, 0), which implied a
279 forced move of the rectangle.)
280 Deflates are clamped to not reduce the width or height of the
281 rectangle below zero. In such cases, the top-left corner is nonetheless
282 handled properly. For example, a rectangle at (10, 10) with size (20,
283 40) that is inflated by (-15, -15) will become located at (20, 25) at
284 size (0, 10). Finally, observe that the width and height are treated
285 independently. In the above example, the width is reduced by 20,
286 whereas the height is reduced by the full 30 (rather than also stopping
287 at 20, when the width reached zero).
291 void Inflate(wxCoord dx
, wxCoord dy
) const;
292 void Inflate(const wxSize
& diff
) const;
293 void Inflate(wxCoord diff
) const;
294 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
299 Modifies the rectangle to contain the overlapping box of this rectangle and the
300 one passed in as parameter. The const version returns the new rectangle, the
301 other one modifies this rectangle in place.
303 wxRect
Intersect(const wxRect
& rect
);
304 const wxRect
& Intersect(const wxRect
& rect
);
308 Returns @true if this rectangle has a non-empty intersection with the
309 rectangle @a rect and @false otherwise.
311 bool Intersects(const wxRect
& rect
) const;
314 Returns @true if this rectangle has a width or height less than or equal to
315 0 and @false otherwise.
317 bool IsEmpty() const;
321 Moves the rectangle by the specified offset. If @a dx is positive, the
322 rectangle is moved to the right, if @a dy is positive, it is moved to the
323 bottom, otherwise it is moved to the left or top respectively.
325 void Offset(wxCoord dx
, wxCoord dy
);
326 void Offset(const wxPoint
& pt
);
332 void SetHeight(int height
);
339 void SetSize(const wxSize
& s
);
344 void SetWidth(int width
);
358 Modifies the rectangle to contain the bounding box of this rectangle and the
359 one passed in as parameter. The const version returns the new rectangle, the
360 other one modifies this rectangle in place.
362 wxRect
Union(const wxRect
& rect
);
363 const wxRect
& Union(const wxRect
& rect
);
374 Returns the intersection of two rectangles (which may be empty).
376 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
377 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
378 wxRect
operator +=(const wxRect
& r
);
379 See also wxRect
operator *(const wxRect
& r1
,
381 wxRect
operator *=(const wxRect
& r
);
387 void operator =(const wxRect
& rect
);
392 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
402 x coordinate of the top-level corner of the rectangle.
408 y coordinate of the top-level corner of the rectangle.
418 A @b wxPoint is a useful data structure for graphics operations.
419 It simply contains integer @e x and @e y members.
421 See also wxRealPoint for a floating point version.
436 wxPoint(int x
, int y
);
441 Operators for sum and subtraction between a wxPoint object and a
444 void operator =(const wxPoint
& pt
);
445 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
446 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
447 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
448 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
449 wxPoint
operator +=(const wxPoint
& pt
);
450 wxPoint
operator -=(const wxPoint
& pt
);
451 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
452 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
453 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
454 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
455 wxPoint
operator +=(const wxSize
& sz
);
456 wxPoint
operator -=(const wxSize
& sz
);
474 @class wxColourDatabase
477 wxWidgets maintains a database of standard RGB colours for a predefined
478 set of named colours (such as "BLACK'', "LIGHT GREY''). The
479 application may add to this set if desired by using
480 wxColourDatabase::AddColour and may use it to look up
481 colours by names using wxColourDatabase::Find or find the names
482 for the standard colour suing wxColourDatabase::FindName.
484 There is one predefined instance of this class called
485 @b wxTheColourDatabase.
492 class wxColourDatabase
496 Constructs the colour database. It will be initialized at the first use.
502 Adds a colour to the database. If a colour with the same name already exists,
504 Please note that the overload taking a pointer is deprecated and will be
505 removed in the next wxWidgets version, please don't use it.
507 void AddColour(const wxString
& colourName
,
508 const wxColour
& colour
);
509 void AddColour(const wxString
& colourName
, wxColour
* colour
);
513 Finds a colour given the name. Returns an invalid colour object (that is, such
514 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
515 found in the database.
517 wxColour
Find(const wxString
& colourName
);
520 Finds a colour name given the colour. Returns an empty string if the colour is
521 not found in the database.
523 wxString
FindName(const wxColour
& colour
) const;
532 A font list is a list containing all fonts which have been created. There
533 is only one instance of this class: @b wxTheFontList. Use this object to search
534 for a previously created font of the desired type and create it if not already
536 In some windowing systems, the font may be a scarce resource, so it is best to
537 reuse old resources if possible. When an application finishes, all fonts will
539 deleted and their resources freed, eliminating the possibility of 'memory
547 class wxFontList
: public wxList
551 Constructor. The application should not construct its own font list:
552 use the object pointer @b wxTheFontList.
557 Finds a font of the given specification, or creates one and adds it to the
558 list. See the @ref wxFont::ctor "wxFont constructor" for
559 details of the arguments.
561 wxFont
* FindOrCreateFont(int point_size
, int family
, int style
,
563 bool underline
= false,
564 const wxString
& facename
= NULL
,
565 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
);
574 A @b wxSize is a useful data structure for graphics operations.
575 It simply contains integer @e width and @e height members.
577 wxSize is used throughout wxWidgets as well as wxPoint which, although almost
578 equivalent to wxSize, has a different meaning: wxPoint represents a position
579 while wxSize - the size.
581 @b wxPython note: wxPython defines aliases for the @c x and @c y members
582 named @c width and @c height since it makes much more sense for
589 @see wxPoint, wxRealPoint
596 Creates a size object.
599 wxSize(int width
, int height
);
604 Decreases the size in x- and y- directions
605 By @e size.x and @e size.y for the first overload
606 By @a dx and @a dy for the second one
607 By @a d and @a d for the third one
611 void DecBy(const wxSize
& size
);
612 void DecBy(int dx
, int dy
);
617 Decrements this object so that both of its dimensions are not greater than the
618 corresponding dimensions of the @e size.
622 void DecTo(const wxSize
& size
);
625 Gets the height member.
627 int GetHeight() const;
630 Gets the width member.
632 int GetWidth() const;
636 Increases the size in x- and y- directions
637 By @e size.x and @e size.y for the first overload
638 By @a dx and @a dy for the second one
639 By @a d and @a d for the third one
643 void IncBy(const wxSize
& size
);
644 void IncBy(int dx
, int dy
);
649 Increments this object so that both of its dimensions are not less than the
650 corresponding dimensions of the @e size.
654 void IncTo(const wxSize
& size
);
657 Returns @true if neither of the size object components is equal to -1, which
658 is used as default for the size values in wxWidgets (hence the predefined
659 @c wxDefaultSize has both of its components equal to -1).
660 This method is typically used before calling
663 bool IsFullySpecified() const;
667 Operators for division and multiplication between a wxSize object and an
670 void operator =(const wxSize
& sz
);
671 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
672 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
673 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
674 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
675 wxSize
operator +=(const wxSize
& sz
);
676 wxSize
operator -=(const wxSize
& sz
);
677 wxSize
operator /(const wxSize
& sz
, int factor
);
678 wxSize
operator *(const wxSize
& sz
, int factor
);
679 wxSize
operator *(int factor
, const wxSize
& sz
);
680 wxSize
operator /=(int factor
);
681 wxSize
operator *=(int factor
);
685 Scales the dimensions of this object by the given factors.
686 If you want to scale both dimensions by the same factor you can also use
687 the @ref operators() "operator *="
688 Returns a reference to this object (so that you can concatenate other
689 operations in the same line).
691 wxSize
Scale(float xscale
, float yscale
);
694 Sets the width and height members.
696 void Set(int width
, int height
);
699 Combine this size object with another one replacing the default (i.e. equal
700 to -1) components of this object with those of the other. It is typically
703 @see IsFullySpecified()
705 void SetDefaults(const wxSize
& sizeDefault
);
710 void SetHeight(int height
);
715 void SetWidth(int width
);
722 // ============================================================================
723 // Global functions/macros
724 // ============================================================================
726 /** @ingroup group_funcmacro_gdi */
730 This macro loads a bitmap from either application resources (on the
731 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
732 This can help to avoid using @ifdef_ when creating bitmaps.
734 @see @ref overview_bitmap, wxICON()
738 #define wxBITMAP(bitmapName)
741 This macro loads an icon from either application resources (on the
742 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
743 This can help to avoid using @ifdef_ when creating icons.
745 @see @ref overview_bitmap, wxBITMAP()
752 Returns @true if the display is colour, @false otherwise.
756 bool wxColourDisplay();
759 Returns the depth of the display (a value of 1 denotes a monochrome
764 int wxDisplayDepth();
767 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
768 should call this function with wxNullCursor to restore the system cursor.
770 @see wxCursor, wxWindow::SetCursor()
774 void wxSetCursor(const wxCursor
& cursor
);
778 /** @ingroup group_funcmacro_gdi */
781 Returns the dimensions of the work area on the display. On Windows this
782 means the area not covered by the taskbar, etc. Other platforms are
783 currently defaulting to the whole display until a way is found to provide
784 this info for all window managers, etc.
788 void wxClientDisplayRect(int* x
, int* y
, int* width
, int* height
);
789 wxRect
wxGetClientDisplayRect();
792 /** @ingroup group_funcmacro_gdi */
795 Returns the display size in pixels.
799 void wxDisplaySize(int* width
, int* height
);
800 wxSize
wxGetDisplaySize();
803 /** @ingroup group_funcmacro_gdi */
806 Returns the display size in millimeters.
810 void wxDisplaySizeMM(int* width
, int* height
);
811 wxSize
wxGetDisplaySizeMM();