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 GREY"), 100, 100, 100}, // not X colour
255 {wxT("MEDIUM BLUE"), 0, 0, 205},
256 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35}, // not X colour
257 {wxT("MEDIUM GOLDENROD"), 234, 234, 173}, // not X colour
258 {wxT("MEDIUM ORCHID"), 186, 85, 211},
259 {wxT("MEDIUM SEA GREEN"), 60, 179, 113},
260 {wxT("MEDIUM SLATE BLUE"), 123, 104, 238},
261 {wxT("MEDIUM SPRING GREEN"), 0, 250, 154},
262 {wxT("MEDIUM TURQUOISE"), 72, 209, 204},
263 {wxT("MEDIUM VIOLET RED"), 199, 21, 133},
264 {wxT("MIDNIGHT BLUE"), 25, 25, 112},
265 {wxT("NAVY"), 0, 0, 128},
266 {wxT("ORANGE"), 255, 165, 0},
267 {wxT("ORANGE RED"), 255, 69, 0},
268 {wxT("ORCHID"), 218, 112, 214},
269 {wxT("PALE GREEN"), 152, 251, 152},
270 {wxT("PINK"), 255, 192, 203},
271 {wxT("PLUM"), 221, 160, 221},
272 {wxT("PURPLE"), 160, 32, 240},
273 {wxT("RED"), 255, 0, 0},
274 {wxT("SALMON"), 250, 128, 114},
275 {wxT("SEA GREEN"), 46, 139, 87},
276 {wxT("SIENNA"), 160, 82, 45},
277 {wxT("SKY BLUE"), 135, 206, 235},
278 {wxT("SLATE BLUE"), 106, 90, 205},
279 {wxT("SPRING GREEN"), 0, 255, 127},
280 {wxT("STEEL BLUE"), 70, 130, 180},
281 {wxT("TAN"), 210, 180, 140},
282 {wxT("THISTLE"), 216, 191, 216},
283 {wxT("TURQUOISE"), 64, 224, 208},
284 {wxT("VIOLET"), 238, 130, 238},
285 {wxT("VIOLET RED"), 208, 32, 144},
286 {wxT("WHEAT"), 245, 222, 179},
287 {wxT("WHITE"), 255, 255, 255},
288 {wxT("YELLOW"), 255, 255, 0},
289 {wxT("YELLOW GREEN"), 154, 205, 50},
294 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
296 const wxColourDesc
& cc
= wxColourTable
[n
];
297 AddColour(cc
.name
, new wxColour(cc
.r
,cc
.g
,cc
.b
));
300 m_palTable
= new long[n
];
301 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
303 const wxColourDesc
& cc
= wxColourTable
[n
];
304 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
311 * Changed by Ian Brown, July 1994.
313 * When running under X, the Colour Database starts off empty. The X server
314 * is queried for the colour first time after which it is entered into the
315 * database. This allows our client to use the server colour database which
316 * is hopefully gamma corrected for the display being used.
319 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
)
321 return FindColour(colour
, true);
324 wxColour
*wxColourDatabase::FindColourNoAdd(const wxString
& colour
) const
326 return ((wxColourDatabase
*)this)->FindColour(colour
, false);
329 void wxColourDatabase::AddColour (const wxString
& name
, wxColour
* colour
)
331 wxString colName
= name
;
333 wxString colName2
= colName
;
334 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
337 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
338 if ( it
== m_map
->end() )
339 it
= m_map
->find(colName2
);
340 if ( it
!= m_map
->end() )
346 (*m_map
)[name
] = colour
;
349 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
, bool add
)
351 // VZ: make the comparaison case insensitive and also match both grey and
353 wxString colName
= colour
;
355 wxString colName2
= colName
;
356 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
359 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
360 if ( it
== m_map
->end() )
361 it
= m_map
->find(colName2
);
362 if ( it
!= m_map
->end() )
378 // TODO for other implementations. This should really go into
379 // platform-specific directories.
391 wxColour
*col
= new wxColour( colour
);
396 return (wxColour
*) NULL
;
398 AddColour(colour
, col
);
406 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
409 Display
* display
= (Display
*) wxGetDisplay();
411 /* MATTHEW: [4] Use wxGetMainColormap */
412 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
416 unsigned char r
= (unsigned char)(xcolour
.red
);
417 unsigned char g
= (unsigned char)(xcolour
.green
);
418 unsigned char b
= (unsigned char)(xcolour
.blue
);
420 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
421 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
422 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
425 wxColour
*col
= new wxColour(r
, g
, b
);
426 AddColour(colour
, col
);
432 wxString
wxColourDatabase::FindName (const wxColour
& colour
) const
434 unsigned char red
= colour
.Red ();
435 unsigned char green
= colour
.Green ();
436 unsigned char blue
= colour
.Blue ();
438 typedef wxStringToColourHashMap::iterator iterator
;
440 for (iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
442 wxColour
*col
= it
->second
;
444 if (col
->Red () == red
&& col
->Green () == green
&& col
->Blue () == blue
)
448 return wxEmptyString
;
451 void wxInitializeStockLists()
453 wxTheColourDatabase
= new wxColourDatabase
;
454 wxTheColourDatabase
->Initialize();
456 wxTheBrushList
= new wxBrushList
;
457 wxThePenList
= new wxPenList
;
458 wxTheFontList
= new wxFontList
;
459 wxTheBitmapList
= new wxBitmapList
;
462 void wxInitializeStockObjects ()
468 // wxFontPool = new XFontPool;
471 // why under MSW fonts shouldn't have the standard system size?
474 static const int sizeFont = 10;
478 #if defined(__WXMAC__)
485 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
486 sizeFont
= fontSize
;
487 wxSWISS_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
488 #elif defined(__WXPM__)
489 static const int sizeFont
= 12;
491 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
492 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
495 #if defined(__WXPM__)
497 // Basic OS/2 has a fairly limited number of fonts and these are as good
498 // as I can do to get something that looks halfway "wx" normal
500 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
501 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
502 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
503 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
504 #elif defined(__WXMAC__)
505 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxNORMAL
);
506 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
507 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
508 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
510 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
511 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
512 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
515 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
516 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
517 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
518 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
519 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
520 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
521 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
522 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
523 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
524 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
526 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
527 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
528 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
529 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
530 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
531 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
532 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
533 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
534 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
535 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
537 wxBLACK
= new wxColour (wxT("BLACK"));
538 wxWHITE
= new wxColour (wxT("WHITE"));
539 wxRED
= new wxColour (wxT("RED"));
540 wxBLUE
= new wxColour (wxT("BLUE"));
541 wxGREEN
= new wxColour (wxT("GREEN"));
542 wxCYAN
= new wxColour (wxT("CYAN"));
543 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
545 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
546 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
547 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
550 void wxDeleteStockObjects ()
552 wxDELETE(wxNORMAL_FONT
);
553 wxDELETE(wxSMALL_FONT
);
554 wxDELETE(wxITALIC_FONT
);
555 wxDELETE(wxSWISS_FONT
);
558 wxDELETE(wxCYAN_PEN
);
559 wxDELETE(wxGREEN_PEN
);
560 wxDELETE(wxBLACK_PEN
);
561 wxDELETE(wxWHITE_PEN
);
562 wxDELETE(wxTRANSPARENT_PEN
);
563 wxDELETE(wxBLACK_DASHED_PEN
);
564 wxDELETE(wxGREY_PEN
);
565 wxDELETE(wxMEDIUM_GREY_PEN
);
566 wxDELETE(wxLIGHT_GREY_PEN
);
568 wxDELETE(wxBLUE_BRUSH
);
569 wxDELETE(wxGREEN_BRUSH
);
570 wxDELETE(wxWHITE_BRUSH
);
571 wxDELETE(wxBLACK_BRUSH
);
572 wxDELETE(wxTRANSPARENT_BRUSH
);
573 wxDELETE(wxCYAN_BRUSH
);
574 wxDELETE(wxRED_BRUSH
);
575 wxDELETE(wxGREY_BRUSH
);
576 wxDELETE(wxMEDIUM_GREY_BRUSH
);
577 wxDELETE(wxLIGHT_GREY_BRUSH
);
585 wxDELETE(wxLIGHT_GREY
);
587 wxDELETE(wxSTANDARD_CURSOR
);
588 wxDELETE(wxHOURGLASS_CURSOR
);
589 wxDELETE(wxCROSS_CURSOR
);
592 void wxDeleteStockLists()
594 wxDELETE(wxTheBrushList
);
595 wxDELETE(wxThePenList
);
596 wxDELETE(wxTheFontList
);
597 wxDELETE(wxTheBitmapList
);
600 // ============================================================================
601 // wxTheXXXList stuff (semi-obsolete)
602 // ============================================================================
604 wxBitmapList::wxBitmapList()
608 wxBitmapList::~wxBitmapList ()
610 wxList::compatibility_iterator node
= GetFirst ();
613 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
614 wxList::compatibility_iterator next
= node
->GetNext ();
615 if (bitmap
->GetVisible())
621 // Pen and Brush lists
622 wxPenList::~wxPenList ()
624 wxList::compatibility_iterator node
= GetFirst ();
627 wxPen
*pen
= (wxPen
*) node
->GetData ();
628 wxList::compatibility_iterator next
= node
->GetNext ();
629 if (pen
->GetVisible())
635 void wxPenList::AddPen (wxPen
* pen
)
640 void wxPenList::RemovePen (wxPen
* pen
)
645 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
647 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
649 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
651 each_pen
->GetVisible() &&
652 each_pen
->GetWidth () == width
&&
653 each_pen
->GetStyle () == style
&&
654 each_pen
->GetColour ().Red () == colour
.Red () &&
655 each_pen
->GetColour ().Green () == colour
.Green () &&
656 each_pen
->GetColour ().Blue () == colour
.Blue ())
660 wxPen
*pen
= new wxPen (colour
, width
, style
);
663 // don't save the invalid pens in the list
671 // we'll delete it ourselves later
672 pen
->SetVisible(TRUE
);
677 wxBrushList::~wxBrushList ()
679 wxList::compatibility_iterator node
= GetFirst ();
682 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
683 wxList::compatibility_iterator next
= node
->GetNext ();
684 if (brush
&& brush
->GetVisible())
690 void wxBrushList::AddBrush (wxBrush
* brush
)
695 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
697 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
699 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
701 each_brush
->GetVisible() &&
702 each_brush
->GetStyle () == style
&&
703 each_brush
->GetColour ().Red () == colour
.Red () &&
704 each_brush
->GetColour ().Green () == colour
.Green () &&
705 each_brush
->GetColour ().Blue () == colour
.Blue ())
709 wxBrush
*brush
= new wxBrush (colour
, style
);
713 // don't put the brushes we failed to create into the list
721 // we'll delete it ourselves later
722 brush
->SetVisible(TRUE
);
727 void wxBrushList::RemoveBrush (wxBrush
* brush
)
729 DeleteObject (brush
);
732 wxFontList::~wxFontList ()
734 wxList::compatibility_iterator node
= GetFirst ();
737 // Only delete objects that are 'visible', i.e.
738 // that have been created using FindOrCreate...,
739 // where the pointers are expected to be shared
740 // (and therefore not deleted by any one part of an app).
741 wxFont
*font
= (wxFont
*) node
->GetData ();
742 wxList::compatibility_iterator next
= node
->GetNext ();
743 if (font
->GetVisible())
749 void wxFontList::AddFont (wxFont
* font
)
754 void wxFontList::RemoveFont (wxFont
* font
)
759 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
764 const wxString
& facename
,
765 wxFontEncoding encoding
)
767 wxFont
*font
= (wxFont
*)NULL
;
768 wxList::compatibility_iterator node
;
769 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
771 font
= (wxFont
*)node
->GetData();
772 if ( font
->GetVisible() &&
774 font
->GetPointSize () == pointSize
&&
775 font
->GetStyle () == style
&&
776 font
->GetWeight () == weight
&&
777 font
->GetUnderlined () == underline
)
779 int fontFamily
= font
->GetFamily();
781 #if defined(__WXGTK__)
782 // under GTK the default family is wxSWISS, so looking for a font
783 // with wxDEFAULT family should return a wxSWISS one instead of
784 // creating a new one
785 bool same
= (fontFamily
== family
) ||
786 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
788 // VZ: but why elsewhere do we require an exact match? mystery...
789 bool same
= fontFamily
== family
;
792 // empty facename matches anything at all: this is bad because
793 // depending on which fonts are already created, we might get back
794 // a different font if we create it with empty facename, but it is
795 // still better than never matching anything in the cache at all
797 if ( same
&& !!facename
)
799 const wxString
& fontFace
= font
->GetFaceName();
801 // empty facename matches everything
802 same
= !fontFace
|| fontFace
== facename
;
805 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
807 // have to match the encoding too
808 same
= font
->GetEncoding() == encoding
;
820 // font not found, create the new one
821 font
= new wxFont(pointSize
, family
, style
, weight
,
822 underline
, facename
, encoding
);
826 // and mark it as being cacheable
827 font
->SetVisible(TRUE
);
833 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
838 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
840 DeleteObject(bitmap
);
843 wxSize
wxGetDisplaySize()
846 wxDisplaySize(& x
, & y
);
850 wxRect
wxGetClientDisplayRect()
852 int x
, y
, width
, height
;
853 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
854 return wxRect(x
, y
, width
, height
);
857 wxSize
wxGetDisplaySizeMM()
860 wxDisplaySizeMM(& x
, & y
);
864 wxResourceCache::~wxResourceCache ()
866 wxList::compatibility_iterator node
= GetFirst ();
868 wxObject
*item
= (wxObject
*)node
->GetData();
871 node
= node
->GetNext ();