]> git.saurik.com Git - wxWidgets.git/blob - src/common/gdicmn.cpp
Upported wxListBox key handling and SetFirstItem()
[wxWidgets.git] / src / common / gdicmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdicmn.cpp
3 // Purpose: Common GDI classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "gdicmn.h"
14 #endif
15
16 #ifdef __VMS
17 #define XtDisplay XTDISPLAY
18 #endif
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #include "wx/event.h"
28 #include "wx/gdicmn.h"
29 #include "wx/brush.h"
30 #include "wx/pen.h"
31 #include "wx/bitmap.h"
32 #include "wx/icon.h"
33 #include "wx/cursor.h"
34 #include "wx/font.h"
35 #include "wx/palette.h"
36 #include "wx/app.h"
37 #include "wx/dc.h"
38 #include "wx/utils.h"
39 #include "wx/settings.h"
40
41 #include "wx/log.h"
42 #include <string.h>
43
44 #ifdef __WXMSW__
45 #include <windows.h>
46 #endif
47
48 #ifdef __WXMOTIF__
49 #ifdef __VMS__
50 #pragma message disable nosimpint
51 #endif
52 #include <Xm/Xm.h>
53 #ifdef __VMS__
54 #pragma message enable nosimpint
55 #endif
56 #endif
57
58 IMPLEMENT_CLASS(wxColourDatabase, wxList)
59 IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
60 IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
61 IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
62 IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
63 IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
64
65 IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject)
66
67 wxRect::wxRect(const wxPoint& topLeft, const wxPoint& bottomRight)
68 {
69 x = topLeft.x;
70 y = topLeft.y;
71 width = bottomRight.x - topLeft.x + 1;
72 height = bottomRight.y - topLeft.y + 1;
73
74 if (width < 0)
75 {
76 width = -width;
77 x -= width;
78 }
79
80 if (height < 0)
81 {
82 height = -height;
83 y -= height;
84 }
85 }
86
87 wxRect::wxRect(const wxPoint& point, const wxSize& size)
88 {
89 x = point.x; y = point.y;
90 width = size.x; height = size.y;
91 }
92
93 bool wxRect::operator==(const wxRect& rect) const
94 {
95 return ((x == rect.x) &&
96 (y == rect.y) &&
97 (width == rect.width) &&
98 (height == rect.height));
99 }
100
101 wxRect& wxRect::operator += (const wxRect& rect)
102 {
103 *this = (*this + rect);
104 return ( *this ) ;
105 }
106
107 wxRect wxRect::operator + (const wxRect& rect) const
108 {
109 int x1 = wxMin(this->x, rect.x);
110 int y1 = wxMin(this->y, rect.y);
111 int y2 = wxMax(y+height, rect.height+rect.y);
112 int x2 = wxMax(x+width, rect.width+rect.x);
113 return wxRect(x1, y1, x2-x1, y2-y1);
114 }
115
116 bool wxRect::Inside(int cx, int cy) const
117 {
118 return ( (cx >= x) && (cy >= y)
119 && ((cy - y) < height)
120 && ((cx - x) < width)
121 );
122 }
123
124 wxColourDatabase::wxColourDatabase (int type) : wxList (type)
125 {
126 }
127
128 wxColourDatabase::~wxColourDatabase ()
129 {
130 // Cleanup Colour allocated in Initialize()
131 wxNode *node = First ();
132 while (node)
133 {
134 wxColour *col = (wxColour *) node->Data ();
135 wxNode *next = node->Next ();
136 delete col;
137 node = next;
138 }
139 }
140
141 // Colour database stuff
142 void wxColourDatabase::Initialize ()
143 {
144 static const struct wxColourDesc
145 {
146 const wxChar *name;
147 int r,g,b;
148 }
149 wxColourTable[] =
150 {
151 {wxT("AQUAMARINE"),112, 219, 147},
152 {wxT("BLACK"),0, 0, 0},
153 {wxT("BLUE"), 0, 0, 255},
154 {wxT("BLUE VIOLET"), 159, 95, 159},
155 {wxT("BROWN"), 165, 42, 42},
156 {wxT("CADET BLUE"), 95, 159, 159},
157 {wxT("CORAL"), 255, 127, 0},
158 {wxT("CORNFLOWER BLUE"), 66, 66, 111},
159 {wxT("CYAN"), 0, 255, 255},
160 {wxT("DARK GREY"), 47, 47, 47}, // ?
161
162 {wxT("DARK GREEN"), 47, 79, 47},
163 {wxT("DARK OLIVE GREEN"), 79, 79, 47},
164 {wxT("DARK ORCHID"), 153, 50, 204},
165 {wxT("DARK SLATE BLUE"), 107, 35, 142},
166 {wxT("DARK SLATE GREY"), 47, 79, 79},
167 {wxT("DARK TURQUOISE"), 112, 147, 219},
168 {wxT("DIM GREY"), 84, 84, 84},
169 {wxT("FIREBRICK"), 142, 35, 35},
170 {wxT("FOREST GREEN"), 35, 142, 35},
171 {wxT("GOLD"), 204, 127, 50},
172 {wxT("GOLDENROD"), 219, 219, 112},
173 {wxT("GREY"), 128, 128, 128},
174 {wxT("GREEN"), 0, 255, 0},
175 {wxT("GREEN YELLOW"), 147, 219, 112},
176 {wxT("INDIAN RED"), 79, 47, 47},
177 {wxT("KHAKI"), 159, 159, 95},
178 {wxT("LIGHT BLUE"), 191, 216, 216},
179 {wxT("LIGHT GREY"), 192, 192, 192},
180 {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
181 {wxT("LIME GREEN"), 50, 204, 50},
182 {wxT("LIGHT MAGENTA"), 255, 0, 255},
183 {wxT("MAGENTA"), 255, 0, 255},
184 {wxT("MAROON"), 142, 35, 107},
185 {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
186 {wxT("MEDIUM GREY"), 100, 100, 100},
187 {wxT("MEDIUM BLUE"), 50, 50, 204},
188 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
189 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
190 {wxT("MEDIUM ORCHID"), 147, 112, 219},
191 {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
192 {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
193 {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
194 {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
195 {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
196 {wxT("MIDNIGHT BLUE"), 47, 47, 79},
197 {wxT("NAVY"), 35, 35, 142},
198 {wxT("ORANGE"), 204, 50, 50},
199 {wxT("ORANGE RED"), 255, 0, 127},
200 {wxT("ORCHID"), 219, 112, 219},
201 {wxT("PALE GREEN"), 143, 188, 143},
202 {wxT("PINK"), 188, 143, 234},
203 {wxT("PLUM"), 234, 173, 234},
204 {wxT("PURPLE"), 176, 0, 255},
205 {wxT("RED"), 255, 0, 0},
206 {wxT("SALMON"), 111, 66, 66},
207 {wxT("SEA GREEN"), 35, 142, 107},
208 {wxT("SIENNA"), 142, 107, 35},
209 {wxT("SKY BLUE"), 50, 153, 204},
210 {wxT("SLATE BLUE"), 0, 127, 255},
211 {wxT("SPRING GREEN"), 0, 255, 127},
212 {wxT("STEEL BLUE"), 35, 107, 142},
213 {wxT("TAN"), 219, 147, 112},
214 {wxT("THISTLE"), 216, 191, 216},
215 {wxT("TURQUOISE"), 173, 234, 234},
216 {wxT("VIOLET"), 79, 47, 79},
217 {wxT("VIOLET RED"), 204, 50, 153},
218 {wxT("WHEAT"), 216, 216, 191},
219 {wxT("WHITE"), 255, 255, 255},
220 {wxT("YELLOW"), 255, 255, 0},
221 {wxT("YELLOW GREEN"), 153, 204, 50},
222 {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
223 {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
224 {wxT("LIGHT MAGENTA"), 255, 0, 255},
225 {wxT("MEDIUM GREY"), 100, 100, 100},
226 };
227
228 for ( size_t n = 0; n < WXSIZEOF(wxColourTable); n++ )
229 {
230 const wxColourDesc& cc = wxColourTable[n];
231 Append(cc.name, new wxColour(cc.r,cc.g,cc.b));
232 }
233 }
234
235 /*
236 * Changed by Ian Brown, July 1994.
237 *
238 * When running under X, the Colour Database starts off empty. The X server
239 * is queried for the colour first time after which it is entered into the
240 * database. This allows our client to use the server colour database which
241 * is hopefully gamma corrected for the display being used.
242 */
243
244 wxColour *wxColourDatabase::FindColour(const wxString& colour)
245 {
246 // VZ: make the comparaison case insensitive and also match both grey and
247 // gray
248 wxString colName = colour;
249 colName.MakeUpper();
250 wxString colName2 = colName;
251 if ( !colName2.Replace(_T("GRAY"), _T("GREY")) )
252 colName2.clear();
253
254 wxNode *node = First();
255 while ( node )
256 {
257 const wxChar *key = node->GetKeyString();
258 if ( colName == key || colName2 == key )
259 {
260 return (wxColour *)node->Data();
261 }
262
263 node = node->Next();
264 }
265
266 #ifdef __WXMSW__
267 return NULL;
268 #endif
269 #ifdef __WXPM__
270 return NULL;
271 #endif
272
273 // TODO for other implementations. This should really go into
274 // platform-specific directories.
275 #ifdef __WXMAC__
276 return NULL;
277 #endif
278 #ifdef __WXSTUBS__
279 return NULL;
280 #endif
281
282 #ifdef __WXGTK__
283 wxColour *col = new wxColour( colour );
284
285 if (!(col->Ok())) {
286 delete col;
287 return (wxColour *) NULL;
288 }
289 Append( colour, col );
290 return col;
291 #endif
292
293 #ifdef __X__
294 XColor xcolour;
295
296 #ifdef __WXMOTIF__
297 Display *display = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()) ;
298 #endif
299 #ifdef __XVIEW__
300 Xv_Screen screen = xv_get(xview_server, SERVER_NTH_SCREEN, 0);
301 Xv_opaque root_window = xv_get(screen, XV_ROOT);
302 Display *display = (Display *)xv_get(root_window, XV_DISPLAY);
303 #endif
304
305 /* MATTHEW: [4] Use wxGetMainColormap */
306 if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour,&xcolour))
307 return NULL;
308
309 unsigned char r = (unsigned char)(xcolour.red >> 8);
310 unsigned char g = (unsigned char)(xcolour.green >> 8);
311 unsigned char b = (unsigned char)(xcolour.blue >> 8);
312
313 wxColour *col = new wxColour(r, g, b);
314 Append(colour, col);
315
316 return col;
317 #endif // __X__
318 }
319
320 wxString wxColourDatabase::FindName (const wxColour& colour) const
321 {
322 wxString name;
323
324 unsigned char red = colour.Red ();
325 unsigned char green = colour.Green ();
326 unsigned char blue = colour.Blue ();
327
328 for (wxNode * node = First (); node; node = node->Next ())
329 {
330 wxColour *col = (wxColour *) node->Data ();
331
332 if (col->Red () == red && col->Green () == green && col->Blue () == blue)
333 {
334 const wxChar *found = node->GetKeyString();
335 if ( found )
336 {
337 name = found;
338
339 break;
340 }
341 }
342 }
343
344 return name;
345 }
346
347 void wxInitializeStockLists () {
348 wxTheBrushList = new wxBrushList;
349 wxThePenList = new wxPenList;
350 wxTheFontList = new wxFontList;
351 wxTheBitmapList = new wxBitmapList;
352 }
353
354 void wxInitializeStockObjects ()
355 {
356 #ifdef __WXMOTIF__
357 #endif
358 #ifdef __X__
359 // TODO
360 // wxFontPool = new XFontPool;
361 #endif
362
363 // why under MSW fonts shouldn't have the standard system size?
364 /*
365 #ifdef __WXMSW__
366 static const int sizeFont = 10;
367 #else
368 #endif
369 */
370 #if defined(__WXPM__)
371 static const int sizeFont = 12;
372 wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL);
373 #else
374 wxNORMAL_FONT = new wxFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
375 static const int sizeFont = wxNORMAL_FONT->GetPointSize();
376 #endif
377
378 wxSMALL_FONT = new wxFont (sizeFont - 2, wxSWISS, wxNORMAL, wxNORMAL);
379 wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
380 wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL);
381
382 wxRED_PEN = new wxPen ("RED", 1, wxSOLID);
383 wxCYAN_PEN = new wxPen ("CYAN", 1, wxSOLID);
384 wxGREEN_PEN = new wxPen ("GREEN", 1, wxSOLID);
385 wxBLACK_PEN = new wxPen ("BLACK", 1, wxSOLID);
386 wxWHITE_PEN = new wxPen ("WHITE", 1, wxSOLID);
387 wxTRANSPARENT_PEN = new wxPen ("BLACK", 1, wxTRANSPARENT);
388 wxBLACK_DASHED_PEN = new wxPen ("BLACK", 1, wxSHORT_DASH);
389 wxGREY_PEN = new wxPen ("GREY", 1, wxSOLID);
390 wxMEDIUM_GREY_PEN = new wxPen ("MEDIUM GREY", 1, wxSOLID);
391 wxLIGHT_GREY_PEN = new wxPen ("LIGHT GREY", 1, wxSOLID);
392
393 wxBLUE_BRUSH = new wxBrush ("BLUE", wxSOLID);
394 wxGREEN_BRUSH = new wxBrush ("GREEN", wxSOLID);
395 wxWHITE_BRUSH = new wxBrush ("WHITE", wxSOLID);
396 wxBLACK_BRUSH = new wxBrush ("BLACK", wxSOLID);
397 wxTRANSPARENT_BRUSH = new wxBrush ("BLACK", wxTRANSPARENT);
398 wxCYAN_BRUSH = new wxBrush ("CYAN", wxSOLID);
399 wxRED_BRUSH = new wxBrush ("RED", wxSOLID);
400 wxGREY_BRUSH = new wxBrush ("GREY", wxSOLID);
401 wxMEDIUM_GREY_BRUSH = new wxBrush ("MEDIUM GREY", wxSOLID);
402 wxLIGHT_GREY_BRUSH = new wxBrush ("LIGHT GREY", wxSOLID);
403
404 wxBLACK = new wxColour ("BLACK");
405 wxWHITE = new wxColour ("WHITE");
406 wxRED = new wxColour ("RED");
407 wxBLUE = new wxColour ("BLUE");
408 wxGREEN = new wxColour ("GREEN");
409 wxCYAN = new wxColour ("CYAN");
410 wxLIGHT_GREY = new wxColour ("LIGHT GREY");
411
412 wxSTANDARD_CURSOR = new wxCursor (wxCURSOR_ARROW);
413 wxHOURGLASS_CURSOR = new wxCursor (wxCURSOR_WAIT);
414 wxCROSS_CURSOR = new wxCursor (wxCURSOR_CROSS);
415 }
416
417 void wxDeleteStockObjects ()
418 {
419 wxDELETE(wxNORMAL_FONT);
420 wxDELETE(wxSMALL_FONT);
421 wxDELETE(wxITALIC_FONT);
422 wxDELETE(wxSWISS_FONT);
423
424 wxDELETE(wxRED_PEN);
425 wxDELETE(wxCYAN_PEN);
426 wxDELETE(wxGREEN_PEN);
427 wxDELETE(wxBLACK_PEN);
428 wxDELETE(wxWHITE_PEN);
429 wxDELETE(wxTRANSPARENT_PEN);
430 wxDELETE(wxBLACK_DASHED_PEN);
431 wxDELETE(wxGREY_PEN);
432 wxDELETE(wxMEDIUM_GREY_PEN);
433 wxDELETE(wxLIGHT_GREY_PEN);
434
435 wxDELETE(wxBLUE_BRUSH);
436 wxDELETE(wxGREEN_BRUSH);
437 wxDELETE(wxWHITE_BRUSH);
438 wxDELETE(wxBLACK_BRUSH);
439 wxDELETE(wxTRANSPARENT_BRUSH);
440 wxDELETE(wxCYAN_BRUSH);
441 wxDELETE(wxRED_BRUSH);
442 wxDELETE(wxGREY_BRUSH);
443 wxDELETE(wxMEDIUM_GREY_BRUSH);
444 wxDELETE(wxLIGHT_GREY_BRUSH);
445
446 wxDELETE(wxBLACK);
447 wxDELETE(wxWHITE);
448 wxDELETE(wxRED);
449 wxDELETE(wxBLUE);
450 wxDELETE(wxGREEN);
451 wxDELETE(wxCYAN);
452 wxDELETE(wxLIGHT_GREY);
453
454 wxDELETE(wxSTANDARD_CURSOR);
455 wxDELETE(wxHOURGLASS_CURSOR);
456 wxDELETE(wxCROSS_CURSOR);
457 }
458
459 void wxDeleteStockLists() {
460 wxDELETE(wxTheBrushList);
461 wxDELETE(wxThePenList);
462 wxDELETE(wxTheFontList);
463 wxDELETE(wxTheBitmapList);
464 }
465
466 wxBitmapList::wxBitmapList ()
467 {
468 }
469
470 wxBitmapList::~wxBitmapList ()
471 {
472 wxNode *node = First ();
473 while (node)
474 {
475 wxBitmap *bitmap = (wxBitmap *) node->Data ();
476 wxNode *next = node->Next ();
477 if (bitmap->GetVisible())
478 delete bitmap;
479 node = next;
480 }
481 }
482
483 // Pen and Brush lists
484 wxPenList::~wxPenList ()
485 {
486 wxNode *node = First ();
487 while (node)
488 {
489 wxPen *pen = (wxPen *) node->Data ();
490 wxNode *next = node->Next ();
491 if (pen->GetVisible())
492 delete pen;
493 node = next;
494 }
495 }
496
497 void wxPenList::AddPen (wxPen * pen)
498 {
499 Append (pen);
500 }
501
502 void wxPenList::RemovePen (wxPen * pen)
503 {
504 DeleteObject (pen);
505 }
506
507 wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
508 {
509 for (wxNode * node = First (); node; node = node->Next ())
510 {
511 wxPen *each_pen = (wxPen *) node->Data ();
512 if (each_pen &&
513 each_pen->GetVisible() &&
514 each_pen->GetWidth () == width &&
515 each_pen->GetStyle () == style &&
516 each_pen->GetColour ().Red () == colour.Red () &&
517 each_pen->GetColour ().Green () == colour.Green () &&
518 each_pen->GetColour ().Blue () == colour.Blue ())
519 return each_pen;
520 }
521 wxPen *pen = new wxPen (colour, width, style);
522
523 // Yes, we can return a pointer to this in a later FindOrCreatePen call,
524 // because we created it within FindOrCreatePen. Safeguards against
525 // returning a pointer to an automatic variable and hanging on to it
526 // (dangling pointer).
527 pen->SetVisible(TRUE);
528
529 return pen;
530 }
531
532 wxBrushList::~wxBrushList ()
533 {
534 wxNode *node = First ();
535 while (node)
536 {
537 wxBrush *brush = (wxBrush *) node->Data ();
538 wxNode *next = node->Next ();
539 if (brush->GetVisible())
540 delete brush;
541 node = next;
542 }
543 }
544
545 void wxBrushList::AddBrush (wxBrush * brush)
546 {
547 Append (brush);
548 }
549
550 wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
551 {
552 for (wxNode * node = First (); node; node = node->Next ())
553 {
554 wxBrush *each_brush = (wxBrush *) node->Data ();
555 if (each_brush &&
556 each_brush->GetVisible() &&
557 each_brush->GetStyle () == style &&
558 each_brush->GetColour ().Red () == colour.Red () &&
559 each_brush->GetColour ().Green () == colour.Green () &&
560 each_brush->GetColour ().Blue () == colour.Blue ())
561 return each_brush;
562 }
563
564 // Yes, we can return a pointer to this in a later FindOrCreateBrush call,
565 // because we created it within FindOrCreateBrush. Safeguards against
566 // returning a pointer to an automatic variable and hanging on to it
567 // (dangling pointer).
568 wxBrush *brush = new wxBrush (colour, style);
569
570 brush->SetVisible(TRUE);
571
572 return brush;
573 }
574
575 void wxBrushList::RemoveBrush (wxBrush * brush)
576 {
577 DeleteObject (brush);
578 }
579
580 wxFontList::~wxFontList ()
581 {
582 wxNode *node = First ();
583 while (node)
584 {
585 // Only delete objects that are 'visible', i.e.
586 // that have been created using FindOrCreate...,
587 // where the pointers are expected to be shared
588 // (and therefore not deleted by any one part of an app).
589 wxFont *font = (wxFont *) node->Data ();
590 wxNode *next = node->Next ();
591 if (font->GetVisible())
592 delete font;
593 node = next;
594 }
595 }
596
597 void wxFontList::AddFont (wxFont * font)
598 {
599 Append (font);
600 }
601
602 void wxFontList::RemoveFont (wxFont * font)
603 {
604 DeleteObject (font);
605 }
606
607 wxFont *wxFontList::FindOrCreateFont(int pointSize,
608 int family,
609 int style,
610 int weight,
611 bool underline,
612 const wxString& facename,
613 wxFontEncoding encoding)
614 {
615 wxFont *font = (wxFont *)NULL;
616 wxNode *node;
617 for ( node = First(); node; node = node->Next() )
618 {
619 font = (wxFont *)node->Data();
620 if ( font->GetVisible() &&
621 font->Ok() &&
622 font->GetPointSize () == pointSize &&
623 font->GetStyle () == style &&
624 font->GetWeight () == weight &&
625 font->GetUnderlined () == underline )
626 {
627 int fontFamily = font->GetFamily();
628
629 #if defined(__WXGTK__)
630 // under GTK the default family is wxSWISS, so looking for a font
631 // with wxDEFAULT family should return a wxSWISS one instead of
632 // creating a new one
633 bool same = (fontFamily == family) ||
634 (fontFamily == wxSWISS && family == wxDEFAULT);
635 #else // !GTK
636 // VZ: but why elsewhere do we require an exact match? mystery...
637 bool same = fontFamily == family;
638 #endif // GTK/!GTK
639
640 // empty facename matches anything at all: this is bad because
641 // depending on which fonts are already created, we might get back
642 // a different font if we create it with empty facename, but it is
643 // still better than never matching anything in the cache at all
644 // in this case
645 if ( same && !!facename )
646 {
647 const wxString& fontFace = font->GetFaceName();
648
649 // empty facename matches everything
650 same = !fontFace || fontFace == facename;
651 }
652
653 if ( same && (encoding != wxFONTENCODING_DEFAULT) )
654 {
655 // have to match the encoding too
656 same = font->GetEncoding() == encoding;
657 }
658
659 if ( same )
660 {
661 return font;
662 }
663 }
664 }
665
666 if ( !node )
667 {
668 // font not found, create the new one
669 font = new wxFont(pointSize, family, style, weight,
670 underline, facename, encoding);
671
672 // and mark it as being cacheable
673 font->SetVisible(TRUE);
674 }
675
676 return font;
677 }
678
679 void wxBitmapList::AddBitmap(wxBitmap *bitmap)
680 {
681 Append(bitmap);
682 }
683
684 void wxBitmapList::RemoveBitmap(wxBitmap *bitmap)
685 {
686 DeleteObject(bitmap);
687 }
688
689 wxSize wxGetDisplaySize()
690 {
691 int x, y;
692 wxDisplaySize(& x, & y);
693 return wxSize(x, y);
694 }
695
696 wxSize wxGetDisplaySizeMM()
697 {
698 int x, y;
699 wxDisplaySizeMM(& x, & y);
700 return wxSize(x, y);
701 }
702
703 wxResourceCache::~wxResourceCache ()
704 {
705 wxNode *node = First ();
706 while (node) {
707 wxObject *item = (wxObject *)node->Data();
708 delete item;
709
710 node = node->Next ();
711 }
712 }
713