]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/gdicmn.cpp
Added some standard further identifiers to help with WinCE toolbars
[wxWidgets.git] / src / common / gdicmn.cpp
index 2c62bcefdad4c750685e71b1cc3285fad4896aff..4762e5b5f85275429d506c729e39c942a7bc40fc 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/dc.h"
 #include "wx/utils.h"
 #include "wx/settings.h"
+#include "wx/hashmap.h"
 
 #include "wx/log.h"
 #include <string.h>
 
 #ifdef __WXMSW__
-#include <windows.h>
+#include "wx/msw/wrapwin.h"
 #endif
 
 #ifdef __WXMOTIF__
 #endif
 #endif
 
-IMPLEMENT_CLASS(wxColourDatabase, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
-IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
+#ifdef __WXX11__
+#include "X11/Xlib.h"
+#endif
+
+#ifdef __WXMAC__
+#include "wx/mac/private.h"
+#include "wx/mac/uma.h"
+#endif
+//IMPLEMENT_CLASS(wxColourDatabase, wxList)
+//IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
+//IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
+//IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
+//IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
+//IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
 
 IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject)
 
@@ -113,6 +122,29 @@ wxRect wxRect::operator + (const wxRect& rect) const
     return wxRect(x1, y1, x2-x1, y2-y1);
 }
 
+wxRect& wxRect::Inflate(wxCoord dx, wxCoord dy)
+{
+    x -= dx;
+    y -= dy;
+    width += 2*dx;
+    height += 2*dy;
+
+    // check that we didn't make the rectangle invalid by accident (you almost
+    // never want to have negative coords and never want negative size)
+    if ( x < 0 )
+        x = 0;
+    if ( y < 0 )
+        y = 0;
+
+    // what else can we do?
+    if ( width < 0 )
+        width = 0;
+    if ( height < 0 )
+        height = 0;
+
+    return *this;
+}
+
 bool wxRect::Inside(int cx, int cy) const
 {
     return ( (cx >= x) && (cy >= y)
@@ -121,21 +153,53 @@ bool wxRect::Inside(int cx, int cy) const
           );
 }
 
-wxColourDatabase::wxColourDatabase (int type) : wxList (type)
+wxRect& wxRect::Intersect(const wxRect& rect)
+{
+    int x2 = GetRight(),
+        y2 = GetBottom();
+
+    if ( x < rect.x )
+        x = rect.x;
+    if ( y < rect.y )
+        y = rect.y;
+    if ( x2 > rect.GetRight() )
+        x2 = rect.GetRight();
+    if ( y2 > rect.GetBottom() )
+        y2 = rect.GetBottom();
+
+    width = x2 - x + 1;
+    height = y2 - y + 1;
+
+    if ( width <= 0 || height <= 0 )
+    {
+        width =
+        height = 0;
+    }
+
+    return *this;
+}
+
+bool wxRect::Intersects(const wxRect& rect) const
+{
+    wxRect r = Intersect(rect);
+
+    // if there is no intersection, both width and height are 0
+    return r.width != 0;
+}
+
+WX_DECLARE_STRING_HASH_MAP( wxColour*, wxStringToColourHashMap );
+
+wxColourDatabase::wxColourDatabase ()
 {
+    m_map = new wxStringToColourHashMap;
 }
 
 wxColourDatabase::~wxColourDatabase ()
 {
-  // Cleanup Colour allocated in Initialize()
-  wxNode *node = First ();
-  while (node)
-    {
-      wxColour *col = (wxColour *) node->Data ();
-      wxNode *next = node->Next ();
-      delete col;
-      node = next;
-    }
+    WX_CLEAR_HASH_MAP(wxStringToColourHashMap, *m_map);
+
+    delete m_map;
+    m_map = NULL;
 #ifdef __WXPM__
     delete [] m_palTable;
 #endif
@@ -144,6 +208,8 @@ wxColourDatabase::~wxColourDatabase ()
 // Colour database stuff
 void wxColourDatabase::Initialize ()
 {
+    // these colour definitions are taken from X consortium definitions with a
+    // few more colours added
     static const struct wxColourDesc
     {
         const wxChar *name;
@@ -151,81 +217,76 @@ void wxColourDatabase::Initialize ()
     }
     wxColourTable[] =
     {
-        {wxT("AQUAMARINE"),112, 219, 147},
+        {wxT("AQUAMARINE"),127, 255, 212},
         {wxT("BLACK"),0, 0, 0},
         {wxT("BLUE"), 0, 0, 255},
-        {wxT("BLUE VIOLET"), 159, 95, 159},
+        {wxT("BLUE VIOLET"), 138, 43, 226},
         {wxT("BROWN"), 165, 42, 42},
-        {wxT("CADET BLUE"), 95, 159, 159},
-        {wxT("CORAL"), 255, 127, 0},
-        {wxT("CORNFLOWER BLUE"), 66, 66, 111},
+        {wxT("CADET BLUE"), 95, 158, 160},
+        {wxT("CORAL"), 255, 127, 80},
+        {wxT("CORNFLOWER BLUE"), 100, 149, 237},
         {wxT("CYAN"), 0, 255, 255},
-        {wxT("DARK GREY"), 47, 47, 47},   // ?
-
-        {wxT("DARK GREEN"), 47, 79, 47},
-        {wxT("DARK OLIVE GREEN"), 79, 79, 47},
+        {wxT("DARK GREY"), 169, 169, 169},
+        {wxT("DARK GREEN"), 0, 100, 0},
+        {wxT("DARK OLIVE GREEN"), 85, 107, 47},
         {wxT("DARK ORCHID"), 153, 50, 204},
-        {wxT("DARK SLATE BLUE"), 107, 35, 142},
+        {wxT("DARK SLATE BLUE"), 72, 61, 139},
         {wxT("DARK SLATE GREY"), 47, 79, 79},
-        {wxT("DARK TURQUOISE"), 112, 147, 219},
-        {wxT("DIM GREY"), 84, 84, 84},
-        {wxT("FIREBRICK"), 142, 35, 35},
-        {wxT("FOREST GREEN"), 35, 142, 35},
-        {wxT("GOLD"), 204, 127, 50},
-        {wxT("GOLDENROD"), 219, 219, 112},
-        {wxT("GREY"), 128, 128, 128},
+        {wxT("DARK TURQUOISE"), 0, 206, 209},
+        {wxT("DIM GREY"), 105, 105, 105},
+        {wxT("FIREBRICK"), 178, 34, 34},
+        {wxT("FOREST GREEN"), 34, 139, 34},
+        {wxT("GOLD"), 255, 215, 0},
+        {wxT("GOLDENROD"), 218, 165, 32},
+        {wxT("GREY"), 190, 190, 190},
         {wxT("GREEN"), 0, 255, 0},
-        {wxT("GREEN YELLOW"), 147, 219, 112},
-        {wxT("INDIAN RED"), 79, 47, 47},
-        {wxT("KHAKI"), 159, 159, 95},
-        {wxT("LIGHT BLUE"), 191, 216, 216},
-        {wxT("LIGHT GREY"), 192, 192, 192},
-        {wxT("LIGHT STEEL BLUE"), 143, 143, 188},
-        {wxT("LIME GREEN"), 50, 204, 50},
-        {wxT("LIGHT MAGENTA"), 255, 0, 255},
+        {wxT("GREEN YELLOW"), 173, 255, 47},
+        {wxT("INDIAN RED"), 205, 92, 92},
+        {wxT("KHAKI"), 240, 230, 140},
+        {wxT("LIGHT BLUE"), 173, 216, 230},
+        {wxT("LIGHT GREY"), 211, 211, 211},
+        {wxT("LIGHT STEEL BLUE"), 176, 196, 222},
+        {wxT("LIME GREEN"), 50, 205, 50},
+        {wxT("LIGHT MAGENTA"), 255, 0, 255}, // not X colour
         {wxT("MAGENTA"), 255, 0, 255},
-        {wxT("MAROON"), 142, 35, 107},
-        {wxT("MEDIUM AQUAMARINE"), 50, 204, 153},
-        {wxT("MEDIUM GREY"), 100, 100, 100},
-        {wxT("MEDIUM BLUE"), 50, 50, 204},
-        {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
-        {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
-        {wxT("MEDIUM ORCHID"), 147, 112, 219},
-        {wxT("MEDIUM SEA GREEN"), 66, 111, 66},
-        {wxT("MEDIUM SLATE BLUE"), 127, 0, 255},
-        {wxT("MEDIUM SPRING GREEN"), 127, 255, 0},
-        {wxT("MEDIUM TURQUOISE"), 112, 219, 219},
-        {wxT("MEDIUM VIOLET RED"), 219, 112, 147},
-        {wxT("MIDNIGHT BLUE"), 47, 47, 79},
-        {wxT("NAVY"), 35, 35, 142},
-        {wxT("ORANGE"), 204, 50, 50},
-        {wxT("ORANGE RED"), 255, 0, 127},
-        {wxT("ORCHID"), 219, 112, 219},
-        {wxT("PALE GREEN"), 143, 188, 143},
-        {wxT("PINK"), 188, 143, 234},
-        {wxT("PLUM"), 234, 173, 234},
-        {wxT("PURPLE"), 176, 0, 255},
+        {wxT("MAROON"), 176, 48, 96},
+        {wxT("MEDIUM AQUAMARINE"), 102, 205, 170},
+        {wxT("MEDIUM GREY"), 100, 100, 100}, // not X colour
+        {wxT("MEDIUM BLUE"), 0, 0, 205},
+        {wxT("MEDIUM FOREST GREEN"), 107, 142, 35}, // not X colour
+        {wxT("MEDIUM GOLDENROD"), 234, 234, 173}, // not X colour
+        {wxT("MEDIUM ORCHID"), 186, 85, 211},
+        {wxT("MEDIUM SEA GREEN"), 60, 179, 113},
+        {wxT("MEDIUM SLATE BLUE"), 123, 104, 238},
+        {wxT("MEDIUM SPRING GREEN"), 0, 250, 154},
+        {wxT("MEDIUM TURQUOISE"), 72, 209, 204},
+        {wxT("MEDIUM VIOLET RED"), 199, 21, 133},
+        {wxT("MIDNIGHT BLUE"), 25, 25, 112},
+        {wxT("NAVY"), 0, 0, 128},
+        {wxT("ORANGE"), 255, 165, 0},
+        {wxT("ORANGE RED"), 255, 69, 0},
+        {wxT("ORCHID"), 218, 112, 214},
+        {wxT("PALE GREEN"), 152, 251, 152},
+        {wxT("PINK"), 255, 192, 203},
+        {wxT("PLUM"), 221, 160, 221},
+        {wxT("PURPLE"), 160, 32, 240},
         {wxT("RED"), 255, 0, 0},
-        {wxT("SALMON"), 111, 66, 66},
-        {wxT("SEA GREEN"), 35, 142, 107},
-        {wxT("SIENNA"), 142, 107, 35},
-        {wxT("SKY BLUE"), 50, 153, 204},
-        {wxT("SLATE BLUE"), 0, 127, 255},
+        {wxT("SALMON"), 250, 128, 114},
+        {wxT("SEA GREEN"), 46, 139, 87},
+        {wxT("SIENNA"), 160, 82, 45},
+        {wxT("SKY BLUE"), 135, 206, 235},
+        {wxT("SLATE BLUE"), 106, 90, 205},
         {wxT("SPRING GREEN"), 0, 255, 127},
-        {wxT("STEEL BLUE"), 35, 107, 142},
-        {wxT("TAN"), 219, 147, 112},
+        {wxT("STEEL BLUE"), 70, 130, 180},
+        {wxT("TAN"), 210, 180, 140},
         {wxT("THISTLE"), 216, 191, 216},
-        {wxT("TURQUOISE"), 173, 234, 234},
-        {wxT("VIOLET"), 79, 47, 79},
-        {wxT("VIOLET RED"), 204, 50, 153},
-        {wxT("WHEAT"), 216, 216, 191},
+        {wxT("TURQUOISE"), 64, 224, 208},
+        {wxT("VIOLET"), 238, 130, 238},
+        {wxT("VIOLET RED"), 208, 32, 144},
+        {wxT("WHEAT"), 245, 222, 179},
         {wxT("WHITE"), 255, 255, 255},
         {wxT("YELLOW"), 255, 255, 0},
-        {wxT("YELLOW GREEN"), 153, 204, 50},
-        {wxT("MEDIUM GOLDENROD"), 234, 234, 173},
-        {wxT("MEDIUM FOREST GREEN"), 107, 142, 35},
-        {wxT("LIGHT MAGENTA"), 255, 0, 255},
-        {wxT("MEDIUM GREY"), 100, 100, 100},
+        {wxT("YELLOW GREEN"), 154, 205, 50},
     };
 
     size_t      n;
@@ -233,7 +294,7 @@ void wxColourDatabase::Initialize ()
     for ( n = 0; n < WXSIZEOF(wxColourTable); n++ )
     {
         const wxColourDesc& cc = wxColourTable[n];
-        Append(cc.name, new wxColour(cc.r,cc.g,cc.b));
+        AddColour(cc.name, new wxColour(cc.r,cc.g,cc.b));
     }
 #ifdef __WXPM__
     m_palTable = new long[n];
@@ -256,6 +317,36 @@ void wxColourDatabase::Initialize ()
  */
 
 wxColour *wxColourDatabase::FindColour(const wxString& colour)
+{
+    return FindColour(colour, true);
+}
+
+wxColour *wxColourDatabase::FindColourNoAdd(const wxString& colour) const
+{
+    return ((wxColourDatabase*)this)->FindColour(colour, false);
+}
+
+void wxColourDatabase::AddColour (const wxString& name, wxColour* colour)
+{
+    wxString colName = name;
+    colName.MakeUpper();
+    wxString colName2 = colName;
+    if ( !colName2.Replace(_T("GRAY"), _T("GREY")) )
+        colName2.clear();
+
+    wxStringToColourHashMap::iterator it = m_map->find(colName);
+    if ( it == m_map->end() )
+        it = m_map->find(colName2);
+    if ( it != m_map->end() )
+    {
+        delete it->second;
+        it->second = colour;
+    }
+
+    (*m_map)[name] = colour;
+}
+
+wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add)
 {
     // VZ: make the comparaison case insensitive and also match both grey and
     //     gray
@@ -265,17 +356,14 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
     if ( !colName2.Replace(_T("GRAY"), _T("GREY")) )
         colName2.clear();
 
-    wxNode *node = First();
-    while ( node )
-    {
-        const wxChar *key = node->GetKeyString();
-        if ( colName == key || colName2 == key )
-        {
-            return (wxColour *)node->Data();
-        }
+    wxStringToColourHashMap::iterator it = m_map->find(colName);
+    if ( it == m_map->end() )
+        it = m_map->find(colName2);
+    if ( it != m_map->end() )
+        return it->second;
 
-        node = node->Next();
-    }
+    if ( !add )
+        return NULL;
 
 #ifdef __WXMSW__
   return NULL;
@@ -283,12 +371,18 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
 #ifdef __WXPM__
   return NULL;
 #endif
+#ifdef __WXMGL__
+  return NULL;
+#endif
 
 // TODO for other implementations. This should really go into
 // platform-specific directories.
 #ifdef __WXMAC__
   return NULL;
 #endif
+#ifdef __WXCOCOA__
+  return NULL;
+#endif
 #ifdef __WXSTUBS__
   return NULL;
 #endif
@@ -296,11 +390,12 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
 #ifdef __WXGTK__
   wxColour *col = new wxColour( colour );
 
-  if (!(col->Ok())) {
+  if (!(col->Ok()))
+  {
       delete col;
       return (wxColour *) NULL;
   }
-  Append( colour, col );
+  AddColour(colour, col);
   return col;
 #endif
 
@@ -310,22 +405,25 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
 #ifdef __WXMOTIF__
     Display *display = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()) ;
 #endif
-#ifdef __XVIEW__
-    Xv_Screen screen = xv_get(xview_server, SERVER_NTH_SCREEN, 0);
-    Xv_opaque root_window = xv_get(screen, XV_ROOT);
-    Display *display = (Display *)xv_get(root_window, XV_DISPLAY);
+#ifdef __WXX11__
+    Display* display = (Display*) wxGetDisplay();
 #endif
-
     /* MATTHEW: [4] Use wxGetMainColormap */
-    if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour,&xcolour))
+    if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour.ToAscii() ,&xcolour))
       return NULL;
 
+#if wxUSE_NANOX
+    unsigned char r = (unsigned char)(xcolour.red);
+    unsigned char g = (unsigned char)(xcolour.green);
+    unsigned char b = (unsigned char)(xcolour.blue);
+#else
     unsigned char r = (unsigned char)(xcolour.red >> 8);
     unsigned char g = (unsigned char)(xcolour.green >> 8);
     unsigned char b = (unsigned char)(xcolour.blue >> 8);
+#endif
 
     wxColour *col = new wxColour(r, g, b);
-    Append(colour, col);
+    AddColour(colour, col);
 
     return col;
 #endif // __X__
@@ -333,36 +431,32 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
 
 wxString wxColourDatabase::FindName (const wxColour& colour) const
 {
-    wxString name;
-
     unsigned char red = colour.Red ();
     unsigned char green = colour.Green ();
     unsigned char blue = colour.Blue ();
 
-    for (wxNode * node = First (); node; node = node->Next ())
+    typedef wxStringToColourHashMap::iterator iterator;
+
+    for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it )
     {
-        wxColour *col = (wxColour *) node->Data ();
+        wxColour *col = it->second;
 
         if (col->Red () == red && col->Green () == green && col->Blue () == blue)
-        {
-            const wxChar *found = node->GetKeyString();
-            if ( found )
-            {
-                name = found;
-
-                break;
-            }
-        }
+            return it->first;
     }
 
-    return name;
+    return wxEmptyString;
 }
 
-void wxInitializeStockLists () {
-  wxTheBrushList = new wxBrushList;
-  wxThePenList = new wxPenList;
-  wxTheFontList = new wxFontList;
-  wxTheBitmapList = new wxBitmapList;
+void wxInitializeStockLists()
+{
+    wxTheColourDatabase = new wxColourDatabase;
+    wxTheColourDatabase->Initialize();
+
+    wxTheBrushList = new wxBrushList;
+    wxThePenList = new wxPenList;
+    wxTheFontList = new wxFontList;
+    wxTheBitmapList = new wxBitmapList;
 }
 
 void wxInitializeStockObjects ()
@@ -381,47 +475,72 @@ void wxInitializeStockObjects ()
 #else
 #endif
 */
-#if defined(__WXPM__) || defined(__WXMAC__)
+#if defined(__WXMAC__)
+    int sizeFont = 12;
+
+    Str255 fontName ;
+    SInt16 fontSize ;
+    Style fontStyle ;
+
+       GetThemeFont(kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+       sizeFont = fontSize ;
+    wxSWISS_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal(fontName) );
+#elif defined(__WXPM__)
   static const int sizeFont = 12;
-  wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL);
 #else
-  wxNORMAL_FONT = new wxFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+  wxNORMAL_FONT = new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
   static const int sizeFont = wxNORMAL_FONT->GetPointSize();
 #endif
 
+#if defined(__WXPM__)
+  /*
+  // Basic OS/2 has a fairly limited number of fonts and these are as good
+  // as I can do to get something that looks halfway "wx" normal
+  */
+  wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxBOLD);
+  wxSMALL_FONT = new wxFont (sizeFont - 4, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */
+  wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
+  wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */
+#elif defined(__WXMAC__)
+    wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL);
+    wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
+       GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+    wxSMALL_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) );
+#else
   wxSMALL_FONT = new wxFont (sizeFont - 2, wxSWISS, wxNORMAL, wxNORMAL);
   wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
   wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL);
+#endif
 
-  wxRED_PEN = new wxPen ("RED", 1, wxSOLID);
-  wxCYAN_PEN = new wxPen ("CYAN", 1, wxSOLID);
-  wxGREEN_PEN = new wxPen ("GREEN", 1, wxSOLID);
-  wxBLACK_PEN = new wxPen ("BLACK", 1, wxSOLID);
-  wxWHITE_PEN = new wxPen ("WHITE", 1, wxSOLID);
-  wxTRANSPARENT_PEN = new wxPen ("BLACK", 1, wxTRANSPARENT);
-  wxBLACK_DASHED_PEN = new wxPen ("BLACK", 1, wxSHORT_DASH);
-  wxGREY_PEN = new wxPen ("GREY", 1, wxSOLID);
-  wxMEDIUM_GREY_PEN = new wxPen ("MEDIUM GREY", 1, wxSOLID);
-  wxLIGHT_GREY_PEN = new wxPen ("LIGHT GREY", 1, wxSOLID);
-
-  wxBLUE_BRUSH = new wxBrush ("BLUE", wxSOLID);
-  wxGREEN_BRUSH = new wxBrush ("GREEN", wxSOLID);
-  wxWHITE_BRUSH = new wxBrush ("WHITE", wxSOLID);
-  wxBLACK_BRUSH = new wxBrush ("BLACK", wxSOLID);
-  wxTRANSPARENT_BRUSH = new wxBrush ("BLACK", wxTRANSPARENT);
-  wxCYAN_BRUSH = new wxBrush ("CYAN", wxSOLID);
-  wxRED_BRUSH = new wxBrush ("RED", wxSOLID);
-  wxGREY_BRUSH = new wxBrush ("GREY", wxSOLID);
-  wxMEDIUM_GREY_BRUSH = new wxBrush ("MEDIUM GREY", wxSOLID);
-  wxLIGHT_GREY_BRUSH = new wxBrush ("LIGHT GREY", wxSOLID);
-
-  wxBLACK = new wxColour ("BLACK");
-  wxWHITE = new wxColour ("WHITE");
-  wxRED = new wxColour ("RED");
-  wxBLUE = new wxColour ("BLUE");
-  wxGREEN = new wxColour ("GREEN");
-  wxCYAN = new wxColour ("CYAN");
-  wxLIGHT_GREY = new wxColour ("LIGHT GREY");
+  wxRED_PEN = new wxPen (wxT("RED"), 1, wxSOLID);
+  wxCYAN_PEN = new wxPen (wxT("CYAN"), 1, wxSOLID);
+  wxGREEN_PEN = new wxPen (wxT("GREEN"), 1, wxSOLID);
+  wxBLACK_PEN = new wxPen (wxT("BLACK"), 1, wxSOLID);
+  wxWHITE_PEN = new wxPen (wxT("WHITE"), 1, wxSOLID);
+  wxTRANSPARENT_PEN = new wxPen (wxT("BLACK"), 1, wxTRANSPARENT);
+  wxBLACK_DASHED_PEN = new wxPen (wxT("BLACK"), 1, wxSHORT_DASH);
+  wxGREY_PEN = new wxPen (wxT("GREY"), 1, wxSOLID);
+  wxMEDIUM_GREY_PEN = new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID);
+  wxLIGHT_GREY_PEN = new wxPen (wxT("LIGHT GREY"), 1, wxSOLID);
+
+  wxBLUE_BRUSH = new wxBrush (wxT("BLUE"), wxSOLID);
+  wxGREEN_BRUSH = new wxBrush (wxT("GREEN"), wxSOLID);
+  wxWHITE_BRUSH = new wxBrush (wxT("WHITE"), wxSOLID);
+  wxBLACK_BRUSH = new wxBrush (wxT("BLACK"), wxSOLID);
+  wxTRANSPARENT_BRUSH = new wxBrush (wxT("BLACK"), wxTRANSPARENT);
+  wxCYAN_BRUSH = new wxBrush (wxT("CYAN"), wxSOLID);
+  wxRED_BRUSH = new wxBrush (wxT("RED"), wxSOLID);
+  wxGREY_BRUSH = new wxBrush (wxT("GREY"), wxSOLID);
+  wxMEDIUM_GREY_BRUSH = new wxBrush (wxT("MEDIUM GREY"), wxSOLID);
+  wxLIGHT_GREY_BRUSH = new wxBrush (wxT("LIGHT GREY"), wxSOLID);
+
+  wxBLACK = new wxColour (wxT("BLACK"));
+  wxWHITE = new wxColour (wxT("WHITE"));
+  wxRED = new wxColour (wxT("RED"));
+  wxBLUE = new wxColour (wxT("BLUE"));
+  wxGREEN = new wxColour (wxT("GREEN"));
+  wxCYAN = new wxColour (wxT("CYAN"));
+  wxLIGHT_GREY = new wxColour (wxT("LIGHT GREY"));
 
   wxSTANDARD_CURSOR = new wxCursor (wxCURSOR_ARROW);
   wxHOURGLASS_CURSOR = new wxCursor (wxCURSOR_WAIT);
@@ -470,24 +589,29 @@ void wxDeleteStockObjects ()
   wxDELETE(wxCROSS_CURSOR);
 }
 
-void wxDeleteStockLists() {
+void wxDeleteStockLists()
+{
   wxDELETE(wxTheBrushList);
   wxDELETE(wxThePenList);
   wxDELETE(wxTheFontList);
   wxDELETE(wxTheBitmapList);
 }
 
-wxBitmapList::wxBitmapList ()
+// ============================================================================
+// wxTheXXXList stuff (semi-obsolete)
+// ============================================================================
+
+wxBitmapList::wxBitmapList()
 {
 }
 
 wxBitmapList::~wxBitmapList ()
 {
-  wxNode *node = First ();
+  wxList::compatibility_iterator node = GetFirst ();
   while (node)
     {
-      wxBitmap *bitmap = (wxBitmap *) node->Data ();
-      wxNode *next = node->Next ();
+      wxBitmap *bitmap = (wxBitmap *) node->GetData ();
+      wxList::compatibility_iterator next = node->GetNext ();
       if (bitmap->GetVisible())
         delete bitmap;
       node = next;
@@ -497,11 +621,11 @@ wxBitmapList::~wxBitmapList ()
 // Pen and Brush lists
 wxPenList::~wxPenList ()
 {
-  wxNode *node = First ();
+  wxList::compatibility_iterator node = GetFirst ();
   while (node)
     {
-      wxPen *pen = (wxPen *) node->Data ();
-      wxNode *next = node->Next ();
+      wxPen *pen = (wxPen *) node->GetData ();
+      wxList::compatibility_iterator next = node->GetNext ();
       if (pen->GetVisible())
         delete pen;
       node = next;
@@ -520,9 +644,9 @@ void wxPenList::RemovePen (wxPen * pen)
 
 wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
 {
-    for (wxNode * node = First (); node; node = node->Next ())
+    for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ())
     {
-        wxPen *each_pen = (wxPen *) node->Data ();
+        wxPen *each_pen = (wxPen *) node->GetData ();
         if (each_pen &&
                 each_pen->GetVisible() &&
                 each_pen->GetWidth () == width &&
@@ -542,10 +666,9 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
         return NULL;
     }
 
-    // Yes, we can return a pointer to this in a later FindOrCreatePen call,
-    // because we created it within FindOrCreatePen. Safeguards against
-    // returning a pointer to an automatic variable and hanging on to it
-    // (dangling pointer).
+    AddPen(pen);
+
+    // we'll delete it ourselves later
     pen->SetVisible(TRUE);
 
     return pen;
@@ -553,12 +676,12 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
 
 wxBrushList::~wxBrushList ()
 {
-  wxNode *node = First ();
+  wxList::compatibility_iterator node = GetFirst ();
   while (node)
     {
-      wxBrush *brush = (wxBrush *) node->Data ();
-      wxNode *next = node->Next ();
-      if (brush->GetVisible())
+      wxBrush *brush = (wxBrush *) node->GetData ();
+      wxList::compatibility_iterator next = node->GetNext ();
+      if (brush && brush->GetVisible())
         delete brush;
       node = next;
     }
@@ -571,9 +694,9 @@ void wxBrushList::AddBrush (wxBrush * brush)
 
 wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
 {
-    for (wxNode * node = First (); node; node = node->Next ())
+    for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ())
     {
-        wxBrush *each_brush = (wxBrush *) node->Data ();
+        wxBrush *each_brush = (wxBrush *) node->GetData ();
         if (each_brush &&
                 each_brush->GetVisible() &&
                 each_brush->GetStyle () == style &&
@@ -593,12 +716,11 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
         return NULL;
     }
 
+    AddBrush(brush);
+
+    // we'll delete it ourselves later
     brush->SetVisible(TRUE);
 
-    // Yes, we can return a pointer to this in a later FindOrCreateBrush call,
-    // because we created it within FindOrCreateBrush. Safeguards against
-    // returning a pointer to an automatic variable and hanging on to it
-    // (dangling pointer).
     return brush;
 }
 
@@ -609,15 +731,15 @@ void wxBrushList::RemoveBrush (wxBrush * brush)
 
 wxFontList::~wxFontList ()
 {
-    wxNode *node = First ();
+    wxList::compatibility_iterator node = GetFirst ();
     while (node)
     {
         // Only delete objects that are 'visible', i.e.
         // that have been created using FindOrCreate...,
         // where the pointers are expected to be shared
         // (and therefore not deleted by any one part of an app).
-        wxFont *font = (wxFont *) node->Data ();
-        wxNode *next = node->Next ();
+        wxFont *font = (wxFont *) node->GetData ();
+        wxList::compatibility_iterator next = node->GetNext ();
         if (font->GetVisible())
             delete font;
         node = next;
@@ -643,10 +765,10 @@ wxFont *wxFontList::FindOrCreateFont(int pointSize,
                                      wxFontEncoding encoding)
 {
     wxFont *font = (wxFont *)NULL;
-    wxNode *node;
-    for ( node = First(); node; node = node->Next() )
+    wxList::compatibility_iterator node;
+    for ( node = GetFirst(); node; node = node->GetNext() )
     {
-        font = (wxFont *)node->Data();
+        font = (wxFont *)node->GetData();
         if ( font->GetVisible() &&
              font->Ok() &&
              font->GetPointSize () == pointSize &&
@@ -699,6 +821,8 @@ wxFont *wxFontList::FindOrCreateFont(int pointSize,
         font = new wxFont(pointSize, family, style, weight,
                           underline, facename, encoding);
 
+        AddFont(font);
+
         // and mark it as being cacheable
         font->SetVisible(TRUE);
     }
@@ -723,6 +847,13 @@ wxSize wxGetDisplaySize()
     return wxSize(x, y);
 }
 
+wxRect wxGetClientDisplayRect()
+{
+    int x, y, width, height;
+    wxClientDisplayRect(&x, &y, &width, &height);  // call plat-specific version
+    return wxRect(x, y, width, height);
+}
+
 wxSize wxGetDisplaySizeMM()
 {
     int x, y;
@@ -732,12 +863,12 @@ wxSize wxGetDisplaySizeMM()
 
 wxResourceCache::~wxResourceCache ()
 {
-    wxNode *node = First ();
+    wxList::compatibility_iterator node = GetFirst ();
     while (node) {
-        wxObject *item = (wxObject *)node->Data();
+        wxObject *item = (wxObject *)node->GetData();
         delete item;
 
-        node = node->Next ();
+        node = node->GetNext ();
     }
 }