From f516d986371b7643efda569d64ae19e75d221411 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 16 Apr 2006 22:18:29 +0000 Subject: [PATCH] create stock GDI objects on demand; use const with GDI objects appropriately (patch 1445355) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gdicmn.h | 152 ++++++++++----- include/wx/generic/calctrl.h | 2 +- include/wx/generic/tabg.h | 16 +- include/wx/gtk/cursor.h | 2 +- include/wx/gtk1/cursor.h | 2 +- include/wx/motif/private.h | 2 +- include/wx/utils.h | 10 +- include/wx/x11/privx.h | 2 +- src/cocoa/cursor.mm | 2 +- src/common/appcmn.cpp | 3 +- src/common/datacmn.cpp | 40 ---- src/common/gdicmn.cpp | 348 ++++++++++++++++++++--------------- src/generic/calctrl.cpp | 2 +- src/generic/listctrl.cpp | 4 +- src/generic/treectlg.cpp | 2 +- src/gtk/cursor.cpp | 4 +- src/gtk/window.cpp | 2 +- src/gtk1/cursor.cpp | 4 +- src/gtk1/window.cpp | 2 +- src/mac/carbon/gdiobj.cpp | 45 ++++- src/mac/carbon/utils.cpp | 2 +- src/mac/classic/gdiobj.cpp | 48 ++++- src/mac/classic/utils.cpp | 2 +- src/mgl/cursor.cpp | 2 +- src/motif/checkbox.cpp | 3 +- src/motif/cursor.cpp | 4 +- src/motif/radiobox.cpp | 3 +- src/motif/radiobut.cpp | 3 +- src/motif/utils.cpp | 2 +- src/motif/window.cpp | 4 +- src/msw/utilsgui.cpp | 2 +- src/os2/gdiobj.cpp | 43 ++++- src/os2/utilsgui.cpp | 4 +- src/palmos/utilsgui.cpp | 2 +- src/x11/cursor.cpp | 2 +- 35 files changed, 489 insertions(+), 283 deletions(-) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index f823993b03..fd6d6c2543 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -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)? diff --git a/include/wx/generic/calctrl.h b/include/wx/generic/calctrl.h index 324e3bac40..25b5902d70 100644 --- a/include/wx/generic/calctrl.h +++ b/include/wx/generic/calctrl.h @@ -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) diff --git a/include/wx/generic/tabg.h b/include/wx/generic/tabg.h index 0ee3f792d2..30cfeaf587 100644 --- a/include/wx/generic/tabg.h +++ b/include/wx/generic/tabg.h @@ -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; diff --git a/include/wx/gtk/cursor.h b/include/wx/gtk/cursor.h index 1fe4410d33..3fd0cec98f 100644 --- a/include/wx/gtk/cursor.h +++ b/include/wx/gtk/cursor.h @@ -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; diff --git a/include/wx/gtk1/cursor.h b/include/wx/gtk1/cursor.h index 963a26182d..cdc2717854 100644 --- a/include/wx/gtk1/cursor.h +++ b/include/wx/gtk1/cursor.h @@ -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; diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index f68f32c033..315899ffaa 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -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, diff --git a/include/wx/utils.h b/include/wx/utils.h index b84f78f44f..f5d087d385 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -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(); } diff --git a/include/wx/x11/privx.h b/include/wx/x11/privx.h index 658ee94b34..e28ccf353e 100644 --- a/include/wx/x11/privx.h +++ b/include/wx/x11/privx.h @@ -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(); } diff --git a/src/cocoa/cursor.mm b/src/cocoa/cursor.mm index 14499cfff5..347587794f 100644 --- a/src/cocoa/cursor.mm +++ b/src/cocoa/cursor.mm @@ -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) diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 747e7e2ecd..d78a126972 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -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(); diff --git a/src/common/datacmn.cpp b/src/common/datacmn.cpp index 1b75320de4..eb7d51cc9b 100644 --- a/src/common/datacmn.cpp +++ b/src/common/datacmn.cpp @@ -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; diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index e2c0f65521..18320eb5db 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -38,10 +38,6 @@ #include "wx/log.h" #include -#if defined(__WXMSW__) -#include "wx/msw/wrapwin.h" -#endif - #ifdef __WXMOTIF__ #ifdef __VMS__ #pragma message disable nosimpint @@ -56,11 +52,6 @@ #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() diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index 10995b0442..3af0091d42 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -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 diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 6e1707802a..50f4ec9c71 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -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 diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index e190fde075..a536833274 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -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 diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index 9f7329bfee..7c431b8efa 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -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; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index aede8763ff..70d044e9b8 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -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; diff --git a/src/gtk1/cursor.cpp b/src/gtk1/cursor.cpp index cac9e5aaba..70a3e24583 100644 --- a/src/gtk1/cursor.cpp +++ b/src/gtk1/cursor.cpp @@ -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; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index f2b3a7a69a..828d45afc0 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -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; diff --git a/src/mac/carbon/gdiobj.cpp b/src/mac/carbon/gdiobj.cpp index b28f2b8d1a..f6c046cc61 100644 --- a/src/mac/carbon/gdiobj.cpp +++ b/src/mac/carbon/gdiobj.cpp @@ -12,7 +12,50 @@ #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(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(super::GetFont(item)); + break; + } + ms_stockObject[item] = font; + } + return font; +} diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 824bc4dad9..5cb7a352f9 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -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) { diff --git a/src/mac/classic/gdiobj.cpp b/src/mac/classic/gdiobj.cpp index 1f65f6f86b..9b74779924 100644 --- a/src/mac/classic/gdiobj.cpp +++ b/src/mac/classic/gdiobj.cpp @@ -10,7 +10,53 @@ ///////////////////////////////////////////////////////////////////////////// #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; +} diff --git a/src/mac/classic/utils.cpp b/src/mac/classic/utils.cpp index 3e5d68a185..78cbfd0da7 100644 --- a/src/mac/classic/utils.cpp +++ b/src/mac/classic/utils.cpp @@ -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) { diff --git a/src/mgl/cursor.cpp b/src/mgl/cursor.cpp index b2a4c69a7c..5fdf62fae9 100644 --- a/src/mgl/cursor.cpp +++ b/src/mgl/cursor.cpp @@ -243,7 +243,7 @@ void wxEndBusyCursor() gs_savedCursor = wxNullCursor; } -void wxBeginBusyCursor(wxCursor *cursor) +void wxBeginBusyCursor(const wxCursor *cursor) { if ( gs_busyCount++ > 0 ) return; diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index 9a274cc63a..6b9402557b 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -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. diff --git a/src/motif/cursor.cpp b/src/motif/cursor.cpp index deddb7a41c..5548cac505 100644 --- a/src/motif/cursor.cpp +++ b/src/motif/cursor.cpp @@ -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) diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index a341e977a8..2761725f12 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -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++) { diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index 82c359104b..70847aee23 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -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, diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index d4322fe7cc..fa3ba9073f 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -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); diff --git a/src/motif/window.cpp b/src/motif/window.cpp index cea79f107f..e553ef1ef2 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -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; diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index 497f40df34..7926bdb330 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -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 ) { diff --git a/src/os2/gdiobj.cpp b/src/os2/gdiobj.cpp index af715606bc..5adc704f5e 100644 --- a/src/os2/gdiobj.cpp +++ b/src/os2/gdiobj.cpp @@ -12,7 +12,48 @@ #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; +} diff --git a/src/os2/utilsgui.cpp b/src/os2/utilsgui.cpp index 66647fcd2e..e64fc12f9b 100644 --- a/src/os2/utilsgui.cpp +++ b/src/os2/utilsgui.cpp @@ -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 ) { diff --git a/src/palmos/utilsgui.cpp b/src/palmos/utilsgui.cpp index eaab8f03b1..29aba3dd83 100644 --- a/src/palmos/utilsgui.cpp +++ b/src/palmos/utilsgui.cpp @@ -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) { } diff --git a/src/x11/cursor.cpp b/src/x11/cursor.cpp index 0635c03de7..77ac73f161 100644 --- a/src/x11/cursor.cpp +++ b/src/x11/cursor.cpp @@ -186,7 +186,7 @@ void wxEndBusyCursor() wxTheApp->ProcessIdle(); } -void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) +void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) ) { if (gs_busyCount++ > 0) return; -- 2.45.2