]>
git.saurik.com Git - wxWidgets.git/blob - interface/gdicmn.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRealPoint
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.
30 Members of the @b wxRealPoint object.
33 wxRealPoint(double x
, double y
);
43 A class for manipulating rectangles.
55 Creates a wxRect object from size values at the origin.
58 wxRect(int x
, int y
, int width
, int height
);
59 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
60 wxRect(const wxPoint
& pos
, const wxSize
& size
);
61 wxRect(const wxSize
& size
);
66 Returns the rectangle having the same size as this one but centered relatively
67 to the given rectangle @e r. By default, rectangle is centred in both
68 directions but if @a dir includes only @c wxVERTICAL or only
69 @c wxHORIZONTAL flag, then it is only centered in this direction while
70 the other component of its position remains unchanged.
72 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const;
73 const wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const;
78 Returns @true if the given rectangle is completely inside this rectangle
79 (or touches its boundary) and @false otherwise.
81 bool Contains(int x
, int y
) const;
82 const bool Contains(const wxPoint
& pt
) const;
83 const bool Contains(const wxRect
& rect
) const;
88 Decrease the rectangle size.
89 This method is the opposite from Inflate():
90 Deflate(a, b) is equivalent to Inflate(-a, -b).
91 Please refer to Inflate() for full description.
95 void Deflate(wxCoord dx
, wxCoord dy
) const;
96 void Deflate(const wxSize
& diff
) const;
97 void Deflate(wxCoord diff
) const;
98 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const;
102 Gets the bottom point of the rectangle.
104 int GetBottom() const;
107 Gets the position of the bottom left corner.
109 wxPoint
GetBottomLeft() const;
112 Gets the position of the bottom right corner.
114 wxPoint
GetBottomRight() const;
117 Gets the height member.
119 int GetHeight() const;
122 Gets the left point of the rectangle (the same as wxRect::GetX).
129 wxPoint
GetPosition() const;
132 Gets the right point of the rectangle.
134 int GetRight() const;
141 wxSize
GetSize() const;
144 Gets the top point of the rectangle (the same as wxRect::GetY).
149 Gets the position of the top left corner of the rectangle, same as
152 wxPoint
GetTopLeft() const;
155 Gets the position of the top right corner.
157 wxPoint
GetTopRight() const;
160 Gets the width member.
162 int GetWidth() const;
176 Increases the size of the rectangle.
177 The second form uses the same @a diff for both @a dx and @e dy.
178 The first two versions modify the rectangle in place, the last one returns a
179 new rectangle leaving this one unchanged.
180 The left border is moved farther left and the right border is moved farther
181 right by @e dx. The upper border is moved farther up and the bottom border
182 is moved farther down by @e dy. (Note the the width and height of the
183 rectangle thus change by 2*@a dx and 2*@e dy, respectively.) If one or
184 both of @a dx and @a dy are negative, the opposite happens: the rectangle
185 size decreases in the respective direction.
186 Inflating and deflating behaves "naturally''. Defined more precisely, that
188 "Real'' inflates (that is, @a dx and/or @a dy = 0) are not
189 constrained. Thus inflating a rectangle can cause its upper left corner
190 to move into the negative numbers. (the versions prior to 2.5.4 forced
191 the top left coordinate to not fall below (0, 0), which implied a
192 forced move of the rectangle.)
193 Deflates are clamped to not reduce the width or height of the
194 rectangle below zero. In such cases, the top-left corner is nonetheless
195 handled properly. For example, a rectangle at (10, 10) with size (20,
196 40) that is inflated by (-15, -15) will become located at (20, 25) at
197 size (0, 10). Finally, observe that the width and height are treated
198 independently. In the above example, the width is reduced by 20,
199 whereas the height is reduced by the full 30 (rather than also stopping
200 at 20, when the width reached zero).
204 void Inflate(wxCoord dx
, wxCoord dy
) const;
205 void Inflate(const wxSize
& diff
) const;
206 void Inflate(wxCoord diff
) const;
207 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const;
212 Modifies the rectangle to contain the overlapping box of this rectangle and the
213 one passed in as parameter. The const version returns the new rectangle, the
214 other one modifies this rectangle in place.
216 wxRect
Intersect(const wxRect
& rect
);
217 const wxRect
& Intersect(const wxRect
& rect
);
221 Returns @true if this rectangle has a non-empty intersection with the
222 rectangle @a rect and @false otherwise.
224 bool Intersects(const wxRect
& rect
) const;
227 Returns @true if this rectangle has a width or height less than or equal to
228 0 and @false otherwise.
230 bool IsEmpty() const;
234 Moves the rectangle by the specified offset. If @a dx is positive, the
235 rectangle is moved to the right, if @a dy is positive, it is moved to the
236 bottom, otherwise it is moved to the left or top respectively.
238 void Offset(wxCoord dx
, wxCoord dy
);
239 void Offset(const wxPoint
& pt
);
245 void SetHeight(int height
);
252 void SetSize(const wxSize
& s
);
257 void SetWidth(int width
);
271 Modifies the rectangle to contain the bounding box of this rectangle and the
272 one passed in as parameter. The const version returns the new rectangle, the
273 other one modifies this rectangle in place.
275 wxRect
Union(const wxRect
& rect
);
276 const wxRect
& Union(const wxRect
& rect
);
287 Returns the intersection of two rectangles (which may be empty).
289 bool operator !=(const wxRect
& r1
, const wxRect
& r2
);
290 wxRect
operator +(const wxRect
& r1
, const wxRect
& r2
);
291 wxRect
operator +=(const wxRect
& r
);
292 See also wxRect
operator *(const wxRect
& r1
,
294 wxRect
operator *=(const wxRect
& r
);
300 void operator =(const wxRect
& rect
);
305 bool operator ==(const wxRect
& r1
, const wxRect
& r2
);
315 x coordinate of the top-level corner of the rectangle.
321 y coordinate of the top-level corner of the rectangle.
331 A brush list is a list containing all brushes which have been created.
338 class wxBrushList
: public wxList
342 Constructor. The application should not construct its own brush list:
343 use the object pointer @b wxTheBrushList.
348 Finds a brush with the specified attributes and returns it, else creates a new
350 to the brush list, and returns it.
355 Brush style. See wxBrush::SetStyle for a list of styles.
357 wxBrush
* FindOrCreateBrush(const wxColour
& colour
,
358 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.
385 wxPoint(int x
, int y
);
390 Operators for sum and subtraction between a wxPoint object and a
393 void operator =(const wxPoint
& pt
);
394 bool operator ==(const wxPoint
& p1
, const wxPoint
& p2
);
395 bool operator !=(const wxPoint
& p1
, const wxPoint
& p2
);
396 wxPoint
operator +(const wxPoint
& p1
, const wxPoint
& p2
);
397 wxPoint
operator -(const wxPoint
& p1
, const wxPoint
& p2
);
398 wxPoint
operator +=(const wxPoint
& pt
);
399 wxPoint
operator -=(const wxPoint
& pt
);
400 wxPoint
operator +(const wxPoint
& pt
, const wxSize
& sz
);
401 wxPoint
operator -(const wxPoint
& pt
, const wxSize
& sz
);
402 wxPoint
operator +(const wxSize
& sz
, const wxPoint
& pt
);
403 wxPoint
operator -(const wxSize
& sz
, const wxPoint
& pt
);
404 wxPoint
operator +=(const wxSize
& sz
);
405 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.
441 class wxColourDatabase
445 Constructs the colour database. It will be initialized at the first use.
451 Adds a colour to the database. If a colour with the same name already exists,
453 Please note that the overload taking a pointer is deprecated and will be
454 removed in the next wxWidgets version, please don't use it.
456 void AddColour(const wxString
& colourName
,
457 const wxColour
& colour
);
458 void AddColour(const wxString
& colourName
, wxColour
* colour
);
462 Finds a colour given the name. Returns an invalid colour object (that is, such
463 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
464 found in the database.
466 wxColour
Find(const wxString
& colourName
);
469 Finds a colour name given the colour. Returns an empty string if the colour is
470 not found in the database.
472 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
496 class wxFontList
: public wxList
500 Constructor. The application should not construct its own font list:
501 use the object pointer @b wxTheFontList.
506 Finds a font of the given specification, or creates one and adds it to the
507 list. See the @ref wxFont::ctor "wxFont constructor" for
508 details of the arguments.
510 wxFont
* FindOrCreateFont(int point_size
, int family
, int style
,
512 bool underline
= false,
513 const wxString
& facename
= NULL
,
514 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
538 @see wxPoint, wxRealPoint
545 Creates a size object.
548 wxSize(int width
, int height
);
553 Decreases the size in x- and y- directions
554 By @e size.x and @e size.y for the first overload
555 By @a dx and @a dy for the second one
556 By @a d and @a d for the third one
560 void DecBy(const wxSize
& size
);
561 void DecBy(int dx
, int dy
);
566 Decrements this object so that both of its dimensions are not greater than the
567 corresponding dimensions of the @e size.
571 void DecTo(const wxSize
& size
);
574 Gets the height member.
576 int GetHeight() const;
579 Gets the width member.
581 int GetWidth() const;
585 Increases the size in x- and y- directions
586 By @e size.x and @e size.y for the first overload
587 By @a dx and @a dy for the second one
588 By @a d and @a d for the third one
592 void IncBy(const wxSize
& size
);
593 void IncBy(int dx
, int dy
);
598 Increments this object so that both of its dimensions are not less than the
599 corresponding dimensions of the @e size.
603 void IncTo(const wxSize
& size
);
606 Returns @true if neither of the size object components is equal to -1, which
607 is used as default for the size values in wxWidgets (hence the predefined
608 @c wxDefaultSize has both of its components equal to -1).
609 This method is typically used before calling
612 bool IsFullySpecified() const;
616 Operators for division and multiplication between a wxSize object and an
619 void operator =(const wxSize
& sz
);
620 bool operator ==(const wxSize
& s1
, const wxSize
& s2
);
621 bool operator !=(const wxSize
& s1
, const wxSize
& s2
);
622 wxSize
operator +(const wxSize
& s1
, const wxSize
& s2
);
623 wxSize
operator -(const wxSize
& s1
, const wxSize
& s2
);
624 wxSize
operator +=(const wxSize
& sz
);
625 wxSize
operator -=(const wxSize
& sz
);
626 wxSize
operator /(const wxSize
& sz
, int factor
);
627 wxSize
operator *(const wxSize
& sz
, int factor
);
628 wxSize
operator *(int factor
, const wxSize
& sz
);
629 wxSize
operator /=(int factor
);
630 wxSize
operator *=(int factor
);
634 Scales the dimensions of this object by the given factors.
635 If you want to scale both dimensions by the same factor you can also use
636 the @ref operators() "operator *="
637 Returns a reference to this object (so that you can concatenate other
638 operations in the same line).
640 wxSize
Scale(float xscale
, float yscale
);
643 Sets the width and height members.
645 void Set(int width
, int height
);
648 Combine this size object with another one replacing the default (i.e. equal
649 to -1) components of this object with those of the other. It is typically
652 @see IsFullySpecified()
654 void SetDefaults(const wxSize
& sizeDefault
);
659 void SetHeight(int height
);
664 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.
709 Constructor. The application should not construct its own pen list:
710 use the object pointer @b wxThePenList.
716 Finds a pen with the specified attributes and returns it, else creates a new
718 to the pen list, and returns it.
723 Colour name, which should be in the colour database.
727 Pen style. See wxPen::wxPen for a list of styles.
729 wxPen
* FindOrCreatePen(const wxColour
& colour
, int width
,
731 wxPen
* FindOrCreatePen(const wxString
& colourName
, int width
,
738 // ============================================================================
739 // Global functions/macros
740 // ============================================================================
742 /** @ingroup group_funcmacro_gdi */
746 Returns the dimensions of the work area on the display. On Windows
747 this means the area not covered by the taskbar, etc. Other platforms
748 are currently defaulting to the whole display until a way is found to
749 provide this info for all window managers, etc.
751 void wxClientDisplayRect(int* x
, int* y
, int* width
,
753 wxRect
wxGetClientDisplayRect();
756 Returns the display size in pixels.
758 void wxDisplaySize(int* width
, int* height
);
759 wxSize
wxGetDisplaySize();
762 Returns the display size in millimeters.
764 void wxDisplaySizeMM(int* width
, int* height
);
765 wxSize
wxGetDisplaySizeMM();
768 This macro loads an icon from either application resources (on the platforms
769 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
770 avoid using @c #ifdefs when creating icons.
772 @see @ref overview_wxbitmapoverview, wxBITMAP()
777 Returns @true if the display is colour, @false otherwise.
779 bool wxColourDisplay();
782 This macro loads a bitmap from either application resources (on the platforms
783 for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to
784 avoid using @c #ifdefs when creating bitmaps.
786 @see @ref overview_wxbitmapoverview, wxICON()
788 #define wxBITMAP() /* implementation is private */
791 Returns the depth of the display (a value of 1 denotes a monochrome display).
793 int wxDisplayDepth();