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