]> git.saurik.com Git - wxWidgets.git/commitdiff
create stock GDI objects on demand; use const with GDI objects appropriately (patch...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Apr 2006 22:18:29 +0000 (22:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Apr 2006 22:18:29 +0000 (22:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

35 files changed:
include/wx/gdicmn.h
include/wx/generic/calctrl.h
include/wx/generic/tabg.h
include/wx/gtk/cursor.h
include/wx/gtk1/cursor.h
include/wx/motif/private.h
include/wx/utils.h
include/wx/x11/privx.h
src/cocoa/cursor.mm
src/common/appcmn.cpp
src/common/datacmn.cpp
src/common/gdicmn.cpp
src/generic/calctrl.cpp
src/generic/listctrl.cpp
src/generic/treectlg.cpp
src/gtk/cursor.cpp
src/gtk/window.cpp
src/gtk1/cursor.cpp
src/gtk1/window.cpp
src/mac/carbon/gdiobj.cpp
src/mac/carbon/utils.cpp
src/mac/classic/gdiobj.cpp
src/mac/classic/utils.cpp
src/mgl/cursor.cpp
src/motif/checkbox.cpp
src/motif/cursor.cpp
src/motif/radiobox.cpp
src/motif/radiobut.cpp
src/motif/utils.cpp
src/motif/window.cpp
src/msw/utilsgui.cpp
src/os2/gdiobj.cpp
src/os2/utilsgui.cpp
src/palmos/utilsgui.cpp
src/x11/cursor.cpp

index f823993b03a36a6535e70121edc024b0b0ac0b4e..fd6d6c25435713d9b933950cdb161b8c23c5a925 100644 (file)
@@ -553,41 +553,116 @@ extern WXDLLEXPORT_DATA(wxBrushList*)   wxTheBrushList;
 extern WXDLLEXPORT_DATA(wxFontList*)    wxTheFontList;
 extern WXDLLEXPORT_DATA(wxBitmapList*)  wxTheBitmapList;
 
-// Stock objects
-extern WXDLLEXPORT_DATA(wxFont*)      wxNORMAL_FONT;
-extern WXDLLEXPORT_DATA(wxFont*)      wxSMALL_FONT;
-extern WXDLLEXPORT_DATA(wxFont*)      wxITALIC_FONT;
-extern WXDLLEXPORT_DATA(wxFont*)      wxSWISS_FONT;
-
-extern WXDLLEXPORT_DATA(wxPen*)      wxRED_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxCYAN_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxGREEN_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxBLACK_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxWHITE_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxTRANSPARENT_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxBLACK_DASHED_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxGREY_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxMEDIUM_GREY_PEN;
-extern WXDLLEXPORT_DATA(wxPen*)      wxLIGHT_GREY_PEN;
-
-extern WXDLLEXPORT_DATA(wxBrush*)    wxBLUE_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxGREEN_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxWHITE_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxBLACK_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxGREY_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxMEDIUM_GREY_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxLIGHT_GREY_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxTRANSPARENT_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxCYAN_BRUSH;
-extern WXDLLEXPORT_DATA(wxBrush*)    wxRED_BRUSH;
-
-extern WXDLLEXPORT_DATA(wxColour*)    wxBLACK;
-extern WXDLLEXPORT_DATA(wxColour*)    wxWHITE;
-extern WXDLLEXPORT_DATA(wxColour*)    wxRED;
-extern WXDLLEXPORT_DATA(wxColour*)    wxBLUE;
-extern WXDLLEXPORT_DATA(wxColour*)    wxGREEN;
-extern WXDLLEXPORT_DATA(wxColour*)    wxCYAN;
-extern WXDLLEXPORT_DATA(wxColour*)    wxLIGHT_GREY;
+/* Stock objects
+
+  wxStockGDI creates the stock GDI objects on demand.  Pointers to the
+  created objects are stored in the ms_stockObject array, which is indexed
+  by the Item enum values.  Platorm-specific fonts can be created by
+  implementing a derived class with an override for the GetFont function.
+  wxStockGDI operates as a singleton, accessed through the ms_instance
+  pointer.  By default this pointer is set to an instance of wxStockGDI.
+  A derived class must arrange to set this pointer to an instance of itself.
+*/
+class WXDLLIMPEXP_CORE wxStockGDI
+{
+public:
+    enum Item {
+        BRUSH_BLACK,
+        BRUSH_BLUE,
+        BRUSH_CYAN,
+        BRUSH_GREEN,
+        BRUSH_GREY,
+        BRUSH_LIGHTGREY,
+        BRUSH_MEDIUMGREY,
+        BRUSH_RED,
+        BRUSH_TRANSPARENT,
+        BRUSH_WHITE,
+        COLOUR_BLACK,
+        COLOUR_BLUE,
+        COLOUR_CYAN,
+        COLOUR_GREEN,
+        COLOUR_LIGHTGREY,
+        COLOUR_RED,
+        COLOUR_WHITE,
+        CURSOR_CROSS,
+        CURSOR_HOURGLASS,
+        CURSOR_STANDARD,
+        FONT_ITALIC,
+        FONT_NORMAL,
+        FONT_SMALL,
+        FONT_SWISS,
+        PEN_BLACK,
+        PEN_BLACKDASHED,
+        PEN_CYAN,
+        PEN_GREEN,
+        PEN_GREY,
+        PEN_LIGHTGREY,
+        PEN_MEDIUMGREY,
+        PEN_RED,
+        PEN_TRANSPARENT,
+        PEN_WHITE,
+        ITEMCOUNT
+    };
+
+    wxStockGDI();
+    virtual ~wxStockGDI();
+    static void DeleteAll();
+
+    static wxStockGDI& instance() { return *ms_instance; }
+
+    static const wxBrush* GetBrush(Item item);
+    static const wxColour* GetColour(Item item);
+    static const wxCursor* GetCursor(Item item);
+    // Can be overridden by platform-specific derived classes
+    virtual const wxFont* GetFont(Item item);
+    static const wxPen* GetPen(Item item);
+
+protected:
+    static wxStockGDI* ms_instance;
+
+    static wxObject* ms_stockObject[ITEMCOUNT];
+
+    DECLARE_NO_COPY_CLASS(wxStockGDI)
+};
+
+#define wxITALIC_FONT  wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
+#define wxNORMAL_FONT  wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
+#define wxSMALL_FONT   wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
+#define wxSWISS_FONT   wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
+
+#define wxBLACK_DASHED_PEN  wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
+#define wxBLACK_PEN         wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
+#define wxCYAN_PEN          wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
+#define wxGREEN_PEN         wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
+#define wxGREY_PEN          wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
+#define wxLIGHT_GREY_PEN    wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
+#define wxMEDIUM_GREY_PEN   wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
+#define wxRED_PEN           wxStockGDI::GetPen(wxStockGDI::PEN_RED)
+#define wxTRANSPARENT_PEN   wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
+#define wxWHITE_PEN         wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
+
+#define wxBLACK_BRUSH        wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
+#define wxBLUE_BRUSH         wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
+#define wxCYAN_BRUSH         wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
+#define wxGREEN_BRUSH        wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
+#define wxGREY_BRUSH         wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
+#define wxLIGHT_GREY_BRUSH   wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
+#define wxMEDIUM_GREY_BRUSH  wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
+#define wxRED_BRUSH          wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
+#define wxTRANSPARENT_BRUSH  wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
+#define wxWHITE_BRUSH        wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
+
+#define wxBLACK       wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
+#define wxBLUE        wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
+#define wxCYAN        wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
+#define wxGREEN       wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
+#define wxLIGHT_GREY  wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
+#define wxRED         wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
+#define wxWHITE       wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
+
+#define wxCROSS_CURSOR      wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
+#define wxHOURGLASS_CURSOR  wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
+#define wxSTANDARD_CURSOR   wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
 
 // 'Null' objects
 extern WXDLLEXPORT_DATA(wxBitmap)     wxNullBitmap;
@@ -599,11 +674,6 @@ extern WXDLLEXPORT_DATA(wxPalette)     wxNullPalette;
 extern WXDLLEXPORT_DATA(wxFont)       wxNullFont;
 extern WXDLLEXPORT_DATA(wxColour)     wxNullColour;
 
-// Stock cursors types
-extern WXDLLEXPORT_DATA(wxCursor*)    wxSTANDARD_CURSOR;
-extern WXDLLEXPORT_DATA(wxCursor*)    wxHOURGLASS_CURSOR;
-extern WXDLLEXPORT_DATA(wxCursor*)    wxCROSS_CURSOR;
-
 extern WXDLLEXPORT_DATA(wxColourDatabase*)  wxTheColourDatabase;
 
 extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[];
@@ -619,9 +689,7 @@ extern WXDLLEXPORT_DATA(wxList) wxPendingDelete;
 // ---------------------------------------------------------------------------
 
 // resource management
-extern void WXDLLEXPORT wxInitializeStockObjects();
 extern void WXDLLEXPORT wxInitializeStockLists();
-extern void WXDLLEXPORT wxDeleteStockObjects();
 extern void WXDLLEXPORT wxDeleteStockLists();
 
 // is the display colour (or monochrome)?
index 324e3bac405b330b2f9cd159d9899230e627b37d..25b5902d70f66f2dc1668929a3059b145865994a 100644 (file)
@@ -261,7 +261,7 @@ private:
     // OnPaint helper-methods
 
     // Highlight the [fromdate : todate] range using pen and brush
-    void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, wxPen* pen, wxBrush* brush);
+    void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pen, const wxBrush* brush);
 
     // Get the "coordinates" for the date relative to the month currently displayed.
     // using (day, week): upper left coord is (1, 1), lower right coord is (7, 6)
index 0ee3f792d2fd6549437ae8f112ff8cd9037f6b2b..30cfeaf587df46237106731815dae801487daebe 100644 (file)
@@ -148,10 +148,10 @@ public:
   inline wxColour GetShadowColour(void) const { return m_shadowColour; }
   inline wxColour GetBackgroundColour(void) const { return m_backgroundColour; }
   inline wxColour GetTextColour(void) const { return m_textColour; }
-  inline wxPen *GetHighlightPen(void) const { return m_highlightPen; }
-  inline wxPen *GetShadowPen(void) const { return m_shadowPen; }
-  inline wxPen *GetBackgroundPen(void) const { return m_backgroundPen; }
-  inline wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; }
+  inline const wxPen *GetHighlightPen(void) const { return m_highlightPen; }
+  inline const wxPen *GetShadowPen(void) const { return m_shadowPen; }
+  inline const wxPen *GetBackgroundPen(void) const { return m_backgroundPen; }
+  inline const wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; }
 
   inline void SetViewRect(const wxRect& rect) { m_tabViewRect = rect; }
   inline wxRect GetViewRect(void) const { return m_tabViewRect; }
@@ -253,10 +253,10 @@ protected:
    wxColour         m_textColour;
 
    // Pen and brush cache
-   wxPen*           m_highlightPen;
-   wxPen*           m_shadowPen;
-   wxPen*           m_backgroundPen;
-   wxBrush*         m_backgroundBrush;
+   const wxPen*     m_highlightPen;
+   const wxPen*     m_shadowPen;
+   const wxPen*     m_backgroundPen;
+   const wxBrush*   m_backgroundBrush;
 
    wxFont           m_tabFont;
    wxFont           m_tabSelectedFont;
index 1fe4410d33e1a3690ae5c3d7df2e6799b3898d5b..3fd0cec98fe201a7ef7563aa5aa46e2ffefd168f 100644 (file)
@@ -33,7 +33,7 @@ public:
 #endif
     wxCursor( const char bits[], int width, int  height,
               int hotSpotX=-1, int hotSpotY=-1,
-              const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 );
+              const char maskBits[] = NULL, const wxColour *fg = NULL, const wxColour *bg = NULL );
     ~wxCursor();
     bool operator == ( const wxCursor& cursor ) const;
     bool operator != ( const wxCursor& cursor ) const;
index 963a26182d625376252ed02e4d5fe7d8bcc3d506..cdc271785453c6a9b88dd7b8590a2d3e44d8419d 100644 (file)
@@ -33,7 +33,7 @@ public:
 #endif
     wxCursor( const char bits[], int width, int  height,
               int hotSpotX=-1, int hotSpotY=-1,
-              const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 );
+              const char maskBits[] = NULL, const wxColour *fg = NULL, const wxColour *bg = NULL );
     ~wxCursor();
     bool operator == ( const wxCursor& cursor ) const;
     bool operator != ( const wxCursor& cursor ) const;
index f68f32c033018039454e885aecc11fb9a77634d4..315899ffaa46bdaf1f69bd9d51f162ee500de84b 100644 (file)
@@ -99,7 +99,7 @@ extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
 extern void wxDoChangeForegroundColour(WXWidget widget,
                                        wxColour& foregroundColour);
 extern void wxDoChangeBackgroundColour(WXWidget widget,
-                                       wxColour& backgroundColour,
+                                       const wxColour& backgroundColour,
                                        bool changeArmColour = false);
 extern void wxDoChangeFont(WXWidget widget, const wxFont& font);
 extern void wxGetTextExtent(WXDisplay* display, const wxFont& font,
index b84f78f44f4b6fb17003dc37333d4caef8e4b807..f5d087d38551108c80db19f2bb16f62276ff3bf9 100644 (file)
@@ -19,6 +19,9 @@
 #include "wx/object.h"
 #include "wx/list.h"
 #include "wx/filefn.h"
+#if wxUSE_GUI
+    #include "wx/gdicmn.h"
+#endif
 
 class WXDLLIMPEXP_BASE wxArrayString;
 class WXDLLIMPEXP_BASE wxArrayInt;
@@ -44,7 +47,6 @@ class WXDLLIMPEXP_CORE wxProcess;
 class WXDLLIMPEXP_CORE wxFrame;
 class WXDLLIMPEXP_CORE wxWindow;
 class WXDLLIMPEXP_CORE wxWindowList;
-class WXDLLIMPEXP_CORE wxPoint;
 
 // ----------------------------------------------------------------------------
 // Macros
@@ -614,9 +616,7 @@ private:
 // ----------------------------------------------------------------------------
 
 // Set the cursor to the busy cursor for all windows
-class WXDLLEXPORT wxCursor;
-extern WXDLLEXPORT_DATA(wxCursor*) wxHOURGLASS_CURSOR;
-WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
+WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursor *cursor = wxHOURGLASS_CURSOR);
 
 // Restore cursor to normal
 WXDLLEXPORT void wxEndBusyCursor();
@@ -628,7 +628,7 @@ WXDLLEXPORT bool wxIsBusy();
 class WXDLLEXPORT wxBusyCursor
 {
 public:
-    wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR)
+    wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR)
         { wxBeginBusyCursor(cursor); }
     ~wxBusyCursor()
         { wxEndBusyCursor(); }
index 658ee94b34709aba2febca1380ab25e3f6325f13..e28ccf353e6df25be5aee4dda7287c5af138f303 100644 (file)
@@ -42,7 +42,7 @@ int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap
 Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
 
 extern XColor g_itemColors[];
-extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
+extern int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore);
 
 // For convenience
 inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
index 14499cfff595c56e4ec3aaf38d0ff3ce12e11e16..347587794f1456ef7c1e3325b0adb256afe7e200 100644 (file)
@@ -424,7 +424,7 @@ void wxSetCursor(const wxCursor& cursor)
 static int wxBusyCursorCount = 0;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
   wxBusyCursorCount ++;
   if (wxBusyCursorCount == 1)
index 747e7e2ecdcee8f21f316742f156b07786e9fd62..d78a126972be518ffeffc3d7acf83263eff519c4 100644 (file)
@@ -104,7 +104,6 @@ bool wxAppBase::Initialize(int& argcOrig, wxChar **argvOrig)
 #endif
 
     wxInitializeStockLists();
-    wxInitializeStockObjects();
 
     wxBitmap::InitStandardHandlers();
 
@@ -137,7 +136,7 @@ void wxAppBase::CleanUp()
     // undo everything we did in Initialize() above
     wxBitmap::CleanUpHandlers();
 
-    wxDeleteStockObjects();
+    wxStockGDI::DeleteAll();
 
     wxDeleteStockLists();
 
index 1b75320de439329becebb0c37aaf5f39c9a6b62c..eb7d51cc9bdc6f889c175033698c188296e5cec5 100644 (file)
@@ -51,46 +51,6 @@ wxBrushList  *wxTheBrushList = NULL;
 wxBitmapList *wxTheBitmapList = NULL;
 wxColourDatabase *wxTheColourDatabase = NULL;
 
-// Stock objects
-wxFont *wxNORMAL_FONT;
-wxFont *wxSMALL_FONT;
-wxFont *wxITALIC_FONT;
-wxFont *wxSWISS_FONT;
-
-wxPen *wxRED_PEN;
-wxPen *wxCYAN_PEN;
-wxPen *wxGREEN_PEN;
-wxPen *wxBLACK_PEN;
-wxPen *wxWHITE_PEN;
-wxPen *wxTRANSPARENT_PEN;
-wxPen *wxBLACK_DASHED_PEN;
-wxPen *wxGREY_PEN;
-wxPen *wxMEDIUM_GREY_PEN;
-wxPen *wxLIGHT_GREY_PEN;
-
-wxBrush *wxBLUE_BRUSH;
-wxBrush *wxGREEN_BRUSH;
-wxBrush *wxWHITE_BRUSH;
-wxBrush *wxBLACK_BRUSH;
-wxBrush *wxTRANSPARENT_BRUSH;
-wxBrush *wxCYAN_BRUSH;
-wxBrush *wxRED_BRUSH;
-wxBrush *wxGREY_BRUSH;
-wxBrush *wxMEDIUM_GREY_BRUSH;
-wxBrush *wxLIGHT_GREY_BRUSH;
-
-wxColour *wxBLACK;
-wxColour *wxWHITE;
-wxColour *wxRED;
-wxColour *wxBLUE;
-wxColour *wxGREEN;
-wxColour *wxCYAN;
-wxColour *wxLIGHT_GREY;
-
-wxCursor *wxSTANDARD_CURSOR = NULL;
-wxCursor *wxHOURGLASS_CURSOR = NULL;
-wxCursor *wxCROSS_CURSOR = NULL;
-
 // 'Null' objects
 #if wxUSE_ACCEL
 wxAcceleratorTable wxNullAcceleratorTable;
index e2c0f65521c817487f1903418b10becb759d0565..18320eb5db95e99e232c966f8d3c6104114c80eb 100644 (file)
 #include "wx/log.h"
 #include <string.h>
 
-#if defined(__WXMSW__)
-#include "wx/msw/wrapwin.h"
-#endif
-
 #ifdef __WXMOTIF__
 #ifdef __VMS__
 #pragma message disable nosimpint
 #include "X11/Xlib.h"
 #endif
 
-#ifdef __WXMAC__
-#include "wx/mac/private.h"
-#include "wx/mac/uma.h"
-#endif
-
 #if wxUSE_EXTENDED_RTTI
 
 // wxPoint
@@ -523,155 +514,212 @@ wxColour *wxColourDatabase::FindColour(const wxString& name)
 // stock objects
 // ============================================================================
 
-void wxInitializeStockLists()
+static wxStockGDI gs_wxStockGDI_instance;
+wxStockGDI* wxStockGDI::ms_instance = &gs_wxStockGDI_instance;
+wxObject* wxStockGDI::ms_stockObject[ITEMCOUNT];
+
+wxStockGDI::wxStockGDI()
 {
-    wxTheColourDatabase = new wxColourDatabase;
+}
 
-    wxTheBrushList = new wxBrushList;
-    wxThePenList = new wxPenList;
-    wxTheFontList = new wxFontList;
-    wxTheBitmapList = new wxBitmapList;
+wxStockGDI::~wxStockGDI()
+{
 }
 
-void wxInitializeStockObjects ()
+void wxStockGDI::DeleteAll()
 {
-#ifdef __WXMOTIF__
-#endif
-#ifdef __X__
-  // TODO
-  //  wxFontPool = new XFontPool;
-#endif
+    for (unsigned i = 0; i < ITEMCOUNT; i++)
+    {
+        delete ms_stockObject[i];
+        ms_stockObject[i] = NULL;
+    }
+}
 
-  // why under MSW fonts shouldn't have the standard system size?
-/*
-#ifdef __WXMSW__
-  static const int sizeFont = 10;
-#else
-#endif
-*/
-#if defined(__WXMAC__)
-    // retrieve size of system font for all stock fonts
-    int sizeFont = 12;
-
-    Str255 fontName ;
-    SInt16 fontSize ;
-    Style fontStyle ;
-
-    GetThemeFont(kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
-    sizeFont = fontSize ;
-#ifdef __WXMAC_CLASSIC__
-    wxNORMAL_FONT = new wxFont (fontSize, wxMODERN, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal(fontName) );
-#else
-    wxNORMAL_FONT = new wxFont () ;
-    wxNORMAL_FONT->MacCreateThemeFont( kThemeSystemFont );
-#endif
-#elif defined(__WXPM__)
-    static const int sizeFont = 12;
-#else
-    wxNORMAL_FONT = new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
-    static const int sizeFont = wxNORMAL_FONT->GetPointSize();
-#endif
+const wxBrush* wxStockGDI::GetBrush(Item item)
+{
+    wxBrush* brush = wx_static_cast(wxBrush*, ms_stockObject[item]);
+    if (brush == NULL)
+    {
+        switch (item)
+        {
+        case BRUSH_BLACK:
+            brush = new wxBrush(*GetColour(COLOUR_BLACK), wxSOLID);
+            break;
+        case BRUSH_BLUE:
+            brush = new wxBrush(*GetColour(COLOUR_BLUE), wxSOLID);
+            break;
+        case BRUSH_CYAN:
+            brush = new wxBrush(*GetColour(COLOUR_CYAN), wxSOLID);
+            break;
+        case BRUSH_GREEN:
+            brush = new wxBrush(*GetColour(COLOUR_GREEN), wxSOLID);
+            break;
+        case BRUSH_GREY:
+            brush = new wxBrush(wxColour(wxT("GREY")), wxSOLID);
+            break;
+        case BRUSH_LIGHTGREY:
+            brush = new wxBrush(*GetColour(COLOUR_LIGHTGREY), wxSOLID);
+            break;
+        case BRUSH_MEDIUMGREY:
+            brush = new wxBrush(wxColour(wxT("MEDIUM GREY")), wxSOLID);
+            break;
+        case BRUSH_RED:
+            brush = new wxBrush(*GetColour(COLOUR_RED), wxSOLID);
+            break;
+        case BRUSH_TRANSPARENT:
+            brush = new wxBrush(*GetColour(COLOUR_BLACK), wxTRANSPARENT);
+            break;
+        case BRUSH_WHITE:
+            brush = new wxBrush(*GetColour(COLOUR_WHITE), wxSOLID);
+            break;
+        default:
+            wxFAIL;
+        }
+        ms_stockObject[item] = brush;
+    }
+    return brush;
+}
 
-#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__)
-    wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */
-    wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
-#ifdef __WXMAC_CLASSIC__
-  GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
-    wxSMALL_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) );
-#else
-    wxSMALL_FONT = new wxFont () ;
-    wxSMALL_FONT->MacCreateThemeFont( kThemeSmallSystemFont );
-#endif
-#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
+const wxColour* wxStockGDI::GetColour(Item item)
+{
+    wxColour* colour = wx_static_cast(wxColour*, ms_stockObject[item]);
+    if (colour == NULL)
+    {
+        switch (item)
+        {
+        case COLOUR_BLACK:
+            colour = new wxColour(0, 0, 0);
+            break;
+        case COLOUR_BLUE:
+            colour = new wxColour(0, 0, 255);
+            break;
+        case COLOUR_CYAN:
+            colour = new wxColour(wxT("CYAN"));
+            break;
+        case COLOUR_GREEN:
+            colour = new wxColour(0, 255, 0);
+            break;
+        case COLOUR_LIGHTGREY:
+            colour = new wxColour(wxT("LIGHT GREY"));
+            break;
+        case COLOUR_RED:
+            colour = new wxColour(255, 0, 0);
+            break;
+        case COLOUR_WHITE:
+            colour = new wxColour(255, 255, 255);
+            break;
+        default:
+            wxFAIL;
+        }
+        ms_stockObject[item] = colour;
+    }
+    return colour;
+}
+
+const wxCursor* wxStockGDI::GetCursor(Item item)
+{
+    wxCursor* cursor = wx_static_cast(wxCursor*, ms_stockObject[item]);
+    if (cursor == NULL)
+    {
+        switch (item)
+        {
+        case CURSOR_CROSS:
+            cursor = new wxCursor(wxCURSOR_CROSS);
+            break;
+        case CURSOR_HOURGLASS:
+            cursor = new wxCursor(wxCURSOR_WAIT);
+            break;
+        case CURSOR_STANDARD:
+            cursor = new wxCursor(wxCURSOR_ARROW);
+            break;
+        default:
+            wxFAIL;
+        }
+        ms_stockObject[item] = cursor;
+    }
+    return cursor;
+}
+
+const wxFont* wxStockGDI::GetFont(Item item)
+{
+    wxFont* font = wx_static_cast(wxFont*, ms_stockObject[item]);
+    if (font == NULL)
+    {
+        switch (item)
+        {
+        case FONT_ITALIC:
+            font = new wxFont(GetFont(FONT_NORMAL)->GetPointSize(), wxROMAN, wxITALIC, wxNORMAL);
+            break;
+        case FONT_NORMAL:
+            font = new wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+            break;
+        case FONT_SMALL:
+            font = new wxFont(GetFont(FONT_NORMAL)->GetPointSize() - 2, wxSWISS, wxNORMAL, wxNORMAL);
+            break;
+        case FONT_SWISS:
+            font = new wxFont(GetFont(FONT_NORMAL)->GetPointSize(), wxSWISS, wxNORMAL, wxNORMAL);
+            break;
+        default:
+            wxFAIL;
+        }
+        ms_stockObject[item] = font;
+    }
+    return font;
+}
+
+const wxPen* wxStockGDI::GetPen(Item item)
+{
+    wxPen* pen = wx_static_cast(wxPen*, ms_stockObject[item]);
+    if (pen == NULL)
+    {
+        switch (item)
+        {
+        case PEN_BLACK:
+            pen = new wxPen(*GetColour(COLOUR_BLACK), 1, wxSOLID);
+            break;
+        case PEN_BLACKDASHED:
+            pen = new wxPen(*GetColour(COLOUR_BLACK), 1, wxSHORT_DASH);
+            break;
+        case PEN_CYAN:
+            pen = new wxPen(*GetColour(COLOUR_CYAN), 1, wxSOLID);
+            break;
+        case PEN_GREEN:
+            pen = new wxPen(*GetColour(COLOUR_GREEN), 1, wxSOLID);
+            break;
+        case PEN_GREY:
+            pen = new wxPen(wxColour(wxT("GREY")), 1, wxSOLID);
+            break;
+        case PEN_LIGHTGREY:
+            pen = new wxPen(*GetColour(COLOUR_LIGHTGREY), 1, wxSOLID);
+            break;
+        case PEN_MEDIUMGREY:
+            pen = new wxPen(wxColour(wxT("MEDIUM GREY")), 1, wxSOLID);
+            break;
+        case PEN_RED:
+            pen = new wxPen(*GetColour(COLOUR_RED), 1, wxSOLID);
+            break;
+        case PEN_TRANSPARENT:
+            pen = new wxPen(*GetColour(COLOUR_BLACK), 1, wxTRANSPARENT);
+            break;
+        case PEN_WHITE:
+            pen = new wxPen(*GetColour(COLOUR_WHITE), 1, wxSOLID);
+            break;
+        default:
+            wxFAIL;
+        }
+        ms_stockObject[item] = pen;
+    }
+    return pen;
+}
+
+void wxInitializeStockLists()
+{
+    wxTheColourDatabase = new wxColourDatabase;
 
-    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);
-    wxCROSS_CURSOR = new wxCursor (wxCURSOR_CROSS);
-}
-
-void wxDeleteStockObjects ()
-{
-    wxDELETE(wxNORMAL_FONT);
-    wxDELETE(wxSMALL_FONT);
-    wxDELETE(wxITALIC_FONT);
-    wxDELETE(wxSWISS_FONT);
-
-    wxDELETE(wxRED_PEN);
-    wxDELETE(wxCYAN_PEN);
-    wxDELETE(wxGREEN_PEN);
-    wxDELETE(wxBLACK_PEN);
-    wxDELETE(wxWHITE_PEN);
-    wxDELETE(wxTRANSPARENT_PEN);
-    wxDELETE(wxBLACK_DASHED_PEN);
-    wxDELETE(wxGREY_PEN);
-    wxDELETE(wxMEDIUM_GREY_PEN);
-    wxDELETE(wxLIGHT_GREY_PEN);
-
-    wxDELETE(wxBLUE_BRUSH);
-    wxDELETE(wxGREEN_BRUSH);
-    wxDELETE(wxWHITE_BRUSH);
-    wxDELETE(wxBLACK_BRUSH);
-    wxDELETE(wxTRANSPARENT_BRUSH);
-    wxDELETE(wxCYAN_BRUSH);
-    wxDELETE(wxRED_BRUSH);
-    wxDELETE(wxGREY_BRUSH);
-    wxDELETE(wxMEDIUM_GREY_BRUSH);
-    wxDELETE(wxLIGHT_GREY_BRUSH);
-
-    wxDELETE(wxBLACK);
-    wxDELETE(wxWHITE);
-    wxDELETE(wxRED);
-    wxDELETE(wxBLUE);
-    wxDELETE(wxGREEN);
-    wxDELETE(wxCYAN);
-    wxDELETE(wxLIGHT_GREY);
-
-    wxDELETE(wxSTANDARD_CURSOR);
-    wxDELETE(wxHOURGLASS_CURSOR);
-    wxDELETE(wxCROSS_CURSOR);
+    wxTheBrushList = new wxBrushList;
+    wxThePenList = new wxPenList;
+    wxTheFontList = new wxFontList;
+    wxTheBitmapList = new wxBitmapList;
 }
 
 void wxDeleteStockLists()
index 10995b0442d6c919fd45d785512e8130e4593e10..3af0091d420999604966ed834424e9285f73b463 100644 (file)
@@ -1211,7 +1211,7 @@ void wxCalendarCtrl::RefreshDate(const wxDateTime& date)
     Refresh(true, &rect);
 }
 
-void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, wxPen* pPen, wxBrush* pBrush)
+void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pPen, const wxBrush* pBrush)
 {
     // Highlights the given range using pen and brush
     // Does nothing if todate < fromdate
index 6e1707802a2176f93e1fbcc912d05fc4885019b7..50f4ec9c71241c1486b6a53750531869535a4667 100644 (file)
@@ -412,8 +412,8 @@ class WXDLLEXPORT wxListHeaderWindow : public wxWindow
 {
 protected:
     wxListMainWindow  *m_owner;
-    wxCursor          *m_currentCursor;
-    wxCursor          *m_resizeCursor;
+    const wxCursor    *m_currentCursor;
+    const wxCursor    *m_resizeCursor;
     bool               m_isDragging;
 
     // column being resized or -1
index e190fde07597916942262128004c40774763d715..a53683327480208a01bba972be59382afe753e0b 100644 (file)
@@ -2323,7 +2323,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
 
     if (IsExposed(exposed_x, exposed_y, 10000, h))  // 10000 = very much
     {
-        wxPen *pen =
+        const wxPen *pen =
 #ifndef __WXMAC__
             // don't draw rect outline if we already have the
             // background color under Mac
index 9f7329bfeea6730ad7b83060503057e148f855a3..7c431b8efa8b2b762fa66feb348272aed9057e7c 100644 (file)
@@ -123,7 +123,7 @@ extern GtkWidget *wxGetRootWindow();
 
 wxCursor::wxCursor(const char bits[], int width, int  height,
                    int hotSpotX, int hotSpotY,
-                   const char maskBits[], wxColour *fg, wxColour *bg)
+                   const char maskBits[], const wxColour *fg, const wxColour *bg)
 {
     if (!maskBits)
         maskBits = bits;
@@ -359,7 +359,7 @@ void wxEndBusyCursor()
         wxTheApp->ProcessIdle();
 }
 
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
 {
     if (gs_busyCount++ > 0)
         return;
index aede8763ff6ef3f08472dded52738d8bb6cc5c1f..70d044e9b8f3413ff0245c79cd091ff82692981f 100644 (file)
@@ -4135,7 +4135,7 @@ void wxWindowGTK::DoCaptureMouse()
 
     wxCHECK_RET( window, _T("CaptureMouse() failed") );
 
-    wxCursor* cursor = & m_cursor;
+    const wxCursor* cursor = &m_cursor;
     if (!cursor->Ok())
         cursor = wxSTANDARD_CURSOR;
 
index cac9e5aabaf90133d213c87801704288c94ca4e4..70a3e24583d896b37d66be2bb4508f64c15b4bdb 100644 (file)
@@ -128,7 +128,7 @@ extern GtkWidget *wxGetRootWindow();
 
 wxCursor::wxCursor(const char bits[], int width, int  height,
                    int hotSpotX, int hotSpotY,
-                   const char maskBits[], wxColour *fg, wxColour *bg)
+                   const char maskBits[], const wxColour *fg, const wxColour *bg)
 {
     if (!maskBits)
         maskBits = bits;
@@ -364,7 +364,7 @@ void wxEndBusyCursor()
         wxTheApp->ProcessIdle();
 }
 
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
 {
     if (gs_busyCount++ > 0)
         return;
index f2b3a7a69a79252c8df88403ad64130fac57c85e..828d45afc058c139e6058c2b04c3b3b3813e608f 100644 (file)
@@ -3928,7 +3928,7 @@ void wxWindowGTK::DoCaptureMouse()
 
     wxCHECK_RET( window, _T("CaptureMouse() failed") );
 
-    wxCursor* cursor = & m_cursor;
+    const wxCursor* cursor = &m_cursor;
     if (!cursor->Ok())
         cursor = wxSTANDARD_CURSOR;
 
index b28f2b8d1ae5156adfea59a611262b54ead5ecab..f6c046cc61d9e61eba6e1d3e3e0b7d62d8ddbb7e 100644 (file)
 #include "wx/wxprec.h"
 
 #include "wx/gdiobj.h"
+#include "wx/gdicmn.h"
+#include "wx/mac/private.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
 
-// TODO: Nothing to do, unless you want to.
+class wxStockGDIMac: public wxStockGDI
+{
+public:
+    wxStockGDIMac();
+
+    virtual const wxFont* GetFont(Item item);
+
+private:
+    typedef wxStockGDI super;
+};
+
+static wxStockGDIMac gs_wxStockGDIMac_instance;
+
+wxStockGDIMac::wxStockGDIMac()
+{
+    // Override default instance
+    ms_instance = this;
+}
+
+const wxFont* wxStockGDIMac::GetFont(Item item)
+{
+    wxFont* font = static_cast<wxFont*>(ms_stockObject[item]);
+    if (font == NULL)
+    {
+        switch (item)
+        {
+        case FONT_NORMAL:
+            font = new wxFont;
+            font->MacCreateThemeFont(kThemeSystemFont);
+            break;
+        case FONT_SMALL:
+            font = new wxFont;
+            font->MacCreateThemeFont(kThemeSmallSystemFont);
+            break;
+        default:
+            font = const_cast<wxFont*>(super::GetFont(item));
+            break;
+        }
+        ms_stockObject[item] = font;
+    }
+    return font;
+}
index 824bc4dad97f93f501c4dbbe1b0a267024048215..5cb7a352f9001119ab11a878fc402b3f75fc80cc 100644 (file)
@@ -488,7 +488,7 @@ extern wxCursor    gMacCurrentCursor ;
 wxCursor        gMacStoredActiveCursor ;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
     if (gs_wxBusyCursorCount++ == 0)
     {
index 1f65f6f86b1849db469cbdd6a63bc8aab59f7499..9b74779924c31da498b57262c8a3a4942210dac1 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/gdiobj.h"
+#include "wx/gdicmn.h"
+#include "wx/mac/private.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
 
-// TODO: Nothing to do, unless you want to.
+class wxStockGDIMac: public wxStockGDI
+{
+public:
+    wxStockGDIMac();
+
+    virtual const wxFont* GetFont(Item item);
+
+private:
+    typedef wxStockGDI super;
+};
+
+static wxStockGDIMac gs_wxStockGDIMac_instance;
+
+wxStockGDIMac::wxStockGDIMac()
+{
+    // Override default instance
+    ms_instance = this;
+}
+
+const wxFont* wxStockGDIMac::GetFont(Item item)
+{
+    wxFont* font = wx_static_cast(wxFont*, ms_stockObject[item]);
+    if (font == NULL)
+    {
+        Str255 fontName;
+        SInt16 fontSize;
+        Style fontStyle;
+        switch (item)
+        {
+        case FONT_NORMAL:
+            GetThemeFont(kThemeSystemFont, GetApplicationScript(), fontName, &fontSize, &fontStyle);
+            font = new wxFont(fontSize, wxMODERN, wxNORMAL, wxNORMAL, false, wxMacMakeStringFromPascal(fontName));
+            break;
+        case FONT_SMALL:
+            GetThemeFont(kThemeSmallSystemFont, GetApplicationScript(), fontName, &fontSize, &fontStyle);
+            font = new wxFont(fontSize, wxSWISS, wxNORMAL, wxNORMAL, false, wxMacMakeStringFromPascal(fontName));
+            break;
+        default:
+            font = wx_const_cast(wxFont*, super::GetFont(item));
+            break;
+        }
+        ms_stockObject[item] = font;
+    }
+    return font;
+}
index 3e5d68a18509f40639688a1d33d6982fdaf8f848..78cbfd0da7e816a3dadb1e97eda4c86fe7e45680 100644 (file)
@@ -339,7 +339,7 @@ extern wxCursor    gMacCurrentCursor ;
 wxCursor        gMacStoredActiveCursor ;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
     if (gs_wxBusyCursorCount++ == 0)
     {
index b2a4c69a7c5eb120fe06db2ebaa6c2a7d07ff4b0..5fdf62fae95b9df6fd83e29bf25c9ac7acabe75d 100644 (file)
@@ -243,7 +243,7 @@ void wxEndBusyCursor()
     gs_savedCursor = wxNullCursor;
 }
 
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
     if ( gs_busyCount++ > 0 ) return;
 
index 9a274cc63a3a7909302374e2bbad4e5cc4220856..6b9402557b60c7c50fa3401fc72c7b0ba44811e9 100644 (file)
@@ -153,7 +153,8 @@ void wxCheckBox::ChangeBackgroundColour()
         XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
         NULL);
 
-    int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
+    wxColour colour = *wxBLACK;
+    int selectPixel = colour.AllocColour(XtDisplay((Widget)m_mainWidget));
 
     // Better to have the checkbox selection in black, or it's
     // hard to determine what state it is in.
index deddb7a41c9f9edd67ba0a73ae56ffa3653ae51e..5548cac50555c9bf4527a5406218b82bdc1725a4 100644 (file)
@@ -426,7 +426,7 @@ static int wxBusyCursorCount = 0;
 
 // Helper function
 static void
-wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
+wxXSetBusyCursor (wxWindow * win, const wxCursor * cursor)
 {
     Display *display = (Display*) win->GetXDisplay();
 
@@ -462,7 +462,7 @@ wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
 }
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
     wxBusyCursorCount++;
     if (wxBusyCursorCount == 1)
index a341e977a8eb8ad50acba30538279f33c5b2896b..2761725f12dc09fa0afff148fff8a6d107f35f52 100644 (file)
@@ -347,7 +347,8 @@ void wxRadioBox::ChangeBackgroundColour()
 {
     wxWindow::ChangeBackgroundColour();
 
-    int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
+    wxColour colour = *wxBLACK;
+    int selectPixel = colour.AllocColour(XtDisplay((Widget)m_mainWidget));
 
     for (unsigned int i = 0; i < m_noItems; i++)
     {
index 82c359104b8dc28a90fd12ca7638b8d4203070f2..70847aee230b36116f6d3af682a5a68859860f7a 100644 (file)
@@ -140,7 +140,8 @@ void wxRadioButton::ChangeBackgroundColour()
     wxWindow::ChangeBackgroundColour();
 
     // What colour should this be?
-    int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
+    wxColour colour = *wxBLACK;
+    int selectPixel = colour.AllocColour(XtDisplay((Widget)m_mainWidget));
 
     XtVaSetValues ((Widget) GetMainWidget(),
           XmNselectColor, selectPixel,
index d4322fe7ccf44fb4ba13e97a94b76dad14f8185e..fa3ba9073fc305409722110d0eeaa60e648f3fd4 100644 (file)
@@ -909,7 +909,7 @@ void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
         NULL);
 }
 
-void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
+void wxDoChangeBackgroundColour(WXWidget widget, const wxColour& backgroundColour, bool changeArmColour)
 {
     wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
         (wxColour*) NULL);
index cea79f107fe2c1d6706ee468404ac3d712265303..e553ef1ef25b468880f085fd61a1bf277d40715d 100644 (file)
@@ -693,7 +693,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor)
 
     //    wxASSERT_MSG( m_cursor.Ok(),
     //                  wxT("cursor must be valid after call to the base version"));
-    wxCursor* cursor2 = NULL;
+    const wxCursor* cursor2 = NULL;
     if (m_cursor.Ok())
         cursor2 = & m_cursor;
     else
@@ -2377,7 +2377,7 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
 
 #define YAllocColor XAllocColor
 XColor g_itemColors[5];
-int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
+int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore)
 {
     int result;
     static XmColorProc colorProc;
index 497f40df3485deb286ef4a1b0838a6be8a1900f0..7926bdb3307ca5410804b6aba71e7100a25478bf 100644 (file)
@@ -157,7 +157,7 @@ extern HCURSOR wxGetCurrentBusyCursor()
 }
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
     if ( gs_wxBusyCursorCount++ == 0 )
     {
index af715606bc28110af9500fd3f35f38390a4beb47..5adc704f5e21ade94142c48cd9c2a5aec57c0c52 100644 (file)
 #include "wx/wxprec.h"
 
 #include "wx/gdiobj.h"
+#include "wx/gdicmn.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
 
-// TODO: Nothing to do, unless you want to.
+class wxStockGDIPM: public wxStockGDI
+{
+public:
+    wxStockGDIPM();
+
+    virtual const wxFont* GetFont(Item item);
+
+private:
+    typedef wxStockGDI super;
+};
+
+static wxStockGDIPM gs_wxStockGDIPM_instance;
+
+wxStockGDIPM::wxStockGDIPM()
+{
+    // Override default instance
+    ms_instance = this;
+}
+
+const wxFont* wxStockGDIPM::GetFont(Item item)
+{
+    wxFont* font = wx_static_cast(wxFont*, ms_stockObject[item]);
+    if (font == NULL)
+    {
+        const int fontSize = 12;
+        switch (item)
+        {
+        case FONT_NORMAL:
+            font = new wxFont(fontSize, wxMODERN, wxNORMAL, wxBOLD);
+            break;
+        case FONT_SMALL:
+            font = new wxFont(fontSize - 4, wxSWISS, wxNORMAL, wxNORMAL);
+            break;
+        default:
+            font = wx_const_cast(wxFont*, super::GetFont(item));
+            break;
+        }
+        ms_stockObject[item] = font;
+    }
+    return font;
+}
index 66647fcd2eb98f964091067fb522d937c66b49ae..e64fc12f9b26533d63c0983e7f5617c17e942d52 100644 (file)
@@ -289,9 +289,7 @@ HCURSOR gs_wxBusyCursorOld = 0;  // old cursor
 static int gs_wxBusyCursorCount = 0;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(
-  wxCursor*                         pCursor
-)
+void wxBeginBusyCursor(const wxCursor* pCursor)
 {
     if ( gs_wxBusyCursorCount++ == 0 )
     {
index eaab8f03b112d0dceea8e974613ba66e28eca60e..29aba3dd83d0ef46b6dd206a1abd75082b2bd2d5 100644 (file)
@@ -88,7 +88,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
 static int gs_wxBusyCursorCount = 0;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
 {
 }
 
index 0635c03de7c9949c75b6abb4b05aacbc8d7fdaf0..77ac73f1610416d7f3d4682efb2691dfa03486f2 100644 (file)
@@ -186,7 +186,7 @@ void wxEndBusyCursor()
         wxTheApp->ProcessIdle();
 }
 
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
 {
     if (gs_busyCount++ > 0)
         return;