1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI classes, types and declarations
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
21 #include "wx/string.h"
22 #include "wx/fontenc.h"
23 #include "wx/hashmap.h"
26 // ---------------------------------------------------------------------------
27 // forward declarations
28 // ---------------------------------------------------------------------------
30 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
31 class WXDLLIMPEXP_FWD_CORE wxBrush
;
32 class WXDLLIMPEXP_FWD_CORE wxColour
;
33 class WXDLLIMPEXP_FWD_CORE wxCursor
;
34 class WXDLLIMPEXP_FWD_CORE wxFont
;
35 class WXDLLIMPEXP_FWD_CORE wxIcon
;
36 class WXDLLIMPEXP_FWD_CORE wxPalette
;
37 class WXDLLIMPEXP_FWD_CORE wxPen
;
38 class WXDLLIMPEXP_FWD_CORE wxRegion
;
39 class WXDLLIMPEXP_FWD_BASE wxString
;
40 class WXDLLIMPEXP_FWD_CORE wxIconBundle
;
41 class WXDLLIMPEXP_FWD_CORE wxPoint
;
43 // ---------------------------------------------------------------------------
45 // ---------------------------------------------------------------------------
50 wxBITMAP_TYPE_INVALID
, // should be == 0 for compatibility!
52 wxBITMAP_TYPE_BMP_RESOURCE
,
53 wxBITMAP_TYPE_RESOURCE
= wxBITMAP_TYPE_BMP_RESOURCE
,
55 wxBITMAP_TYPE_ICO_RESOURCE
,
57 wxBITMAP_TYPE_CUR_RESOURCE
,
59 wxBITMAP_TYPE_XBM_DATA
,
61 wxBITMAP_TYPE_XPM_DATA
,
63 wxBITMAP_TYPE_TIF
= wxBITMAP_TYPE_TIFF
,
64 wxBITMAP_TYPE_TIFF_RESOURCE
,
65 wxBITMAP_TYPE_TIF_RESOURCE
= wxBITMAP_TYPE_TIFF_RESOURCE
,
67 wxBITMAP_TYPE_GIF_RESOURCE
,
69 wxBITMAP_TYPE_PNG_RESOURCE
,
71 wxBITMAP_TYPE_JPEG_RESOURCE
,
73 wxBITMAP_TYPE_PNM_RESOURCE
,
75 wxBITMAP_TYPE_PCX_RESOURCE
,
77 wxBITMAP_TYPE_PICT_RESOURCE
,
79 wxBITMAP_TYPE_ICON_RESOURCE
,
83 wxBITMAP_TYPE_MACCURSOR
,
84 wxBITMAP_TYPE_MACCURSOR_RESOURCE
,
87 wxBITMAP_TYPE_ANY
= 50
90 // Polygon filling mode
91 enum wxPolygonFillMode
100 wxCURSOR_NONE
, // should be 0
102 wxCURSOR_RIGHT_ARROW
,
108 wxCURSOR_LEFT_BUTTON
,
110 wxCURSOR_MIDDLE_BUTTON
,
112 wxCURSOR_PAINT_BRUSH
,
115 wxCURSOR_POINT_RIGHT
,
116 wxCURSOR_QUESTION_ARROW
,
117 wxCURSOR_RIGHT_BUTTON
,
128 wxCURSOR_DEFAULT
, // standard X11 cursor
131 wxCURSOR_COPY_ARROW
, // MacOS Theme Plus arrow
134 // Not yet implemented for Windows
135 wxCURSOR_CROSS_REVERSE
,
136 wxCURSOR_DOUBLE_ARROW
,
137 wxCURSOR_BASED_ARROW_UP
,
138 wxCURSOR_BASED_ARROW_DOWN
,
143 wxCURSOR_CLOSED_HAND
,
150 #define wxCURSOR_DEFAULT wxCURSOR_ARROW
154 // TODO CS supply openhand and closedhand cursors
155 #define wxCURSOR_OPEN_HAND wxCURSOR_HAND
156 #define wxCURSOR_CLOSED_HAND wxCURSOR_HAND
159 // ---------------------------------------------------------------------------
161 // ---------------------------------------------------------------------------
163 /* Useful macro for creating icons portably, for example:
165 wxIcon *icon = new wxICON(sample);
169 wxIcon *icon = new wxIcon("sample"); // On wxMSW
170 wxIcon *icon = new wxIcon(sample_xpm); // On wxGTK
174 // Load from a resource
175 #define wxICON(X) wxIcon(wxT(#X))
176 #elif defined(__WXPM__)
177 // Load from a resource
178 #define wxICON(X) wxIcon(wxT(#X))
179 #elif defined(__WXDFB__)
180 // Initialize from an included XPM
181 #define wxICON(X) wxIcon( X##_xpm )
182 #elif defined(__WXGTK__)
183 // Initialize from an included XPM
184 #define wxICON(X) wxIcon( X##_xpm )
185 #elif defined(__WXMAC__)
186 // Initialize from an included XPM
187 #define wxICON(X) wxIcon( X##_xpm )
188 #elif defined(__WXMOTIF__)
189 // Initialize from an included XPM
190 #define wxICON(X) wxIcon( X##_xpm )
191 #elif defined(__WXX11__)
192 // Initialize from an included XPM
193 #define wxICON(X) wxIcon( X##_xpm )
195 // This will usually mean something on any platform
196 #define wxICON(X) wxIcon(wxT(#X))
199 /* Another macro: this one is for portable creation of bitmaps. We assume that
200 under Unix bitmaps live in XPMs and under Windows they're in ressources.
203 #if defined(__WXMSW__) || defined(__WXPM__)
204 #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_BMP_RESOURCE)
205 #elif defined(__WXGTK__) || \
206 defined(__WXMOTIF__) || \
207 defined(__WXX11__) || \
208 defined(__WXMAC__) || \
209 defined(__WXDFB__) || \
211 // Initialize from an included XPM
212 #define wxBITMAP(name) wxBitmap(name##_xpm)
213 #else // other platforms
214 #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
217 // ===========================================================================
219 // ===========================================================================
221 // ---------------------------------------------------------------------------
223 // ---------------------------------------------------------------------------
225 class WXDLLIMPEXP_CORE wxSize
228 // members are public for compatibility, don't use them directly.
232 wxSize() : x(0), y(0) { }
233 wxSize(int xx
, int yy
) : x(xx
), y(yy
) { }
235 // no copy ctor or assignment operator - the defaults are ok
237 wxSize
& operator+=(const wxSize
& sz
) { x
+= sz
.x
; y
+= sz
.y
; return *this; }
238 wxSize
& operator-=(const wxSize
& sz
) { x
-= sz
.x
; y
-= sz
.y
; return *this; }
239 wxSize
& operator/=(int i
) { x
/= i
; y
/= i
; return *this; }
240 wxSize
& operator*=(int i
) { x
*= i
; y
*= i
; return *this; }
241 wxSize
& operator/=(unsigned int i
) { x
/= i
; y
/= i
; return *this; }
242 wxSize
& operator*=(unsigned int i
) { x
*= i
; y
*= i
; return *this; }
243 wxSize
& operator/=(long i
) { x
/= i
; y
/= i
; return *this; }
244 wxSize
& operator*=(long i
) { x
*= i
; y
*= i
; return *this; }
245 wxSize
& operator/=(unsigned long i
) { x
/= i
; y
/= i
; return *this; }
246 wxSize
& operator*=(unsigned long i
) { x
*= i
; y
*= i
; return *this; }
247 wxSize
& operator/=(double i
) { x
= int(x
/i
); y
= int(y
/i
); return *this; }
248 wxSize
& operator*=(double i
) { x
= int(x
*i
); y
= int(y
*i
); return *this; }
250 void IncTo(const wxSize
& sz
)
251 { if ( sz
.x
> x
) x
= sz
.x
; if ( sz
.y
> y
) y
= sz
.y
; }
252 void DecTo(const wxSize
& sz
)
253 { if ( sz
.x
< x
) x
= sz
.x
; if ( sz
.y
< y
) y
= sz
.y
; }
255 void IncBy(int dx
, int dy
) { x
+= dx
; y
+= dy
; }
256 void IncBy(const wxPoint
& pt
);
257 void IncBy(const wxSize
& sz
) { IncBy(sz
.x
, sz
.y
); }
258 void IncBy(int d
) { IncBy(d
, d
); }
260 void DecBy(int dx
, int dy
) { IncBy(-dx
, -dy
); }
261 void DecBy(const wxPoint
& pt
);
262 void DecBy(const wxSize
& sz
) { DecBy(sz
.x
, sz
.y
); }
263 void DecBy(int d
) { DecBy(d
, d
); }
266 wxSize
& Scale(float xscale
, float yscale
)
267 { x
= (int)(x
*xscale
); y
= (int)(y
*yscale
); return *this; }
270 void Set(int xx
, int yy
) { x
= xx
; y
= yy
; }
271 void SetWidth(int w
) { x
= w
; }
272 void SetHeight(int h
) { y
= h
; }
274 int GetWidth() const { return x
; }
275 int GetHeight() const { return y
; }
277 bool IsFullySpecified() const { return x
!= wxDefaultCoord
&& y
!= wxDefaultCoord
; }
279 // combine this size with the other one replacing the default (i.e. equal
280 // to wxDefaultCoord) components of this object with those of the other
281 void SetDefaults(const wxSize
& size
)
283 if ( x
== wxDefaultCoord
)
285 if ( y
== wxDefaultCoord
)
290 int GetX() const { return x
; }
291 int GetY() const { return y
; }
294 inline bool operator==(const wxSize
& s1
, const wxSize
& s2
)
296 return s1
.x
== s2
.x
&& s1
.y
== s2
.y
;
299 inline bool operator!=(const wxSize
& s1
, const wxSize
& s2
)
301 return s1
.x
!= s2
.x
|| s1
.y
!= s2
.y
;
304 inline wxSize
operator+(const wxSize
& s1
, const wxSize
& s2
)
306 return wxSize(s1
.x
+ s2
.x
, s1
.y
+ s2
.y
);
309 inline wxSize
operator-(const wxSize
& s1
, const wxSize
& s2
)
311 return wxSize(s1
.x
- s2
.x
, s1
.y
- s2
.y
);
314 inline wxSize
operator/(const wxSize
& s
, int i
)
316 return wxSize(s
.x
/ i
, s
.y
/ i
);
319 inline wxSize
operator*(const wxSize
& s
, int i
)
321 return wxSize(s
.x
* i
, s
.y
* i
);
324 inline wxSize
operator*(int i
, const wxSize
& s
)
326 return wxSize(s
.x
* i
, s
.y
* i
);
329 inline wxSize
operator/(const wxSize
& s
, unsigned int i
)
331 return wxSize(s
.x
/ i
, s
.y
/ i
);
334 inline wxSize
operator*(const wxSize
& s
, unsigned int i
)
336 return wxSize(s
.x
* i
, s
.y
* i
);
339 inline wxSize
operator*(unsigned int i
, const wxSize
& s
)
341 return wxSize(s
.x
* i
, s
.y
* i
);
344 inline wxSize
operator/(const wxSize
& s
, long i
)
346 return wxSize(s
.x
/ i
, s
.y
/ i
);
349 inline wxSize
operator*(const wxSize
& s
, long i
)
351 return wxSize(s
.x
* i
, s
.y
* i
);
354 inline wxSize
operator*(long i
, const wxSize
& s
)
356 return wxSize(s
.x
* i
, s
.y
* i
);
359 inline wxSize
operator/(const wxSize
& s
, unsigned long i
)
361 return wxSize(s
.x
/ i
, s
.y
/ i
);
364 inline wxSize
operator*(const wxSize
& s
, unsigned long i
)
366 return wxSize(s
.x
* i
, s
.y
* i
);
369 inline wxSize
operator*(unsigned long i
, const wxSize
& s
)
371 return wxSize(s
.x
* i
, s
.y
* i
);
374 inline wxSize
operator*(const wxSize
& s
, double i
)
376 return wxSize(int(s
.x
* i
), int(s
.y
* i
));
379 inline wxSize
operator*(double i
, const wxSize
& s
)
381 return wxSize(int(s
.x
* i
), int(s
.y
* i
));
386 // ---------------------------------------------------------------------------
387 // Point classes: with real or integer coordinates
388 // ---------------------------------------------------------------------------
390 class WXDLLIMPEXP_CORE wxRealPoint
396 wxRealPoint() : x(0.0), y(0.0) { }
397 wxRealPoint(double xx
, double yy
) : x(xx
), y(yy
) { }
398 wxRealPoint(const wxPoint
& pt
);
400 // no copy ctor or assignment operator - the defaults are ok
402 //assignment operators
403 wxRealPoint
& operator+=(const wxRealPoint
& p
) { x
+= p
.x
; y
+= p
.y
; return *this; }
404 wxRealPoint
& operator-=(const wxRealPoint
& p
) { x
-= p
.x
; y
-= p
.y
; return *this; }
406 wxRealPoint
& operator+=(const wxSize
& s
) { x
+= s
.GetWidth(); y
+= s
.GetHeight(); return *this; }
407 wxRealPoint
& operator-=(const wxSize
& s
) { x
-= s
.GetWidth(); y
-= s
.GetHeight(); return *this; }
411 inline bool operator==(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
413 return wxIsSameDouble(p1
.x
, p2
.x
) && wxIsSameDouble(p1
.y
, p2
.y
);
416 inline bool operator!=(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
421 inline wxRealPoint
operator+(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
423 return wxRealPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
427 inline wxRealPoint
operator-(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
429 return wxRealPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
433 inline wxRealPoint
operator/(const wxRealPoint
& s
, int i
)
435 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
438 inline wxRealPoint
operator*(const wxRealPoint
& s
, int i
)
440 return wxRealPoint(s
.x
* i
, s
.y
* i
);
443 inline wxRealPoint
operator*(int i
, const wxRealPoint
& s
)
445 return wxRealPoint(s
.x
* i
, s
.y
* i
);
448 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned int i
)
450 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
453 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned int i
)
455 return wxRealPoint(s
.x
* i
, s
.y
* i
);
458 inline wxRealPoint
operator*(unsigned int i
, const wxRealPoint
& s
)
460 return wxRealPoint(s
.x
* i
, s
.y
* i
);
463 inline wxRealPoint
operator/(const wxRealPoint
& s
, long i
)
465 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
468 inline wxRealPoint
operator*(const wxRealPoint
& s
, long i
)
470 return wxRealPoint(s
.x
* i
, s
.y
* i
);
473 inline wxRealPoint
operator*(long i
, const wxRealPoint
& s
)
475 return wxRealPoint(s
.x
* i
, s
.y
* i
);
478 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned long i
)
480 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
483 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned long i
)
485 return wxRealPoint(s
.x
* i
, s
.y
* i
);
488 inline wxRealPoint
operator*(unsigned long i
, const wxRealPoint
& s
)
490 return wxRealPoint(s
.x
* i
, s
.y
* i
);
493 inline wxRealPoint
operator*(const wxRealPoint
& s
, double i
)
495 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
498 inline wxRealPoint
operator*(double i
, const wxRealPoint
& s
)
500 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
504 // ----------------------------------------------------------------------------
505 // wxPoint: 2D point with integer coordinates
506 // ----------------------------------------------------------------------------
508 class WXDLLIMPEXP_CORE wxPoint
513 wxPoint() : x(0), y(0) { }
514 wxPoint(int xx
, int yy
) : x(xx
), y(yy
) { }
515 wxPoint(const wxRealPoint
& pt
) : x(int(pt
.x
)), y(int(pt
.y
)) { }
517 // no copy ctor or assignment operator - the defaults are ok
519 //assignment operators
520 wxPoint
& operator+=(const wxPoint
& p
) { x
+= p
.x
; y
+= p
.y
; return *this; }
521 wxPoint
& operator-=(const wxPoint
& p
) { x
-= p
.x
; y
-= p
.y
; return *this; }
523 wxPoint
& operator+=(const wxSize
& s
) { x
+= s
.GetWidth(); y
+= s
.GetHeight(); return *this; }
524 wxPoint
& operator-=(const wxSize
& s
) { x
-= s
.GetWidth(); y
-= s
.GetHeight(); return *this; }
526 // check if both components are set/initialized
527 bool IsFullySpecified() const { return x
!= wxDefaultCoord
&& y
!= wxDefaultCoord
; }
529 // fill in the unset components with the values from the other point
530 void SetDefaults(const wxPoint
& pt
)
532 if ( x
== wxDefaultCoord
)
534 if ( y
== wxDefaultCoord
)
541 inline bool operator==(const wxPoint
& p1
, const wxPoint
& p2
)
543 return p1
.x
== p2
.x
&& p1
.y
== p2
.y
;
546 inline bool operator!=(const wxPoint
& p1
, const wxPoint
& p2
)
552 // arithmetic operations (component wise)
553 inline wxPoint
operator+(const wxPoint
& p1
, const wxPoint
& p2
)
555 return wxPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
558 inline wxPoint
operator-(const wxPoint
& p1
, const wxPoint
& p2
)
560 return wxPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
563 inline wxPoint
operator+(const wxPoint
& p
, const wxSize
& s
)
565 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
568 inline wxPoint
operator-(const wxPoint
& p
, const wxSize
& s
)
570 return wxPoint(p
.x
- s
.x
, p
.y
- s
.y
);
573 inline wxPoint
operator+(const wxSize
& s
, const wxPoint
& p
)
575 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
578 inline wxPoint
operator-(const wxSize
& s
, const wxPoint
& p
)
580 return wxPoint(s
.x
- p
.x
, s
.y
- p
.y
);
583 inline wxPoint
operator-(const wxPoint
& p
)
585 return wxPoint(-p
.x
, -p
.y
);
588 inline wxPoint
operator/(const wxPoint
& s
, int i
)
590 return wxPoint(s
.x
/ i
, s
.y
/ i
);
593 inline wxPoint
operator*(const wxPoint
& s
, int i
)
595 return wxPoint(s
.x
* i
, s
.y
* i
);
598 inline wxPoint
operator*(int i
, const wxPoint
& s
)
600 return wxPoint(s
.x
* i
, s
.y
* i
);
603 inline wxPoint
operator/(const wxPoint
& s
, unsigned int i
)
605 return wxPoint(s
.x
/ i
, s
.y
/ i
);
608 inline wxPoint
operator*(const wxPoint
& s
, unsigned int i
)
610 return wxPoint(s
.x
* i
, s
.y
* i
);
613 inline wxPoint
operator*(unsigned int i
, const wxPoint
& s
)
615 return wxPoint(s
.x
* i
, s
.y
* i
);
618 inline wxPoint
operator/(const wxPoint
& s
, long i
)
620 return wxPoint(s
.x
/ i
, s
.y
/ i
);
623 inline wxPoint
operator*(const wxPoint
& s
, long i
)
625 return wxPoint(s
.x
* i
, s
.y
* i
);
628 inline wxPoint
operator*(long i
, const wxPoint
& s
)
630 return wxPoint(s
.x
* i
, s
.y
* i
);
633 inline wxPoint
operator/(const wxPoint
& s
, unsigned long i
)
635 return wxPoint(s
.x
/ i
, s
.y
/ i
);
638 inline wxPoint
operator*(const wxPoint
& s
, unsigned long i
)
640 return wxPoint(s
.x
* i
, s
.y
* i
);
643 inline wxPoint
operator*(unsigned long i
, const wxPoint
& s
)
645 return wxPoint(s
.x
* i
, s
.y
* i
);
648 inline wxPoint
operator*(const wxPoint
& s
, double i
)
650 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
653 inline wxPoint
operator*(double i
, const wxPoint
& s
)
655 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
658 WX_DECLARE_LIST_WITH_DECL(wxPoint
, wxPointList
, class WXDLLIMPEXP_CORE
);
660 // ---------------------------------------------------------------------------
662 // ---------------------------------------------------------------------------
664 class WXDLLIMPEXP_CORE wxRect
668 : x(0), y(0), width(0), height(0)
670 wxRect(int xx
, int yy
, int ww
, int hh
)
671 : x(xx
), y(yy
), width(ww
), height(hh
)
673 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
674 wxRect(const wxPoint
& pt
, const wxSize
& size
)
675 : x(pt
.x
), y(pt
.y
), width(size
.x
), height(size
.y
)
677 wxRect(const wxSize
& size
)
678 : x(0), y(0), width(size
.x
), height(size
.y
)
681 // default copy ctor and assignment operators ok
683 int GetX() const { return x
; }
684 void SetX(int xx
) { x
= xx
; }
686 int GetY() const { return y
; }
687 void SetY(int yy
) { y
= yy
; }
689 int GetWidth() const { return width
; }
690 void SetWidth(int w
) { width
= w
; }
692 int GetHeight() const { return height
; }
693 void SetHeight(int h
) { height
= h
; }
695 wxPoint
GetPosition() const { return wxPoint(x
, y
); }
696 void SetPosition( const wxPoint
&p
) { x
= p
.x
; y
= p
.y
; }
698 wxSize
GetSize() const { return wxSize(width
, height
); }
699 void SetSize( const wxSize
&s
) { width
= s
.GetWidth(); height
= s
.GetHeight(); }
701 bool IsEmpty() const { return (width
<= 0) || (height
<= 0); }
703 int GetLeft() const { return x
; }
704 int GetTop() const { return y
; }
705 int GetBottom() const { return y
+ height
- 1; }
706 int GetRight() const { return x
+ width
- 1; }
708 void SetLeft(int left
) { x
= left
; }
709 void SetRight(int right
) { width
= right
- x
+ 1; }
710 void SetTop(int top
) { y
= top
; }
711 void SetBottom(int bottom
) { height
= bottom
- y
+ 1; }
713 wxPoint
GetTopLeft() const { return GetPosition(); }
714 wxPoint
GetLeftTop() const { return GetTopLeft(); }
715 void SetTopLeft(const wxPoint
&p
) { SetPosition(p
); }
716 void SetLeftTop(const wxPoint
&p
) { SetTopLeft(p
); }
718 wxPoint
GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
719 wxPoint
GetRightBottom() const { return GetBottomRight(); }
720 void SetBottomRight(const wxPoint
&p
) { SetRight(p
.x
); SetBottom(p
.y
); }
721 void SetRightBottom(const wxPoint
&p
) { SetBottomRight(p
); }
723 wxPoint
GetTopRight() const { return wxPoint(GetRight(), GetTop()); }
724 wxPoint
GetRightTop() const { return GetTopRight(); }
725 void SetTopRight(const wxPoint
&p
) { SetRight(p
.x
); SetTop(p
.y
); }
726 void SetRightTop(const wxPoint
&p
) { SetTopRight(p
); }
728 wxPoint
GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); }
729 wxPoint
GetLeftBottom() const { return GetBottomLeft(); }
730 void SetBottomLeft(const wxPoint
&p
) { SetLeft(p
.x
); SetBottom(p
.y
); }
731 void SetLeftBottom(const wxPoint
&p
) { SetBottomLeft(p
); }
733 // operations with rect
734 wxRect
& Inflate(wxCoord dx
, wxCoord dy
);
735 wxRect
& Inflate(const wxSize
& d
) { return Inflate(d
.x
, d
.y
); }
736 wxRect
& Inflate(wxCoord d
) { return Inflate(d
, d
); }
737 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const
744 wxRect
& Deflate(wxCoord dx
, wxCoord dy
) { return Inflate(-dx
, -dy
); }
745 wxRect
& Deflate(const wxSize
& d
) { return Inflate(-d
.x
, -d
.y
); }
746 wxRect
& Deflate(wxCoord d
) { return Inflate(-d
); }
747 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const
754 void Offset(wxCoord dx
, wxCoord dy
) { x
+= dx
; y
+= dy
; }
755 void Offset(const wxPoint
& pt
) { Offset(pt
.x
, pt
.y
); }
757 wxRect
& Intersect(const wxRect
& rect
);
758 wxRect
Intersect(const wxRect
& rect
) const
765 wxRect
& Union(const wxRect
& rect
);
766 wxRect
Union(const wxRect
& rect
) const
773 // return true if the point is (not strcitly) inside the rect
774 bool Contains(int x
, int y
) const;
775 bool Contains(const wxPoint
& pt
) const { return Contains(pt
.x
, pt
.y
); }
776 // return true if the rectangle 'rect' is (not strictly) inside this rect
777 bool Contains(const wxRect
& rect
) const;
779 #if WXWIN_COMPATIBILITY_2_6
780 // use Contains() instead
781 wxDEPRECATED( bool Inside(int x
, int y
) const );
782 wxDEPRECATED( bool Inside(const wxPoint
& pt
) const );
783 wxDEPRECATED( bool Inside(const wxRect
& rect
) const );
784 #endif // WXWIN_COMPATIBILITY_2_6
786 // return true if the rectangles have a non empty intersection
787 bool Intersects(const wxRect
& rect
) const;
789 // like Union() but don't ignore empty rectangles
790 wxRect
& operator+=(const wxRect
& rect
);
792 // intersections of two rectrangles not testing for empty rectangles
793 wxRect
& operator*=(const wxRect
& rect
);
795 // centre this rectangle in the given (usually, but not necessarily,
797 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const
799 return wxRect(dir
& wxHORIZONTAL
? r
.x
+ (r
.width
- width
)/2 : x
,
800 dir
& wxVERTICAL
? r
.y
+ (r
.height
- height
)/2 : y
,
804 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const
806 return CentreIn(r
, dir
);
810 int x
, y
, width
, height
;
814 // compare rectangles
815 inline bool operator==(const wxRect
& r1
, const wxRect
& r2
)
817 return (r1
.x
== r2
.x
) && (r1
.y
== r2
.y
) &&
818 (r1
.width
== r2
.width
) && (r1
.height
== r2
.height
);
821 inline bool operator!=(const wxRect
& r1
, const wxRect
& r2
)
826 // like Union() but don't treat empty rectangles specially
827 WXDLLIMPEXP_CORE wxRect
operator+(const wxRect
& r1
, const wxRect
& r2
);
829 // intersections of two rectangles
830 WXDLLIMPEXP_CORE wxRect
operator*(const wxRect
& r1
, const wxRect
& r2
);
835 #if WXWIN_COMPATIBILITY_2_6
836 inline bool wxRect::Inside(int cx
, int cy
) const { return Contains(cx
, cy
); }
837 inline bool wxRect::Inside(const wxPoint
& pt
) const { return Contains(pt
); }
838 inline bool wxRect::Inside(const wxRect
& rect
) const { return Contains(rect
); }
839 #endif // WXWIN_COMPATIBILITY_2_6
842 // define functions which couldn't be defined above because of declarations
844 inline void wxSize::IncBy(const wxPoint
& pt
) { IncBy(pt
.x
, pt
.y
); }
845 inline void wxSize::DecBy(const wxPoint
& pt
) { DecBy(pt
.x
, pt
.y
); }
847 // ---------------------------------------------------------------------------
848 // Management of pens, brushes and fonts
849 // ---------------------------------------------------------------------------
851 typedef wxInt8 wxDash
;
853 class WXDLLIMPEXP_CORE wxGDIObjListBase
{
862 WX_DECLARE_STRING_HASH_MAP(wxColour
*, wxStringToColourHashMap
);
864 class WXDLLIMPEXP_CORE wxColourDatabase
870 // find colour by name or name for the given colour
871 wxColour
Find(const wxString
& name
) const;
872 wxString
FindName(const wxColour
& colour
) const;
874 // add a new colour to the database
875 void AddColour(const wxString
& name
, const wxColour
& colour
);
877 #if WXWIN_COMPATIBILITY_2_6
878 // deprecated, use Find() instead
879 wxDEPRECATED( wxColour
*FindColour(const wxString
& name
) );
880 #endif // WXWIN_COMPATIBILITY_2_6
884 // PM keeps its own type of colour table
890 // load the database with the built in colour values when called for the
891 // first time, do nothing after this
894 wxStringToColourHashMap
*m_map
;
897 class WXDLLIMPEXP_CORE wxResourceCache
: public wxList
900 wxResourceCache() { }
901 #if !wxUSE_STD_CONTAINERS
902 wxResourceCache(const unsigned int keyType
) : wxList(keyType
) { }
904 virtual ~wxResourceCache();
907 // ---------------------------------------------------------------------------
909 // ---------------------------------------------------------------------------
914 wxStockGDI creates the stock GDI objects on demand. Pointers to the
915 created objects are stored in the ms_stockObject array, which is indexed
916 by the Item enum values. Platorm-specific fonts can be created by
917 implementing a derived class with an override for the GetFont function.
918 wxStockGDI operates as a singleton, accessed through the ms_instance
919 pointer. By default this pointer is set to an instance of wxStockGDI.
920 A derived class must arrange to set this pointer to an instance of itself.
922 class WXDLLIMPEXP_CORE wxStockGDI
968 virtual ~wxStockGDI();
969 static void DeleteAll();
971 static wxStockGDI
& instance() { return *ms_instance
; }
973 static const wxBrush
* GetBrush(Item item
);
974 static const wxColour
* GetColour(Item item
);
975 static const wxCursor
* GetCursor(Item item
);
976 // Can be overridden by platform-specific derived classes
977 virtual const wxFont
* GetFont(Item item
);
978 static const wxPen
* GetPen(Item item
);
981 static wxStockGDI
* ms_instance
;
983 static wxObject
* ms_stockObject
[ITEMCOUNT
];
985 wxDECLARE_NO_COPY_CLASS(wxStockGDI
);
988 #define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
989 #define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
990 #define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
991 #define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
993 #define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
994 #define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
995 #define wxBLUE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLUE)
996 #define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
997 #define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
998 #define wxYELLOW_PEN wxStockGDI::GetPen(wxStockGDI::PEN_YELLOW)
999 #define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
1000 #define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
1001 #define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
1002 #define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
1003 #define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
1004 #define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
1006 #define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
1007 #define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
1008 #define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
1009 #define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
1010 #define wxYELLOW_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_YELLOW)
1011 #define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
1012 #define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
1013 #define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
1014 #define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
1015 #define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
1016 #define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
1018 #define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
1019 #define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
1020 #define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
1021 #define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
1022 #define wxYELLOW wxStockGDI::GetColour(wxStockGDI::COLOUR_YELLOW)
1023 #define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
1024 #define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
1025 #define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
1027 #define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
1028 #define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
1029 #define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
1032 extern WXDLLIMPEXP_DATA_CORE(wxBitmap
) wxNullBitmap
;
1033 extern WXDLLIMPEXP_DATA_CORE(wxIcon
) wxNullIcon
;
1034 extern WXDLLIMPEXP_DATA_CORE(wxCursor
) wxNullCursor
;
1035 extern WXDLLIMPEXP_DATA_CORE(wxPen
) wxNullPen
;
1036 extern WXDLLIMPEXP_DATA_CORE(wxBrush
) wxNullBrush
;
1037 extern WXDLLIMPEXP_DATA_CORE(wxPalette
) wxNullPalette
;
1038 extern WXDLLIMPEXP_DATA_CORE(wxFont
) wxNullFont
;
1039 extern WXDLLIMPEXP_DATA_CORE(wxColour
) wxNullColour
;
1040 extern WXDLLIMPEXP_DATA_CORE(wxIconBundle
) wxNullIconBundle
;
1042 extern WXDLLIMPEXP_DATA_CORE(wxColourDatabase
*) wxTheColourDatabase
;
1044 extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr
[];
1046 extern WXDLLIMPEXP_DATA_CORE(const wxSize
) wxDefaultSize
;
1047 extern WXDLLIMPEXP_DATA_CORE(const wxPoint
) wxDefaultPosition
;
1049 // ---------------------------------------------------------------------------
1051 // ---------------------------------------------------------------------------
1053 // resource management
1054 extern void WXDLLIMPEXP_CORE
wxInitializeStockLists();
1055 extern void WXDLLIMPEXP_CORE
wxDeleteStockLists();
1057 // is the display colour (or monochrome)?
1058 extern bool WXDLLIMPEXP_CORE
wxColourDisplay();
1060 // Returns depth of screen
1061 extern int WXDLLIMPEXP_CORE
wxDisplayDepth();
1062 #define wxGetDisplayDepth wxDisplayDepth
1064 // get the display size
1065 extern void WXDLLIMPEXP_CORE
wxDisplaySize(int *width
, int *height
);
1066 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySize();
1067 extern void WXDLLIMPEXP_CORE
wxDisplaySizeMM(int *width
, int *height
);
1068 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySizeMM();
1069 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplayPPI();
1071 // Get position and size of the display workarea
1072 extern void WXDLLIMPEXP_CORE
wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
);
1073 extern wxRect WXDLLIMPEXP_CORE
wxGetClientDisplayRect();
1075 // set global cursor
1076 extern void WXDLLIMPEXP_CORE
wxSetCursor(const wxCursor
& cursor
);