]>
git.saurik.com Git - wxWidgets.git/blob - interface/gdicmn.h
8d05fbffaa46705931f96c52aaea3bbd900933b5
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.
31 Members of the @b wxRealPoint object.
34 wxRealPoint(double x
, double y
);
43 A class for manipulating rectangles.
56 Creates a wxRect object from size values at the origin.
59 wxRect(int x
, int y
, int width
, int height
);
60 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
61 wxRect(const wxPoint
& pos
, const wxSize
& size
);
62 wxRect(const wxSize
& size
);
67 Returns the rectangle having the same size as this one but centered relatively
68 to the given rectangle @e r. By default, rectangle is centred in both
69 directions but if @a dir includes only @c wxVERTICAL or only
70 @c wxHORIZONTAL flag, then it is only centered in this direction while
71 the other component of its position remains unchanged.
73 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
74 const wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
79 Returns @true if the given rectangle is completely inside this rectangle
80 (or touches its boundary) and @false otherwise.
82 bool Contains(int x
, int y
) const;
83 const bool Contains(const wxPoint
& pt
) const;
84 const bool Contains(const wxRect
& rect
) const;
89 Decrease the rectangle size.
90 This method is the opposite from Inflate():
91 Deflate(a, b) is equivalent to Inflate(-a, -b).
92 Please refer to Inflate() for full description.
96 void Deflate(wxCoord dx
, wxCoord dy
) const;
97 void Deflate(const wxSize
& diff
) const;
98 void Deflate(wxCoord diff
) const;
99 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
103 Gets the bottom point of the rectangle.
105 int GetBottom() const;
108 Gets the position of the bottom left corner.
110 wxPoint
GetBottomLeft() const;
113 Gets the position of the bottom right corner.
115 wxPoint
GetBottomRight() const;
118 Gets the height member.
120 int GetHeight() const;
123 Gets the left point of the rectangle (the same as wxRect::GetX).
130 wxPoint
GetPosition() const;
133 Gets the right point of the rectangle.
135 int GetRight() const;
142 wxSize
GetSize() const;
145 Gets the top point of the rectangle (the same as wxRect::GetY).
150 Gets the position of the top left corner of the rectangle, same as
153 wxPoint
GetTopLeft() const;
156 Gets the position of the top right corner.
158 wxPoint
GetTopRight() const;
161 Gets the width member.
163 int GetWidth() const;
177 Increases the size of the rectangle.
178 The second form uses the same @a diff for both @a dx and @e dy.
179 The first two versions modify the rectangle in place, the last one returns a
180 new rectangle leaving this one unchanged.
181 The left border is moved farther left and the right border is moved farther
182 right by @e dx. The upper border is moved farther up and the bottom border
183 is moved farther down by @e dy. (Note the the width and height of the
184 rectangle thus change by 2*@a dx and 2*@e dy, respectively.) If one or
185 both of @a dx and @a dy are negative, the opposite happens: the rectangle
186 size decreases in the respective direction.
187 Inflating and deflating behaves "naturally''. Defined more precisely, that
189 "Real'' inflates (that is, @a dx and/or @a dy = 0) are not
190 constrained. Thus inflating a rectangle can cause its upper left corner
191 to move into the negative numbers. (the versions prior to 2.5.4 forced
192 the top left coordinate to not fall below (0, 0), which implied a
193 forced move of the rectangle.)
194 Deflates are clamped to not reduce the width or height of the
195 rectangle below zero. In such cases, the top-left corner is nonetheless
196 handled properly. For example, a rectangle at (10, 10) with size (20,
197 40) that is inflated by (-15, -15) will become located at (20, 25) at
198 size (0, 10). Finally, observe that the width and height are treated
199 independently. In the above example, the width is reduced by 20,
200 whereas the height is reduced by the full 30 (rather than also stopping
201 at 20, when the width reached zero).
205 void Inflate(wxCoord dx
, wxCoord dy
) const;
206 void Inflate(const wxSize
& diff
) const;
207 void Inflate(wxCoord diff
) const;
208 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
213 Modifies the rectangle to contain the overlapping box of this rectangle and the
214 one passed in as parameter. The const version returns the new rectangle, the
215 other one modifies this rectangle in place.
217 wxRect
Intersect(const wxRect
& rect
);
218 const wxRect
& Intersect(const wxRect
& rect
);
222 Returns @true if this rectangle has a non-empty intersection with the
223 rectangle @a rect and @false otherwise.
225 bool Intersects(const wxRect
& rect
) const;
228 Returns @true if this rectangle has a width or height less than or equal to
229 0 and @false otherwise.
231 bool IsEmpty() const;
235 Moves the rectangle by the specified offset. If @a dx is positive, the
236 rectangle is moved to the right, if @a dy is positive, it is moved to the
237 bottom, otherwise it is moved to the left or top respectively.
239 void Offset(wxCoord dx
, wxCoord dy
);
240 void Offset(const wxPoint
& pt
);
246 void SetHeight(int height
);
253 void SetSize(const wxSize
& s
);
258 void SetWidth(int width
);
272 Modifies the rectangle to contain the bounding box of this rectangle and the
273 one passed in as parameter. The const version returns the new rectangle, the
274 other one modifies this rectangle in place.
276 wxRect
Union(const wxRect
& rect
);
277 const wxRect
& Union(const wxRect
& rect
);
288 Returns the intersection of two rectangles (which may be empty).
290 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
291 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
292 wxRect
operator +=(const wxRect
& r
);
293 See also wxRect
operator *(const wxRect
& r1
,
295 wxRect
operator *=(const wxRect
& r
);
301 void operator =(const wxRect
& rect
);
306 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
316 x coordinate of the top-level corner of the rectangle.
322 y coordinate of the top-level corner of the rectangle.
331 A brush list is a list containing all brushes which have been created.
339 class wxBrushList
: public wxList
343 Constructor. The application should not construct its own brush list:
344 use the object pointer @b wxTheBrushList.
349 Finds a brush with the specified attributes and returns it, else creates a new
351 to the brush list, and returns it.
356 Brush style. See wxBrush::SetStyle for a list of styles.
358 wxBrush
* FindOrCreateBrush(const wxColour
& colour
,
359 int style
= wxSOLID
);
367 A @b wxPoint is a useful data structure for graphics operations.
368 It simply contains integer @e x and @e y members.
370 See also wxRealPoint for a floating point version.
386 wxPoint(int x
, int y
);
391 Operators for sum and subtraction between a wxPoint object and a
394 void operator =(const wxPoint
& pt
);
395 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
396 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
397 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
398 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
399 wxPoint
operator +=(const wxPoint
& pt
);
400 wxPoint
operator -=(const wxPoint
& pt
);
401 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
402 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
403 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
404 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
405 wxPoint
operator +=(const wxSize
& sz
);
406 wxPoint
operator -=(const wxSize
& sz
);
423 @class wxColourDatabase
426 wxWidgets maintains a database of standard RGB colours for a predefined
427 set of named colours (such as "BLACK'', "LIGHT GREY''). The
428 application may add to this set if desired by using
429 wxColourDatabase::AddColour and may use it to look up
430 colours by names using wxColourDatabase::Find or find the names
431 for the standard colour suing wxColourDatabase::FindName.
433 There is one predefined instance of this class called
434 @b wxTheColourDatabase.
442 class wxColourDatabase
446 Constructs the colour database. It will be initialized at the first use.
452 Adds a colour to the database. If a colour with the same name already exists,
454 Please note that the overload taking a pointer is deprecated and will be
455 removed in the next wxWidgets version, please don't use it.
457 void AddColour(const wxString
& colourName
,
458 const wxColour
& colour
);
459 void AddColour(const wxString
& colourName
, wxColour
* colour
);
463 Finds a colour given the name. Returns an invalid colour object (that is, such
464 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
465 found in the database.
467 wxColour
Find(const wxString
& colourName
);
470 Finds a colour name given the colour. Returns an empty string if the colour is
471 not found in the database.
473 wxString
FindName(const wxColour
& colour
) const;
481 A font list is a list containing all fonts which have been created. There
482 is only one instance of this class: @b wxTheFontList. Use this object to search
483 for a previously created font of the desired type and create it if not already
485 In some windowing systems, the font may be a scarce resource, so it is best to
486 reuse old resources if possible. When an application finishes, all fonts will
488 deleted and their resources freed, eliminating the possibility of 'memory
497 class wxFontList
: public wxList
501 Constructor. The application should not construct its own font list:
502 use the object pointer @b wxTheFontList.
507 Finds a font of the given specification, or creates one and adds it to the
508 list. See the @ref wxFont::ctor "wxFont constructor" for
509 details of the arguments.
511 wxFont
* FindOrCreateFont(int point_size
, int family
, int style
,
513 bool underline
= false,
514 const wxString
& facename
= NULL
,
515 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
);
523 A @b wxSize is a useful data structure for graphics operations.
524 It simply contains integer @e width and @e height members.
526 wxSize is used throughout wxWidgets as well as wxPoint which, although almost
527 equivalent to wxSize, has a different meaning: wxPoint represents a position
528 while wxSize - the size.
530 @b wxPython note: wxPython defines aliases for the @c x and @c y members
531 named @c width and @c height since it makes much more sense for
546 Creates a size object.
549 wxSize(int width
, int height
);
554 Decreases the size in x- and y- directions
555 By @e size.x and @e size.y for the first overload
556 By @a dx and @a dy for the second one
557 By @a d and @a d for the third one
561 void DecBy(const wxSize
& size
);
562 void DecBy(int dx
, int dy
);
567 Decrements this object so that both of its dimensions are not greater than the
568 corresponding dimensions of the @e size.
572 void DecTo(const wxSize
& size
);
575 Gets the height member.
577 int GetHeight() const;
580 Gets the width member.
582 int GetWidth() const;
586 Increases the size in x- and y- directions
587 By @e size.x and @e size.y for the first overload
588 By @a dx and @a dy for the second one
589 By @a d and @a d for the third one
593 void IncBy(const wxSize
& size
);
594 void IncBy(int dx
, int dy
);
599 Increments this object so that both of its dimensions are not less than the
600 corresponding dimensions of the @e size.
604 void IncTo(const wxSize
& size
);
607 Returns @true if neither of the size object components is equal to -1, which
608 is used as default for the size values in wxWidgets (hence the predefined
609 @c wxDefaultSize has both of its components equal to -1).
610 This method is typically used before calling
613 bool IsFullySpecified() const;
617 Operators for division and multiplication between a wxSize object and an
620 void operator =(const wxSize
& sz
);
621 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
622 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
623 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
624 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
625 wxSize
operator +=(const wxSize
& sz
);
626 wxSize
operator -=(const wxSize
& sz
);
627 wxSize
operator /(const wxSize
& sz
, int factor
);
628 wxSize
operator *(const wxSize
& sz
, int factor
);
629 wxSize
operator *(int factor
, const wxSize
& sz
);
630 wxSize
operator /=(int factor
);
631 wxSize
operator *=(int factor
);
635 Scales the dimensions of this object by the given factors.
636 If you want to scale both dimensions by the same factor you can also use
637 the @ref operators() "operator *="
638 Returns a reference to this object (so that you can concatenate other
639 operations in the same line).
641 wxSize
Scale(float xscale
, float yscale
);
644 Sets the width and height members.
646 void Set(int width
, int height
);
649 Combine this size object with another one replacing the default (i.e. equal
650 to -1) components of this object with those of the other. It is typically
653 @see IsFullySpecified()
655 void SetDefaults(const wxSize
& sizeDefault
);
660 void SetHeight(int height
);
665 void SetWidth(int width
);
673 There is only one instance of this class: @b wxThePenList. Use
674 this object to search for a previously created pen of the desired
675 type and create it if not already found. In some windowing systems,
676 the pen may be a scarce resource, so it can pay to reuse old
677 resources if possible. When an application finishes, all pens will
678 be deleted and their resources freed, eliminating the possibility of
679 'memory leaks'. However, it is best not to rely on this automatic
680 cleanup because it can lead to double deletion in some circumstances.
682 There are two mechanisms in recent versions of wxWidgets which make the
683 pen list less useful than it once was. Under Windows, scarce resources
684 are cleaned up internally if they are not being used. Also, a referencing
685 counting mechanism applied to all GDI objects means that some sharing
686 of underlying resources is possible. You don't have to keep track of pointers,
687 working out when it is safe delete a pen, because the referencing counting does
688 it for you. For example, you can set a pen in a device context, and then
689 immediately delete the pen you passed, because the pen is 'copied'.
691 So you may find it easier to ignore the pen list, and instead create
692 and copy pens as you see fit. If your Windows resource meter suggests
693 your application is using too many resources, you can resort to using
694 GDI lists to share objects explicitly.
696 The only compelling use for the pen list is for wxWidgets to keep
697 track of pens in order to clean them up on exit. It is also kept for
698 backward compatibility with earlier versions of wxWidgets.
710 Constructor. The application should not construct its own pen list:
711 use the object pointer @b wxThePenList.
717 Finds a pen with the specified attributes and returns it, else creates a new
719 to the pen list, and returns it.
724 Colour name, which should be in the colour database.
728 Pen style. See wxPen::wxPen for a list of styles.
730 wxPen
* FindOrCreatePen(const wxColour
& colour
, int width
,
732 wxPen
* FindOrCreatePen(const wxString
& colourName
, int width
,
738 // ============================================================================
739 // Global functions/macros
740 // ============================================================================
744 Returns the dimensions of the work area on the display. On Windows
745 this means the area not covered by the taskbar, etc. Other platforms
746 are currently defaulting to the whole display until a way is found to
747 provide this info for all window managers, etc.
749 void wxClientDisplayRect(int* x
, int* y
, int* width
,
751 wxRect
wxGetClientDisplayRect();
756 Returns the display size in pixels.
758 void wxDisplaySize(int* width
, int* height
);
759 wxSize
wxGetDisplaySize();
764 Returns the display size in millimeters.
766 void wxDisplaySizeMM(int* width
, int* height
);
767 wxSize
wxGetDisplaySizeMM();
771 This macro loads an icon from either application resources (on the platforms
772 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
773 avoid using @c #ifdefs when creating icons.
775 @see @ref overview_wxbitmapoverview, wxBITMAP
780 Returns @true if the display is colour, @false otherwise.
782 bool wxColourDisplay();
785 This macro loads a bitmap from either application resources (on the platforms
786 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
787 avoid using @c #ifdefs when creating bitmaps.
789 @see @ref overview_wxbitmapoverview, wxICON
791 #define wxBITMAP() /* implementation is private */
794 Returns the depth of the display (a value of 1 denotes a monochrome display).
796 int wxDisplayDepth();