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_RESOURCE
,
65 wxBITMAP_TYPE_GIF_RESOURCE
,
67 wxBITMAP_TYPE_PNG_RESOURCE
,
69 wxBITMAP_TYPE_JPEG_RESOURCE
,
71 wxBITMAP_TYPE_PNM_RESOURCE
,
73 wxBITMAP_TYPE_PCX_RESOURCE
,
75 wxBITMAP_TYPE_PICT_RESOURCE
,
77 wxBITMAP_TYPE_ICON_RESOURCE
,
81 wxBITMAP_TYPE_MACCURSOR
,
82 wxBITMAP_TYPE_MACCURSOR_RESOURCE
,
85 wxBITMAP_TYPE_ANY
= 50
88 // Polygon filling mode
89 enum wxPolygonFillMode
98 wxCURSOR_NONE
, // should be 0
100 wxCURSOR_RIGHT_ARROW
,
106 wxCURSOR_LEFT_BUTTON
,
108 wxCURSOR_MIDDLE_BUTTON
,
110 wxCURSOR_PAINT_BRUSH
,
113 wxCURSOR_POINT_RIGHT
,
114 wxCURSOR_QUESTION_ARROW
,
115 wxCURSOR_RIGHT_BUTTON
,
126 wxCURSOR_DEFAULT
, // standard X11 cursor
129 wxCURSOR_COPY_ARROW
, // MacOS Theme Plus arrow
132 // Not yet implemented for Windows
133 wxCURSOR_CROSS_REVERSE
,
134 wxCURSOR_DOUBLE_ARROW
,
135 wxCURSOR_BASED_ARROW_UP
,
136 wxCURSOR_BASED_ARROW_DOWN
,
141 wxCURSOR_CLOSED_HAND
,
148 #define wxCURSOR_DEFAULT wxCURSOR_ARROW
152 // TODO CS supply openhand and closedhand cursors
153 #define wxCURSOR_OPEN_HAND wxCURSOR_HAND
154 #define wxCURSOR_CLOSED_HAND wxCURSOR_HAND
157 // ---------------------------------------------------------------------------
159 // ---------------------------------------------------------------------------
161 /* Useful macro for creating icons portably, for example:
163 wxIcon *icon = new wxICON(sample);
167 wxIcon *icon = new wxIcon("sample"); // On wxMSW
168 wxIcon *icon = new wxIcon(sample_xpm); // On wxGTK
172 // Load from a resource
173 #define wxICON(X) wxIcon(wxT(#X))
174 #elif defined(__WXPM__)
175 // Load from a resource
176 #define wxICON(X) wxIcon(wxT(#X))
177 #elif defined(__WXMGL__)
178 // Initialize from an included XPM
179 #define wxICON(X) wxIcon( X##_xpm )
180 #elif defined(__WXDFB__)
181 // Initialize from an included XPM
182 #define wxICON(X) wxIcon( X##_xpm )
183 #elif defined(__WXGTK__)
184 // Initialize from an included XPM
185 #define wxICON(X) wxIcon( X##_xpm )
186 #elif defined(__WXMAC__)
187 // Initialize from an included XPM
188 #define wxICON(X) wxIcon( X##_xpm )
189 #elif defined(__WXMOTIF__)
190 // Initialize from an included XPM
191 #define wxICON(X) wxIcon( X##_xpm )
192 #elif defined(__WXX11__)
193 // Initialize from an included XPM
194 #define wxICON(X) wxIcon( X##_xpm )
196 // This will usually mean something on any platform
197 #define wxICON(X) wxIcon(wxT(#X))
200 /* Another macro: this one is for portable creation of bitmaps. We assume that
201 under Unix bitmaps live in XPMs and under Windows they're in ressources.
204 #if defined(__WXMSW__) || defined(__WXPM__)
205 #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE)
206 #elif defined(__WXGTK__) || \
207 defined(__WXMOTIF__) || \
208 defined(__WXX11__) || \
209 defined(__WXMAC__) || \
210 defined(__WXMGL__) || \
211 defined(__WXDFB__) || \
213 // Initialize from an included XPM
214 #define wxBITMAP(name) wxBitmap(name##_xpm)
215 #else // other platforms
216 #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
219 // ===========================================================================
221 // ===========================================================================
223 // ---------------------------------------------------------------------------
225 // ---------------------------------------------------------------------------
227 class WXDLLIMPEXP_CORE wxSize
230 // members are public for compatibility, don't use them directly.
234 wxSize() : x(0), y(0) { }
235 wxSize(int xx
, int yy
) : x(xx
), y(yy
) { }
237 // no copy ctor or assignment operator - the defaults are ok
239 wxSize
& operator+=(const wxSize
& sz
) { x
+= sz
.x
; y
+= sz
.y
; return *this; }
240 wxSize
& operator-=(const wxSize
& sz
) { x
-= sz
.x
; y
-= sz
.y
; return *this; }
241 wxSize
& operator/=(int i
) { x
/= i
; y
/= i
; return *this; }
242 wxSize
& operator*=(int i
) { x
*= i
; y
*= i
; return *this; }
243 wxSize
& operator/=(unsigned int i
) { x
/= i
; y
/= i
; return *this; }
244 wxSize
& operator*=(unsigned int i
) { x
*= i
; y
*= i
; return *this; }
245 wxSize
& operator/=(long i
) { x
/= i
; y
/= i
; return *this; }
246 wxSize
& operator*=(long i
) { x
*= i
; y
*= i
; return *this; }
247 wxSize
& operator/=(unsigned long i
) { x
/= i
; y
/= i
; return *this; }
248 wxSize
& operator*=(unsigned long i
) { x
*= i
; y
*= i
; return *this; }
249 wxSize
& operator/=(double i
) { x
= int(x
/i
); y
= int(y
/i
); return *this; }
250 wxSize
& operator*=(double i
) { x
= int(x
*i
); y
= int(y
*i
); return *this; }
252 void IncTo(const wxSize
& sz
)
253 { if ( sz
.x
> x
) x
= sz
.x
; if ( sz
.y
> y
) y
= sz
.y
; }
254 void DecTo(const wxSize
& sz
)
255 { if ( sz
.x
< x
) x
= sz
.x
; if ( sz
.y
< y
) y
= sz
.y
; }
257 void IncBy(int dx
, int dy
) { x
+= dx
; y
+= dy
; }
258 void IncBy(const wxPoint
& pt
);
259 void IncBy(const wxSize
& sz
) { IncBy(sz
.x
, sz
.y
); }
260 void IncBy(int d
) { IncBy(d
, d
); }
262 void DecBy(int dx
, int dy
) { IncBy(-dx
, -dy
); }
263 void DecBy(const wxPoint
& pt
);
264 void DecBy(const wxSize
& sz
) { DecBy(sz
.x
, sz
.y
); }
265 void DecBy(int d
) { DecBy(d
, d
); }
268 wxSize
& Scale(float xscale
, float yscale
)
269 { x
= (int)(x
*xscale
); y
= (int)(y
*yscale
); return *this; }
272 void Set(int xx
, int yy
) { x
= xx
; y
= yy
; }
273 void SetWidth(int w
) { x
= w
; }
274 void SetHeight(int h
) { y
= h
; }
276 int GetWidth() const { return x
; }
277 int GetHeight() const { return y
; }
279 bool IsFullySpecified() const { return x
!= wxDefaultCoord
&& y
!= wxDefaultCoord
; }
281 // combine this size with the other one replacing the default (i.e. equal
282 // to wxDefaultCoord) components of this object with those of the other
283 void SetDefaults(const wxSize
& size
)
285 if ( x
== wxDefaultCoord
)
287 if ( y
== wxDefaultCoord
)
292 int GetX() const { return x
; }
293 int GetY() const { return y
; }
296 inline bool operator==(const wxSize
& s1
, const wxSize
& s2
)
298 return s1
.x
== s2
.x
&& s1
.y
== s2
.y
;
301 inline bool operator!=(const wxSize
& s1
, const wxSize
& s2
)
303 return s1
.x
!= s2
.x
|| s1
.y
!= s2
.y
;
306 inline wxSize
operator+(const wxSize
& s1
, const wxSize
& s2
)
308 return wxSize(s1
.x
+ s2
.x
, s1
.y
+ s2
.y
);
311 inline wxSize
operator-(const wxSize
& s1
, const wxSize
& s2
)
313 return wxSize(s1
.x
- s2
.x
, s1
.y
- s2
.y
);
316 inline wxSize
operator/(const wxSize
& s
, int i
)
318 return wxSize(s
.x
/ i
, s
.y
/ i
);
321 inline wxSize
operator*(const wxSize
& s
, int i
)
323 return wxSize(s
.x
* i
, s
.y
* i
);
326 inline wxSize
operator*(int i
, const wxSize
& s
)
328 return wxSize(s
.x
* i
, s
.y
* i
);
331 inline wxSize
operator/(const wxSize
& s
, unsigned int i
)
333 return wxSize(s
.x
/ i
, s
.y
/ i
);
336 inline wxSize
operator*(const wxSize
& s
, unsigned int i
)
338 return wxSize(s
.x
* i
, s
.y
* i
);
341 inline wxSize
operator*(unsigned int i
, const wxSize
& s
)
343 return wxSize(s
.x
* i
, s
.y
* i
);
346 inline wxSize
operator/(const wxSize
& s
, long i
)
348 return wxSize(s
.x
/ i
, s
.y
/ i
);
351 inline wxSize
operator*(const wxSize
& s
, long i
)
353 return wxSize(s
.x
* i
, s
.y
* i
);
356 inline wxSize
operator*(long i
, const wxSize
& s
)
358 return wxSize(s
.x
* i
, s
.y
* i
);
361 inline wxSize
operator/(const wxSize
& s
, unsigned long i
)
363 return wxSize(s
.x
/ i
, s
.y
/ i
);
366 inline wxSize
operator*(const wxSize
& s
, unsigned long i
)
368 return wxSize(s
.x
* i
, s
.y
* i
);
371 inline wxSize
operator*(unsigned long i
, const wxSize
& s
)
373 return wxSize(s
.x
* i
, s
.y
* i
);
376 inline wxSize
operator*(const wxSize
& s
, double i
)
378 return wxSize(int(s
.x
* i
), int(s
.y
* i
));
381 inline wxSize
operator*(double i
, const wxSize
& s
)
383 return wxSize(int(s
.x
* i
), int(s
.y
* i
));
388 // ---------------------------------------------------------------------------
389 // Point classes: with real or integer coordinates
390 // ---------------------------------------------------------------------------
392 class WXDLLIMPEXP_CORE wxRealPoint
398 wxRealPoint() : x(0.0), y(0.0) { }
399 wxRealPoint(double xx
, double yy
) : x(xx
), y(yy
) { }
400 wxRealPoint(const wxPoint
& pt
);
402 // no copy ctor or assignment operator - the defaults are ok
404 //assignment operators
405 wxRealPoint
& operator+=(const wxRealPoint
& p
) { x
+= p
.x
; y
+= p
.y
; return *this; }
406 wxRealPoint
& operator-=(const wxRealPoint
& p
) { x
-= p
.x
; y
-= p
.y
; return *this; }
408 wxRealPoint
& operator+=(const wxSize
& s
) { x
+= s
.GetWidth(); y
+= s
.GetHeight(); return *this; }
409 wxRealPoint
& operator-=(const wxSize
& s
) { x
-= s
.GetWidth(); y
-= s
.GetHeight(); return *this; }
413 inline bool operator==(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
415 return wxIsSameDouble(p1
.x
, p2
.x
) && wxIsSameDouble(p1
.y
, p2
.y
);
418 inline bool operator!=(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
423 inline wxRealPoint
operator+(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
425 return wxRealPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
429 inline wxRealPoint
operator-(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
431 return wxRealPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
435 inline wxRealPoint
operator/(const wxRealPoint
& s
, int i
)
437 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
440 inline wxRealPoint
operator*(const wxRealPoint
& s
, int i
)
442 return wxRealPoint(s
.x
* i
, s
.y
* i
);
445 inline wxRealPoint
operator*(int i
, const wxRealPoint
& s
)
447 return wxRealPoint(s
.x
* i
, s
.y
* i
);
450 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned int i
)
452 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
455 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned int i
)
457 return wxRealPoint(s
.x
* i
, s
.y
* i
);
460 inline wxRealPoint
operator*(unsigned int i
, const wxRealPoint
& s
)
462 return wxRealPoint(s
.x
* i
, s
.y
* i
);
465 inline wxRealPoint
operator/(const wxRealPoint
& s
, long i
)
467 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
470 inline wxRealPoint
operator*(const wxRealPoint
& s
, long i
)
472 return wxRealPoint(s
.x
* i
, s
.y
* i
);
475 inline wxRealPoint
operator*(long i
, const wxRealPoint
& s
)
477 return wxRealPoint(s
.x
* i
, s
.y
* i
);
480 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned long i
)
482 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
485 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned long i
)
487 return wxRealPoint(s
.x
* i
, s
.y
* i
);
490 inline wxRealPoint
operator*(unsigned long i
, const wxRealPoint
& s
)
492 return wxRealPoint(s
.x
* i
, s
.y
* i
);
495 inline wxRealPoint
operator*(const wxRealPoint
& s
, double i
)
497 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
500 inline wxRealPoint
operator*(double i
, const wxRealPoint
& s
)
502 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
506 // ----------------------------------------------------------------------------
507 // wxPoint: 2D point with integer coordinates
508 // ----------------------------------------------------------------------------
510 class WXDLLIMPEXP_CORE wxPoint
515 wxPoint() : x(0), y(0) { }
516 wxPoint(int xx
, int yy
) : x(xx
), y(yy
) { }
517 wxPoint(const wxRealPoint
& pt
) : x(int(pt
.x
)), y(int(pt
.y
)) { }
519 // no copy ctor or assignment operator - the defaults are ok
521 //assignment operators
522 wxPoint
& operator+=(const wxPoint
& p
) { x
+= p
.x
; y
+= p
.y
; return *this; }
523 wxPoint
& operator-=(const wxPoint
& p
) { x
-= p
.x
; y
-= p
.y
; return *this; }
525 wxPoint
& operator+=(const wxSize
& s
) { x
+= s
.GetWidth(); y
+= s
.GetHeight(); return *this; }
526 wxPoint
& operator-=(const wxSize
& s
) { x
-= s
.GetWidth(); y
-= s
.GetHeight(); return *this; }
531 inline bool operator==(const wxPoint
& p1
, const wxPoint
& p2
)
533 return p1
.x
== p2
.x
&& p1
.y
== p2
.y
;
536 inline bool operator!=(const wxPoint
& p1
, const wxPoint
& p2
)
542 // arithmetic operations (component wise)
543 inline wxPoint
operator+(const wxPoint
& p1
, const wxPoint
& p2
)
545 return wxPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
548 inline wxPoint
operator-(const wxPoint
& p1
, const wxPoint
& p2
)
550 return wxPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
553 inline wxPoint
operator+(const wxPoint
& p
, const wxSize
& s
)
555 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
558 inline wxPoint
operator-(const wxPoint
& p
, const wxSize
& s
)
560 return wxPoint(p
.x
- s
.x
, p
.y
- s
.y
);
563 inline wxPoint
operator+(const wxSize
& s
, const wxPoint
& p
)
565 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
568 inline wxPoint
operator-(const wxSize
& s
, const wxPoint
& p
)
570 return wxPoint(s
.x
- p
.x
, s
.y
- p
.y
);
573 inline wxPoint
operator-(const wxPoint
& p
)
575 return wxPoint(-p
.x
, -p
.y
);
578 inline wxPoint
operator/(const wxPoint
& s
, int i
)
580 return wxPoint(s
.x
/ i
, s
.y
/ i
);
583 inline wxPoint
operator*(const wxPoint
& s
, int i
)
585 return wxPoint(s
.x
* i
, s
.y
* i
);
588 inline wxPoint
operator*(int i
, const wxPoint
& s
)
590 return wxPoint(s
.x
* i
, s
.y
* i
);
593 inline wxPoint
operator/(const wxPoint
& s
, unsigned int i
)
595 return wxPoint(s
.x
/ i
, s
.y
/ i
);
598 inline wxPoint
operator*(const wxPoint
& s
, unsigned int i
)
600 return wxPoint(s
.x
* i
, s
.y
* i
);
603 inline wxPoint
operator*(unsigned int i
, const wxPoint
& s
)
605 return wxPoint(s
.x
* i
, s
.y
* i
);
608 inline wxPoint
operator/(const wxPoint
& s
, long i
)
610 return wxPoint(s
.x
/ i
, s
.y
/ i
);
613 inline wxPoint
operator*(const wxPoint
& s
, long i
)
615 return wxPoint(s
.x
* i
, s
.y
* i
);
618 inline wxPoint
operator*(long i
, const wxPoint
& s
)
620 return wxPoint(s
.x
* i
, s
.y
* i
);
623 inline wxPoint
operator/(const wxPoint
& s
, unsigned long i
)
625 return wxPoint(s
.x
/ i
, s
.y
/ i
);
628 inline wxPoint
operator*(const wxPoint
& s
, unsigned long i
)
630 return wxPoint(s
.x
* i
, s
.y
* i
);
633 inline wxPoint
operator*(unsigned long i
, const wxPoint
& s
)
635 return wxPoint(s
.x
* i
, s
.y
* i
);
638 inline wxPoint
operator*(const wxPoint
& s
, double i
)
640 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
643 inline wxPoint
operator*(double i
, const wxPoint
& s
)
645 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
648 WX_DECLARE_LIST_WITH_DECL(wxPoint
, wxPointList
, class WXDLLIMPEXP_CORE
);
650 // ---------------------------------------------------------------------------
652 // ---------------------------------------------------------------------------
654 class WXDLLIMPEXP_CORE wxRect
658 : x(0), y(0), width(0), height(0)
660 wxRect(int xx
, int yy
, int ww
, int hh
)
661 : x(xx
), y(yy
), width(ww
), height(hh
)
663 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
664 wxRect(const wxPoint
& pt
, const wxSize
& size
)
665 : x(pt
.x
), y(pt
.y
), width(size
.x
), height(size
.y
)
667 wxRect(const wxSize
& size
)
668 : x(0), y(0), width(size
.x
), height(size
.y
)
671 // default copy ctor and assignment operators ok
673 int GetX() const { return x
; }
674 void SetX(int xx
) { x
= xx
; }
676 int GetY() const { return y
; }
677 void SetY(int yy
) { y
= yy
; }
679 int GetWidth() const { return width
; }
680 void SetWidth(int w
) { width
= w
; }
682 int GetHeight() const { return height
; }
683 void SetHeight(int h
) { height
= h
; }
685 wxPoint
GetPosition() const { return wxPoint(x
, y
); }
686 void SetPosition( const wxPoint
&p
) { x
= p
.x
; y
= p
.y
; }
688 wxSize
GetSize() const { return wxSize(width
, height
); }
689 void SetSize( const wxSize
&s
) { width
= s
.GetWidth(); height
= s
.GetHeight(); }
691 bool IsEmpty() const { return (width
<= 0) || (height
<= 0); }
693 int GetLeft() const { return x
; }
694 int GetTop() const { return y
; }
695 int GetBottom() const { return y
+ height
- 1; }
696 int GetRight() const { return x
+ width
- 1; }
698 void SetLeft(int left
) { x
= left
; }
699 void SetRight(int right
) { width
= right
- x
+ 1; }
700 void SetTop(int top
) { y
= top
; }
701 void SetBottom(int bottom
) { height
= bottom
- y
+ 1; }
703 wxPoint
GetTopLeft() const { return GetPosition(); }
704 wxPoint
GetLeftTop() const { return GetTopLeft(); }
705 void SetTopLeft(const wxPoint
&p
) { SetPosition(p
); }
706 void SetLeftTop(const wxPoint
&p
) { SetTopLeft(p
); }
708 wxPoint
GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
709 wxPoint
GetRightBottom() const { return GetBottomRight(); }
710 void SetBottomRight(const wxPoint
&p
) { SetRight(p
.x
); SetBottom(p
.y
); }
711 void SetRightBottom(const wxPoint
&p
) { SetBottomRight(p
); }
713 wxPoint
GetTopRight() const { return wxPoint(GetRight(), GetTop()); }
714 wxPoint
GetRightTop() const { return GetTopRight(); }
715 void SetTopRight(const wxPoint
&p
) { SetRight(p
.x
); SetTop(p
.y
); }
716 void SetRightTop(const wxPoint
&p
) { SetTopLeft(p
); }
718 wxPoint
GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); }
719 wxPoint
GetLeftBottom() const { return GetBottomLeft(); }
720 void SetBottomLeft(const wxPoint
&p
) { SetLeft(p
.x
); SetBottom(p
.y
); }
721 void SetLeftBottom(const wxPoint
&p
) { SetBottomLeft(p
); }
723 // operations with rect
724 wxRect
& Inflate(wxCoord dx
, wxCoord dy
);
725 wxRect
& Inflate(const wxSize
& d
) { return Inflate(d
.x
, d
.y
); }
726 wxRect
& Inflate(wxCoord d
) { return Inflate(d
, d
); }
727 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const
734 wxRect
& Deflate(wxCoord dx
, wxCoord dy
) { return Inflate(-dx
, -dy
); }
735 wxRect
& Deflate(const wxSize
& d
) { return Inflate(-d
.x
, -d
.y
); }
736 wxRect
& Deflate(wxCoord d
) { return Inflate(-d
); }
737 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const
744 void Offset(wxCoord dx
, wxCoord dy
) { x
+= dx
; y
+= dy
; }
745 void Offset(const wxPoint
& pt
) { Offset(pt
.x
, pt
.y
); }
747 wxRect
& Intersect(const wxRect
& rect
);
748 wxRect
Intersect(const wxRect
& rect
) const
755 wxRect
& Union(const wxRect
& rect
);
756 wxRect
Union(const wxRect
& rect
) const
763 // return true if the point is (not strcitly) inside the rect
764 bool Contains(int x
, int y
) const;
765 bool Contains(const wxPoint
& pt
) const { return Contains(pt
.x
, pt
.y
); }
766 // return true if the rectangle 'rect' is (not strictly) inside this rect
767 bool Contains(const wxRect
& rect
) const;
769 #if WXWIN_COMPATIBILITY_2_6
770 // use Contains() instead
771 wxDEPRECATED( bool Inside(int x
, int y
) const );
772 wxDEPRECATED( bool Inside(const wxPoint
& pt
) const );
773 wxDEPRECATED( bool Inside(const wxRect
& rect
) const );
774 #endif // WXWIN_COMPATIBILITY_2_6
776 // return true if the rectangles have a non empty intersection
777 bool Intersects(const wxRect
& rect
) const;
779 // like Union() but don't ignore empty rectangles
780 wxRect
& operator+=(const wxRect
& rect
);
782 // intersections of two rectrangles not testing for empty rectangles
783 wxRect
& operator*=(const wxRect
& rect
);
785 // centre this rectangle in the given (usually, but not necessarily,
787 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const
789 return wxRect(dir
& wxHORIZONTAL
? r
.x
+ (r
.width
- width
)/2 : x
,
790 dir
& wxVERTICAL
? r
.y
+ (r
.height
- height
)/2 : y
,
794 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const
796 return CentreIn(r
, dir
);
800 int x
, y
, width
, height
;
804 // compare rectangles
805 inline bool operator==(const wxRect
& r1
, const wxRect
& r2
)
807 return (r1
.x
== r2
.x
) && (r1
.y
== r2
.y
) &&
808 (r1
.width
== r2
.width
) && (r1
.height
== r2
.height
);
811 inline bool operator!=(const wxRect
& r1
, const wxRect
& r2
)
816 // like Union() but don't treat empty rectangles specially
817 WXDLLIMPEXP_CORE wxRect
operator+(const wxRect
& r1
, const wxRect
& r2
);
819 // intersections of two rectangles
820 WXDLLIMPEXP_CORE wxRect
operator*(const wxRect
& r1
, const wxRect
& r2
);
825 #if WXWIN_COMPATIBILITY_2_6
826 inline bool wxRect::Inside(int cx
, int cy
) const { return Contains(cx
, cy
); }
827 inline bool wxRect::Inside(const wxPoint
& pt
) const { return Contains(pt
); }
828 inline bool wxRect::Inside(const wxRect
& rect
) const { return Contains(rect
); }
829 #endif // WXWIN_COMPATIBILITY_2_6
832 // define functions which couldn't be defined above because of declarations
834 inline void wxSize::IncBy(const wxPoint
& pt
) { IncBy(pt
.x
, pt
.y
); }
835 inline void wxSize::DecBy(const wxPoint
& pt
) { DecBy(pt
.x
, pt
.y
); }
837 // ---------------------------------------------------------------------------
838 // Management of pens, brushes and fonts
839 // ---------------------------------------------------------------------------
841 typedef wxInt8 wxDash
;
843 class WXDLLIMPEXP_CORE wxGDIObjListBase
{
852 WX_DECLARE_STRING_HASH_MAP(wxColour
*, wxStringToColourHashMap
);
854 class WXDLLIMPEXP_CORE wxColourDatabase
860 // find colour by name or name for the given colour
861 wxColour
Find(const wxString
& name
) const;
862 wxString
FindName(const wxColour
& colour
) const;
864 // add a new colour to the database
865 void AddColour(const wxString
& name
, const wxColour
& colour
);
867 #if WXWIN_COMPATIBILITY_2_6
868 // deprecated, use Find() instead
869 wxDEPRECATED( wxColour
*FindColour(const wxString
& name
) );
870 #endif // WXWIN_COMPATIBILITY_2_6
874 // PM keeps its own type of colour table
880 // load the database with the built in colour values when called for the
881 // first time, do nothing after this
884 wxStringToColourHashMap
*m_map
;
887 class WXDLLIMPEXP_CORE wxResourceCache
: public wxList
890 wxResourceCache() { }
892 wxResourceCache(const unsigned int keyType
) : wxList(keyType
) { }
894 virtual ~wxResourceCache();
897 // ---------------------------------------------------------------------------
899 // ---------------------------------------------------------------------------
904 wxStockGDI creates the stock GDI objects on demand. Pointers to the
905 created objects are stored in the ms_stockObject array, which is indexed
906 by the Item enum values. Platorm-specific fonts can be created by
907 implementing a derived class with an override for the GetFont function.
908 wxStockGDI operates as a singleton, accessed through the ms_instance
909 pointer. By default this pointer is set to an instance of wxStockGDI.
910 A derived class must arrange to set this pointer to an instance of itself.
912 class WXDLLIMPEXP_CORE wxStockGDI
958 virtual ~wxStockGDI();
959 static void DeleteAll();
961 static wxStockGDI
& instance() { return *ms_instance
; }
963 static const wxBrush
* GetBrush(Item item
);
964 static const wxColour
* GetColour(Item item
);
965 static const wxCursor
* GetCursor(Item item
);
966 // Can be overridden by platform-specific derived classes
967 virtual const wxFont
* GetFont(Item item
);
968 static const wxPen
* GetPen(Item item
);
971 static wxStockGDI
* ms_instance
;
973 static wxObject
* ms_stockObject
[ITEMCOUNT
];
975 wxDECLARE_NO_COPY_CLASS(wxStockGDI
);
978 #define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
979 #define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
980 #define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
981 #define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
983 #define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
984 #define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
985 #define wxBLUE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLUE)
986 #define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
987 #define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
988 #define wxYELLOW_PEN wxStockGDI::GetPen(wxStockGDI::PEN_YELLOW)
989 #define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
990 #define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
991 #define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
992 #define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
993 #define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
994 #define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
996 #define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
997 #define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
998 #define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
999 #define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
1000 #define wxYELLOW_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_YELLOW)
1001 #define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
1002 #define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
1003 #define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
1004 #define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
1005 #define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
1006 #define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
1008 #define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
1009 #define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
1010 #define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
1011 #define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
1012 #define wxYELLOW wxStockGDI::GetColour(wxStockGDI::COLOUR_YELLOW)
1013 #define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
1014 #define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
1015 #define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
1017 #define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
1018 #define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
1019 #define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
1022 extern WXDLLIMPEXP_DATA_CORE(wxBitmap
) wxNullBitmap
;
1023 extern WXDLLIMPEXP_DATA_CORE(wxIcon
) wxNullIcon
;
1024 extern WXDLLIMPEXP_DATA_CORE(wxCursor
) wxNullCursor
;
1025 extern WXDLLIMPEXP_DATA_CORE(wxPen
) wxNullPen
;
1026 extern WXDLLIMPEXP_DATA_CORE(wxBrush
) wxNullBrush
;
1027 extern WXDLLIMPEXP_DATA_CORE(wxPalette
) wxNullPalette
;
1028 extern WXDLLIMPEXP_DATA_CORE(wxFont
) wxNullFont
;
1029 extern WXDLLIMPEXP_DATA_CORE(wxColour
) wxNullColour
;
1030 extern WXDLLIMPEXP_DATA_CORE(wxIconBundle
) wxNullIconBundle
;
1032 extern WXDLLIMPEXP_DATA_CORE(wxColourDatabase
*) wxTheColourDatabase
;
1034 extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr
[];
1036 extern WXDLLIMPEXP_DATA_CORE(const wxSize
) wxDefaultSize
;
1037 extern WXDLLIMPEXP_DATA_CORE(const wxPoint
) wxDefaultPosition
;
1039 // ---------------------------------------------------------------------------
1041 // ---------------------------------------------------------------------------
1043 // resource management
1044 extern void WXDLLIMPEXP_CORE
wxInitializeStockLists();
1045 extern void WXDLLIMPEXP_CORE
wxDeleteStockLists();
1047 // is the display colour (or monochrome)?
1048 extern bool WXDLLIMPEXP_CORE
wxColourDisplay();
1050 // Returns depth of screen
1051 extern int WXDLLIMPEXP_CORE
wxDisplayDepth();
1052 #define wxGetDisplayDepth wxDisplayDepth
1054 // get the display size
1055 extern void WXDLLIMPEXP_CORE
wxDisplaySize(int *width
, int *height
);
1056 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySize();
1057 extern void WXDLLIMPEXP_CORE
wxDisplaySizeMM(int *width
, int *height
);
1058 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySizeMM();
1059 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplayPPI();
1061 // Get position and size of the display workarea
1062 extern void WXDLLIMPEXP_CORE
wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
);
1063 extern wxRect WXDLLIMPEXP_CORE
wxGetClientDisplayRect();
1065 // set global cursor
1066 extern void WXDLLIMPEXP_CORE
wxSetCursor(const wxCursor
& cursor
);