1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
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"
67 //IMPLEMENT_CLASS(wxColourDatabase, wxList)
68 //IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
69 //IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
70 //IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
71 //IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
72 //IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
74 IMPLEMENT_ABSTRACT_CLASS(wxDCBase
, wxObject
)
76 wxRect::wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
)
80 width
= bottomRight
.x
- topLeft
.x
+ 1;
81 height
= bottomRight
.y
- topLeft
.y
+ 1;
96 wxRect::wxRect(const wxPoint
& point
, const wxSize
& size
)
98 x
= point
.x
; y
= point
.y
;
99 width
= size
.x
; height
= size
.y
;
102 bool wxRect::operator==(const wxRect
& rect
) const
104 return ((x
== rect
.x
) &&
106 (width
== rect
.width
) &&
107 (height
== rect
.height
));
110 wxRect
& wxRect::operator += (const wxRect
& rect
)
112 *this = (*this + rect
);
116 wxRect
wxRect::operator + (const wxRect
& rect
) const
118 int x1
= wxMin(this->x
, rect
.x
);
119 int y1
= wxMin(this->y
, rect
.y
);
120 int y2
= wxMax(y
+height
, rect
.height
+rect
.y
);
121 int x2
= wxMax(x
+width
, rect
.width
+rect
.x
);
122 return wxRect(x1
, y1
, x2
-x1
, y2
-y1
);
125 wxRect
& wxRect::Inflate(wxCoord dx
, wxCoord dy
)
132 // check that we didn't make the rectangle invalid by accident (you almost
133 // never want to have negative coords and never want negative size)
139 // what else can we do?
148 bool wxRect::Inside(int cx
, int cy
) const
150 return ( (cx
>= x
) && (cy
>= y
)
151 && ((cy
- y
) < height
)
152 && ((cx
- x
) < width
)
156 wxRect
& wxRect::Intersect(const wxRect
& rect
)
165 if ( x2
> rect
.GetRight() )
166 x2
= rect
.GetRight();
167 if ( y2
> rect
.GetBottom() )
168 y2
= rect
.GetBottom();
173 if ( width
<= 0 || height
<= 0 )
182 bool wxRect::Intersects(const wxRect
& rect
) const
184 wxRect r
= Intersect(rect
);
186 // if there is no intersection, both width and height are 0
190 WX_DECLARE_STRING_HASH_MAP( wxColour
*, wxStringToColourHashMap
);
192 wxColourDatabase::wxColourDatabase ()
194 m_map
= new wxStringToColourHashMap
;
197 wxColourDatabase::~wxColourDatabase ()
199 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
204 delete [] m_palTable
;
208 // Colour database stuff
209 void wxColourDatabase::Initialize ()
211 // these colour definitions are taken from X consortium definitions with a
212 // few more colours added
213 static const struct wxColourDesc
220 {wxT("AQUAMARINE"),127, 255, 212},
221 {wxT("BLACK"),0, 0, 0},
222 {wxT("BLUE"), 0, 0, 255},
223 {wxT("BLUE VIOLET"), 138, 43, 226},
224 {wxT("BROWN"), 165, 42, 42},
225 {wxT("CADET BLUE"), 95, 158, 160},
226 {wxT("CORAL"), 255, 127, 80},
227 {wxT("CORNFLOWER BLUE"), 100, 149, 237},
228 {wxT("CYAN"), 0, 255, 255},
229 {wxT("DARK GREY"), 169, 169, 169},
230 {wxT("DARK GREEN"), 0, 100, 0},
231 {wxT("DARK OLIVE GREEN"), 85, 107, 47},
232 {wxT("DARK ORCHID"), 153, 50, 204},
233 {wxT("DARK SLATE BLUE"), 72, 61, 139},
234 {wxT("DARK SLATE GREY"), 47, 79, 79},
235 {wxT("DARK TURQUOISE"), 0, 206, 209},
236 {wxT("DIM GREY"), 105, 105, 105},
237 {wxT("FIREBRICK"), 178, 34, 34},
238 {wxT("FOREST GREEN"), 34, 139, 34},
239 {wxT("GOLD"), 255, 215, 0},
240 {wxT("GOLDENROD"), 218, 165, 32},
241 {wxT("GREY"), 190, 190, 190},
242 {wxT("GREEN"), 0, 255, 0},
243 {wxT("GREEN YELLOW"), 173, 255, 47},
244 {wxT("INDIAN RED"), 205, 92, 92},
245 {wxT("KHAKI"), 240, 230, 140},
246 {wxT("LIGHT BLUE"), 173, 216, 230},
247 {wxT("LIGHT GREY"), 211, 211, 211},
248 {wxT("LIGHT STEEL BLUE"), 176, 196, 222},
249 {wxT("LIME GREEN"), 50, 205, 50},
250 {wxT("LIGHT MAGENTA"), 255, 0, 255}, // not X colour
251 {wxT("MAGENTA"), 255, 0, 255},
252 {wxT("MAROON"), 176, 48, 96},
253 {wxT("MEDIUM AQUAMARINE"), 102, 205, 170},
254 {wxT("MEDIUM BLUE"), 0, 0, 205},
255 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35}, // not X colour
256 {wxT("MEDIUM GOLD"), 204, 127, 50}, // not X, "GOLD" in 2.4
257 {wxT("MEDIUM GOLDENROD"), 234, 234, 173}, // not X colour
258 {wxT("MEDIUM GREY"), 100, 100, 100}, // not X colour
259 {wxT("MEDIUM ORANGE"), 204, 50, 50}, // not X, "ORANGE" in 2.4
260 {wxT("MEDIUM ORCHID"), 186, 85, 211},
261 {wxT("MEDIUM SEA GREEN"), 60, 179, 113},
262 {wxT("MEDIUM SLATE BLUE"), 123, 104, 238},
263 {wxT("MEDIUM SPRING GREEN"), 0, 250, 154},
264 {wxT("MEDIUM TURQUOISE"), 72, 209, 204},
265 {wxT("MEDIUM VIOLET RED"), 199, 21, 133},
266 {wxT("MIDNIGHT BLUE"), 25, 25, 112},
267 {wxT("NAVY"), 0, 0, 128},
268 {wxT("ORANGE"), 255, 165, 0},
269 {wxT("ORANGE RED"), 255, 69, 0},
270 {wxT("ORCHID"), 218, 112, 214},
271 {wxT("PALE GREEN"), 152, 251, 152},
272 {wxT("PINK"), 255, 192, 203},
273 {wxT("PLUM"), 221, 160, 221},
274 {wxT("PURPLE"), 160, 32, 240},
275 {wxT("RED"), 255, 0, 0},
276 {wxT("SALMON"), 250, 128, 114},
277 {wxT("SEA GREEN"), 46, 139, 87},
278 {wxT("SIENNA"), 160, 82, 45},
279 {wxT("SKY BLUE"), 135, 206, 235},
280 {wxT("SLATE BLUE"), 106, 90, 205},
281 {wxT("SPRING GREEN"), 0, 255, 127},
282 {wxT("STEEL BLUE"), 70, 130, 180},
283 {wxT("TAN"), 210, 180, 140},
284 {wxT("THISTLE"), 216, 191, 216},
285 {wxT("TURQUOISE"), 64, 224, 208},
286 {wxT("VIOLET"), 238, 130, 238},
287 {wxT("VIOLET RED"), 208, 32, 144},
288 {wxT("WHEAT"), 245, 222, 179},
289 {wxT("WHITE"), 255, 255, 255},
290 {wxT("YELLOW"), 255, 255, 0},
291 {wxT("YELLOW GREEN"), 154, 205, 50},
296 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
298 const wxColourDesc
& cc
= wxColourTable
[n
];
299 AddColour(cc
.name
, new wxColour(cc
.r
,cc
.g
,cc
.b
));
302 m_palTable
= new long[n
];
303 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
305 const wxColourDesc
& cc
= wxColourTable
[n
];
306 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
313 * Changed by Ian Brown, July 1994.
315 * When running under X, the Colour Database starts off empty. The X server
316 * is queried for the colour first time after which it is entered into the
317 * database. This allows our client to use the server colour database which
318 * is hopefully gamma corrected for the display being used.
321 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
)
323 return FindColour(colour
, true);
326 wxColour
*wxColourDatabase::FindColourNoAdd(const wxString
& colour
) const
328 return ((wxColourDatabase
*)this)->FindColour(colour
, false);
331 void wxColourDatabase::AddColour (const wxString
& name
, wxColour
* colour
)
333 wxString colName
= name
;
335 wxString colName2
= colName
;
336 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
339 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
340 if ( it
== m_map
->end() )
341 it
= m_map
->find(colName2
);
342 if ( it
!= m_map
->end() )
348 (*m_map
)[name
] = colour
;
351 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
, bool add
)
353 // VZ: make the comparaison case insensitive and also match both grey and
355 wxString colName
= colour
;
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() )
380 // TODO for other implementations. This should really go into
381 // platform-specific directories.
393 wxColour
*col
= new wxColour( colour
);
398 return (wxColour
*) NULL
;
400 AddColour(colour
, col
);
408 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
411 Display
* display
= (Display
*) wxGetDisplay();
413 /* MATTHEW: [4] Use wxGetMainColormap */
414 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
418 unsigned char r
= (unsigned char)(xcolour
.red
);
419 unsigned char g
= (unsigned char)(xcolour
.green
);
420 unsigned char b
= (unsigned char)(xcolour
.blue
);
422 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
423 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
424 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
427 wxColour
*col
= new wxColour(r
, g
, b
);
428 AddColour(colour
, col
);
434 wxString
wxColourDatabase::FindName (const wxColour
& colour
) const
436 unsigned char red
= colour
.Red ();
437 unsigned char green
= colour
.Green ();
438 unsigned char blue
= colour
.Blue ();
440 typedef wxStringToColourHashMap::iterator iterator
;
442 for (iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
444 wxColour
*col
= it
->second
;
446 if (col
->Red () == red
&& col
->Green () == green
&& col
->Blue () == blue
)
450 return wxEmptyString
;
453 void wxInitializeStockLists()
455 wxTheColourDatabase
= new wxColourDatabase
;
456 wxTheColourDatabase
->Initialize();
458 wxTheBrushList
= new wxBrushList
;
459 wxThePenList
= new wxPenList
;
460 wxTheFontList
= new wxFontList
;
461 wxTheBitmapList
= new wxBitmapList
;
464 void wxInitializeStockObjects ()
470 // wxFontPool = new XFontPool;
473 // why under MSW fonts shouldn't have the standard system size?
476 static const int sizeFont = 10;
480 #if defined(__WXMAC__)
487 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
488 sizeFont
= fontSize
;
489 wxSWISS_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
490 #elif defined(__WXPM__)
491 static const int sizeFont
= 12;
493 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
494 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
497 #if defined(__WXPM__)
499 // Basic OS/2 has a fairly limited number of fonts and these are as good
500 // as I can do to get something that looks halfway "wx" normal
502 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
503 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
504 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
505 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
506 #elif defined(__WXMAC__)
507 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxNORMAL
);
508 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
509 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
510 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
512 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
513 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
514 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
517 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
518 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
519 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
520 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
521 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
522 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
523 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
524 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
525 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
526 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
528 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
529 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
530 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
531 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
532 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
533 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
534 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
535 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
536 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
537 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
539 wxBLACK
= new wxColour (wxT("BLACK"));
540 wxWHITE
= new wxColour (wxT("WHITE"));
541 wxRED
= new wxColour (wxT("RED"));
542 wxBLUE
= new wxColour (wxT("BLUE"));
543 wxGREEN
= new wxColour (wxT("GREEN"));
544 wxCYAN
= new wxColour (wxT("CYAN"));
545 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
547 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
548 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
549 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
552 void wxDeleteStockObjects ()
554 wxDELETE(wxNORMAL_FONT
);
555 wxDELETE(wxSMALL_FONT
);
556 wxDELETE(wxITALIC_FONT
);
557 wxDELETE(wxSWISS_FONT
);
560 wxDELETE(wxCYAN_PEN
);
561 wxDELETE(wxGREEN_PEN
);
562 wxDELETE(wxBLACK_PEN
);
563 wxDELETE(wxWHITE_PEN
);
564 wxDELETE(wxTRANSPARENT_PEN
);
565 wxDELETE(wxBLACK_DASHED_PEN
);
566 wxDELETE(wxGREY_PEN
);
567 wxDELETE(wxMEDIUM_GREY_PEN
);
568 wxDELETE(wxLIGHT_GREY_PEN
);
570 wxDELETE(wxBLUE_BRUSH
);
571 wxDELETE(wxGREEN_BRUSH
);
572 wxDELETE(wxWHITE_BRUSH
);
573 wxDELETE(wxBLACK_BRUSH
);
574 wxDELETE(wxTRANSPARENT_BRUSH
);
575 wxDELETE(wxCYAN_BRUSH
);
576 wxDELETE(wxRED_BRUSH
);
577 wxDELETE(wxGREY_BRUSH
);
578 wxDELETE(wxMEDIUM_GREY_BRUSH
);
579 wxDELETE(wxLIGHT_GREY_BRUSH
);
587 wxDELETE(wxLIGHT_GREY
);
589 wxDELETE(wxSTANDARD_CURSOR
);
590 wxDELETE(wxHOURGLASS_CURSOR
);
591 wxDELETE(wxCROSS_CURSOR
);
594 void wxDeleteStockLists()
596 wxDELETE(wxTheBrushList
);
597 wxDELETE(wxThePenList
);
598 wxDELETE(wxTheFontList
);
599 wxDELETE(wxTheBitmapList
);
602 // ============================================================================
603 // wxTheXXXList stuff (semi-obsolete)
604 // ============================================================================
606 wxBitmapList::wxBitmapList()
610 wxBitmapList::~wxBitmapList ()
612 wxList::compatibility_iterator node
= GetFirst ();
615 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
616 wxList::compatibility_iterator next
= node
->GetNext ();
617 if (bitmap
->GetVisible())
623 // Pen and Brush lists
624 wxPenList::~wxPenList ()
626 wxList::compatibility_iterator node
= GetFirst ();
629 wxPen
*pen
= (wxPen
*) node
->GetData ();
630 wxList::compatibility_iterator next
= node
->GetNext ();
631 if (pen
->GetVisible())
637 void wxPenList::AddPen (wxPen
* pen
)
642 void wxPenList::RemovePen (wxPen
* pen
)
647 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
649 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
651 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
653 each_pen
->GetVisible() &&
654 each_pen
->GetWidth () == width
&&
655 each_pen
->GetStyle () == style
&&
656 each_pen
->GetColour ().Red () == colour
.Red () &&
657 each_pen
->GetColour ().Green () == colour
.Green () &&
658 each_pen
->GetColour ().Blue () == colour
.Blue ())
662 wxPen
*pen
= new wxPen (colour
, width
, style
);
665 // don't save the invalid pens in the list
673 // we'll delete it ourselves later
674 pen
->SetVisible(TRUE
);
679 wxBrushList::~wxBrushList ()
681 wxList::compatibility_iterator node
= GetFirst ();
684 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
685 wxList::compatibility_iterator next
= node
->GetNext ();
686 if (brush
&& brush
->GetVisible())
692 void wxBrushList::AddBrush (wxBrush
* brush
)
697 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
699 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
701 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
703 each_brush
->GetVisible() &&
704 each_brush
->GetStyle () == style
&&
705 each_brush
->GetColour ().Red () == colour
.Red () &&
706 each_brush
->GetColour ().Green () == colour
.Green () &&
707 each_brush
->GetColour ().Blue () == colour
.Blue ())
711 wxBrush
*brush
= new wxBrush (colour
, style
);
715 // don't put the brushes we failed to create into the list
723 // we'll delete it ourselves later
724 brush
->SetVisible(TRUE
);
729 void wxBrushList::RemoveBrush (wxBrush
* brush
)
731 DeleteObject (brush
);
734 wxFontList::~wxFontList ()
736 wxList::compatibility_iterator node
= GetFirst ();
739 // Only delete objects that are 'visible', i.e.
740 // that have been created using FindOrCreate...,
741 // where the pointers are expected to be shared
742 // (and therefore not deleted by any one part of an app).
743 wxFont
*font
= (wxFont
*) node
->GetData ();
744 wxList::compatibility_iterator next
= node
->GetNext ();
745 if (font
->GetVisible())
751 void wxFontList::AddFont (wxFont
* font
)
756 void wxFontList::RemoveFont (wxFont
* font
)
761 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
766 const wxString
& facename
,
767 wxFontEncoding encoding
)
769 wxFont
*font
= (wxFont
*)NULL
;
770 wxList::compatibility_iterator node
;
771 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
773 font
= (wxFont
*)node
->GetData();
774 if ( font
->GetVisible() &&
776 font
->GetPointSize () == pointSize
&&
777 font
->GetStyle () == style
&&
778 font
->GetWeight () == weight
&&
779 font
->GetUnderlined () == underline
)
781 int fontFamily
= font
->GetFamily();
783 #if defined(__WXGTK__)
784 // under GTK the default family is wxSWISS, so looking for a font
785 // with wxDEFAULT family should return a wxSWISS one instead of
786 // creating a new one
787 bool same
= (fontFamily
== family
) ||
788 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
790 // VZ: but why elsewhere do we require an exact match? mystery...
791 bool same
= fontFamily
== family
;
794 // empty facename matches anything at all: this is bad because
795 // depending on which fonts are already created, we might get back
796 // a different font if we create it with empty facename, but it is
797 // still better than never matching anything in the cache at all
799 if ( same
&& !!facename
)
801 const wxString
& fontFace
= font
->GetFaceName();
803 // empty facename matches everything
804 same
= !fontFace
|| fontFace
== facename
;
807 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
809 // have to match the encoding too
810 same
= font
->GetEncoding() == encoding
;
822 // font not found, create the new one
823 font
= new wxFont(pointSize
, family
, style
, weight
,
824 underline
, facename
, encoding
);
828 // and mark it as being cacheable
829 font
->SetVisible(TRUE
);
835 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
840 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
842 DeleteObject(bitmap
);
845 wxSize
wxGetDisplaySize()
848 wxDisplaySize(& x
, & y
);
852 wxRect
wxGetClientDisplayRect()
854 int x
, y
, width
, height
;
855 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
856 return wxRect(x
, y
, width
, height
);
859 wxSize
wxGetDisplaySizeMM()
862 wxDisplaySizeMM(& x
, & y
);
866 wxResourceCache::~wxResourceCache ()
868 wxList::compatibility_iterator node
= GetFirst ();
870 wxObject
*item
= (wxObject
*)node
->GetData();
873 node
= node
->GetNext ();