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 static const struct wxColourDesc
218 {wxT("AQUAMARINE"),112, 219, 147},
219 {wxT("BLACK"),0, 0, 0},
220 {wxT("BLUE"), 0, 0, 255},
221 {wxT("BLUE VIOLET"), 159, 95, 159},
222 {wxT("BROWN"), 165, 42, 42},
223 {wxT("CADET BLUE"), 95, 159, 159},
224 {wxT("CORAL"), 255, 127, 0},
225 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
226 {wxT("CYAN"), 0, 255, 255},
227 {wxT("DARK GREY"), 47, 47, 47}, // ?
229 {wxT("DARK GREEN"), 47, 79, 47},
230 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
231 {wxT("DARK ORCHID"), 153, 50, 204},
232 {wxT("DARK SLATE BLUE"), 107, 35, 142},
233 {wxT("DARK SLATE GREY"), 47, 79, 79},
234 {wxT("DARK TURQUOISE"), 112, 147, 219},
235 {wxT("DIM GREY"), 84, 84, 84},
236 {wxT("FIREBRICK"), 142, 35, 35},
237 {wxT("FOREST GREEN"), 35, 142, 35},
238 {wxT("GOLD"), 204, 127, 50},
239 {wxT("GOLDENROD"), 219, 219, 112},
240 {wxT("GREY"), 128, 128, 128},
241 {wxT("GREEN"), 0, 255, 0},
242 {wxT("GREEN YELLOW"), 147, 219, 112},
243 {wxT("INDIAN RED"), 79, 47, 47},
244 {wxT("KHAKI"), 159, 159, 95},
245 {wxT("LIGHT BLUE"), 191, 216, 216},
246 {wxT("LIGHT GREY"), 192, 192, 192},
247 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
248 {wxT("LIME GREEN"), 50, 204, 50},
249 {wxT("LIGHT MAGENTA"), 255, 0, 255},
250 {wxT("MAGENTA"), 255, 0, 255},
251 {wxT("MAROON"), 142, 35, 107},
252 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
253 {wxT("MEDIUM GREY"), 100, 100, 100},
254 {wxT("MEDIUM BLUE"), 50, 50, 204},
255 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
256 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
257 {wxT("MEDIUM ORCHID"), 147, 112, 219},
258 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
259 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
260 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
261 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
262 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
263 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
264 {wxT("NAVY"), 35, 35, 142},
265 {wxT("ORANGE"), 204, 50, 50},
266 {wxT("ORANGE RED"), 255, 0, 127},
267 {wxT("ORCHID"), 219, 112, 219},
268 {wxT("PALE GREEN"), 143, 188, 143},
269 {wxT("PINK"), 188, 143, 234},
270 {wxT("PLUM"), 234, 173, 234},
271 {wxT("PURPLE"), 176, 0, 255},
272 {wxT("RED"), 255, 0, 0},
273 {wxT("SALMON"), 111, 66, 66},
274 {wxT("SEA GREEN"), 35, 142, 107},
275 {wxT("SIENNA"), 142, 107, 35},
276 {wxT("SKY BLUE"), 50, 153, 204},
277 {wxT("SLATE BLUE"), 0, 127, 255},
278 {wxT("SPRING GREEN"), 0, 255, 127},
279 {wxT("STEEL BLUE"), 35, 107, 142},
280 {wxT("TAN"), 219, 147, 112},
281 {wxT("THISTLE"), 216, 191, 216},
282 {wxT("TURQUOISE"), 173, 234, 234},
283 {wxT("VIOLET"), 79, 47, 79},
284 {wxT("VIOLET RED"), 204, 50, 153},
285 {wxT("WHEAT"), 216, 216, 191},
286 {wxT("WHITE"), 255, 255, 255},
287 {wxT("YELLOW"), 255, 255, 0},
288 {wxT("YELLOW GREEN"), 153, 204, 50},
289 {wxT("YELLOW GREEN"), 153, 204, 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 ();