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