1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/gdicmn.cpp
3 // Purpose: Common GDI classes
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #include "wx/gdicmn.h"
19 #include "wx/gdiobj.h"
25 #include "wx/palette.h"
27 #include "wx/iconbndl.h"
28 #include "wx/cursor.h"
29 #include "wx/settings.h"
30 #include "wx/bitmap.h"
31 #include "wx/colour.h"
37 IMPLEMENT_ABSTRACT_CLASS(wxGDIObject
, wxObject
)
40 WXDLLIMPEXP_DATA_CORE(wxBrushList
*) wxTheBrushList
;
41 WXDLLIMPEXP_DATA_CORE(wxFontList
*) wxTheFontList
;
42 WXDLLIMPEXP_DATA_CORE(wxPenList
*) wxThePenList
;
44 WXDLLIMPEXP_DATA_CORE(wxColourDatabase
*) wxTheColourDatabase
;
46 WXDLLIMPEXP_DATA_CORE(wxBitmap
) wxNullBitmap
;
47 WXDLLIMPEXP_DATA_CORE(wxBrush
) wxNullBrush
;
48 WXDLLIMPEXP_DATA_CORE(wxColour
) wxNullColour
;
49 WXDLLIMPEXP_DATA_CORE(wxCursor
) wxNullCursor
;
50 WXDLLIMPEXP_DATA_CORE(wxFont
) wxNullFont
;
51 WXDLLIMPEXP_DATA_CORE(wxIcon
) wxNullIcon
;
52 WXDLLIMPEXP_DATA_CORE(wxPen
) wxNullPen
;
54 WXDLLIMPEXP_DATA_CORE(wxPalette
) wxNullPalette
;
56 WXDLLIMPEXP_DATA_CORE(wxIconBundle
) wxNullIconBundle
;
58 const wxSize
wxDefaultSize(wxDefaultCoord
, wxDefaultCoord
);
59 const wxPoint
wxDefaultPosition(wxDefaultCoord
, wxDefaultCoord
);
61 #include "wx/listimpl.cpp"
62 WX_DEFINE_LIST(wxPointList
)
65 #if wxUSE_EXTENDED_RTTI
69 template<> void wxStringReadValue(const wxString
&s
, wxPoint
&data
)
71 wxSscanf(s
, wxT("%d,%d"), &data
.x
, &data
.y
) ;
74 template<> void wxStringWriteValue(wxString
&s
, const wxPoint
&data
)
76 s
= wxString::Format(wxT("%d,%d"), data
.x
, data
.y
) ;
79 wxCUSTOM_TYPE_INFO(wxPoint
, wxToStringConverter
<wxPoint
> , wxFromStringConverter
<wxPoint
>)
81 template<> void wxStringReadValue(const wxString
&s
, wxSize
&data
)
83 wxSscanf(s
, wxT("%d,%d"), &data
.x
, &data
.y
) ;
86 template<> void wxStringWriteValue(wxString
&s
, const wxSize
&data
)
88 s
= wxString::Format(wxT("%d,%d"), data
.x
, data
.y
) ;
91 wxCUSTOM_TYPE_INFO(wxSize
, wxToStringConverter
<wxSize
> , wxFromStringConverter
<wxSize
>)
95 wxRect::wxRect(const wxPoint
& point1
, const wxPoint
& point2
)
99 width
= point2
.x
- point1
.x
;
100 height
= point2
.y
- point1
.y
;
117 wxRect
& wxRect::Union(const wxRect
& rect
)
119 // ignore empty rectangles: union with an empty rectangle shouldn't extend
120 // this one to (0, 0)
121 if ( !width
|| !height
)
125 else if ( rect
.width
&& rect
.height
)
127 int x1
= wxMin(x
, rect
.x
);
128 int y1
= wxMin(y
, rect
.y
);
129 int y2
= wxMax(y
+ height
, rect
.height
+ rect
.y
);
130 int x2
= wxMax(x
+ width
, rect
.width
+ rect
.x
);
137 //else: we're not empty and rect is empty
142 wxRect
& wxRect::Inflate(wxCoord dx
, wxCoord dy
)
146 // Don't allow deflate to eat more width than we have,
147 // a well-defined rectangle cannot have negative width.
153 // The inflate is valid.
160 // Don't allow deflate to eat more height than we have,
161 // a well-defined rectangle cannot have negative height.
167 // The inflate is valid.
175 bool wxRect::Contains(int cx
, int cy
) const
177 return ( (cx
>= x
) && (cy
>= y
)
178 && ((cy
- y
) < height
)
179 && ((cx
- x
) < width
)
183 bool wxRect::Contains(const wxRect
& rect
) const
185 return Contains(rect
.GetTopLeft()) && Contains(rect
.GetBottomRight());
188 wxRect
& wxRect::Intersect(const wxRect
& rect
)
197 if ( x2
> rect
.GetRight() )
198 x2
= rect
.GetRight();
199 if ( y2
> rect
.GetBottom() )
200 y2
= rect
.GetBottom();
205 if ( width
<= 0 || height
<= 0 )
214 bool wxRect::Intersects(const wxRect
& rect
) const
216 wxRect r
= Intersect(rect
);
218 // if there is no intersection, both width and height are 0
222 wxRect
& wxRect::operator+=(const wxRect
& rect
)
224 *this = *this + rect
;
229 wxRect
& wxRect::operator*=(const wxRect
& rect
)
231 *this = *this * rect
;
236 wxRect
operator+(const wxRect
& r1
, const wxRect
& r2
)
238 int x1
= wxMin(r1
.x
, r2
.x
);
239 int y1
= wxMin(r1
.y
, r2
.y
);
240 int y2
= wxMax(r1
.y
+r1
.height
, r2
.height
+r2
.y
);
241 int x2
= wxMax(r1
.x
+r1
.width
, r2
.width
+r2
.x
);
242 return wxRect(x1
, y1
, x2
-x1
, y2
-y1
);
245 wxRect
operator*(const wxRect
& r1
, const wxRect
& r2
)
247 int x1
= wxMax(r1
.x
, r2
.x
);
248 int y1
= wxMax(r1
.y
, r2
.y
);
249 int y2
= wxMin(r1
.y
+r1
.height
, r2
.height
+r2
.y
);
250 int x2
= wxMin(r1
.x
+r1
.width
, r2
.width
+r2
.x
);
251 return wxRect(x1
, y1
, x2
-x1
, y2
-y1
);
254 wxRealPoint::wxRealPoint(const wxPoint
& pt
)
259 // ============================================================================
261 // ============================================================================
263 // ----------------------------------------------------------------------------
264 // wxColourDatabase ctor/dtor
265 // ----------------------------------------------------------------------------
267 wxColourDatabase::wxColourDatabase ()
269 // will be created on demand in Initialize()
273 wxColourDatabase::~wxColourDatabase ()
277 WX_CLEAR_HASH_MAP(wxStringToColourHashMap
, *m_map
);
283 delete [] m_palTable
;
287 // Colour database stuff
288 void wxColourDatabase::Initialize()
292 // already initialized
296 m_map
= new wxStringToColourHashMap
;
298 static const struct wxColourDesc
305 {wxT("AQUAMARINE"),112, 219, 147},
306 {wxT("BLACK"),0, 0, 0},
307 {wxT("BLUE"), 0, 0, 255},
308 {wxT("BLUE VIOLET"), 159, 95, 159},
309 {wxT("BROWN"), 165, 42, 42},
310 {wxT("CADET BLUE"), 95, 159, 159},
311 {wxT("CORAL"), 255, 127, 0},
312 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
313 {wxT("CYAN"), 0, 255, 255},
314 {wxT("DARK GREY"), 47, 47, 47}, // ?
316 {wxT("DARK GREEN"), 47, 79, 47},
317 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
318 {wxT("DARK ORCHID"), 153, 50, 204},
319 {wxT("DARK SLATE BLUE"), 107, 35, 142},
320 {wxT("DARK SLATE GREY"), 47, 79, 79},
321 {wxT("DARK TURQUOISE"), 112, 147, 219},
322 {wxT("DIM GREY"), 84, 84, 84},
323 {wxT("FIREBRICK"), 142, 35, 35},
324 {wxT("FOREST GREEN"), 35, 142, 35},
325 {wxT("GOLD"), 204, 127, 50},
326 {wxT("GOLDENROD"), 219, 219, 112},
327 {wxT("GREY"), 128, 128, 128},
328 {wxT("GREEN"), 0, 255, 0},
329 {wxT("GREEN YELLOW"), 147, 219, 112},
330 {wxT("INDIAN RED"), 79, 47, 47},
331 {wxT("KHAKI"), 159, 159, 95},
332 {wxT("LIGHT BLUE"), 191, 216, 216},
333 {wxT("LIGHT GREY"), 192, 192, 192},
334 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
335 {wxT("LIME GREEN"), 50, 204, 50},
336 {wxT("LIGHT MAGENTA"), 255, 0, 255},
337 {wxT("MAGENTA"), 255, 0, 255},
338 {wxT("MAROON"), 142, 35, 107},
339 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
340 {wxT("MEDIUM GREY"), 100, 100, 100},
341 {wxT("MEDIUM BLUE"), 50, 50, 204},
342 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
343 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
344 {wxT("MEDIUM ORCHID"), 147, 112, 219},
345 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
346 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
347 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
348 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
349 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
350 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
351 {wxT("NAVY"), 35, 35, 142},
352 {wxT("ORANGE"), 204, 50, 50},
353 {wxT("ORANGE RED"), 255, 0, 127},
354 {wxT("ORCHID"), 219, 112, 219},
355 {wxT("PALE GREEN"), 143, 188, 143},
356 {wxT("PINK"), 255, 192, 203},
357 {wxT("PLUM"), 234, 173, 234},
358 {wxT("PURPLE"), 176, 0, 255},
359 {wxT("RED"), 255, 0, 0},
360 {wxT("SALMON"), 111, 66, 66},
361 {wxT("SEA GREEN"), 35, 142, 107},
362 {wxT("SIENNA"), 142, 107, 35},
363 {wxT("SKY BLUE"), 50, 153, 204},
364 {wxT("SLATE BLUE"), 0, 127, 255},
365 {wxT("SPRING GREEN"), 0, 255, 127},
366 {wxT("STEEL BLUE"), 35, 107, 142},
367 {wxT("TAN"), 219, 147, 112},
368 {wxT("THISTLE"), 216, 191, 216},
369 {wxT("TURQUOISE"), 173, 234, 234},
370 {wxT("VIOLET"), 79, 47, 79},
371 {wxT("VIOLET RED"), 204, 50, 153},
372 {wxT("WHEAT"), 216, 216, 191},
373 {wxT("WHITE"), 255, 255, 255},
374 {wxT("YELLOW"), 255, 255, 0},
375 {wxT("YELLOW GREEN"), 153, 204, 50}
380 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
382 const wxColourDesc
& cc
= wxColourTable
[n
];
383 (*m_map
)[cc
.name
] = new wxColour(cc
.r
, cc
.g
, cc
.b
);
387 m_palTable
= new long[n
];
388 for ( n
= 0; n
< WXSIZEOF(wxColourTable
); n
++ )
390 const wxColourDesc
& cc
= wxColourTable
[n
];
391 m_palTable
[n
] = OS2RGB(cc
.r
,cc
.g
,cc
.b
);
397 // ----------------------------------------------------------------------------
398 // wxColourDatabase operations
399 // ----------------------------------------------------------------------------
401 void wxColourDatabase::AddColour(const wxString
& name
, const wxColour
& colour
)
405 // canonicalize the colour names before using them as keys: they should be
407 wxString colName
= name
;
410 // ... and we also allow both grey/gray
411 wxString colNameAlt
= colName
;
412 if ( !colNameAlt
.Replace(wxT("GRAY"), wxT("GREY")) )
414 // but in this case it is not necessary so avoid extra search below
418 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
419 if ( it
== m_map
->end() && !colNameAlt
.empty() )
420 it
= m_map
->find(colNameAlt
);
421 if ( it
!= m_map
->end() )
423 *(it
->second
) = colour
;
427 (*m_map
)[colName
] = new wxColour(colour
);
431 wxColour
wxColourDatabase::Find(const wxString
& colour
) const
433 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
436 // make the comparaison case insensitive and also match both grey and gray
437 wxString colName
= colour
;
439 wxString colNameAlt
= colName
;
440 if ( !colNameAlt
.Replace(wxT("GRAY"), wxT("GREY")) )
443 wxStringToColourHashMap::iterator it
= m_map
->find(colName
);
444 if ( it
== m_map
->end() && !colNameAlt
.empty() )
445 it
= m_map
->find(colNameAlt
);
446 if ( it
!= m_map
->end() )
447 return *(it
->second
);
449 // we did not find any result in existing colours:
450 // we won't use wxString -> wxColour conversion because the
451 // wxColour::Set(const wxString &) function which does that conversion
452 // internally uses this function (wxColourDatabase::Find) and we want
453 // to avoid infinite recursion !
457 wxString
wxColourDatabase::FindName(const wxColour
& colour
) const
459 wxColourDatabase
* const self
= wxConstCast(this, wxColourDatabase
);
462 typedef wxStringToColourHashMap::iterator iterator
;
464 for ( iterator it
= m_map
->begin(), en
= m_map
->end(); it
!= en
; ++it
)
466 if ( *(it
->second
) == colour
)
470 return wxEmptyString
;
473 // ----------------------------------------------------------------------------
474 // deprecated wxColourDatabase methods
475 // ----------------------------------------------------------------------------
477 #if WXWIN_COMPATIBILITY_2_6
478 wxColour
*wxColourDatabase::FindColour(const wxString
& name
)
480 // This function is deprecated, use Find() instead.
481 // Formerly this function sometimes would return a deletable pointer and
482 // sometimes a non-deletable one (when returning a colour from the database).
483 // Trying to delete the latter anyway results in problems, so probably
484 // nobody ever freed the pointers. Currently it always returns a new
485 // instance, which means there will be memory leaks.
486 wxLogDebug(wxT("wxColourDataBase::FindColour():")
487 wxT(" Please use wxColourDataBase::Find() instead"));
489 // using a static variable here is not the most elegant solution but unless
490 // we want to make wxStringToColourHashMap public (i.e. move it to the
491 // header) so that we could have a member function returning
492 // wxStringToColourHashMap::iterator, there is really no good way to do it
495 // and knowing that this function is going to disappear in the next release
496 // anyhow I don't want to waste time on this
498 static wxColour s_col
;
504 return new wxColour(s_col
);
506 #endif // WXWIN_COMPATIBILITY_2_6
508 // ============================================================================
510 // ============================================================================
512 static wxStockGDI gs_wxStockGDI_instance
;
513 wxStockGDI
* wxStockGDI::ms_instance
= &gs_wxStockGDI_instance
;
514 wxObject
* wxStockGDI::ms_stockObject
[ITEMCOUNT
];
516 wxStockGDI::wxStockGDI()
520 wxStockGDI::~wxStockGDI()
524 void wxStockGDI::DeleteAll()
526 for (unsigned i
= 0; i
< ITEMCOUNT
; i
++)
528 wxDELETE(ms_stockObject
[i
]);
532 const wxBrush
* wxStockGDI::GetBrush(Item item
)
534 wxBrush
* brush
= static_cast<wxBrush
*>(ms_stockObject
[item
]);
540 brush
= new wxBrush(*GetColour(COLOUR_BLACK
), wxBRUSHSTYLE_SOLID
);
543 brush
= new wxBrush(*GetColour(COLOUR_BLUE
), wxBRUSHSTYLE_SOLID
);
546 brush
= new wxBrush(*GetColour(COLOUR_CYAN
), wxBRUSHSTYLE_SOLID
);
549 brush
= new wxBrush(*GetColour(COLOUR_GREEN
), wxBRUSHSTYLE_SOLID
);
552 brush
= new wxBrush(*GetColour(COLOUR_YELLOW
), wxBRUSHSTYLE_SOLID
);
555 brush
= new wxBrush(wxColour(wxT("GREY")), wxBRUSHSTYLE_SOLID
);
557 case BRUSH_LIGHTGREY
:
558 brush
= new wxBrush(*GetColour(COLOUR_LIGHTGREY
), wxBRUSHSTYLE_SOLID
);
560 case BRUSH_MEDIUMGREY
:
561 brush
= new wxBrush(wxColour(wxT("MEDIUM GREY")), wxBRUSHSTYLE_SOLID
);
564 brush
= new wxBrush(*GetColour(COLOUR_RED
), wxBRUSHSTYLE_SOLID
);
566 case BRUSH_TRANSPARENT
:
567 brush
= new wxBrush(*GetColour(COLOUR_BLACK
), wxBRUSHSTYLE_TRANSPARENT
);
570 brush
= new wxBrush(*GetColour(COLOUR_WHITE
), wxBRUSHSTYLE_SOLID
);
575 ms_stockObject
[item
] = brush
;
580 const wxColour
* wxStockGDI::GetColour(Item item
)
582 wxColour
* colour
= static_cast<wxColour
*>(ms_stockObject
[item
]);
588 colour
= new wxColour(0, 0, 0);
591 colour
= new wxColour(0, 0, 255);
594 colour
= new wxColour(wxT("CYAN"));
597 colour
= new wxColour(0, 255, 0);
600 colour
= new wxColour(255, 255, 0);
602 case COLOUR_LIGHTGREY
:
603 colour
= new wxColour(wxT("LIGHT GREY"));
606 colour
= new wxColour(255, 0, 0);
609 colour
= new wxColour(255, 255, 255);
614 ms_stockObject
[item
] = colour
;
619 const wxCursor
* wxStockGDI::GetCursor(Item item
)
621 wxCursor
* cursor
= static_cast<wxCursor
*>(ms_stockObject
[item
]);
627 cursor
= new wxCursor(wxCURSOR_CROSS
);
629 case CURSOR_HOURGLASS
:
630 cursor
= new wxCursor(wxCURSOR_WAIT
);
632 case CURSOR_STANDARD
:
633 cursor
= new wxCursor(wxCURSOR_ARROW
);
638 ms_stockObject
[item
] = cursor
;
643 const wxFont
* wxStockGDI::GetFont(Item item
)
645 wxFont
* font
= static_cast<wxFont
*>(ms_stockObject
[item
]);
651 font
= new wxFont(GetFont(FONT_NORMAL
)->GetPointSize(), wxROMAN
, wxITALIC
, wxNORMAL
);
654 font
= new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
657 font
= new wxFont(GetFont(FONT_NORMAL
)->GetPointSize()
658 // Using the font 2 points smaller than the normal one
659 // results in font so small as to be unreadable under MSW.
660 // We might want to actually use -1 under the other
661 // platforms too but for now be conservative and keep -2
662 // there for compatibility with the old behaviour as the
663 // small font seems to be readable enough there as it is.
669 wxSWISS
, wxNORMAL
, wxNORMAL
);
672 font
= new wxFont(GetFont(FONT_NORMAL
)->GetPointSize(), wxSWISS
, wxNORMAL
, wxNORMAL
);
677 ms_stockObject
[item
] = font
;
682 const wxPen
* wxStockGDI::GetPen(Item item
)
684 wxPen
* pen
= static_cast<wxPen
*>(ms_stockObject
[item
]);
690 pen
= new wxPen(*GetColour(COLOUR_BLACK
), 1, wxPENSTYLE_SOLID
);
692 case PEN_BLACKDASHED
:
693 pen
= new wxPen(*GetColour(COLOUR_BLACK
), 1, wxPENSTYLE_SHORT_DASH
);
696 pen
= new wxPen(*GetColour(COLOUR_BLUE
), 1, wxPENSTYLE_SOLID
);
699 pen
= new wxPen(*GetColour(COLOUR_CYAN
), 1, wxPENSTYLE_SOLID
);
702 pen
= new wxPen(*GetColour(COLOUR_GREEN
), 1, wxPENSTYLE_SOLID
);
705 pen
= new wxPen(*GetColour(COLOUR_YELLOW
), 1, wxPENSTYLE_SOLID
);
708 pen
= new wxPen(wxColour(wxT("GREY")), 1, wxPENSTYLE_SOLID
);
711 pen
= new wxPen(*GetColour(COLOUR_LIGHTGREY
), 1, wxPENSTYLE_SOLID
);
714 pen
= new wxPen(wxColour(wxT("MEDIUM GREY")), 1, wxPENSTYLE_SOLID
);
717 pen
= new wxPen(*GetColour(COLOUR_RED
), 1, wxPENSTYLE_SOLID
);
719 case PEN_TRANSPARENT
:
720 pen
= new wxPen(*GetColour(COLOUR_BLACK
), 1, wxPENSTYLE_TRANSPARENT
);
723 pen
= new wxPen(*GetColour(COLOUR_WHITE
), 1, wxPENSTYLE_SOLID
);
728 ms_stockObject
[item
] = pen
;
733 void wxInitializeStockLists()
735 wxTheColourDatabase
= new wxColourDatabase
;
737 wxTheBrushList
= new wxBrushList
;
738 wxThePenList
= new wxPenList
;
739 wxTheFontList
= new wxFontList
;
742 void wxDeleteStockLists()
744 wxDELETE(wxTheBrushList
);
745 wxDELETE(wxThePenList
);
746 wxDELETE(wxTheFontList
);
748 // wxTheColourDatabase is cleaned up by wxAppBase::CleanUp()
751 // ============================================================================
752 // wxTheXXXList stuff (semi-obsolete)
753 // ============================================================================
755 wxGDIObjListBase::wxGDIObjListBase()
759 wxGDIObjListBase::~wxGDIObjListBase()
761 for (wxList::compatibility_iterator node
= list
.GetFirst(); node
; node
= node
->GetNext())
763 delete static_cast<wxObject
*>(node
->GetData());
767 wxPen
*wxPenList::FindOrCreatePen (const wxColour
& colour
, int width
, wxPenStyle style
)
769 for ( wxList::compatibility_iterator node
= list
.GetFirst();
771 node
= node
->GetNext() )
773 wxPen
* const pen
= (wxPen
*) node
->GetData();
774 if ( pen
->GetWidth () == width
&&
775 pen
->GetStyle () == style
&&
776 pen
->GetColour() == colour
)
781 wxPen
penTmp(colour
, width
, style
);
784 pen
= new wxPen(penTmp
);
791 wxBrush
*wxBrushList::FindOrCreateBrush (const wxColour
& colour
, wxBrushStyle style
)
793 for ( wxList::compatibility_iterator node
= list
.GetFirst();
795 node
= node
->GetNext() )
797 wxBrush
* const brush
= (wxBrush
*) node
->GetData ();
798 if ( brush
->GetStyle() == style
&& brush
->GetColour() == colour
)
802 wxBrush
* brush
= NULL
;
803 wxBrush
brushTmp(colour
, style
);
806 brush
= new wxBrush(brushTmp
);
813 wxFont
*wxFontList::FindOrCreateFont(int pointSize
,
818 const wxString
& facename
,
819 wxFontEncoding encoding
)
821 // In all ports but wxOSX, the effective family of a font created using
822 // wxFONTFAMILY_DEFAULT is wxFONTFAMILY_SWISS so this is what we need to
823 // use for comparison.
825 // In wxOSX the original wxFONTFAMILY_DEFAULT seems to be kept and it uses
826 // a different font than wxFONTFAMILY_SWISS anyhow so we just preserve it.
828 if ( family
== wxFONTFAMILY_DEFAULT
)
829 family
= wxFONTFAMILY_SWISS
;
833 wxList::compatibility_iterator node
;
834 for (node
= list
.GetFirst(); node
; node
= node
->GetNext())
836 font
= (wxFont
*)node
->GetData();
838 font
->GetPointSize () == pointSize
&&
839 font
->GetStyle () == style
&&
840 font
->GetWeight () == weight
&&
841 font
->GetUnderlined () == underline
)
843 bool same
= font
->GetFamily() == family
;
845 // empty facename matches anything at all: this is bad because
846 // depending on which fonts are already created, we might get back
847 // a different font if we create it with empty facename, but it is
848 // still better than never matching anything in the cache at all
850 if ( same
&& !facename
.empty() )
852 const wxString
& fontFace
= font
->GetFaceName();
854 // empty facename matches everything
855 same
= !fontFace
|| fontFace
== facename
;
858 if ( same
&& (encoding
!= wxFONTENCODING_DEFAULT
) )
860 // have to match the encoding too
861 same
= font
->GetEncoding() == encoding
;
871 // font not found, create the new one
873 wxFont
fontTmp(pointSize
, family
, style
, weight
, underline
, facename
, encoding
);
876 font
= new wxFont(fontTmp
);
883 #if WXWIN_COMPATIBILITY_2_6
884 void wxBrushList::AddBrush(wxBrush
*) { }
885 void wxBrushList::RemoveBrush(wxBrush
*) { }
886 void wxFontList::AddFont(wxFont
*) { }
887 void wxFontList::RemoveFont(wxFont
*) { }
888 void wxPenList::AddPen(wxPen
*) { }
889 void wxPenList::RemovePen(wxPen
*) { }
892 wxSize
wxGetDisplaySize()
895 wxDisplaySize(& x
, & y
);
899 wxRect
wxGetClientDisplayRect()
901 int x
, y
, width
, height
;
902 wxClientDisplayRect(&x
, &y
, &width
, &height
); // call plat-specific version
903 return wxRect(x
, y
, width
, height
);
906 wxSize
wxGetDisplaySizeMM()
909 wxDisplaySizeMM(& x
, & y
);
913 wxSize
wxGetDisplayPPI()
915 const wxSize pixels
= wxGetDisplaySize();
916 const wxSize mm
= wxGetDisplaySizeMM();
918 return wxSize((int)((pixels
.x
* inches2mm
) / mm
.x
),
919 (int)((pixels
.y
* inches2mm
) / mm
.y
));
922 wxResourceCache::~wxResourceCache ()
924 wxList::compatibility_iterator node
= GetFirst ();
926 wxObject
*item
= (wxObject
*)node
->GetData();
929 node
= node
->GetNext ();