]>
git.saurik.com Git - wxWidgets.git/blob - interface/gdicmn.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxRealPoint class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A @b wxRealPoint is a useful data structure for graphics operations.
14 It contains floating point @e x and @e y members.
15 See also wxPoint for an integer version.
34 Members of the @b wxRealPoint object.
37 wxRealPoint(double x
, double y
);
46 A class for manipulating rectangles.
59 Creates a wxRect object from size values at the origin.
62 wxRect(int x
, int y
, int width
, int height
);
63 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
64 wxRect(const wxPoint
& pos
, const wxSize
& size
);
65 wxRect(const wxSize
& size
);
70 Returns the rectangle having the same size as this one but centered relatively
71 to the given rectangle @e r. By default, rectangle is centred in both
72 directions but if @e dir includes only @c wxVERTICAL or only
73 @c wxHORIZONTAL flag, then it is only centered in this direction while
74 the other component of its position remains unchanged.
76 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
);
77 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
);
82 Returns @true if the given rectangle is completely inside this rectangle
83 (or touches its boundary) and @false otherwise.
85 bool Contains(int x
, int y
);
86 bool Contains(const wxPoint
& pt
);
87 bool Contains(const wxRect
& rect
);
92 Decrease the rectangle size.
94 This method is the opposite from Inflate():
95 Deflate(a, b) is equivalent to Inflate(-a, -b).
96 Please refer to Inflate() for full description.
100 void Deflate(wxCoord dx
, wxCoord dy
);
101 void Deflate(const wxSize
& diff
);
102 void Deflate(wxCoord diff
);
103 wxRect
Deflate(wxCoord dx
, wxCoord dy
);
107 Gets the bottom point of the rectangle.
112 Gets the position of the bottom left corner.
114 wxPoint
GetBottomLeft();
117 Gets the position of the bottom right corner.
119 wxPoint
GetBottomRight();
122 Gets the height member.
127 Gets the left point of the rectangle (the same as wxRect::GetX).
134 wxPoint
GetPosition();
137 Gets the right point of the rectangle.
149 Gets the top point of the rectangle (the same as wxRect::GetY).
154 Gets the position of the top left corner of the rectangle, same as
157 wxPoint
GetTopLeft();
160 Gets the position of the top right corner.
162 wxPoint
GetTopRight();
165 Gets the width member.
172 #define int GetX() /* implementation is private */
177 #define int GetY() /* implementation is private */
181 Increases the size of the rectangle.
183 The second form uses the same @e diff for both @e dx and @e dy.
185 The first two versions modify the rectangle in place, the last one returns a
186 new rectangle leaving this one unchanged.
188 The left border is moved farther left and the right border is moved farther
189 right by @e dx. The upper border is moved farther up and the bottom border
190 is moved farther down by @e dy. (Note the the width and height of the
191 rectangle thus change by 2*@e dx and 2*@e dy, respectively.) If one or
192 both of @e dx and @e dy are negative, the opposite happens: the rectangle
193 size decreases in the respective direction.
195 Inflating and deflating behaves "naturally''. Defined more precisely, that
198 "Real'' inflates (that is, @e dx and/or @e dy = 0) are not
199 constrained. Thus inflating a rectangle can cause its upper left corner
200 to move into the negative numbers. (the versions prior to 2.5.4 forced
201 the top left coordinate to not fall below (0, 0), which implied a
202 forced move of the rectangle.)
204 Deflates are clamped to not reduce the width or height of the
205 rectangle below zero. In such cases, the top-left corner is nonetheless
206 handled properly. For example, a rectangle at (10, 10) with size (20,
207 40) that is inflated by (-15, -15) will become located at (20, 25) at
208 size (0, 10). Finally, observe that the width and height are treated
209 independently. In the above example, the width is reduced by 20,
210 whereas the height is reduced by the full 30 (rather than also stopping
211 at 20, when the width reached zero).
215 void Inflate(wxCoord dx
, wxCoord dy
);
216 void Inflate(const wxSize
& diff
);
217 void Inflate(wxCoord diff
);
218 wxRect
Inflate(wxCoord dx
, wxCoord dy
);
223 Modifies the rectangle to contain the overlapping box of this rectangle and the
224 one passed in as parameter. The const version returns the new rectangle, the
225 other one modifies this rectangle in place.
227 wxRect
Intersect(const wxRect
& rect
);
228 wxRect
Intersect(const wxRect
& rect
);
232 Returns @true if this rectangle has a non-empty intersection with the
233 rectangle @e rect and @false otherwise.
235 bool Intersects(const wxRect
& rect
);
238 Returns @true if this rectangle has a width or height less than or equal to
239 0 and @false otherwise.
245 Moves the rectangle by the specified offset. If @e dx is positive, the
246 rectangle is moved to the right, if @e dy is positive, it is moved to the
247 bottom, otherwise it is moved to the left or top respectively.
249 void Offset(wxCoord dx
, wxCoord dy
);
250 void Offset(const wxPoint
& pt
);
256 void SetHeight(int height
);
263 void SetSize(const wxSize
& s
);
268 void SetWidth(int width
);
273 #define void SetX(int x) /* implementation is private */
278 #define void SetY(int y) /* implementation is private */
282 Modifies the rectangle to contain the bounding box of this rectangle and the
283 one passed in as parameter. The const version returns the new rectangle, the
284 other one modifies this rectangle in place.
286 wxRect
Union(const wxRect
& rect
);
287 wxRect
Union(const wxRect
& rect
);
299 Returns the intersection of two rectangles (which may be empty).
301 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
302 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
303 wxRect
operator +=(const wxRect
& r
);
304 See also wxRect
operator *(const wxRect
& r1
,
306 wxRect
operator *=(const wxRect
& r
);
312 void operator =(const wxRect
& rect
);
317 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
329 x coordinate of the top-level corner of the rectangle.
336 y coordinate of the top-level corner of the rectangle.
345 A brush list is a list containing all brushes which have been created.
353 class wxBrushList
: public wxList
357 Constructor. The application should not construct its own brush list:
358 use the object pointer @b wxTheBrushList.
363 Finds a brush with the specified attributes and returns it, else creates a new
365 to the brush list, and returns it.
371 Brush style. See wxBrush::SetStyle for a list of styles.
373 wxBrush
* FindOrCreateBrush(const wxColour
& colour
,
374 int style
= wxSOLID
);
382 A @b wxPoint is a useful data structure for graphics operations.
383 It simply contains integer @e x and @e y members.
385 See also wxRealPoint for a floating point version.
401 wxPoint(int x
, int y
);
406 Operators for sum and subtraction between a wxPoint object and a
409 void operator =(const wxPoint
& pt
);
410 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
411 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
412 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
413 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
414 wxPoint
operator +=(const wxPoint
& pt
);
415 wxPoint
operator -=(const wxPoint
& pt
);
416 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
417 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
418 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
419 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
420 wxPoint
operator +=(const wxSize
& sz
);
421 wxPoint
operator -=(const wxSize
& sz
);
440 @class wxColourDatabase
443 wxWidgets maintains a database of standard RGB colours for a predefined
444 set of named colours (such as "BLACK'', "LIGHT GREY''). The
445 application may add to this set if desired by using
446 wxColourDatabase::AddColour and may use it to look up
447 colours by names using wxColourDatabase::Find or find the names
448 for the standard colour suing wxColourDatabase::FindName.
450 There is one predefined instance of this class called
451 @b wxTheColourDatabase.
459 class wxColourDatabase
463 Constructs the colour database. It will be initialized at the first use.
469 Adds a colour to the database. If a colour with the same name already exists,
472 Please note that the overload taking a pointer is deprecated and will be
473 removed in the next wxWidgets version, please don't use it.
475 void AddColour(const wxString
& colourName
,
476 const wxColour
& colour
);
477 void AddColour(const wxString
& colourName
, wxColour
* colour
);
481 Finds a colour given the name. Returns an invalid colour object (that is, such
482 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
483 found in the database.
485 wxColour
Find(const wxString
& colourName
);
488 Finds a colour name given the colour. Returns an empty string if the colour is
489 not found in the database.
491 wxString
FindName(const wxColour
& colour
);
499 A font list is a list containing all fonts which have been created. There
500 is only one instance of this class: @b wxTheFontList. Use this object to search
501 for a previously created font of the desired type and create it if not already
503 In some windowing systems, the font may be a scarce resource, so it is best to
504 reuse old resources if possible. When an application finishes, all fonts will
506 deleted and their resources freed, eliminating the possibility of 'memory
515 class wxFontList
: public wxList
519 Constructor. The application should not construct its own font list:
520 use the object pointer @b wxTheFontList.
525 Finds a font of the given specification, or creates one and adds it to the
526 list. See the @ref wxFont::ctor "wxFont constructor" for
527 details of the arguments.
529 wxFont
* FindOrCreateFont(int point_size
, int family
, int style
,
531 bool underline
= @
false,
532 const wxString
& facename
= @NULL
,
533 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
);
541 A @b wxSize is a useful data structure for graphics operations.
542 It simply contains integer @e width and @e height members.
544 wxSize is used throughout wxWidgets as well as wxPoint which, although almost
545 equivalent to wxSize, has a different meaning: wxPoint represents a position
546 while wxSize - the size.
548 @b wxPython note: wxPython defines aliases for the @c x and @c y members
549 named @c width and @c height since it makes much more sense for
564 Creates a size object.
567 wxSize(int width
, int height
);
572 Decreases the size in x- and y- directions
574 By @e size.x and @e size.y for the first overload
575 By @e dx and @e dy for the second one
576 By @e d and @e d for the third one
580 void DecBy(const wxSize
& size
);
581 void DecBy(int dx
, int dy
);
586 Decrements this object so that both of its dimensions are not greater than the
587 corresponding dimensions of the @e size.
591 void DecTo(const wxSize
& size
);
594 Gets the height member.
599 Gets the width member.
605 Increases the size in x- and y- directions
607 By @e size.x and @e size.y for the first overload
608 By @e dx and @e dy for the second one
609 By @e d and @e d for the third one
613 void IncBy(const wxSize
& size
);
614 void IncBy(int dx
, int dy
);
619 Increments this object so that both of its dimensions are not less than the
620 corresponding dimensions of the @e size.
624 void IncTo(const wxSize
& size
);
627 Returns @true if neither of the size object components is equal to -1, which
628 is used as default for the size values in wxWidgets (hence the predefined
629 @c wxDefaultSize has both of its components equal to -1).
631 This method is typically used before calling
634 bool IsFullySpecified();
638 Operators for division and multiplication between a wxSize object and an
641 void operator =(const wxSize
& sz
);
642 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
643 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
644 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
645 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
646 wxSize
operator +=(const wxSize
& sz
);
647 wxSize
operator -=(const wxSize
& sz
);
648 wxSize
operator /(const wxSize
& sz
, int factor
);
649 wxSize
operator *(const wxSize
& sz
, int factor
);
650 wxSize
operator *(int factor
, const wxSize
& sz
);
651 wxSize
operator /=(int factor
);
652 wxSize
operator *=(int factor
);
656 Scales the dimensions of this object by the given factors.
657 If you want to scale both dimensions by the same factor you can also use
658 the @ref operators() "operator *="
660 Returns a reference to this object (so that you can concatenate other
661 operations in the same line).
663 wxSize
Scale(float xscale
, float yscale
);
666 Sets the width and height members.
668 #define void Set(int width, int height) /* implementation is private */
671 Combine this size object with another one replacing the default (i.e. equal
672 to -1) components of this object with those of the other. It is typically
675 @sa IsFullySpecified()
677 void SetDefaults(const wxSize
& sizeDefault
);
682 void SetHeight(int height
);
687 void SetWidth(int width
);
695 There is only one instance of this class: @b wxThePenList. Use
696 this object to search for a previously created pen of the desired
697 type and create it if not already found. In some windowing systems,
698 the pen may be a scarce resource, so it can pay to reuse old
699 resources if possible. When an application finishes, all pens will
700 be deleted and their resources freed, eliminating the possibility of
701 'memory leaks'. However, it is best not to rely on this automatic
702 cleanup because it can lead to double deletion in some circumstances.
704 There are two mechanisms in recent versions of wxWidgets which make the
705 pen list less useful than it once was. Under Windows, scarce resources
706 are cleaned up internally if they are not being used. Also, a referencing
707 counting mechanism applied to all GDI objects means that some sharing
708 of underlying resources is possible. You don't have to keep track of pointers,
709 working out when it is safe delete a pen, because the referencing counting does
710 it for you. For example, you can set a pen in a device context, and then
711 immediately delete the pen you passed, because the pen is 'copied'.
713 So you may find it easier to ignore the pen list, and instead create
714 and copy pens as you see fit. If your Windows resource meter suggests
715 your application is using too many resources, you can resort to using
716 GDI lists to share objects explicitly.
718 The only compelling use for the pen list is for wxWidgets to keep
719 track of pens in order to clean them up on exit. It is also kept for
720 backward compatibility with earlier versions of wxWidgets.
732 Constructor. The application should not construct its own pen list:
733 use the object pointer @b wxThePenList.
739 Finds a pen with the specified attributes and returns it, else creates a new
741 to the pen list, and returns it.
747 Colour name, which should be in the colour database.
753 Pen style. See wxPen::wxPen for a list of styles.
755 wxPen
* FindOrCreatePen(const wxColour
& colour
, int width
,
757 wxPen
* FindOrCreatePen(const wxString
& colourName
, int width
,
763 // ============================================================================
764 // Global functions/macros
765 // ============================================================================
769 Returns the dimensions of the work area on the display. On Windows
770 this means the area not covered by the taskbar, etc. Other platforms
771 are currently defaulting to the whole display until a way is found to
772 provide this info for all window managers, etc.
774 void wxClientDisplayRect(int * x
, int * y
, int * width
,
776 wxRect
wxGetClientDisplayRect();
781 Returns the display size in pixels.
783 void wxDisplaySize(int * width
, int * height
);
784 wxSize
wxGetDisplaySize();
789 Returns the display size in millimeters.
791 void wxDisplaySizeMM(int * width
, int * height
);
792 wxSize
wxGetDisplaySizeMM();
796 This macro loads an icon from either application resources (on the platforms
797 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
798 avoid using @c #ifdefs when creating icons.
800 @sa @ref overview_wxbitmapoverview "Bitmaps and icons overview", wxBITMAP
802 #define wxICON() /* implementation is private */
805 Returns @true if the display is colour, @false otherwise.
807 bool wxColourDisplay();
810 This macro loads a bitmap from either application resources (on the platforms
811 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
812 avoid using @c #ifdefs when creating bitmaps.
814 @sa @ref overview_wxbitmapoverview "Bitmaps and icons overview", wxICON
816 #define wxBITMAP() /* implementation is private */
819 Returns the depth of the display (a value of 1 denotes a monochrome display).
821 int wxDisplayDepth();