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
& point1
, const wxPoint
& point2
)
104 width
= point2
.x
- point1
.x
;
105 height
= point2
.y
- point1
.y
;
122 wxRect::wxRect(const wxPoint
& point
, const wxSize
& size
)
124 x
= point
.x
; y
= point
.y
;
125 width
= size
.x
; height
= size
.y
;
128 bool wxRect::operator==(const wxRect
& rect
) const
130 return ((x
== rect
.x
) &&
132 (width
== rect
.width
) &&
133 (height
== rect
.height
));
136 wxRect
& wxRect::operator += (const wxRect
& rect
)
138 *this = (*this + rect
);
142 wxRect
wxRect::operator + (const wxRect
& rect
) const
144 int x1
= wxMin(this->x
, rect
.x
);
145 int y1
= wxMin(this->y
, rect
.y
);
146 int y2
= wxMax(y
+height
, rect
.height
+rect
.y
);
147 int x2
= wxMax(x
+width
, rect
.width
+rect
.x
);
148 return wxRect(x1
, y1
, x2
-x1
, y2
-y1
);
151 wxRect
& wxRect::Inflate(wxCoord dx
, wxCoord dy
)
158 // check that we didn't make the rectangle invalid by accident (you almost
159 // never want to have negative coords and never want negative size)
165 // what else can we do?
174 bool wxRect::Inside(int cx
, int cy
) const
176 return ( (cx
>= x
) && (cy
>= y
)
177 && ((cy
- y
) < height
)
178 && ((cx
- x
) < width
)
182 wxRect
& wxRect::Intersect(const wxRect
& rect
)
191 if ( x2
> rect
.GetRight() )
192 x2
= rect
.GetRight();
193 if ( y2
> rect
.GetBottom() )
194 y2
= rect
.GetBottom();
199 if ( width
<= 0 || height
<= 0 )
208 bool wxRect::Intersects(const wxRect
& rect
) const
210 wxRect r
= Intersect(rect
);
212 // if there is no intersection, both width and height are 0
216 WX_DECLARE_STRING_HASH_MAP( wxColour
*, wxStringToColourHashMap
);
218 wxColourDatabase::wxColourDatabase ()
220 m_map
= new wxStringToColourHashMap
;
223 wxColourDatabase::~wxColourDatabase ()
225 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
230 delete [] m_palTable
;
234 // Colour database stuff
235 void wxColourDatabase::Initialize ()
237 static const struct wxColourDesc
244 {wxT("AQUAMARINE"),112, 219, 147},
245 {wxT("BLACK"),0, 0, 0},
246 {wxT("BLUE"), 0, 0, 255},
247 {wxT("BLUE VIOLET"), 159, 95, 159},
248 {wxT("BROWN"), 165, 42, 42},
249 {wxT("CADET BLUE"), 95, 159, 159},
250 {wxT("CORAL"), 255, 127, 0},
251 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
252 {wxT("CYAN"), 0, 255, 255},
253 {wxT("DARK GREY"), 47, 47, 47}, // ?
255 {wxT("DARK GREEN"), 47, 79, 47},
256 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
257 {wxT("DARK ORCHID"), 153, 50, 204},
258 {wxT("DARK SLATE BLUE"), 107, 35, 142},
259 {wxT("DARK SLATE GREY"), 47, 79, 79},
260 {wxT("DARK TURQUOISE"), 112, 147, 219},
261 {wxT("DIM GREY"), 84, 84, 84},
262 {wxT("FIREBRICK"), 142, 35, 35},
263 {wxT("FOREST GREEN"), 35, 142, 35},
264 {wxT("GOLD"), 204, 127, 50},
265 {wxT("GOLDENROD"), 219, 219, 112},
266 {wxT("GREY"), 128, 128, 128},
267 {wxT("GREEN"), 0, 255, 0},
268 {wxT("GREEN YELLOW"), 147, 219, 112},
269 {wxT("INDIAN RED"), 79, 47, 47},
270 {wxT("KHAKI"), 159, 159, 95},
271 {wxT("LIGHT BLUE"), 191, 216, 216},
272 {wxT("LIGHT GREY"), 192, 192, 192},
273 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
274 {wxT("LIME GREEN"), 50, 204, 50},
275 {wxT("LIGHT MAGENTA"), 255, 0, 255},
276 {wxT("MAGENTA"), 255, 0, 255},
277 {wxT("MAROON"), 142, 35, 107},
278 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
279 {wxT("MEDIUM GREY"), 100, 100, 100},
280 {wxT("MEDIUM BLUE"), 50, 50, 204},
281 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
282 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
283 {wxT("MEDIUM ORCHID"), 147, 112, 219},
284 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
285 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
286 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
287 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
288 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
289 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
290 {wxT("NAVY"), 35, 35, 142},
291 {wxT("ORANGE"), 204, 50, 50},
292 {wxT("ORANGE RED"), 255, 0, 127},
293 {wxT("ORCHID"), 219, 112, 219},
294 {wxT("PALE GREEN"), 143, 188, 143},
295 {wxT("PINK"), 188, 143, 234},
296 {wxT("PLUM"), 234, 173, 234},
297 {wxT("PURPLE"), 176, 0, 255},
298 {wxT("RED"), 255, 0, 0},
299 {wxT("SALMON"), 111, 66, 66},
300 {wxT("SEA GREEN"), 35, 142, 107},
301 {wxT("SIENNA"), 142, 107, 35},
302 {wxT("SKY BLUE"), 50, 153, 204},
303 {wxT("SLATE BLUE"), 0, 127, 255},
304 {wxT("SPRING GREEN"), 0, 255, 127},
305 {wxT("STEEL BLUE"), 35, 107, 142},
306 {wxT("TAN"), 219, 147, 112},
307 {wxT("THISTLE"), 216, 191, 216},
308 {wxT("TURQUOISE"), 173, 234, 234},
309 {wxT("VIOLET"), 79, 47, 79},
310 {wxT("VIOLET RED"), 204, 50, 153},
311 {wxT("WHEAT"), 216, 216, 191},
312 {wxT("WHITE"), 255, 255, 255},
313 {wxT("YELLOW"), 255, 255, 0},
314 {wxT("YELLOW GREEN"), 153, 204, 50},
315 {wxT("YELLOW GREEN"), 153, 204, 50}
320 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
322 const wxColourDesc
& cc
= wxColourTable
[n
];
323 AddColour(cc
.name
, new wxColour(cc
.r
,cc
.g
,cc
.b
));
326 m_palTable
= new long[n
];
327 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
329 const wxColourDesc
& cc
= wxColourTable
[n
];
330 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
337 * Changed by Ian Brown, July 1994.
339 * When running under X, the Colour Database starts off empty. The X server
340 * is queried for the colour first time after which it is entered into the
341 * database. This allows our client to use the server colour database which
342 * is hopefully gamma corrected for the display being used.
345 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
)
347 return FindColour(colour
, true);
350 wxColour
*wxColourDatabase::FindColourNoAdd(const wxString
& colour
) const
352 return ((wxColourDatabase
*)this)->FindColour(colour
, false);
355 void wxColourDatabase::AddColour (const wxString
& name
, wxColour
* colour
)
357 wxString colName
= name
;
359 wxString colName2
= colName
;
360 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
363 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
364 if ( it
== m_map
->end() )
365 it
= m_map
->find(colName2
);
366 if ( it
!= m_map
->end() )
372 (*m_map
)[name
] = colour
;
375 wxColour
*wxColourDatabase::FindColour(const wxString
& colour
, bool add
)
377 // VZ: make the comparaison case insensitive and also match both grey and
379 wxString colName
= colour
;
381 wxString colName2
= colName
;
382 if ( !colName2
.Replace(_T("GRAY"), _T("GREY")) )
385 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
386 if ( it
== m_map
->end() )
387 it
= m_map
->find(colName2
);
388 if ( it
!= m_map
->end() )
404 // TODO for other implementations. This should really go into
405 // platform-specific directories.
417 wxColour
*col
= new wxColour( colour
);
422 return (wxColour
*) NULL
;
424 AddColour(colour
, col
);
432 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
435 Display
* display
= (Display
*) wxGetDisplay();
437 /* MATTHEW: [4] Use wxGetMainColormap */
438 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
442 unsigned char r
= (unsigned char)(xcolour
.red
);
443 unsigned char g
= (unsigned char)(xcolour
.green
);
444 unsigned char b
= (unsigned char)(xcolour
.blue
);
446 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
447 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
448 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
451 wxColour
*col
= new wxColour(r
, g
, b
);
452 AddColour(colour
, col
);
458 wxString
wxColourDatabase::FindName (const wxColour
& colour
) const
460 unsigned char red
= colour
.Red ();
461 unsigned char green
= colour
.Green ();
462 unsigned char blue
= colour
.Blue ();
464 typedef wxStringToColourHashMap::iterator iterator
;
466 for (iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
468 wxColour
*col
= it
->second
;
470 if (col
->Red () == red
&& col
->Green () == green
&& col
->Blue () == blue
)
474 return wxEmptyString
;
477 void wxInitializeStockLists()
479 wxTheColourDatabase
= new wxColourDatabase
;
480 wxTheColourDatabase
->Initialize();
482 wxTheBrushList
= new wxBrushList
;
483 wxThePenList
= new wxPenList
;
484 wxTheFontList
= new wxFontList
;
485 wxTheBitmapList
= new wxBitmapList
;
488 void wxInitializeStockObjects ()
494 // wxFontPool = new XFontPool;
497 // why under MSW fonts shouldn't have the standard system size?
500 static const int sizeFont = 10;
504 #if defined(__WXMAC__)
511 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
512 sizeFont
= fontSize
;
513 wxNORMAL_FONT
= new wxFont (fontSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
514 #elif defined(__WXPM__)
515 static const int sizeFont
= 12;
517 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
518 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
521 #if defined(__WXPM__)
523 // Basic OS/2 has a fairly limited number of fonts and these are as good
524 // as I can do to get something that looks halfway "wx" normal
526 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
527 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
528 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
529 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
530 #elif defined(__WXMAC__)
531 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
532 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
533 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
534 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
536 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
537 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
538 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
541 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
542 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
543 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
544 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
545 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
546 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
547 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
548 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
549 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
550 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
552 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
553 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
554 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
555 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
556 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
557 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
558 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
559 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
560 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
561 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
563 wxBLACK
= new wxColour (wxT("BLACK"));
564 wxWHITE
= new wxColour (wxT("WHITE"));
565 wxRED
= new wxColour (wxT("RED"));
566 wxBLUE
= new wxColour (wxT("BLUE"));
567 wxGREEN
= new wxColour (wxT("GREEN"));
568 wxCYAN
= new wxColour (wxT("CYAN"));
569 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
571 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
572 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
573 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
576 void wxDeleteStockObjects ()
578 wxDELETE(wxNORMAL_FONT
);
579 wxDELETE(wxSMALL_FONT
);
580 wxDELETE(wxITALIC_FONT
);
581 wxDELETE(wxSWISS_FONT
);
584 wxDELETE(wxCYAN_PEN
);
585 wxDELETE(wxGREEN_PEN
);
586 wxDELETE(wxBLACK_PEN
);
587 wxDELETE(wxWHITE_PEN
);
588 wxDELETE(wxTRANSPARENT_PEN
);
589 wxDELETE(wxBLACK_DASHED_PEN
);
590 wxDELETE(wxGREY_PEN
);
591 wxDELETE(wxMEDIUM_GREY_PEN
);
592 wxDELETE(wxLIGHT_GREY_PEN
);
594 wxDELETE(wxBLUE_BRUSH
);
595 wxDELETE(wxGREEN_BRUSH
);
596 wxDELETE(wxWHITE_BRUSH
);
597 wxDELETE(wxBLACK_BRUSH
);
598 wxDELETE(wxTRANSPARENT_BRUSH
);
599 wxDELETE(wxCYAN_BRUSH
);
600 wxDELETE(wxRED_BRUSH
);
601 wxDELETE(wxGREY_BRUSH
);
602 wxDELETE(wxMEDIUM_GREY_BRUSH
);
603 wxDELETE(wxLIGHT_GREY_BRUSH
);
611 wxDELETE(wxLIGHT_GREY
);
613 wxDELETE(wxSTANDARD_CURSOR
);
614 wxDELETE(wxHOURGLASS_CURSOR
);
615 wxDELETE(wxCROSS_CURSOR
);
618 void wxDeleteStockLists()
620 wxDELETE(wxTheBrushList
);
621 wxDELETE(wxThePenList
);
622 wxDELETE(wxTheFontList
);
623 wxDELETE(wxTheBitmapList
);
626 // ============================================================================
627 // wxTheXXXList stuff (semi-obsolete)
628 // ============================================================================
630 wxBitmapList::wxBitmapList()
634 wxBitmapList::~wxBitmapList ()
636 wxList::compatibility_iterator node
= GetFirst ();
639 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
640 wxList::compatibility_iterator next
= node
->GetNext ();
641 if (bitmap
->GetVisible())
647 // Pen and Brush lists
648 wxPenList::~wxPenList ()
650 wxList::compatibility_iterator node
= GetFirst ();
653 wxPen
*pen
= (wxPen
*) node
->GetData ();
654 wxList::compatibility_iterator next
= node
->GetNext ();
655 if (pen
->GetVisible())
661 void wxPenList::AddPen (wxPen
* pen
)
666 void wxPenList::RemovePen (wxPen
* pen
)
671 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
673 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
675 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
677 each_pen
->GetVisible() &&
678 each_pen
->GetWidth () == width
&&
679 each_pen
->GetStyle () == style
&&
680 each_pen
->GetColour ().Red () == colour
.Red () &&
681 each_pen
->GetColour ().Green () == colour
.Green () &&
682 each_pen
->GetColour ().Blue () == colour
.Blue ())
686 wxPen
*pen
= new wxPen (colour
, width
, style
);
689 // don't save the invalid pens in the list
697 // we'll delete it ourselves later
698 pen
->SetVisible(TRUE
);
703 wxBrushList::~wxBrushList ()
705 wxList::compatibility_iterator node
= GetFirst ();
708 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
709 wxList::compatibility_iterator next
= node
->GetNext ();
710 if (brush
&& brush
->GetVisible())
716 void wxBrushList::AddBrush (wxBrush
* brush
)
721 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
723 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
725 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
727 each_brush
->GetVisible() &&
728 each_brush
->GetStyle () == style
&&
729 each_brush
->GetColour ().Red () == colour
.Red () &&
730 each_brush
->GetColour ().Green () == colour
.Green () &&
731 each_brush
->GetColour ().Blue () == colour
.Blue ())
735 wxBrush
*brush
= new wxBrush (colour
, style
);
739 // don't put the brushes we failed to create into the list
747 // we'll delete it ourselves later
748 brush
->SetVisible(TRUE
);
753 void wxBrushList::RemoveBrush (wxBrush
* brush
)
755 DeleteObject (brush
);
758 wxFontList::~wxFontList ()
760 wxList::compatibility_iterator node
= GetFirst ();
763 // Only delete objects that are 'visible', i.e.
764 // that have been created using FindOrCreate...,
765 // where the pointers are expected to be shared
766 // (and therefore not deleted by any one part of an app).
767 wxFont
*font
= (wxFont
*) node
->GetData ();
768 wxList::compatibility_iterator next
= node
->GetNext ();
769 if (font
->GetVisible())
775 void wxFontList::AddFont (wxFont
* font
)
780 void wxFontList::RemoveFont (wxFont
* font
)
785 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
790 const wxString
& facename
,
791 wxFontEncoding encoding
)
793 wxFont
*font
= (wxFont
*)NULL
;
794 wxList::compatibility_iterator node
;
795 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
797 font
= (wxFont
*)node
->GetData();
798 if ( font
->GetVisible() &&
800 font
->GetPointSize () == pointSize
&&
801 font
->GetStyle () == style
&&
802 font
->GetWeight () == weight
&&
803 font
->GetUnderlined () == underline
)
805 int fontFamily
= font
->GetFamily();
807 #if defined(__WXGTK__)
808 // under GTK the default family is wxSWISS, so looking for a font
809 // with wxDEFAULT family should return a wxSWISS one instead of
810 // creating a new one
811 bool same
= (fontFamily
== family
) ||
812 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
814 // VZ: but why elsewhere do we require an exact match? mystery...
815 bool same
= fontFamily
== family
;
818 // empty facename matches anything at all: this is bad because
819 // depending on which fonts are already created, we might get back
820 // a different font if we create it with empty facename, but it is
821 // still better than never matching anything in the cache at all
823 if ( same
&& !!facename
)
825 const wxString
& fontFace
= font
->GetFaceName();
827 // empty facename matches everything
828 same
= !fontFace
|| fontFace
== facename
;
831 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
833 // have to match the encoding too
834 same
= font
->GetEncoding() == encoding
;
846 // font not found, create the new one
847 font
= new wxFont(pointSize
, family
, style
, weight
,
848 underline
, facename
, encoding
);
852 // and mark it as being cacheable
853 font
->SetVisible(TRUE
);
859 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
864 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
866 DeleteObject(bitmap
);
869 wxSize
wxGetDisplaySize()
872 wxDisplaySize(& x
, & y
);
876 wxRect
wxGetClientDisplayRect()
878 int x
, y
, width
, height
;
879 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
880 return wxRect(x
, y
, width
, height
);
883 wxSize
wxGetDisplaySizeMM()
886 wxDisplaySizeMM(& x
, & y
);
890 wxResourceCache::~wxResourceCache ()
892 wxList::compatibility_iterator node
= GetFirst ();
894 wxObject
*item
= (wxObject
*)node
->GetData();
897 node
= node
->GetNext ();