]> git.saurik.com Git - wxWidgets.git/blame - src/common/gdicmn.cpp
Removed USING_CONFIGURE define. As VZ pointed out, checking HAVE_CONFIG_H
[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
JS
92const wxRect& wxRect::operator += (const wxRect& rect)
93{
94 *this = (*this + rect);
95 return ( *this ) ;
96}
97
98wxRect wxRect::operator + (const wxRect& rect) const
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__
50920146
OK
147 {_T("AQUAMARINE"),112, 219, 147},
148 {_T("BLACK"),0, 0, 0},
149 {_T("BLUE"), 0, 0, 255},
150 {_T("BLUE VIOLET"), 159, 95, 159},
151 {_T("BROWN"), 165, 42, 42},
152 {_T("CADET BLUE"), 95, 159, 159},
153 {_T("CORAL"), 255, 127, 0},
154 {_T("CORNFLOWER BLUE"), 66, 66, 111},
155 {_T("CYAN"), 0, 255, 255},
156 {_T("DARK GREY"), 47, 47, 47}, // ?
157
158 {_T("DARK GREEN"), 47, 79, 47},
159 {_T("DARK OLIVE GREEN"), 79, 79, 47},
160 {_T("DARK ORCHID"), 153, 50, 204},
161 {_T("DARK SLATE BLUE"), 107, 35, 142},
162 {_T("DARK SLATE GREY"), 47, 79, 79},
163 {_T("DARK TURQUOISE"), 112, 147, 219},
164 {_T("DIM GREY"), 84, 84, 84},
165 {_T("FIREBRICK"), 142, 35, 35},
166 {_T("FOREST GREEN"), 35, 142, 35},
167 {_T("GOLD"), 204, 127, 50},
168 {_T("GOLDENROD"), 219, 219, 112},
169 {_T("GREY"), 128, 128, 128},
170 {_T("GREEN"), 0, 255, 0},
171 {_T("GREEN YELLOW"), 147, 219, 112},
172 {_T("INDIAN RED"), 79, 47, 47},
173 {_T("KHAKI"), 159, 159, 95},
174 {_T("LIGHT BLUE"), 191, 216, 216},
175 {_T("LIGHT GREY"), 192, 192, 192},
176 {_T("LIGHT STEEL BLUE"), 143, 143, 188},
177 {_T("LIME GREEN"), 50, 204, 50},
178 {_T("LIGHT MAGENTA"), 255, 0, 255},
179 {_T("MAGENTA"), 255, 0, 255},
180 {_T("MAROON"), 142, 35, 107},
181 {_T("MEDIUM AQUAMARINE"), 50, 204, 153},
182 {_T("MEDIUM GREY"), 100, 100, 100},
183 {_T("MEDIUM BLUE"), 50, 50, 204},
184 {_T("MEDIUM FOREST GREEN"), 107, 142, 35},
185 {_T("MEDIUM GOLDENROD"), 234, 234, 173},
186 {_T("MEDIUM ORCHID"), 147, 112, 219},
187 {_T("MEDIUM SEA GREEN"), 66, 111, 66},
188 {_T("MEDIUM SLATE BLUE"), 127, 0, 255},
189 {_T("MEDIUM SPRING GREEN"), 127, 255, 0},
190 {_T("MEDIUM TURQUOISE"), 112, 219, 219},
191 {_T("MEDIUM VIOLET RED"), 219, 112, 147},
192 {_T("MIDNIGHT BLUE"), 47, 47, 79},
193 {_T("NAVY"), 35, 35, 142},
194 {_T("ORANGE"), 204, 50, 50},
195 {_T("ORANGE RED"), 255, 0, 127},
196 {_T("ORCHID"), 219, 112, 219},
197 {_T("PALE GREEN"), 143, 188, 143},
198 {_T("PINK"), 188, 143, 234},
199 {_T("PLUM"), 234, 173, 234},
200 {_T("PURPLE"), 176, 0, 255},
201 {_T("RED"), 255, 0, 0},
202 {_T("SALMON"), 111, 66, 66},
203 {_T("SEA GREEN"), 35, 142, 107},
204 {_T("SIENNA"), 142, 107, 35},
205 {_T("SKY BLUE"), 50, 153, 204},
206 {_T("SLATE BLUE"), 0, 127, 255},
207 {_T("SPRING GREEN"), 0, 255, 127},
208 {_T("STEEL BLUE"), 35, 107, 142},
209 {_T("TAN"), 219, 147, 112},
210 {_T("THISTLE"), 216, 191, 216},
211 {_T("TURQUOISE"), 173, 234, 234},
212 {_T("VIOLET"), 79, 47, 79},
213 {_T("VIOLET RED"), 204, 50, 153},
214 {_T("WHEAT"), 216, 216, 191},
215 {_T("WHITE"), 255, 255, 255},
216 {_T("YELLOW"), 255, 255, 0},
217 {_T("YELLOW GREEN"), 153, 204, 50},
66bd6b93 218// #endif
c801d85f 219
2049ba38 220#if defined(__WXGTK__) || defined(__X__)
50920146
OK
221 {_T("MEDIUM GOLDENROD"), 234, 234, 173},
222 {_T("MEDIUM FOREST GREEN"), 107, 142, 35},
223 {_T("LIGHT MAGENTA"), 255, 0, 255},
224 {_T("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
259
34138703
JS
260// TODO for other implementations. This should really go into
261// platform-specific directories.
169935ad
SC
262#ifdef __WXMAC__
263 else return NULL;
264#endif
34138703
JS
265#ifdef __WXSTUBS__
266 else return NULL;
267#endif
268
2049ba38 269#ifdef __WXGTK__
c801d85f
KB
270 else {
271 wxColour *col = new wxColour( colour );
8bbe427f 272
c801d85f
KB
273 if (!(col->Ok())) {
274 delete col;
c67daf87 275 return (wxColour *) NULL;
c801d85f
KB
276 }
277 Append( colour, col );
278 return col;
279 }
280#endif
281
282#ifdef __X__
283 else {
284 XColor xcolour;
285
2049ba38 286#ifdef __WXMOTIF__
46ccb510 287 Display *display = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()) ;
c801d85f 288#endif
1c4a764c
VZ
289#ifdef __XVIEW__
290 Xv_Screen screen = xv_get(xview_server, SERVER_NTH_SCREEN, 0);
291 Xv_opaque root_window = xv_get(screen, XV_ROOT);
292 Display *display = (Display *)xv_get(root_window, XV_DISPLAY);
293#endif
c801d85f
KB
294
295 /* MATTHEW: [4] Use wxGetMainColormap */
46ccb510 296 if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour,&xcolour))
c801d85f
KB
297 return NULL;
298
299 unsigned char r = (unsigned char)(xcolour.red >> 8);
300 unsigned char g = (unsigned char)(xcolour.green >> 8);
301 unsigned char b = (unsigned char)(xcolour.blue >> 8);
302
303 wxColour *col = new wxColour(r, g, b);
304 Append(colour, col);
305
306 return col;
307 }
308#endif
309}
310
311wxString wxColourDatabase::FindName (const wxColour& colour) const
312{
a23fd0e1 313 wxString name;
8bbe427f 314
a23fd0e1
VZ
315 unsigned char red = colour.Red ();
316 unsigned char green = colour.Green ();
317 unsigned char blue = colour.Blue ();
8bbe427f 318
a23fd0e1
VZ
319 for (wxNode * node = First (); node; node = node->Next ())
320 {
321 wxColour *col = (wxColour *) node->Data ();
322
323 if (col->Red () == red && col->Green () == green && col->Blue () == blue)
8bbe427f 324 {
a23fd0e1
VZ
325 const wxChar *found = node->GetKeyString();
326 if ( found )
327 {
328 name = found;
329
330 break;
331 }
8bbe427f 332 }
a23fd0e1 333 }
c801d85f 334
a23fd0e1 335 return name;
c801d85f
KB
336}
337
a3622daa 338void wxInitializeStockLists () {
c801d85f
KB
339 wxTheBrushList = new wxBrushList;
340 wxThePenList = new wxPenList;
341 wxTheFontList = new wxFontList;
342 wxTheBitmapList = new wxBitmapList;
a3622daa 343}
c801d85f 344
a3622daa
VZ
345void wxInitializeStockObjects ()
346{
2049ba38 347#ifdef __WXMOTIF__
c801d85f
KB
348#endif
349#ifdef __X__
46ccb510
JS
350 // TODO
351 // wxFontPool = new XFontPool;
c801d85f
KB
352#endif
353
354 wxNORMAL_FONT = new wxFont (12, wxMODERN, wxNORMAL, wxNORMAL);
355 wxSMALL_FONT = new wxFont (10, wxSWISS, wxNORMAL, wxNORMAL);
356 wxITALIC_FONT = new wxFont (12, wxROMAN, wxITALIC, wxNORMAL);
357 wxSWISS_FONT = new wxFont (12, wxSWISS, wxNORMAL, wxNORMAL);
358
359 wxRED_PEN = new wxPen ("RED", 1, wxSOLID);
360 wxCYAN_PEN = new wxPen ("CYAN", 1, wxSOLID);
361 wxGREEN_PEN = new wxPen ("GREEN", 1, wxSOLID);
362 wxBLACK_PEN = new wxPen ("BLACK", 1, wxSOLID);
363 wxWHITE_PEN = new wxPen ("WHITE", 1, wxSOLID);
364 wxTRANSPARENT_PEN = new wxPen ("BLACK", 1, wxTRANSPARENT);
365 wxBLACK_DASHED_PEN = new wxPen ("BLACK", 1, wxSHORT_DASH);
366 wxGREY_PEN = new wxPen ("GREY", 1, wxSOLID);
367 wxMEDIUM_GREY_PEN = new wxPen ("MEDIUM GREY", 1, wxSOLID);
368 wxLIGHT_GREY_PEN = new wxPen ("LIGHT GREY", 1, wxSOLID);
369
370 wxBLUE_BRUSH = new wxBrush ("BLUE", wxSOLID);
371 wxGREEN_BRUSH = new wxBrush ("GREEN", wxSOLID);
372 wxWHITE_BRUSH = new wxBrush ("WHITE", wxSOLID);
373 wxBLACK_BRUSH = new wxBrush ("BLACK", wxSOLID);
374 wxTRANSPARENT_BRUSH = new wxBrush ("BLACK", wxTRANSPARENT);
375 wxCYAN_BRUSH = new wxBrush ("CYAN", wxSOLID);
376 wxRED_BRUSH = new wxBrush ("RED", wxSOLID);
377 wxGREY_BRUSH = new wxBrush ("GREY", wxSOLID);
378 wxMEDIUM_GREY_BRUSH = new wxBrush ("MEDIUM GREY", wxSOLID);
379 wxLIGHT_GREY_BRUSH = new wxBrush ("LIGHT GREY", wxSOLID);
380
381 wxBLACK = new wxColour ("BLACK");
382 wxWHITE = new wxColour ("WHITE");
383 wxRED = new wxColour ("RED");
384 wxBLUE = new wxColour ("BLUE");
385 wxGREEN = new wxColour ("GREEN");
386 wxCYAN = new wxColour ("CYAN");
387 wxLIGHT_GREY = new wxColour ("LIGHT GREY");
388
389 wxSTANDARD_CURSOR = new wxCursor (wxCURSOR_ARROW);
390 wxHOURGLASS_CURSOR = new wxCursor (wxCURSOR_WAIT);
391 wxCROSS_CURSOR = new wxCursor (wxCURSOR_CROSS);
392}
393
8bbe427f 394void wxDeleteStockObjects ()
c801d85f 395{
a3622daa
VZ
396 wxDELETE(wxNORMAL_FONT);
397 wxDELETE(wxSMALL_FONT);
398 wxDELETE(wxITALIC_FONT);
399 wxDELETE(wxSWISS_FONT);
400
401 wxDELETE(wxRED_PEN);
402 wxDELETE(wxCYAN_PEN);
403 wxDELETE(wxGREEN_PEN);
404 wxDELETE(wxBLACK_PEN);
405 wxDELETE(wxWHITE_PEN);
406 wxDELETE(wxTRANSPARENT_PEN);
407 wxDELETE(wxBLACK_DASHED_PEN);
408 wxDELETE(wxGREY_PEN);
409 wxDELETE(wxMEDIUM_GREY_PEN);
410 wxDELETE(wxLIGHT_GREY_PEN);
411
412 wxDELETE(wxBLUE_BRUSH);
413 wxDELETE(wxGREEN_BRUSH);
414 wxDELETE(wxWHITE_BRUSH);
415 wxDELETE(wxBLACK_BRUSH);
416 wxDELETE(wxTRANSPARENT_BRUSH);
417 wxDELETE(wxCYAN_BRUSH);
418 wxDELETE(wxRED_BRUSH);
419 wxDELETE(wxGREY_BRUSH);
420 wxDELETE(wxMEDIUM_GREY_BRUSH);
421 wxDELETE(wxLIGHT_GREY_BRUSH);
422
423 wxDELETE(wxBLACK);
424 wxDELETE(wxWHITE);
425 wxDELETE(wxRED);
426 wxDELETE(wxBLUE);
427 wxDELETE(wxGREEN);
428 wxDELETE(wxCYAN);
429 wxDELETE(wxLIGHT_GREY);
430
431 wxDELETE(wxSTANDARD_CURSOR);
432 wxDELETE(wxHOURGLASS_CURSOR);
433 wxDELETE(wxCROSS_CURSOR);
434}
435
436void wxDeleteStockLists() {
437 wxDELETE(wxTheBrushList);
438 wxDELETE(wxThePenList);
439 wxDELETE(wxTheFontList);
440 wxDELETE(wxTheBitmapList);
c801d85f
KB
441}
442
6a6c0a8b 443wxBitmapList::wxBitmapList ()
c801d85f
KB
444{
445}
446
6a6c0a8b 447wxBitmapList::~wxBitmapList ()
c801d85f 448{
7fe7d506 449#if defined(__WXMSW__) || defined(__WXMOTIF__)
c801d85f
KB
450 wxNode *node = First ();
451 while (node)
452 {
453 wxBitmap *bitmap = (wxBitmap *) node->Data ();
454 wxNode *next = node->Next ();
4c444f19
JS
455 if (bitmap->GetVisible())
456 delete bitmap;
c801d85f
KB
457 node = next;
458 }
4c444f19 459#endif
c801d85f
KB
460}
461
462// Pen and Brush lists
6a6c0a8b 463wxPenList::~wxPenList ()
c801d85f 464{
7fe7d506 465#if defined(__WXMSW__) || defined(__WXMOTIF__)
c801d85f
KB
466 wxNode *node = First ();
467 while (node)
468 {
469 wxPen *pen = (wxPen *) node->Data ();
470 wxNode *next = node->Next ();
4c444f19
JS
471 if (pen->GetVisible())
472 delete pen;
c801d85f
KB
473 node = next;
474 }
4c444f19 475#endif
c801d85f
KB
476}
477
478void wxPenList::AddPen (wxPen * pen)
479{
480 Append (pen);
481}
482
483void wxPenList::RemovePen (wxPen * pen)
484{
485 DeleteObject (pen);
486}
487
debe6624 488wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
c801d85f
KB
489{
490 for (wxNode * node = First (); node; node = node->Next ())
491 {
492 wxPen *each_pen = (wxPen *) node->Data ();
493 if (each_pen && each_pen->GetVisible() &&
8bbe427f
VZ
494 each_pen->GetWidth () == width &&
495 each_pen->GetStyle () == style &&
496 each_pen->GetColour ().Red () == colour.Red () &&
497 each_pen->GetColour ().Green () == colour.Green () &&
498 each_pen->GetColour ().Blue () == colour.Blue ())
499 return each_pen;
c801d85f
KB
500 }
501 wxPen *pen = new wxPen (colour, width, style);
502
503 // Yes, we can return a pointer to this in a later FindOrCreatePen call,
504 // because we created it within FindOrCreatePen. Safeguards against
505 // returning a pointer to an automatic variable and hanging on to it
506 // (dangling pointer).
507 pen->SetVisible(TRUE);
508 return pen;
509}
510
6a6c0a8b 511wxBrushList::~wxBrushList ()
c801d85f 512{
7fe7d506 513#if defined(__WXMSW__) || defined(__WXMOTIF__)
c801d85f
KB
514 wxNode *node = First ();
515 while (node)
516 {
517 wxBrush *brush = (wxBrush *) node->Data ();
518 wxNode *next = node->Next ();
4c444f19
JS
519 if (brush->GetVisible())
520 delete brush;
c801d85f
KB
521 node = next;
522 }
4c444f19 523#endif
c801d85f
KB
524}
525
526void wxBrushList::AddBrush (wxBrush * brush)
527{
528 Append (brush);
529}
530
debe6624 531wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
c801d85f
KB
532{
533 for (wxNode * node = First (); node; node = node->Next ())
534 {
535 wxBrush *each_brush = (wxBrush *) node->Data ();
536 if (each_brush && each_brush->GetVisible() &&
8bbe427f
VZ
537 each_brush->GetStyle () == style &&
538 each_brush->GetColour ().Red () == colour.Red () &&
539 each_brush->GetColour ().Green () == colour.Green () &&
540 each_brush->GetColour ().Blue () == colour.Blue ())
541 return each_brush;
c801d85f
KB
542 }
543 // Yes, we can return a pointer to this in a later FindOrCreateBrush call,
544 // because we created it within FindOrCreateBrush. Safeguards against
545 // returning a pointer to an automatic variable and hanging on to it
546 // (dangling pointer).
547 wxBrush *brush = new wxBrush (colour, style);
548 brush->SetVisible(TRUE);
549 return brush;
550}
551
c801d85f
KB
552void wxBrushList::RemoveBrush (wxBrush * brush)
553{
554 DeleteObject (brush);
555}
556
6a6c0a8b 557wxFontList::~wxFontList ()
c801d85f 558{
c801d85f
KB
559 wxNode *node = First ();
560 while (node)
561 {
8bbe427f
VZ
562 // Only delete objects that are 'visible', i.e.
563 // that have been created using FindOrCreate...,
564 // where the pointers are expected to be shared
565 // (and therefore not deleted by any one part of an app).
c801d85f
KB
566 wxFont *font = (wxFont *) node->Data ();
567 wxNode *next = node->Next ();
8bbe427f
VZ
568 if (font->GetVisible())
569 delete font;
c801d85f 570 node = next;
4c444f19 571}
c801d85f
KB
572}
573
574void wxFontList::AddFont (wxFont * font)
575{
576 Append (font);
577}
578
579void wxFontList::RemoveFont (wxFont * font)
580{
581 DeleteObject (font);
582}
583
584wxFont *wxFontList::
8bbe427f 585 FindOrCreateFont (int PointSize, int FamilyOrFontId, int Style, int Weight, bool underline, const wxString& Face)
c801d85f
KB
586{
587 for (wxNode * node = First (); node; node = node->Next ())
588 {
589 wxFont *each_font = (wxFont *) node->Data ();
590 if (each_font && each_font->GetVisible() && each_font->Ok() &&
8bbe427f
VZ
591 each_font->GetPointSize () == PointSize &&
592 each_font->GetStyle () == Style &&
593 each_font->GetWeight () == Weight &&
594 each_font->GetUnderlined () == underline &&
595 //#if defined(__X__)
596 // each_font->GetFontId () == FamilyOrFontId) /* New font system */
597 //#else
598 each_font->GetFamily () == FamilyOrFontId &&
d0bdc3ca 599 ((each_font->GetFaceName() == _T("")) || each_font->GetFaceName() == Face))
8bbe427f
VZ
600 //#endif
601 return each_font;
c801d85f
KB
602 }
603 wxFont *font = new wxFont (PointSize, FamilyOrFontId, Style, Weight, underline, Face);
604 font->SetVisible(TRUE);
605 return font;
606}
607
608void wxBitmapList::AddBitmap(wxBitmap *bitmap)
8bbe427f
VZ
609{
610 Append(bitmap);
611}
612
c801d85f 613void wxBitmapList::RemoveBitmap(wxBitmap *bitmap)
8bbe427f
VZ
614{
615 DeleteObject(bitmap);
616}
c801d85f 617
6a6c0a8b
JS
618wxSize wxGetDisplaySize()
619{
620 int x, y;
621 wxDisplaySize(& x, & y);
622 return wxSize(x, y);
623}
624
8bbe427f
VZ
625wxResourceCache::~wxResourceCache ()
626{
a3622daa
VZ
627 wxNode *node = First ();
628 while (node) {
629 wxGDIObject *item = (wxGDIObject *)node->Data();
630 if (item->IsKindOf(CLASSINFO(wxBrush))) {
631 wxBrush *brush = (wxBrush *)item;
632 delete brush;
633 }
634
635 if (item->IsKindOf(CLASSINFO(wxFont))) {
636 wxFont *font = (wxFont *)item;
637 delete font;
638 }
639
640 if (item->IsKindOf(CLASSINFO(wxBitmap))) {
641 wxBitmap *bitmap = (wxBitmap *)item;
642 delete bitmap;
643 }
644
645 if (item->IsKindOf(CLASSINFO(wxColour))) {
646 wxColour *colour = (wxColour *)item;
647 delete colour;
648 }
649
650 wxNode *next = node->Next ();
651 node = next;
652 }
653}
654