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 // ----------------------------------------------------------------------------
221 // wxColourDatabase ctor/dtor
222 // ----------------------------------------------------------------------------
224 wxColourDatabase::wxColourDatabase ()
226 // will be created on demand in Initialize()
230 wxColourDatabase::~wxColourDatabase ()
234 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
240 delete [] m_palTable
;
244 // Colour database stuff
245 void wxColourDatabase::Initialize()
249 // already initialized
253 m_map
= new wxStringToColourHashMap
;
255 static const struct wxColourDesc
262 {wxT("AQUAMARINE"),112, 219, 147},
263 {wxT("BLACK"),0, 0, 0},
264 {wxT("BLUE"), 0, 0, 255},
265 {wxT("BLUE VIOLET"), 159, 95, 159},
266 {wxT("BROWN"), 165, 42, 42},
267 {wxT("CADET BLUE"), 95, 159, 159},
268 {wxT("CORAL"), 255, 127, 0},
269 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
270 {wxT("CYAN"), 0, 255, 255},
271 {wxT("DARK GREY"), 47, 47, 47}, // ?
273 {wxT("DARK GREEN"), 47, 79, 47},
274 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
275 {wxT("DARK ORCHID"), 153, 50, 204},
276 {wxT("DARK SLATE BLUE"), 107, 35, 142},
277 {wxT("DARK SLATE GREY"), 47, 79, 79},
278 {wxT("DARK TURQUOISE"), 112, 147, 219},
279 {wxT("DIM GREY"), 84, 84, 84},
280 {wxT("FIREBRICK"), 142, 35, 35},
281 {wxT("FOREST GREEN"), 35, 142, 35},
282 {wxT("GOLD"), 204, 127, 50},
283 {wxT("GOLDENROD"), 219, 219, 112},
284 {wxT("GREY"), 128, 128, 128},
285 {wxT("GREEN"), 0, 255, 0},
286 {wxT("GREEN YELLOW"), 147, 219, 112},
287 {wxT("INDIAN RED"), 79, 47, 47},
288 {wxT("KHAKI"), 159, 159, 95},
289 {wxT("LIGHT BLUE"), 191, 216, 216},
290 {wxT("LIGHT GREY"), 192, 192, 192},
291 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
292 {wxT("LIME GREEN"), 50, 204, 50},
293 {wxT("LIGHT MAGENTA"), 255, 0, 255},
294 {wxT("MAGENTA"), 255, 0, 255},
295 {wxT("MAROON"), 142, 35, 107},
296 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
297 {wxT("MEDIUM GREY"), 100, 100, 100},
298 {wxT("MEDIUM BLUE"), 50, 50, 204},
299 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
300 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
301 {wxT("MEDIUM ORCHID"), 147, 112, 219},
302 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
303 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
304 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
305 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
306 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
307 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
308 {wxT("NAVY"), 35, 35, 142},
309 {wxT("ORANGE"), 204, 50, 50},
310 {wxT("ORANGE RED"), 255, 0, 127},
311 {wxT("ORCHID"), 219, 112, 219},
312 {wxT("PALE GREEN"), 143, 188, 143},
313 {wxT("PINK"), 188, 143, 234},
314 {wxT("PLUM"), 234, 173, 234},
315 {wxT("PURPLE"), 176, 0, 255},
316 {wxT("RED"), 255, 0, 0},
317 {wxT("SALMON"), 111, 66, 66},
318 {wxT("SEA GREEN"), 35, 142, 107},
319 {wxT("SIENNA"), 142, 107, 35},
320 {wxT("SKY BLUE"), 50, 153, 204},
321 {wxT("SLATE BLUE"), 0, 127, 255},
322 {wxT("SPRING GREEN"), 0, 255, 127},
323 {wxT("STEEL BLUE"), 35, 107, 142},
324 {wxT("TAN"), 219, 147, 112},
325 {wxT("THISTLE"), 216, 191, 216},
326 {wxT("TURQUOISE"), 173, 234, 234},
327 {wxT("VIOLET"), 79, 47, 79},
328 {wxT("VIOLET RED"), 204, 50, 153},
329 {wxT("WHEAT"), 216, 216, 191},
330 {wxT("WHITE"), 255, 255, 255},
331 {wxT("YELLOW"), 255, 255, 0},
332 {wxT("YELLOW GREEN"), 153, 204, 50}
337 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
339 const wxColourDesc
& cc
= wxColourTable
[n
];
340 (*m_map
)[cc
.name
] = new wxColour(cc
.r
, cc
.g
, cc
.b
);
344 m_palTable
= new long[n
];
345 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
347 const wxColourDesc
& cc
= wxColourTable
[n
];
348 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
354 // ----------------------------------------------------------------------------
355 // wxColourDatabase operations
356 // ----------------------------------------------------------------------------
358 void wxColourDatabase::AddColour(const wxString
& name
, const wxColour
& colour
)
362 // canonicalize the colour names before using them as keys: they should be
364 wxString colName
= name
;
367 // ... and we also allow both grey/gray
368 wxString colNameAlt
= colName
;
369 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
371 // but in this case it is not necessary so avoid extra search below
375 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
376 if ( it
== m_map
->end() && !colNameAlt
.empty() )
377 it
= m_map
->find(colNameAlt
);
378 if ( it
!= m_map
->end() )
380 *(it
->second
) = colour
;
384 (*m_map
)[name
] = new wxColour(colour
);
388 wxColour
wxColourDatabase::Find(const wxString
& colour
) const
390 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
393 // first look among the existing colours
395 // make the comparaison case insensitive and also match both grey and gray
396 wxString colName
= colour
;
398 wxString colNameAlt
= colName
;
399 if ( !colNameAlt
.Replace(_T("GRAY"), _T("GREY")) )
402 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
403 if ( it
== m_map
->end() && !colNameAlt
.empty() )
404 it
= m_map
->find(colNameAlt
);
405 if ( it
!= m_map
->end() )
406 return *(it
->second
);
408 // if we didn't find it, query the system, maybe it knows about it
409 #if defined(__WXGTK__) || defined(__X__)
410 wxColour col
= wxColour::CreateByName(colour
);
415 self
->AddColour(colour
, col
);
420 // TODO: move this to wxColour::CreateByName()
424 Display
*display
= XtDisplay((Widget
) wxTheApp
->GetTopLevelWidget()) ;
427 Display
* display
= (Display
*) wxGetDisplay();
429 /* MATTHEW: [4] Use wxGetMainColormap */
430 if (!XParseColor(display
, (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) display
), colour
.ToAscii() ,&xcolour
))
434 unsigned char r
= (unsigned char)(xcolour
.red
);
435 unsigned char g
= (unsigned char)(xcolour
.green
);
436 unsigned char b
= (unsigned char)(xcolour
.blue
);
438 unsigned char r
= (unsigned char)(xcolour
.red
>> 8);
439 unsigned char g
= (unsigned char)(xcolour
.green
>> 8);
440 unsigned char b
= (unsigned char)(xcolour
.blue
>> 8);
443 wxColour
col(r
, g
, b
);
444 AddColour(colour
, col
);
447 #else // other platform
452 wxString
wxColourDatabase::FindName(const wxColour
& colour
) const
454 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
457 typedef wxStringToColourHashMap::iterator iterator
;
459 for ( iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
461 if ( *(it
->second
) == colour
)
465 return wxEmptyString
;
468 // ----------------------------------------------------------------------------
469 // deprecated wxColourDatabase methods
470 // ----------------------------------------------------------------------------
472 wxColour
*wxColourDatabase::FindColour(const wxString
& name
)
474 // This function is deprecated, use Find() instead.
475 // Formerly this function sometimes would return a deletable pointer and
476 // sometimes a non-deletable one (when returning a colour from the database).
477 // Trying to delete the latter anyway results in problems, so probably
478 // nobody ever freed the pointers. Currently it always returns a new
479 // instance, which means there will be memory leaks.
480 wxLogDebug(wxT("wxColourDataBase::FindColour():")
481 wxT(" Please use wxColourDataBase::Find() instead"));
483 // using a static variable here is not the most elegant solution but unless
484 // we want to make wxStringToColourHashMap public (i.e. move it to the
485 // header) so that we could have a member function returning
486 // wxStringToColourHashMap::iterator, there is really no good way to do it
489 // and knowing that this function is going to disappear in the next release
490 // anyhow I don't want to waste time on this
492 static wxColour s_col
;
498 return new wxColour(s_col
);
501 // ============================================================================
503 // ============================================================================
505 void wxInitializeStockLists()
507 wxTheColourDatabase
= new wxColourDatabase
;
509 wxTheBrushList
= new wxBrushList
;
510 wxThePenList
= new wxPenList
;
511 wxTheFontList
= new wxFontList
;
512 wxTheBitmapList
= new wxBitmapList
;
515 void wxInitializeStockObjects ()
521 // wxFontPool = new XFontPool;
524 // why under MSW fonts shouldn't have the standard system size?
527 static const int sizeFont = 10;
531 #if defined(__WXMAC__)
532 // retrieve size of system font for all stock fonts
539 GetThemeFont(kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
540 sizeFont
= fontSize
;
541 #if __WXMAC_CLASSIC__
542 wxNORMAL_FONT
= new wxFont (fontSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal(fontName
) );
544 wxNORMAL_FONT
= new wxFont () ;
545 wxNORMAL_FONT
->MacCreateThemeFont( kThemeSystemFont
);
547 #elif defined(__WXPM__)
548 static const int sizeFont
= 12;
550 wxNORMAL_FONT
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
551 static const int sizeFont
= wxNORMAL_FONT
->GetPointSize();
554 #if defined(__WXPM__)
556 // Basic OS/2 has a fairly limited number of fonts and these are as good
557 // as I can do to get something that looks halfway "wx" normal
559 wxNORMAL_FONT
= new wxFont (sizeFont
, wxMODERN
, wxNORMAL
, wxBOLD
);
560 wxSMALL_FONT
= new wxFont (sizeFont
- 4, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
561 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
562 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
563 #elif defined(__WXMAC__)
564 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
); /* Helv */
565 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
566 #if __WXMAC_CLASSIC__
567 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
568 wxSMALL_FONT
= new wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) );
570 wxSMALL_FONT
= new wxFont () ;
571 wxSMALL_FONT
->MacCreateThemeFont( kThemeSmallSystemFont
);
574 wxSMALL_FONT
= new wxFont (sizeFont
- 2, wxSWISS
, wxNORMAL
, wxNORMAL
);
575 wxITALIC_FONT
= new wxFont (sizeFont
, wxROMAN
, wxITALIC
, wxNORMAL
);
576 wxSWISS_FONT
= new wxFont (sizeFont
, wxSWISS
, wxNORMAL
, wxNORMAL
);
579 wxRED_PEN
= new wxPen (wxT("RED"), 1, wxSOLID
);
580 wxCYAN_PEN
= new wxPen (wxT("CYAN"), 1, wxSOLID
);
581 wxGREEN_PEN
= new wxPen (wxT("GREEN"), 1, wxSOLID
);
582 wxBLACK_PEN
= new wxPen (wxT("BLACK"), 1, wxSOLID
);
583 wxWHITE_PEN
= new wxPen (wxT("WHITE"), 1, wxSOLID
);
584 wxTRANSPARENT_PEN
= new wxPen (wxT("BLACK"), 1, wxTRANSPARENT
);
585 wxBLACK_DASHED_PEN
= new wxPen (wxT("BLACK"), 1, wxSHORT_DASH
);
586 wxGREY_PEN
= new wxPen (wxT("GREY"), 1, wxSOLID
);
587 wxMEDIUM_GREY_PEN
= new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID
);
588 wxLIGHT_GREY_PEN
= new wxPen (wxT("LIGHT GREY"), 1, wxSOLID
);
590 wxBLUE_BRUSH
= new wxBrush (wxT("BLUE"), wxSOLID
);
591 wxGREEN_BRUSH
= new wxBrush (wxT("GREEN"), wxSOLID
);
592 wxWHITE_BRUSH
= new wxBrush (wxT("WHITE"), wxSOLID
);
593 wxBLACK_BRUSH
= new wxBrush (wxT("BLACK"), wxSOLID
);
594 wxTRANSPARENT_BRUSH
= new wxBrush (wxT("BLACK"), wxTRANSPARENT
);
595 wxCYAN_BRUSH
= new wxBrush (wxT("CYAN"), wxSOLID
);
596 wxRED_BRUSH
= new wxBrush (wxT("RED"), wxSOLID
);
597 wxGREY_BRUSH
= new wxBrush (wxT("GREY"), wxSOLID
);
598 wxMEDIUM_GREY_BRUSH
= new wxBrush (wxT("MEDIUM GREY"), wxSOLID
);
599 wxLIGHT_GREY_BRUSH
= new wxBrush (wxT("LIGHT GREY"), wxSOLID
);
601 wxBLACK
= new wxColour (wxT("BLACK"));
602 wxWHITE
= new wxColour (wxT("WHITE"));
603 wxRED
= new wxColour (wxT("RED"));
604 wxBLUE
= new wxColour (wxT("BLUE"));
605 wxGREEN
= new wxColour (wxT("GREEN"));
606 wxCYAN
= new wxColour (wxT("CYAN"));
607 wxLIGHT_GREY
= new wxColour (wxT("LIGHT GREY"));
609 wxSTANDARD_CURSOR
= new wxCursor (wxCURSOR_ARROW
);
610 wxHOURGLASS_CURSOR
= new wxCursor (wxCURSOR_WAIT
);
611 wxCROSS_CURSOR
= new wxCursor (wxCURSOR_CROSS
);
614 void wxDeleteStockObjects ()
616 wxDELETE(wxNORMAL_FONT
);
617 wxDELETE(wxSMALL_FONT
);
618 wxDELETE(wxITALIC_FONT
);
619 wxDELETE(wxSWISS_FONT
);
622 wxDELETE(wxCYAN_PEN
);
623 wxDELETE(wxGREEN_PEN
);
624 wxDELETE(wxBLACK_PEN
);
625 wxDELETE(wxWHITE_PEN
);
626 wxDELETE(wxTRANSPARENT_PEN
);
627 wxDELETE(wxBLACK_DASHED_PEN
);
628 wxDELETE(wxGREY_PEN
);
629 wxDELETE(wxMEDIUM_GREY_PEN
);
630 wxDELETE(wxLIGHT_GREY_PEN
);
632 wxDELETE(wxBLUE_BRUSH
);
633 wxDELETE(wxGREEN_BRUSH
);
634 wxDELETE(wxWHITE_BRUSH
);
635 wxDELETE(wxBLACK_BRUSH
);
636 wxDELETE(wxTRANSPARENT_BRUSH
);
637 wxDELETE(wxCYAN_BRUSH
);
638 wxDELETE(wxRED_BRUSH
);
639 wxDELETE(wxGREY_BRUSH
);
640 wxDELETE(wxMEDIUM_GREY_BRUSH
);
641 wxDELETE(wxLIGHT_GREY_BRUSH
);
649 wxDELETE(wxLIGHT_GREY
);
651 wxDELETE(wxSTANDARD_CURSOR
);
652 wxDELETE(wxHOURGLASS_CURSOR
);
653 wxDELETE(wxCROSS_CURSOR
);
656 void wxDeleteStockLists()
658 wxDELETE(wxTheBrushList
);
659 wxDELETE(wxThePenList
);
660 wxDELETE(wxTheFontList
);
661 wxDELETE(wxTheBitmapList
);
664 // ============================================================================
665 // wxTheXXXList stuff (semi-obsolete)
666 // ============================================================================
668 wxBitmapList::wxBitmapList()
672 wxBitmapList::~wxBitmapList ()
674 wxList::compatibility_iterator node
= GetFirst ();
677 wxBitmap
*bitmap
= (wxBitmap
*) node
->GetData ();
678 wxList::compatibility_iterator next
= node
->GetNext ();
679 if (bitmap
->GetVisible())
685 // Pen and Brush lists
686 wxPenList::~wxPenList ()
688 wxList::compatibility_iterator node
= GetFirst ();
691 wxPen
*pen
= (wxPen
*) node
->GetData ();
692 wxList::compatibility_iterator next
= node
->GetNext ();
693 if (pen
->GetVisible())
699 void wxPenList::AddPen (wxPen
* pen
)
704 void wxPenList::RemovePen (wxPen
* pen
)
709 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, int style
)
711 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
713 wxPen
*each_pen
= (wxPen
*) node
->GetData ();
715 each_pen
->GetVisible() &&
716 each_pen
->GetWidth () == width
&&
717 each_pen
->GetStyle () == style
&&
718 each_pen
->GetColour ().Red () == colour
.Red () &&
719 each_pen
->GetColour ().Green () == colour
.Green () &&
720 each_pen
->GetColour ().Blue () == colour
.Blue ())
724 wxPen
*pen
= new wxPen (colour
, width
, style
);
727 // don't save the invalid pens in the list
735 // we'll delete it ourselves later
736 pen
->SetVisible(true);
741 wxBrushList::~wxBrushList ()
743 wxList::compatibility_iterator node
= GetFirst ();
746 wxBrush
*brush
= (wxBrush
*) node
->GetData ();
747 wxList::compatibility_iterator next
= node
->GetNext ();
748 if (brush
&& brush
->GetVisible())
754 void wxBrushList::AddBrush (wxBrush
* brush
)
759 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, int style
)
761 for (wxList::compatibility_iterator node
= GetFirst (); node
; node
= node
->GetNext ())
763 wxBrush
*each_brush
= (wxBrush
*) node
->GetData ();
765 each_brush
->GetVisible() &&
766 each_brush
->GetStyle () == style
&&
767 each_brush
->GetColour ().Red () == colour
.Red () &&
768 each_brush
->GetColour ().Green () == colour
.Green () &&
769 each_brush
->GetColour ().Blue () == colour
.Blue ())
773 wxBrush
*brush
= new wxBrush (colour
, style
);
777 // don't put the brushes we failed to create into the list
785 // we'll delete it ourselves later
786 brush
->SetVisible(true);
791 void wxBrushList::RemoveBrush (wxBrush
* brush
)
793 DeleteObject (brush
);
796 wxFontList::~wxFontList ()
798 wxList::compatibility_iterator node
= GetFirst ();
801 // Only delete objects that are 'visible', i.e.
802 // that have been created using FindOrCreate...,
803 // where the pointers are expected to be shared
804 // (and therefore not deleted by any one part of an app).
805 wxFont
*font
= (wxFont
*) node
->GetData ();
806 wxList::compatibility_iterator next
= node
->GetNext ();
807 if (font
->GetVisible())
813 void wxFontList::AddFont (wxFont
* font
)
818 void wxFontList::RemoveFont (wxFont
* font
)
823 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
828 const wxString
& facename
,
829 wxFontEncoding encoding
)
831 wxFont
*font
= (wxFont
*)NULL
;
832 wxList::compatibility_iterator node
;
833 for ( node
= GetFirst(); node
; node
= node
->GetNext() )
835 font
= (wxFont
*)node
->GetData();
836 if ( font
->GetVisible() &&
838 font
->GetPointSize () == pointSize
&&
839 font
->GetStyle () == style
&&
840 font
->GetWeight () == weight
&&
841 font
->GetUnderlined () == underline
)
843 int fontFamily
= font
->GetFamily();
845 #if defined(__WXGTK__)
846 // under GTK the default family is wxSWISS, so looking for a font
847 // with wxDEFAULT family should return a wxSWISS one instead of
848 // creating a new one
849 bool same
= (fontFamily
== family
) ||
850 (fontFamily
== wxSWISS
&& family
== wxDEFAULT
);
852 // VZ: but why elsewhere do we require an exact match? mystery...
853 bool same
= fontFamily
== family
;
856 // empty facename matches anything at all: this is bad because
857 // depending on which fonts are already created, we might get back
858 // a different font if we create it with empty facename, but it is
859 // still better than never matching anything in the cache at all
861 if ( same
&& !facename
.IsEmpty() )
863 const wxString
& fontFace
= font
->GetFaceName();
865 // empty facename matches everything
866 same
= !fontFace
|| fontFace
== facename
;
869 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
871 // have to match the encoding too
872 same
= font
->GetEncoding() == encoding
;
884 // font not found, create the new one
885 font
= new wxFont(pointSize
, family
, style
, weight
,
886 underline
, facename
, encoding
);
890 // and mark it as being cacheable
891 font
->SetVisible(true);
897 void wxBitmapList::AddBitmap(wxBitmap
*bitmap
)
902 void wxBitmapList::RemoveBitmap(wxBitmap
*bitmap
)
904 DeleteObject(bitmap
);
907 wxSize
wxGetDisplaySize()
910 wxDisplaySize(& x
, & y
);
914 wxRect
wxGetClientDisplayRect()
916 int x
, y
, width
, height
;
917 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
918 return wxRect(x
, y
, width
, height
);
921 wxSize
wxGetDisplaySizeMM()
924 wxDisplaySizeMM(& x
, & y
);
928 wxResourceCache::~wxResourceCache ()
930 wxList::compatibility_iterator node
= GetFirst ();
932 wxObject
*item
= (wxObject
*)node
->GetData();
935 node
= node
->GetNext ();