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;
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[];
// ---------------------------------------------------------------------------
// resource management
-extern void WXDLLEXPORT wxInitializeStockObjects();
extern void WXDLLEXPORT wxInitializeStockLists();
-extern void WXDLLEXPORT wxDeleteStockObjects();
extern void WXDLLEXPORT wxDeleteStockLists();
// is the display colour (or monochrome)?
// 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)
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; }
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;
#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;
#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;
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,
#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;
class WXDLLIMPEXP_CORE wxFrame;
class WXDLLIMPEXP_CORE wxWindow;
class WXDLLIMPEXP_CORE wxWindowList;
-class WXDLLIMPEXP_CORE wxPoint;
// ----------------------------------------------------------------------------
// Macros
// ----------------------------------------------------------------------------
// 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();
class WXDLLEXPORT wxBusyCursor
{
public:
- wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR)
+ wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR)
{ wxBeginBusyCursor(cursor); }
~wxBusyCursor()
{ wxEndBusyCursor(); }
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(); }
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)
#endif
wxInitializeStockLists();
- wxInitializeStockObjects();
wxBitmap::InitStandardHandlers();
// undo everything we did in Initialize() above
wxBitmap::CleanUpHandlers();
- wxDeleteStockObjects();
+ wxStockGDI::DeleteAll();
wxDeleteStockLists();
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;
#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
// 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()
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
{
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
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
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;
wxTheApp->ProcessIdle();
}
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
{
if (gs_busyCount++ > 0)
return;
wxCHECK_RET( window, _T("CaptureMouse() failed") );
- wxCursor* cursor = & m_cursor;
+ const wxCursor* cursor = &m_cursor;
if (!cursor->Ok())
cursor = wxSTANDARD_CURSOR;
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;
wxTheApp->ProcessIdle();
}
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
{
if (gs_busyCount++ > 0)
return;
wxCHECK_RET( window, _T("CaptureMouse() failed") );
- wxCursor* cursor = & m_cursor;
+ const wxCursor* cursor = &m_cursor;
if (!cursor->Ok())
cursor = wxSTANDARD_CURSOR;
#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;
+}
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)
{
/////////////////////////////////////////////////////////////////////////////
#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;
+}
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)
{
gs_savedCursor = wxNullCursor;
}
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
{
if ( gs_busyCount++ > 0 ) return;
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.
// Helper function
static void
-wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
+wxXSetBusyCursor (wxWindow * win, const wxCursor * cursor)
{
Display *display = (Display*) win->GetXDisplay();
}
// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
{
wxBusyCursorCount++;
if (wxBusyCursorCount == 1)
{
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++)
{
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,
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);
// 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
#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;
}
// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
{
if ( gs_wxBusyCursorCount++ == 0 )
{
#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;
+}
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 )
{
static int gs_wxBusyCursorCount = 0;
// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
{
}
wxTheApp->ProcessIdle();
}
-void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
+void wxBeginBusyCursor( const wxCursor *WXUNUSED(cursor) )
{
if (gs_busyCount++ > 0)
return;