1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "gdicmn.h"
17 #define XtDisplay XTDISPLAY
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/gdicmn.h"
31 #include "wx/bitmap.h"
33 #include "wx/cursor.h"
35 #include "wx/palette.h"
39 #include "wx/settings.h"
40 #include "wx/hashmap.h"
46 #include "wx/msw/wrapwin.h"
51 #pragma message disable nosimpint
55 #pragma message enable nosimpint
64 #include "wx/mac/private.h"
65 #include "wx/mac/uma.h"
68 #if wxUSE_EXTENDED_RTTI
72 template<> void wxStringReadValue(const wxString
&s
, wxPoint
&data
)
74 wxSscanf(s
, wxT("%d,%d"), &data
.x
, &data
.y
) ;
77 template<> void wxStringWriteValue(wxString
&s
, const wxPoint
&data
)
79 s
= wxString::Format(wxT("%d,%d"), data
.x
, data
.y
) ;
82 wxCUSTOM_TYPE_INFO(wxPoint
, wxToStringConverter
<wxPoint
> , wxFromStringConverter
<wxPoint
>)
84 template<> void wxStringReadValue(const wxString
&s
, wxSize
&data
)
86 wxSscanf(s
, wxT("%d,%d"), &data
.x
, &data
.y
) ;
89 template<> void wxStringWriteValue(wxString
&s
, const wxSize
&data
)
91 s
= wxString::Format(wxT("%d,%d"), data
.x
, data
.y
) ;
94 wxCUSTOM_TYPE_INFO(wxSize
, wxToStringConverter
<wxSize
> , wxFromStringConverter
<wxSize
>)
98 IMPLEMENT_ABSTRACT_CLASS(wxDCBase
, wxObject
)
100 wxRect::wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
)
104 width
= bottomRight
.x
- topLeft
.x
+ 1;
105 height
= bottomRight
.y
- topLeft
.y
+ 1;
120 wxRect::wxRect(const wxPoint
& point
, const wxSize
& size
)
122 x
= point
.x
; y
= point
.y
;
123 width
= size
.x
; height
= size
.y
;
126 bool wxRect::operator==(const wxRect
& rect
) const
128 return ((x
== rect
.x
) &&
130 (width
== rect
.width
) &&
131 (height
== rect
.height
));
134 wxRect
& wxRect::operator += (const wxRect
& rect
)
136 *this = (*this + rect
);
140 wxRect
wxRect::operator + (const wxRect
& rect
) const
142 int x1
= wxMin(this->x
, rect
.x
);
143 int y1
= wxMin(this->y
, rect
.y
);
144 int y2
= wxMax(y
+height
, rect
.height
+rect
.y
);
145 int x2
= wxMax(x
+width
, rect
.width
+rect
.x
);
146 return wxRect(x1
, y1
, x2
-x1
, y2
-y1
);
149 wxRect
& wxRect::Inflate(wxCoord dx
, wxCoord dy
)
156 // check that we didn't make the rectangle invalid by accident (you almost
157 // never want to have negative coords and never want negative size)
163 // what else can we do?
172 bool wxRect::Inside(int cx
, int cy
) const
174 return ( (cx
>= x
) && (cy
>= y
)
175 && ((cy
- y
) < height
)
176 && ((cx
- x
) < width
)
180 wxRect
& wxRect::Intersect(const wxRect
& rect
)
189 if ( x2
> rect
.GetRight() )
190 x2
= rect
.GetRight();
191 if ( y2
> rect
.GetBottom() )
192 y2
= rect
.GetBottom();
197 if ( width
<= 0 || height
<= 0 )
206 bool wxRect::Intersects(const wxRect
& rect
) const
208 wxRect r
= Intersect(rect
);
210 // if there is no intersection, both width and height are 0
214 WX_DECLARE_STRING_HASH_MAP( wxColour
*, wxStringToColourHashMap
);
216 wxColourDatabase::wxColourDatabase ()
218 m_map
= new wxStringToColourHashMap
;
221 wxColourDatabase::~wxColourDatabase ()
223 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
228 delete [] m_palTable
;
232 // Colour database stuff
233 void wxColourDatabase::Initialize ()
235 static const struct wxColourDesc
242 {wxT("AQUAMARINE"),112, 219, 147},
243 {wxT("BLACK"),0, 0, 0},
244 {wxT("BLUE"), 0, 0, 255},
245 {wxT("BLUE VIOLET"), 159, 95, 159},
246 {wxT("BROWN"), 165, 42, 42},
247 {wxT("CADET BLUE"), 95, 159, 159},
248 {wxT("CORAL"), 255, 127, 0},
249 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
250 {wxT("CYAN"), 0, 255, 255},
251 {wxT("DARK GREY"), 47, 47, 47}, // ?
253 {wxT("DARK GREEN"), 47, 79, 47},
254 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
255 {wxT("DARK ORCHID"), 153, 50, 204},
256 {wxT("DARK SLATE BLUE"), 107, 35, 142},
257 {wxT("DARK SLATE GREY"), 47, 79, 79},
258 {wxT("DARK TURQUOISE"), 112, 147, 219},
259 {wxT("DIM GREY"), 84, 84, 84},
260 {wxT("FIREBRICK"), 142, 35, 35},
261 {wxT("FOREST GREEN"), 35, 142, 35},
262 {wxT("GOLD"), 204, 127, 50},
263 {wxT("GOLDENROD"), 219, 219, 112},
264 {wxT("GREY"), 128, 128, 128},
265 {wxT("GREEN"), 0, 255, 0},
266 {wxT("GREEN YELLOW"), 147, 219, 112},
267 {wxT("INDIAN RED"), 79, 47, 47},
268 {wxT("KHAKI"), 159, 159, 95},
269 {wxT("LIGHT BLUE"), 191, 216, 216},
270 {wxT("LIGHT GREY"), 192, 192, 192},
271 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
272 {wxT("LIME GREEN"), 50, 204, 50},
273 {wxT("LIGHT MAGENTA"), 255, 0, 255},
274 {wxT("MAGENTA"), 255, 0, 255},
275 {wxT("MAROON"), 142, 35, 107},
276 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
277 {wxT("MEDIUM GREY"), 100, 100, 100},
278 {wxT("MEDIUM BLUE"), 50, 50, 204},
279 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
280 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
281 {wxT("MEDIUM ORCHID"), 147, 112, 219},
282 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
283 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
284 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
285 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
286 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
287 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
288 {wxT("NAVY"), 35, 35, 142},
289 {wxT("ORANGE"), 204, 50, 50},
290 {wxT("ORANGE RED"), 255, 0, 127},
291 {wxT("ORCHID"), 219, 112, 219},
292 {wxT("PALE GREEN"), 143, 188, 143},
293 {wxT("PINK"), 188, 143, 234},
294 {wxT("PLUM"), 234, 173, 234},
295 {wxT("PURPLE"), 176, 0, 255},
296 {wxT("RED"), 255, 0, 0},
297 {wxT("SALMON"), 111, 66, 66},
298 {wxT("SEA GREEN"), 35, 142, 107},
299 {wxT("SIENNA"), 142, 107, 35},
300 {wxT("SKY BLUE"), 50, 153, 204},
301 {wxT("SLATE BLUE"), 0, 127, 255},
302 {wxT("SPRING GREEN"), 0, 255, 127},
303 {wxT("STEEL BLUE"), 35, 107, 142},
304 {wxT("TAN"), 219, 147, 112},
305 {wxT("THISTLE"), 216, 191, 216},
306 {wxT("TURQUOISE"), 173, 234, 234},
307 {wxT("VIOLET"), 79, 47, 79},
308 {wxT("VIOLET RED"), 204, 50, 153},
309 {wxT("WHEAT"), 216, 216, 191},
310 {wxT("WHITE"), 255, 255, 255},
311 {wxT("YELLOW"), 255, 255, 0},
312 {wxT("YELLOW GREEN"), 153, 204, 50},
313 {wxT("YELLOW GREEN"), 153, 204, 50}
318 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
320 const wxColourDesc
& cc
= wxColourTable
[n
];
321 AddColour(cc
.name
, new wxColour(cc
.r
,cc
.g
,cc
.b
));
324 m_palTable
= new long[n
];
325 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
327 const wxColourDesc
& cc
= wxColourTable
[n
];
328 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
335 * Changed by Ian Brown, July 1994.
337 * When running under X, the Colour Database starts off empty. The X server
338 * is queried for the colour first time after which it is entered into the
339 * database. This allows our client to use the server colour database which
340 * is hopefully gamma corrected for the display being used.
343 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
)
345 return FindColour(colour
, true);
348 wxColour
*wxColourDatabase::FindColourNoAdd(const wxString
& colour
) const
350 return ((wxColourDatabase
*)this)->FindColour(colour
, false);
353 void wxColourDatabase::AddColour (const wxString
& name
, wxColour
* colour
)
355 wxString colName
= name
;
357 wxString colName2
= colName
;
358 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
361 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
362 if ( it
== m_map
->end() )
363 it
= m_map
->find(colName2
);
364 if ( it
!= m_map
->end() )
370 (*m_map
)[name
] = colour
;
373 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
, bool add
)
375 // VZ: make the comparaison case insensitive and also match both grey and
377 wxString colName
= colour
;
379 wxString colName2
= colName
;
380 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
383 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
384 if ( it
== m_map
->end() )
385 it
= m_map
->find(colName2
);
386 if ( it
!= m_map
->end() )
402 // TODO for other implementations. This should really go into
403 // platform-specific directories.
415 wxColour
*col
= new wxColour( colour
);
420 return (wxColour
*) NULL
;
422 AddColour(colour
, col
);
430 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
433 Display
* display
= (Display
*) wxGetDisplay();
435 /* MATTHEW: [4] Use wxGetMainColormap */
436 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
440 unsigned char r
= (unsigned char)(xcolour
.red
);
441 unsigned char g
= (unsigned char)(xcolour
.green
);
442 unsigned char b
= (unsigned char)(xcolour
.blue
);
444 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
445 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
446 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
449 wxColour
*col
= new wxColour(r
, g
, b
);
450 AddColour(colour
, col
);
456 wxString
wxColourDatabase::FindName (const wxColour
& colour
) const
458 unsigned char red
= colour
.Red ();
459 unsigned char green
= colour
.Green ();
460 unsigned char blue
= colour
.Blue ();
462 typedef wxStringToColourHashMap::iterator iterator
;
464 for (iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
466 wxColour
*col
= it
->second
;
468 if (col
->Red () == red
&& col
->Green () == green
&& col
->Blue () == blue
)
472 return wxEmptyString
;
475 void wxInitializeStockLists()
477 wxTheColourDatabase
= new wxColourDatabase
;
478 wxTheColourDatabase
->Initialize();
480 wxTheBrushList
= new wxBrushList
;
481 wxThePenList
= new wxPenList
;
482 wxTheFontList
= new wxFontList
;
483 wxTheBitmapList
= new wxBitmapList
;
486 void wxInitializeStockObjects ()
492 // wxFontPool = new XFontPool;
495 // why under MSW fonts shouldn't have the standard system size?
498 static const int sizeFont = 10;
502 #if defined(__WXMAC__)
509 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
510 sizeFont
= fontSize
;
511 wxSWISS_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
512 #elif defined(__WXPM__)
513 static const int sizeFont
= 12;
515 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
516 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
519 #if defined(__WXPM__)
521 // Basic OS/2 has a fairly limited number of fonts and these are as good
522 // as I can do to get something that looks halfway "wx" normal
524 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
525 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
526 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
527 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
528 #elif defined(__WXMAC__)
529 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxNORMAL
);
530 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
531 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
532 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
534 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
535 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
536 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
539 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
540 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
541 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
542 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
543 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
544 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
545 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
546 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
547 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
548 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
550 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
551 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
552 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
553 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
554 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
555 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
556 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
557 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
558 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
559 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
561 wxBLACK
= new wxColour (wxT("BLACK"));
562 wxWHITE
= new wxColour (wxT("WHITE"));
563 wxRED
= new wxColour (wxT("RED"));
564 wxBLUE
= new wxColour (wxT("BLUE"));
565 wxGREEN
= new wxColour (wxT("GREEN"));
566 wxCYAN
= new wxColour (wxT("CYAN"));
567 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
569 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
570 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
571 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
574 void wxDeleteStockObjects ()
576 wxDELETE(wxNORMAL_FONT
);
577 wxDELETE(wxSMALL_FONT
);
578 wxDELETE(wxITALIC_FONT
);
579 wxDELETE(wxSWISS_FONT
);
582 wxDELETE(wxCYAN_PEN
);
583 wxDELETE(wxGREEN_PEN
);
584 wxDELETE(wxBLACK_PEN
);
585 wxDELETE(wxWHITE_PEN
);
586 wxDELETE(wxTRANSPARENT_PEN
);
587 wxDELETE(wxBLACK_DASHED_PEN
);
588 wxDELETE(wxGREY_PEN
);
589 wxDELETE(wxMEDIUM_GREY_PEN
);
590 wxDELETE(wxLIGHT_GREY_PEN
);
592 wxDELETE(wxBLUE_BRUSH
);
593 wxDELETE(wxGREEN_BRUSH
);
594 wxDELETE(wxWHITE_BRUSH
);
595 wxDELETE(wxBLACK_BRUSH
);
596 wxDELETE(wxTRANSPARENT_BRUSH
);
597 wxDELETE(wxCYAN_BRUSH
);
598 wxDELETE(wxRED_BRUSH
);
599 wxDELETE(wxGREY_BRUSH
);
600 wxDELETE(wxMEDIUM_GREY_BRUSH
);
601 wxDELETE(wxLIGHT_GREY_BRUSH
);
609 wxDELETE(wxLIGHT_GREY
);
611 wxDELETE(wxSTANDARD_CURSOR
);
612 wxDELETE(wxHOURGLASS_CURSOR
);
613 wxDELETE(wxCROSS_CURSOR
);
616 void wxDeleteStockLists()
618 wxDELETE(wxTheBrushList
);
619 wxDELETE(wxThePenList
);
620 wxDELETE(wxTheFontList
);
621 wxDELETE(wxTheBitmapList
);
624 // ============================================================================
625 // wxTheXXXList stuff (semi-obsolete)
626 // ============================================================================
628 wxBitmapList::wxBitmapList()
632 wxBitmapList::~wxBitmapList ()
634 wxList::compatibility_iterator node
= GetFirst ();
637 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
638 wxList::compatibility_iterator next
= node
->GetNext ();
639 if (bitmap
->GetVisible())
645 // Pen and Brush lists
646 wxPenList::~wxPenList ()
648 wxList::compatibility_iterator node
= GetFirst ();
651 wxPen
*pen
= (wxPen
*) node
->GetData ();
652 wxList::compatibility_iterator next
= node
->GetNext ();
653 if (pen
->GetVisible())
659 void wxPenList::AddPen (wxPen
* pen
)
664 void wxPenList::RemovePen (wxPen
* pen
)
669 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
671 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
673 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
675 each_pen
->GetVisible() &&
676 each_pen
->GetWidth () == width
&&
677 each_pen
->GetStyle () == style
&&
678 each_pen
->GetColour ().Red () == colour
.Red () &&
679 each_pen
->GetColour ().Green () == colour
.Green () &&
680 each_pen
->GetColour ().Blue () == colour
.Blue ())
684 wxPen
*pen
= new wxPen (colour
, width
, style
);
687 // don't save the invalid pens in the list
695 // we'll delete it ourselves later
696 pen
->SetVisible(TRUE
);
701 wxBrushList::~wxBrushList ()
703 wxList::compatibility_iterator node
= GetFirst ();
706 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
707 wxList::compatibility_iterator next
= node
->GetNext ();
708 if (brush
&& brush
->GetVisible())
714 void wxBrushList::AddBrush (wxBrush
* brush
)
719 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
721 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
723 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
725 each_brush
->GetVisible() &&
726 each_brush
->GetStyle () == style
&&
727 each_brush
->GetColour ().Red () == colour
.Red () &&
728 each_brush
->GetColour ().Green () == colour
.Green () &&
729 each_brush
->GetColour ().Blue () == colour
.Blue ())
733 wxBrush
*brush
= new wxBrush (colour
, style
);
737 // don't put the brushes we failed to create into the list
745 // we'll delete it ourselves later
746 brush
->SetVisible(TRUE
);
751 void wxBrushList::RemoveBrush (wxBrush
* brush
)
753 DeleteObject (brush
);
756 wxFontList::~wxFontList ()
758 wxList::compatibility_iterator node
= GetFirst ();
761 // Only delete objects that are 'visible', i.e.
762 // that have been created using FindOrCreate...,
763 // where the pointers are expected to be shared
764 // (and therefore not deleted by any one part of an app).
765 wxFont
*font
= (wxFont
*) node
->GetData ();
766 wxList::compatibility_iterator next
= node
->GetNext ();
767 if (font
->GetVisible())
773 void wxFontList::AddFont (wxFont
* font
)
778 void wxFontList::RemoveFont (wxFont
* font
)
783 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
788 const wxString
& facename
,
789 wxFontEncoding encoding
)
791 wxFont
*font
= (wxFont
*)NULL
;
792 wxList::compatibility_iterator node
;
793 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
795 font
= (wxFont
*)node
->GetData();
796 if ( font
->GetVisible() &&
798 font
->GetPointSize () == pointSize
&&
799 font
->GetStyle () == style
&&
800 font
->GetWeight () == weight
&&
801 font
->GetUnderlined () == underline
)
803 int fontFamily
= font
->GetFamily();
805 #if defined(__WXGTK__)
806 // under GTK the default family is wxSWISS, so looking for a font
807 // with wxDEFAULT family should return a wxSWISS one instead of
808 // creating a new one
809 bool same
= (fontFamily
== family
) ||
810 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
812 // VZ: but why elsewhere do we require an exact match? mystery...
813 bool same
= fontFamily
== family
;
816 // empty facename matches anything at all: this is bad because
817 // depending on which fonts are already created, we might get back
818 // a different font if we create it with empty facename, but it is
819 // still better than never matching anything in the cache at all
821 if ( same
&& !!facename
)
823 const wxString
& fontFace
= font
->GetFaceName();
825 // empty facename matches everything
826 same
= !fontFace
|| fontFace
== facename
;
829 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
831 // have to match the encoding too
832 same
= font
->GetEncoding() == encoding
;
844 // font not found, create the new one
845 font
= new wxFont(pointSize
, family
, style
, weight
,
846 underline
, facename
, encoding
);
850 // and mark it as being cacheable
851 font
->SetVisible(TRUE
);
857 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
862 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
864 DeleteObject(bitmap
);
867 wxSize
wxGetDisplaySize()
870 wxDisplaySize(& x
, & y
);
874 wxRect
wxGetClientDisplayRect()
876 int x
, y
, width
, height
;
877 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
878 return wxRect(x
, y
, width
, height
);
881 wxSize
wxGetDisplaySizeMM()
884 wxDisplaySizeMM(& x
, & y
);
888 wxResourceCache::~wxResourceCache ()
890 wxList::compatibility_iterator node
= GetFirst ();
892 wxObject
*item
= (wxObject
*)node
->GetData();
895 node
= node
->GetNext ();