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}
339 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
341 const wxColourDesc
& cc
= wxColourTable
[n
];
342 (*m_map
)[cc
.name
] = new wxColour(cc
.r
, cc
.g
, cc
.b
);
346 m_palTable
= new long[n
];
347 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
349 const wxColourDesc
& cc
= wxColourTable
[n
];
350 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
356 // ----------------------------------------------------------------------------
357 // wxColourDatabase operations
358 // ----------------------------------------------------------------------------
360 void wxColourDatabase::AddColour(const wxString
& name
, const wxColour
& colour
)
364 // canonicalize the colour names before using them as keys: they should be
366 wxString colName
= name
;
369 // ... and we also allow both grey/gray
370 wxString colNameAlt
= colName
;
371 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
373 // but in this case it is not necessary so avoid extra search below
377 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
378 if ( it
== m_map
->end() && !colNameAlt
.empty() )
379 it
= m_map
->find(colNameAlt
);
380 if ( it
!= m_map
->end() )
382 *(it
->second
) = colour
;
386 (*m_map
)[name
] = new wxColour(colour
);
390 wxColour
wxColourDatabase::Find(const wxString
& colour
) const
392 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
395 // first look among the existing colours
397 // make the comparaison case insensitive and also match both grey and gray
398 wxString colName
= colour
;
400 wxString colNameAlt
= colName
;
401 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
404 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
405 if ( it
== m_map
->end() && !colNameAlt
.empty() )
406 it
= m_map
->find(colNameAlt
);
407 if ( it
!= m_map
->end() )
408 return *(it
->second
);
410 // if we didn't find it, query the system, maybe it knows about it
411 #if defined(__WXGTK__) || defined(__X__)
412 wxColour col
= wxColour::CreateByName(colour
);
417 self
->AddColour(colour
, col
);
422 // TODO: move this to wxColour::CreateByName()
426 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
429 Display
* display
= (Display
*) wxGetDisplay();
431 /* MATTHEW: [4] Use wxGetMainColormap */
432 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
436 unsigned char r
= (unsigned char)(xcolour
.red
);
437 unsigned char g
= (unsigned char)(xcolour
.green
);
438 unsigned char b
= (unsigned char)(xcolour
.blue
);
440 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
441 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
442 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
445 wxColour
col(r
, g
, b
);
446 AddColour(colour
, col
);
449 #else // other platform
454 wxString
wxColourDatabase::FindName(const wxColour
& colour
) const
456 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
459 typedef wxStringToColourHashMap::iterator iterator
;
461 for ( iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
463 if ( *(it
->second
) == colour
)
467 return wxEmptyString
;
470 // ----------------------------------------------------------------------------
471 // deprecated wxColourDatabase methods
472 // ----------------------------------------------------------------------------
474 wxColour
*wxColourDatabase::FindColour(const wxString
& name
)
476 // This function is deprecated, use Find() instead.
477 // Formerly this function sometimes would return a deletable pointer and
478 // sometimes a non-deletable one (when returning a colour from the database).
479 // Trying to delete the latter anyway results in problems, so probably
480 // nobody ever freed the pointers. Currently it always returns a new
481 // instance, which means there will be memory leaks.
482 wxLogDebug(wxT("wxColourDataBase::FindColour():")
483 wxT(" Please use wxColourDataBase::Find() instead"));
485 // using a static variable here is not the most elegant solution but unless
486 // we want to make wxStringToColourHashMap public (i.e. move it to the
487 // header) so that we could have a member function returning
488 // wxStringToColourHashMap::iterator, there is really no good way to do it
491 // and knowing that this function is going to disappear in the next release
492 // anyhow I don't want to waste time on this
494 static wxColour s_col
;
500 return new wxColour(s_col
);
503 // ============================================================================
505 // ============================================================================
507 void wxInitializeStockLists()
509 wxTheColourDatabase
= new wxColourDatabase
;
511 wxTheBrushList
= new wxBrushList
;
512 wxThePenList
= new wxPenList
;
513 wxTheFontList
= new wxFontList
;
514 wxTheBitmapList
= new wxBitmapList
;
517 void wxInitializeStockObjects ()
523 // wxFontPool = new XFontPool;
526 // why under MSW fonts shouldn't have the standard system size?
529 static const int sizeFont = 10;
533 #if defined(__WXMAC__)
534 // retrieve size of system font for all stock fonts
541 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
542 sizeFont
= fontSize
;
543 #if __WXMAC_CLASSIC__
544 wxNORMAL_FONT
= new wxFont (fontSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
546 wxNORMAL_FONT
= new wxFont () ;
547 wxNORMAL_FONT
->MacCreateThemeFont( kThemeSystemFont
);
549 #elif defined(__WXPM__)
550 static const int sizeFont
= 12;
552 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
553 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
556 #if defined(__WXPM__)
558 // Basic OS/2 has a fairly limited number of fonts and these are as good
559 // as I can do to get something that looks halfway "wx" normal
561 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
562 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
563 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
564 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
565 #elif defined(__WXMAC__)
566 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
567 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
568 #if __WXMAC_CLASSIC__
569 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
570 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
572 wxSMALL_FONT
= new wxFont () ;
573 wxSMALL_FONT
->MacCreateThemeFont( kThemeSmallSystemFont
);
576 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
577 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
578 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
581 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
582 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
583 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
584 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
585 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
586 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
587 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
588 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
589 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
590 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
592 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
593 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
594 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
595 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
596 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
597 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
598 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
599 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
600 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
601 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
603 wxBLACK
= new wxColour (wxT("BLACK"));
604 wxWHITE
= new wxColour (wxT("WHITE"));
605 wxRED
= new wxColour (wxT("RED"));
606 wxBLUE
= new wxColour (wxT("BLUE"));
607 wxGREEN
= new wxColour (wxT("GREEN"));
608 wxCYAN
= new wxColour (wxT("CYAN"));
609 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
611 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
612 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
613 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
616 void wxDeleteStockObjects ()
618 wxDELETE(wxNORMAL_FONT
);
619 wxDELETE(wxSMALL_FONT
);
620 wxDELETE(wxITALIC_FONT
);
621 wxDELETE(wxSWISS_FONT
);
624 wxDELETE(wxCYAN_PEN
);
625 wxDELETE(wxGREEN_PEN
);
626 wxDELETE(wxBLACK_PEN
);
627 wxDELETE(wxWHITE_PEN
);
628 wxDELETE(wxTRANSPARENT_PEN
);
629 wxDELETE(wxBLACK_DASHED_PEN
);
630 wxDELETE(wxGREY_PEN
);
631 wxDELETE(wxMEDIUM_GREY_PEN
);
632 wxDELETE(wxLIGHT_GREY_PEN
);
634 wxDELETE(wxBLUE_BRUSH
);
635 wxDELETE(wxGREEN_BRUSH
);
636 wxDELETE(wxWHITE_BRUSH
);
637 wxDELETE(wxBLACK_BRUSH
);
638 wxDELETE(wxTRANSPARENT_BRUSH
);
639 wxDELETE(wxCYAN_BRUSH
);
640 wxDELETE(wxRED_BRUSH
);
641 wxDELETE(wxGREY_BRUSH
);
642 wxDELETE(wxMEDIUM_GREY_BRUSH
);
643 wxDELETE(wxLIGHT_GREY_BRUSH
);
651 wxDELETE(wxLIGHT_GREY
);
653 wxDELETE(wxSTANDARD_CURSOR
);
654 wxDELETE(wxHOURGLASS_CURSOR
);
655 wxDELETE(wxCROSS_CURSOR
);
658 void wxDeleteStockLists()
660 wxDELETE(wxTheBrushList
);
661 wxDELETE(wxThePenList
);
662 wxDELETE(wxTheFontList
);
663 wxDELETE(wxTheBitmapList
);
666 // ============================================================================
667 // wxTheXXXList stuff (semi-obsolete)
668 // ============================================================================
670 wxBitmapList::wxBitmapList()
674 wxBitmapList::~wxBitmapList ()
676 wxList::compatibility_iterator node
= GetFirst ();
679 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
680 wxList::compatibility_iterator next
= node
->GetNext ();
681 if (bitmap
->GetVisible())
687 // Pen and Brush lists
688 wxPenList::~wxPenList ()
690 wxList::compatibility_iterator node
= GetFirst ();
693 wxPen
*pen
= (wxPen
*) node
->GetData ();
694 wxList::compatibility_iterator next
= node
->GetNext ();
695 if (pen
->GetVisible())
701 void wxPenList::AddPen (wxPen
* pen
)
706 void wxPenList::RemovePen (wxPen
* pen
)
711 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
713 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
715 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
717 each_pen
->GetVisible() &&
718 each_pen
->GetWidth () == width
&&
719 each_pen
->GetStyle () == style
&&
720 each_pen
->GetColour ().Red () == colour
.Red () &&
721 each_pen
->GetColour ().Green () == colour
.Green () &&
722 each_pen
->GetColour ().Blue () == colour
.Blue ())
726 wxPen
*pen
= new wxPen (colour
, width
, style
);
729 // don't save the invalid pens in the list
737 // we'll delete it ourselves later
738 pen
->SetVisible(TRUE
);
743 wxBrushList::~wxBrushList ()
745 wxList::compatibility_iterator node
= GetFirst ();
748 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
749 wxList::compatibility_iterator next
= node
->GetNext ();
750 if (brush
&& brush
->GetVisible())
756 void wxBrushList::AddBrush (wxBrush
* brush
)
761 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
763 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
765 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
767 each_brush
->GetVisible() &&
768 each_brush
->GetStyle () == style
&&
769 each_brush
->GetColour ().Red () == colour
.Red () &&
770 each_brush
->GetColour ().Green () == colour
.Green () &&
771 each_brush
->GetColour ().Blue () == colour
.Blue ())
775 wxBrush
*brush
= new wxBrush (colour
, style
);
779 // don't put the brushes we failed to create into the list
787 // we'll delete it ourselves later
788 brush
->SetVisible(TRUE
);
793 void wxBrushList::RemoveBrush (wxBrush
* brush
)
795 DeleteObject (brush
);
798 wxFontList::~wxFontList ()
800 wxList::compatibility_iterator node
= GetFirst ();
803 // Only delete objects that are 'visible', i.e.
804 // that have been created using FindOrCreate...,
805 // where the pointers are expected to be shared
806 // (and therefore not deleted by any one part of an app).
807 wxFont
*font
= (wxFont
*) node
->GetData ();
808 wxList::compatibility_iterator next
= node
->GetNext ();
809 if (font
->GetVisible())
815 void wxFontList::AddFont (wxFont
* font
)
820 void wxFontList::RemoveFont (wxFont
* font
)
825 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
830 const wxString
& facename
,
831 wxFontEncoding encoding
)
833 wxFont
*font
= (wxFont
*)NULL
;
834 wxList::compatibility_iterator node
;
835 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
837 font
= (wxFont
*)node
->GetData();
838 if ( font
->GetVisible() &&
840 font
->GetPointSize () == pointSize
&&
841 font
->GetStyle () == style
&&
842 font
->GetWeight () == weight
&&
843 font
->GetUnderlined () == underline
)
845 int fontFamily
= font
->GetFamily();
847 #if defined(__WXGTK__)
848 // under GTK the default family is wxSWISS, so looking for a font
849 // with wxDEFAULT family should return a wxSWISS one instead of
850 // creating a new one
851 bool same
= (fontFamily
== family
) ||
852 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
854 // VZ: but why elsewhere do we require an exact match? mystery...
855 bool same
= fontFamily
== family
;
858 // empty facename matches anything at all: this is bad because
859 // depending on which fonts are already created, we might get back
860 // a different font if we create it with empty facename, but it is
861 // still better than never matching anything in the cache at all
863 if ( same
&& !!facename
)
865 const wxString
& fontFace
= font
->GetFaceName();
867 // empty facename matches everything
868 same
= !fontFace
|| fontFace
== facename
;
871 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
873 // have to match the encoding too
874 same
= font
->GetEncoding() == encoding
;
886 // font not found, create the new one
887 font
= new wxFont(pointSize
, family
, style
, weight
,
888 underline
, facename
, encoding
);
892 // and mark it as being cacheable
893 font
->SetVisible(TRUE
);
899 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
904 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
906 DeleteObject(bitmap
);
909 wxSize
wxGetDisplaySize()
912 wxDisplaySize(& x
, & y
);
916 wxRect
wxGetClientDisplayRect()
918 int x
, y
, width
, height
;
919 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
920 return wxRect(x
, y
, width
, height
);
923 wxSize
wxGetDisplaySizeMM()
926 wxDisplaySizeMM(& x
, & y
);
930 wxResourceCache::~wxResourceCache ()
932 wxList::compatibility_iterator node
= GetFirst ();
934 wxObject
*item
= (wxObject
*)node
->GetData();
937 node
= node
->GetNext ();