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(mondrian);
167 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
168 wxIcon *icon = new wxIcon(mondrian_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 wxSize
& sz
) { IncBy(sz
.x
, sz
.y
); }
259 void IncBy(int d
) { IncBy(d
, d
); }
261 void DecBy(int dx
, int dy
) { IncBy(-dx
, -dy
); }
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
) { }
401 inline bool operator==(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
403 return wxIsSameDouble(p1
.x
, p2
.x
) && wxIsSameDouble(p1
.y
, p2
.y
);
406 inline bool operator!=(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
411 inline wxRealPoint
operator+(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
413 return wxRealPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
417 inline wxRealPoint
operator-(const wxRealPoint
& p1
, const wxRealPoint
& p2
)
419 return wxRealPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
423 inline wxRealPoint
operator/(const wxRealPoint
& s
, int i
)
425 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
428 inline wxRealPoint
operator*(const wxRealPoint
& s
, int i
)
430 return wxRealPoint(s
.x
* i
, s
.y
* i
);
433 inline wxRealPoint
operator*(int i
, const wxRealPoint
& s
)
435 return wxRealPoint(s
.x
* i
, s
.y
* i
);
438 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned int i
)
440 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
443 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned int i
)
445 return wxRealPoint(s
.x
* i
, s
.y
* i
);
448 inline wxRealPoint
operator*(unsigned int i
, const wxRealPoint
& s
)
450 return wxRealPoint(s
.x
* i
, s
.y
* i
);
453 inline wxRealPoint
operator/(const wxRealPoint
& s
, long i
)
455 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
458 inline wxRealPoint
operator*(const wxRealPoint
& s
, long i
)
460 return wxRealPoint(s
.x
* i
, s
.y
* i
);
463 inline wxRealPoint
operator*(long i
, const wxRealPoint
& s
)
465 return wxRealPoint(s
.x
* i
, s
.y
* i
);
468 inline wxRealPoint
operator/(const wxRealPoint
& s
, unsigned long i
)
470 return wxRealPoint(s
.x
/ i
, s
.y
/ i
);
473 inline wxRealPoint
operator*(const wxRealPoint
& s
, unsigned long i
)
475 return wxRealPoint(s
.x
* i
, s
.y
* i
);
478 inline wxRealPoint
operator*(unsigned long i
, const wxRealPoint
& s
)
480 return wxRealPoint(s
.x
* i
, s
.y
* i
);
483 inline wxRealPoint
operator*(const wxRealPoint
& s
, double i
)
485 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
488 inline wxRealPoint
operator*(double i
, const wxRealPoint
& s
)
490 return wxRealPoint(int(s
.x
* i
), int(s
.y
* i
));
494 // ----------------------------------------------------------------------------
495 // wxPoint: 2D point with integer coordinates
496 // ----------------------------------------------------------------------------
498 class WXDLLIMPEXP_CORE wxPoint
503 wxPoint() : x(0), y(0) { }
504 wxPoint(int xx
, int yy
) : x(xx
), y(yy
) { }
506 // no copy ctor or assignment operator - the defaults are ok
508 //assignment operators
509 wxPoint
& operator+=(const wxPoint
& p
) { x
+= p
.x
; y
+= p
.y
; return *this; }
510 wxPoint
& operator-=(const wxPoint
& p
) { x
-= p
.x
; y
-= p
.y
; return *this; }
512 wxPoint
& operator+=(const wxSize
& s
) { x
+= s
.GetWidth(); y
+= s
.GetHeight(); return *this; }
513 wxPoint
& operator-=(const wxSize
& s
) { x
-= s
.GetWidth(); y
-= s
.GetHeight(); return *this; }
518 inline bool operator==(const wxPoint
& p1
, const wxPoint
& p2
)
520 return p1
.x
== p2
.x
&& p1
.y
== p2
.y
;
523 inline bool operator!=(const wxPoint
& p1
, const wxPoint
& p2
)
529 // arithmetic operations (component wise)
530 inline wxPoint
operator+(const wxPoint
& p1
, const wxPoint
& p2
)
532 return wxPoint(p1
.x
+ p2
.x
, p1
.y
+ p2
.y
);
535 inline wxPoint
operator-(const wxPoint
& p1
, const wxPoint
& p2
)
537 return wxPoint(p1
.x
- p2
.x
, p1
.y
- p2
.y
);
540 inline wxPoint
operator+(const wxPoint
& p
, const wxSize
& s
)
542 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
545 inline wxPoint
operator-(const wxPoint
& p
, const wxSize
& s
)
547 return wxPoint(p
.x
- s
.x
, p
.y
- s
.y
);
550 inline wxPoint
operator+(const wxSize
& s
, const wxPoint
& p
)
552 return wxPoint(p
.x
+ s
.x
, p
.y
+ s
.y
);
555 inline wxPoint
operator-(const wxSize
& s
, const wxPoint
& p
)
557 return wxPoint(s
.x
- p
.x
, s
.y
- p
.y
);
560 inline wxPoint
operator-(const wxPoint
& p
)
562 return wxPoint(-p
.x
, -p
.y
);
565 inline wxPoint
operator/(const wxPoint
& s
, int i
)
567 return wxPoint(s
.x
/ i
, s
.y
/ i
);
570 inline wxPoint
operator*(const wxPoint
& s
, int i
)
572 return wxPoint(s
.x
* i
, s
.y
* i
);
575 inline wxPoint
operator*(int i
, const wxPoint
& s
)
577 return wxPoint(s
.x
* i
, s
.y
* i
);
580 inline wxPoint
operator/(const wxPoint
& s
, unsigned int i
)
582 return wxPoint(s
.x
/ i
, s
.y
/ i
);
585 inline wxPoint
operator*(const wxPoint
& s
, unsigned int i
)
587 return wxPoint(s
.x
* i
, s
.y
* i
);
590 inline wxPoint
operator*(unsigned int i
, const wxPoint
& s
)
592 return wxPoint(s
.x
* i
, s
.y
* i
);
595 inline wxPoint
operator/(const wxPoint
& s
, long i
)
597 return wxPoint(s
.x
/ i
, s
.y
/ i
);
600 inline wxPoint
operator*(const wxPoint
& s
, long i
)
602 return wxPoint(s
.x
* i
, s
.y
* i
);
605 inline wxPoint
operator*(long i
, const wxPoint
& s
)
607 return wxPoint(s
.x
* i
, s
.y
* i
);
610 inline wxPoint
operator/(const wxPoint
& s
, unsigned long i
)
612 return wxPoint(s
.x
/ i
, s
.y
/ i
);
615 inline wxPoint
operator*(const wxPoint
& s
, unsigned long i
)
617 return wxPoint(s
.x
* i
, s
.y
* i
);
620 inline wxPoint
operator*(unsigned long i
, const wxPoint
& s
)
622 return wxPoint(s
.x
* i
, s
.y
* i
);
625 inline wxPoint
operator*(const wxPoint
& s
, double i
)
627 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
630 inline wxPoint
operator*(double i
, const wxPoint
& s
)
632 return wxPoint(int(s
.x
* i
), int(s
.y
* i
));
635 WX_DECLARE_LIST_WITH_DECL(wxPoint
, wxPointList
, class WXDLLIMPEXP_CORE
);
637 // ---------------------------------------------------------------------------
639 // ---------------------------------------------------------------------------
641 class WXDLLIMPEXP_CORE wxRect
645 : x(0), y(0), width(0), height(0)
647 wxRect(int xx
, int yy
, int ww
, int hh
)
648 : x(xx
), y(yy
), width(ww
), height(hh
)
650 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
651 wxRect(const wxPoint
& pt
, const wxSize
& size
)
652 : x(pt
.x
), y(pt
.y
), width(size
.x
), height(size
.y
)
654 wxRect(const wxSize
& size
)
655 : x(0), y(0), width(size
.x
), height(size
.y
)
658 // default copy ctor and assignment operators ok
660 int GetX() const { return x
; }
661 void SetX(int xx
) { x
= xx
; }
663 int GetY() const { return y
; }
664 void SetY(int yy
) { y
= yy
; }
666 int GetWidth() const { return width
; }
667 void SetWidth(int w
) { width
= w
; }
669 int GetHeight() const { return height
; }
670 void SetHeight(int h
) { height
= h
; }
672 wxPoint
GetPosition() const { return wxPoint(x
, y
); }
673 void SetPosition( const wxPoint
&p
) { x
= p
.x
; y
= p
.y
; }
675 wxSize
GetSize() const { return wxSize(width
, height
); }
676 void SetSize( const wxSize
&s
) { width
= s
.GetWidth(); height
= s
.GetHeight(); }
678 bool IsEmpty() const { return (width
<= 0) || (height
<= 0); }
680 int GetLeft() const { return x
; }
681 int GetTop() const { return y
; }
682 int GetBottom() const { return y
+ height
- 1; }
683 int GetRight() const { return x
+ width
- 1; }
685 void SetLeft(int left
) { x
= left
; }
686 void SetRight(int right
) { width
= right
- x
+ 1; }
687 void SetTop(int top
) { y
= top
; }
688 void SetBottom(int bottom
) { height
= bottom
- y
+ 1; }
690 wxPoint
GetTopLeft() const { return GetPosition(); }
691 wxPoint
GetLeftTop() const { return GetTopLeft(); }
692 void SetTopLeft(const wxPoint
&p
) { SetPosition(p
); }
693 void SetLeftTop(const wxPoint
&p
) { SetTopLeft(p
); }
695 wxPoint
GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
696 wxPoint
GetRightBottom() const { return GetBottomRight(); }
697 void SetBottomRight(const wxPoint
&p
) { SetRight(p
.x
); SetBottom(p
.y
); }
698 void SetRightBottom(const wxPoint
&p
) { SetBottomRight(p
); }
700 wxPoint
GetTopRight() const { return wxPoint(GetRight(), GetTop()); }
701 wxPoint
GetRightTop() const { return GetTopRight(); }
702 void SetTopRight(const wxPoint
&p
) { SetRight(p
.x
); SetTop(p
.y
); }
703 void SetRightTop(const wxPoint
&p
) { SetTopLeft(p
); }
705 wxPoint
GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); }
706 wxPoint
GetLeftBottom() const { return GetBottomLeft(); }
707 void SetBottomLeft(const wxPoint
&p
) { SetLeft(p
.x
); SetBottom(p
.y
); }
708 void SetLeftBottom(const wxPoint
&p
) { SetBottomLeft(p
); }
710 // operations with rect
711 wxRect
& Inflate(wxCoord dx
, wxCoord dy
);
712 wxRect
& Inflate(const wxSize
& d
) { return Inflate(d
.x
, d
.y
); }
713 wxRect
& Inflate(wxCoord d
) { return Inflate(d
, d
); }
714 wxRect
Inflate(wxCoord dx
, wxCoord dy
) const
721 wxRect
& Deflate(wxCoord dx
, wxCoord dy
) { return Inflate(-dx
, -dy
); }
722 wxRect
& Deflate(const wxSize
& d
) { return Inflate(-d
.x
, -d
.y
); }
723 wxRect
& Deflate(wxCoord d
) { return Inflate(-d
); }
724 wxRect
Deflate(wxCoord dx
, wxCoord dy
) const
731 void Offset(wxCoord dx
, wxCoord dy
) { x
+= dx
; y
+= dy
; }
732 void Offset(const wxPoint
& pt
) { Offset(pt
.x
, pt
.y
); }
734 wxRect
& Intersect(const wxRect
& rect
);
735 wxRect
Intersect(const wxRect
& rect
) const
742 wxRect
& Union(const wxRect
& rect
);
743 wxRect
Union(const wxRect
& rect
) const
750 // return true if the point is (not strcitly) inside the rect
751 bool Contains(int x
, int y
) const;
752 bool Contains(const wxPoint
& pt
) const { return Contains(pt
.x
, pt
.y
); }
753 // return true if the rectangle 'rect' is (not strictly) inside this rect
754 bool Contains(const wxRect
& rect
) const;
756 #if WXWIN_COMPATIBILITY_2_6
757 // use Contains() instead
758 wxDEPRECATED( bool Inside(int x
, int y
) const );
759 wxDEPRECATED( bool Inside(const wxPoint
& pt
) const );
760 wxDEPRECATED( bool Inside(const wxRect
& rect
) const );
761 #endif // WXWIN_COMPATIBILITY_2_6
763 // return true if the rectangles have a non empty intersection
764 bool Intersects(const wxRect
& rect
) const;
766 // like Union() but don't ignore empty rectangles
767 wxRect
& operator+=(const wxRect
& rect
);
769 // intersections of two rectrangles not testing for empty rectangles
770 wxRect
& operator*=(const wxRect
& rect
);
772 // centre this rectangle in the given (usually, but not necessarily,
774 wxRect
CentreIn(const wxRect
& r
, int dir
= wxBOTH
) const
776 return wxRect(dir
& wxHORIZONTAL ? r
.x
+ (r
.width
- width
)/2 : x
,
777 dir
& wxVERTICAL ? r
.y
+ (r
.height
- height
)/2 : y
,
781 wxRect
CenterIn(const wxRect
& r
, int dir
= wxBOTH
) const
783 return CentreIn(r
, dir
);
787 int x
, y
, width
, height
;
791 // compare rectangles
792 inline bool operator==(const wxRect
& r1
, const wxRect
& r2
)
794 return (r1
.x
== r2
.x
) && (r1
.y
== r2
.y
) &&
795 (r1
.width
== r2
.width
) && (r1
.height
== r2
.height
);
798 inline bool operator!=(const wxRect
& r1
, const wxRect
& r2
)
803 // like Union() but don't treat empty rectangles specially
804 WXDLLIMPEXP_CORE wxRect
operator+(const wxRect
& r1
, const wxRect
& r2
);
806 // intersections of two rectangles
807 WXDLLIMPEXP_CORE wxRect
operator*(const wxRect
& r1
, const wxRect
& r2
);
812 #if WXWIN_COMPATIBILITY_2_6
813 inline bool wxRect
::Inside(int cx
, int cy
) const { return Contains(cx
, cy
); }
814 inline bool wxRect
::Inside(const wxPoint
& pt
) const { return Contains(pt
); }
815 inline bool wxRect
::Inside(const wxRect
& rect
) const { return Contains(rect
); }
816 #endif // WXWIN_COMPATIBILITY_2_6
819 // ---------------------------------------------------------------------------
820 // Management of pens, brushes and fonts
821 // ---------------------------------------------------------------------------
823 typedef wxInt8 wxDash
;
825 class WXDLLIMPEXP_CORE wxGDIObjListBase
{
834 WX_DECLARE_STRING_HASH_MAP(wxColour
*, wxStringToColourHashMap
);
836 class WXDLLIMPEXP_CORE wxColourDatabase
842 // find colour by name or name for the given colour
843 wxColour
Find(const wxString
& name
) const;
844 wxString
FindName(const wxColour
& colour
) const;
846 // add a new colour to the database
847 void AddColour(const wxString
& name
, const wxColour
& colour
);
849 #if WXWIN_COMPATIBILITY_2_6
850 // deprecated, use Find() instead
851 wxDEPRECATED( wxColour
*FindColour(const wxString
& name
) );
852 #endif // WXWIN_COMPATIBILITY_2_6
856 // PM keeps its own type of colour table
862 // load the database with the built in colour values when called for the
863 // first time, do nothing after this
866 wxStringToColourHashMap
*m_map
;
869 class WXDLLIMPEXP_CORE wxResourceCache
: public wxList
872 wxResourceCache() { }
874 wxResourceCache(const unsigned int keyType
) : wxList(keyType
) { }
876 virtual ~wxResourceCache();
879 // ---------------------------------------------------------------------------
881 // ---------------------------------------------------------------------------
886 wxStockGDI creates the stock GDI objects on demand. Pointers to the
887 created objects are stored in the ms_stockObject array, which is indexed
888 by the Item enum values. Platorm-specific fonts can be created by
889 implementing a derived class with an override for the GetFont function.
890 wxStockGDI operates as a singleton, accessed through the ms_instance
891 pointer. By default this pointer is set to an instance of wxStockGDI.
892 A derived class must arrange to set this pointer to an instance of itself.
894 class WXDLLIMPEXP_CORE wxStockGDI
940 virtual ~wxStockGDI();
941 static void DeleteAll();
943 static wxStockGDI
& instance() { return *ms_instance
; }
945 static const wxBrush
* GetBrush(Item item
);
946 static const wxColour
* GetColour(Item item
);
947 static const wxCursor
* GetCursor(Item item
);
948 // Can be overridden by platform-specific derived classes
949 virtual const wxFont
* GetFont(Item item
);
950 static const wxPen
* GetPen(Item item
);
953 static wxStockGDI
* ms_instance
;
955 static wxObject
* ms_stockObject
[ITEMCOUNT
];
957 wxDECLARE_NO_COPY_CLASS(wxStockGDI
);
960 #define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
961 #define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
962 #define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
963 #define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
965 #define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
966 #define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
967 #define wxBLUE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLUE)
968 #define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
969 #define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
970 #define wxYELLOW_PEN wxStockGDI::GetPen(wxStockGDI::PEN_YELLOW)
971 #define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
972 #define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
973 #define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
974 #define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
975 #define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
976 #define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
978 #define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
979 #define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
980 #define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
981 #define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
982 #define wxYELLOW_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_YELLOW)
983 #define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
984 #define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
985 #define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
986 #define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
987 #define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
988 #define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
990 #define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
991 #define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
992 #define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
993 #define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
994 #define wxYELLOW wxStockGDI::GetColour(wxStockGDI::COLOUR_YELLOW)
995 #define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
996 #define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
997 #define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
999 #define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
1000 #define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
1001 #define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
1004 extern WXDLLIMPEXP_DATA_CORE(wxBitmap
) wxNullBitmap
;
1005 extern WXDLLIMPEXP_DATA_CORE(wxIcon
) wxNullIcon
;
1006 extern WXDLLIMPEXP_DATA_CORE(wxCursor
) wxNullCursor
;
1007 extern WXDLLIMPEXP_DATA_CORE(wxPen
) wxNullPen
;
1008 extern WXDLLIMPEXP_DATA_CORE(wxBrush
) wxNullBrush
;
1009 extern WXDLLIMPEXP_DATA_CORE(wxPalette
) wxNullPalette
;
1010 extern WXDLLIMPEXP_DATA_CORE(wxFont
) wxNullFont
;
1011 extern WXDLLIMPEXP_DATA_CORE(wxColour
) wxNullColour
;
1012 extern WXDLLIMPEXP_DATA_CORE(wxIconBundle
) wxNullIconBundle
;
1014 extern WXDLLIMPEXP_DATA_CORE(wxColourDatabase
*) wxTheColourDatabase
;
1016 extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr
[];
1018 extern WXDLLIMPEXP_DATA_CORE(const wxSize
) wxDefaultSize
;
1019 extern WXDLLIMPEXP_DATA_CORE(const wxPoint
) wxDefaultPosition
;
1021 // ---------------------------------------------------------------------------
1023 // ---------------------------------------------------------------------------
1025 // resource management
1026 extern void WXDLLIMPEXP_CORE
wxInitializeStockLists();
1027 extern void WXDLLIMPEXP_CORE
wxDeleteStockLists();
1029 // is the display colour (or monochrome)?
1030 extern bool WXDLLIMPEXP_CORE
wxColourDisplay();
1032 // Returns depth of screen
1033 extern int WXDLLIMPEXP_CORE
wxDisplayDepth();
1034 #define wxGetDisplayDepth wxDisplayDepth
1036 // get the display size
1037 extern void WXDLLIMPEXP_CORE
wxDisplaySize(int *width
, int *height
);
1038 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySize();
1039 extern void WXDLLIMPEXP_CORE
wxDisplaySizeMM(int *width
, int *height
);
1040 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplaySizeMM();
1041 extern wxSize WXDLLIMPEXP_CORE
wxGetDisplayPPI();
1043 // Get position and size of the display workarea
1044 extern void WXDLLIMPEXP_CORE
wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
);
1045 extern wxRect WXDLLIMPEXP_CORE
wxGetClientDisplayRect();
1047 // set global cursor
1048 extern void WXDLLIMPEXP_CORE
wxSetCursor(const wxCursor
& cursor
);