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 // ============================================================================
218 // ============================================================================
220 WX_DECLARE_STRING_HASH_MAP( wxColour
*, wxStringToColourHashMap
);
222 // ----------------------------------------------------------------------------
223 // wxColourDatabase ctor/dtor
224 // ----------------------------------------------------------------------------
226 wxColourDatabase
::wxColourDatabase ()
228 // will be created on demand in Initialize()
232 wxColourDatabase
::~wxColourDatabase ()
236 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
242 delete [] m_palTable
;
246 // Colour database stuff
247 void wxColourDatabase
::Initialize()
251 // already initialized
255 m_map
= new wxStringToColourHashMap
;
257 static const struct wxColourDesc
264 {wxT("AQUAMARINE"),112, 219, 147},
265 {wxT("BLACK"),0, 0, 0},
266 {wxT("BLUE"), 0, 0, 255},
267 {wxT("BLUE VIOLET"), 159, 95, 159},
268 {wxT("BROWN"), 165, 42, 42},
269 {wxT("CADET BLUE"), 95, 159, 159},
270 {wxT("CORAL"), 255, 127, 0},
271 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
272 {wxT("CYAN"), 0, 255, 255},
273 {wxT("DARK GREY"), 47, 47, 47}, // ?
275 {wxT("DARK GREEN"), 47, 79, 47},
276 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
277 {wxT("DARK ORCHID"), 153, 50, 204},
278 {wxT("DARK SLATE BLUE"), 107, 35, 142},
279 {wxT("DARK SLATE GREY"), 47, 79, 79},
280 {wxT("DARK TURQUOISE"), 112, 147, 219},
281 {wxT("DIM GREY"), 84, 84, 84},
282 {wxT("FIREBRICK"), 142, 35, 35},
283 {wxT("FOREST GREEN"), 35, 142, 35},
284 {wxT("GOLD"), 204, 127, 50},
285 {wxT("GOLDENROD"), 219, 219, 112},
286 {wxT("GREY"), 128, 128, 128},
287 {wxT("GREEN"), 0, 255, 0},
288 {wxT("GREEN YELLOW"), 147, 219, 112},
289 {wxT("INDIAN RED"), 79, 47, 47},
290 {wxT("KHAKI"), 159, 159, 95},
291 {wxT("LIGHT BLUE"), 191, 216, 216},
292 {wxT("LIGHT GREY"), 192, 192, 192},
293 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
294 {wxT("LIME GREEN"), 50, 204, 50},
295 {wxT("LIGHT MAGENTA"), 255, 0, 255},
296 {wxT("MAGENTA"), 255, 0, 255},
297 {wxT("MAROON"), 142, 35, 107},
298 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
299 {wxT("MEDIUM GREY"), 100, 100, 100},
300 {wxT("MEDIUM BLUE"), 50, 50, 204},
301 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
302 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
303 {wxT("MEDIUM ORCHID"), 147, 112, 219},
304 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
305 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
306 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
307 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
308 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
309 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
310 {wxT("NAVY"), 35, 35, 142},
311 {wxT("ORANGE"), 204, 50, 50},
312 {wxT("ORANGE RED"), 255, 0, 127},
313 {wxT("ORCHID"), 219, 112, 219},
314 {wxT("PALE GREEN"), 143, 188, 143},
315 {wxT("PINK"), 188, 143, 234},
316 {wxT("PLUM"), 234, 173, 234},
317 {wxT("PURPLE"), 176, 0, 255},
318 {wxT("RED"), 255, 0, 0},
319 {wxT("SALMON"), 111, 66, 66},
320 {wxT("SEA GREEN"), 35, 142, 107},
321 {wxT("SIENNA"), 142, 107, 35},
322 {wxT("SKY BLUE"), 50, 153, 204},
323 {wxT("SLATE BLUE"), 0, 127, 255},
324 {wxT("SPRING GREEN"), 0, 255, 127},
325 {wxT("STEEL BLUE"), 35, 107, 142},
326 {wxT("TAN"), 219, 147, 112},
327 {wxT("THISTLE"), 216, 191, 216},
328 {wxT("TURQUOISE"), 173, 234, 234},
329 {wxT("VIOLET"), 79, 47, 79},
330 {wxT("VIOLET RED"), 204, 50, 153},
331 {wxT("WHEAT"), 216, 216, 191},
332 {wxT("WHITE"), 255, 255, 255},
333 {wxT("YELLOW"), 255, 255, 0},
334 {wxT("YELLOW GREEN"), 153, 204, 50},
335 {wxT("YELLOW GREEN"), 153, 204, 50}
340 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
342 const wxColourDesc
& cc
= wxColourTable
[n
];
343 (*m_map
)[cc
.name
] = new wxColour(cc
.r
, cc
.g
, cc
.b
);
347 m_palTable
= new long[n
];
348 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
350 const wxColourDesc
& cc
= wxColourTable
[n
];
351 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
357 // ----------------------------------------------------------------------------
358 // wxColourDatabase operations
359 // ----------------------------------------------------------------------------
361 void wxColourDatabase
::AddColour(const wxString
& name
, const wxColour
& colour
)
365 // canonicalize the colour names before using them as keys: they should be
367 wxString colName
= name
;
370 // ... and we also allow both grey/gray
371 wxString colNameAlt
= colName
;
372 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
374 // but in this case it is not necessary so avoid extra search below
378 wxStringToColourHashMap
::iterator it
= m_map
->find(colName
);
379 if ( it
== m_map
->end() && !colNameAlt
.empty() )
380 it
= m_map
->find(colNameAlt
);
381 if ( it
!= m_map
->end() )
383 *(it
->second
) = colour
;
387 (*m_map
)[name
] = new wxColour(colour
);
391 wxColour wxColourDatabase
::Find(const wxString
& colour
) const
393 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
396 // first look among the existing colours
398 // make the comparaison case insensitive and also match both grey and gray
399 wxString colName
= colour
;
401 wxString colNameAlt
= colName
;
402 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
405 wxStringToColourHashMap
::iterator it
= m_map
->find(colName
);
406 if ( it
== m_map
->end() && !colNameAlt
.empty() )
407 it
= m_map
->find(colNameAlt
);
408 if ( it
!= m_map
->end() )
409 return *(it
->second
);
411 // if we didn't find it,query the system, maybe it knows about it
413 // TODO: move this into platform-specific files
415 wxColour
col( colour
);
420 self
->AddColour(colour
, col
);
428 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
431 Display
* display
= (Display
*) wxGetDisplay();
433 /* MATTHEW: [4] Use wxGetMainColormap */
434 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
438 unsigned char r
= (unsigned char)(xcolour
.red
);
439 unsigned char g
= (unsigned char)(xcolour
.green
);
440 unsigned char b
= (unsigned char)(xcolour
.blue
);
442 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
443 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
444 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
447 wxColour
col(r
, g
, b
);
448 AddColour(colour
, col
);
451 #else // other platform
456 wxString wxColourDatabase
::FindName(const wxColour
& colour
) const
458 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
461 typedef wxStringToColourHashMap
::iterator iterator
;
463 for ( iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
465 if ( *(it
->second
) == colour
)
469 return wxEmptyString
;
472 // ----------------------------------------------------------------------------
473 // deprecated wxColourDatabase methods
474 // ----------------------------------------------------------------------------
476 wxColour
*wxColourDatabase
::FindColour(const wxString
& name
)
478 wxColour col
= Find(name
);
482 return new wxColour(col
);
485 void wxColourDatabase
::AddColour(const wxString
& name
, wxColour
*colour
)
487 wxCHECK_RET( colour
, _T("NULL pointer in wxColourDatabase::AddColour") );
489 AddColour(name
, wxColour(*colour
));
492 // ============================================================================
494 // ============================================================================
496 void wxInitializeStockLists()
498 wxTheColourDatabase
= new wxColourDatabase
;
500 wxTheBrushList
= new wxBrushList
;
501 wxThePenList
= new wxPenList
;
502 wxTheFontList
= new wxFontList
;
503 wxTheBitmapList
= new wxBitmapList
;
506 void wxInitializeStockObjects ()
512 // wxFontPool = new XFontPool;
515 // why under MSW fonts shouldn't have the standard system size?
518 static const int sizeFont = 10;
522 #if defined(__WXMAC__)
529 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
530 sizeFont
= fontSize
;
531 wxNORMAL_FONT
= new wxFont (fontSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
532 #elif defined(__WXPM__)
533 static const int sizeFont
= 12;
535 wxNORMAL_FONT
= new wxFont(wxSystemSettings
::GetFont(wxSYS_DEFAULT_GUI_FONT
));
536 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
539 #if defined(__WXPM__)
541 // Basic OS/2 has a fairly limited number of fonts and these are as good
542 // as I can do to get something that looks halfway "wx" normal
544 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
545 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
546 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
547 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
548 #elif defined(__WXMAC__)
549 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
550 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
551 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
552 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
554 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
555 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
556 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
559 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
560 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
561 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
562 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
563 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
564 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
565 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
566 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
567 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
568 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
570 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
571 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
572 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
573 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
574 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
575 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
576 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
577 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
578 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
579 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
581 wxBLACK
= new wxColour (wxT("BLACK"));
582 wxWHITE
= new wxColour (wxT("WHITE"));
583 wxRED
= new wxColour (wxT("RED"));
584 wxBLUE
= new wxColour (wxT("BLUE"));
585 wxGREEN
= new wxColour (wxT("GREEN"));
586 wxCYAN
= new wxColour (wxT("CYAN"));
587 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
589 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
590 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
591 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
594 void wxDeleteStockObjects ()
596 wxDELETE(wxNORMAL_FONT
);
597 wxDELETE(wxSMALL_FONT
);
598 wxDELETE(wxITALIC_FONT
);
599 wxDELETE(wxSWISS_FONT
);
602 wxDELETE(wxCYAN_PEN
);
603 wxDELETE(wxGREEN_PEN
);
604 wxDELETE(wxBLACK_PEN
);
605 wxDELETE(wxWHITE_PEN
);
606 wxDELETE(wxTRANSPARENT_PEN
);
607 wxDELETE(wxBLACK_DASHED_PEN
);
608 wxDELETE(wxGREY_PEN
);
609 wxDELETE(wxMEDIUM_GREY_PEN
);
610 wxDELETE(wxLIGHT_GREY_PEN
);
612 wxDELETE(wxBLUE_BRUSH
);
613 wxDELETE(wxGREEN_BRUSH
);
614 wxDELETE(wxWHITE_BRUSH
);
615 wxDELETE(wxBLACK_BRUSH
);
616 wxDELETE(wxTRANSPARENT_BRUSH
);
617 wxDELETE(wxCYAN_BRUSH
);
618 wxDELETE(wxRED_BRUSH
);
619 wxDELETE(wxGREY_BRUSH
);
620 wxDELETE(wxMEDIUM_GREY_BRUSH
);
621 wxDELETE(wxLIGHT_GREY_BRUSH
);
629 wxDELETE(wxLIGHT_GREY
);
631 wxDELETE(wxSTANDARD_CURSOR
);
632 wxDELETE(wxHOURGLASS_CURSOR
);
633 wxDELETE(wxCROSS_CURSOR
);
636 void wxDeleteStockLists()
638 wxDELETE(wxTheBrushList
);
639 wxDELETE(wxThePenList
);
640 wxDELETE(wxTheFontList
);
641 wxDELETE(wxTheBitmapList
);
644 // ============================================================================
645 // wxTheXXXList stuff (semi-obsolete)
646 // ============================================================================
648 wxBitmapList
::wxBitmapList()
652 wxBitmapList
::~wxBitmapList ()
654 wxList
::compatibility_iterator node
= GetFirst ();
657 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
658 wxList
::compatibility_iterator next
= node
->GetNext ();
659 if (bitmap
->GetVisible())
665 // Pen and Brush lists
666 wxPenList
::~wxPenList ()
668 wxList
::compatibility_iterator node
= GetFirst ();
671 wxPen
*pen
= (wxPen
*) node
->GetData ();
672 wxList
::compatibility_iterator next
= node
->GetNext ();
673 if (pen
->GetVisible())
679 void wxPenList
::AddPen (wxPen
* pen
)
684 void wxPenList
::RemovePen (wxPen
* pen
)
689 wxPen
*wxPenList
::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
691 for (wxList
::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
693 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
695 each_pen
->GetVisible() &&
696 each_pen
->GetWidth () == width
&&
697 each_pen
->GetStyle () == style
&&
698 each_pen
->GetColour ().Red () == colour
.Red () &&
699 each_pen
->GetColour ().Green () == colour
.Green () &&
700 each_pen
->GetColour ().Blue () == colour
.Blue ())
704 wxPen
*pen
= new wxPen (colour
, width
, style
);
707 // don't save the invalid pens in the list
715 // we'll delete it ourselves later
716 pen
->SetVisible(TRUE
);
721 wxBrushList
::~wxBrushList ()
723 wxList
::compatibility_iterator node
= GetFirst ();
726 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
727 wxList
::compatibility_iterator next
= node
->GetNext ();
728 if (brush
&& brush
->GetVisible())
734 void wxBrushList
::AddBrush (wxBrush
* brush
)
739 wxBrush
*wxBrushList
::FindOrCreateBrush (const wxColour
& colour
, int style
)
741 for (wxList
::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
743 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
745 each_brush
->GetVisible() &&
746 each_brush
->GetStyle () == style
&&
747 each_brush
->GetColour ().Red () == colour
.Red () &&
748 each_brush
->GetColour ().Green () == colour
.Green () &&
749 each_brush
->GetColour ().Blue () == colour
.Blue ())
753 wxBrush
*brush
= new wxBrush (colour
, style
);
757 // don't put the brushes we failed to create into the list
765 // we'll delete it ourselves later
766 brush
->SetVisible(TRUE
);
771 void wxBrushList
::RemoveBrush (wxBrush
* brush
)
773 DeleteObject (brush
);
776 wxFontList
::~wxFontList ()
778 wxList
::compatibility_iterator node
= GetFirst ();
781 // Only delete objects that are 'visible', i.e.
782 // that have been created using FindOrCreate...,
783 // where the pointers are expected to be shared
784 // (and therefore not deleted by any one part of an app).
785 wxFont
*font
= (wxFont
*) node
->GetData ();
786 wxList
::compatibility_iterator next
= node
->GetNext ();
787 if (font
->GetVisible())
793 void wxFontList
::AddFont (wxFont
* font
)
798 void wxFontList
::RemoveFont (wxFont
* font
)
803 wxFont
*wxFontList
::FindOrCreateFont(int pointSize
,
808 const wxString
& facename
,
809 wxFontEncoding encoding
)
811 wxFont
*font
= (wxFont
*)NULL
;
812 wxList
::compatibility_iterator node
;
813 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
815 font
= (wxFont
*)node
->GetData();
816 if ( font
->GetVisible() &&
818 font
->GetPointSize () == pointSize
&&
819 font
->GetStyle () == style
&&
820 font
->GetWeight () == weight
&&
821 font
->GetUnderlined () == underline
)
823 int fontFamily
= font
->GetFamily();
825 #if defined(__WXGTK__)
826 // under GTK the default family is wxSWISS, so looking for a font
827 // with wxDEFAULT family should return a wxSWISS one instead of
828 // creating a new one
829 bool same
= (fontFamily
== family
) ||
830 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
832 // VZ: but why elsewhere do we require an exact match? mystery...
833 bool same
= fontFamily
== family
;
836 // empty facename matches anything at all: this is bad because
837 // depending on which fonts are already created, we might get back
838 // a different font if we create it with empty facename, but it is
839 // still better than never matching anything in the cache at all
841 if ( same
&& !!facename
)
843 const wxString
& fontFace
= font
->GetFaceName();
845 // empty facename matches everything
846 same
= !fontFace
|| fontFace
== facename
;
849 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
851 // have to match the encoding too
852 same
= font
->GetEncoding() == encoding
;
864 // font not found, create the new one
865 font
= new wxFont(pointSize
, family
, style
, weight
,
866 underline
, facename
, encoding
);
870 // and mark it as being cacheable
871 font
->SetVisible(TRUE
);
877 void wxBitmapList
::AddBitmap(wxBitmap
*bitmap
)
882 void wxBitmapList
::RemoveBitmap(wxBitmap
*bitmap
)
884 DeleteObject(bitmap
);
887 wxSize
wxGetDisplaySize()
890 wxDisplaySize(& x
, & y
);
894 wxRect
wxGetClientDisplayRect()
896 int x
, y
, width
, height
;
897 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
898 return wxRect(x
, y
, width
, height
);
901 wxSize
wxGetDisplaySizeMM()
904 wxDisplaySizeMM(& x
, & y
);
908 wxResourceCache
::~wxResourceCache ()
910 wxList
::compatibility_iterator node
= GetFirst ();
912 wxObject
*item
= (wxObject
*)node
->GetData();
915 node
= node
->GetNext ();