wx/gtk/dcscreen.h
wx/gtk/dnd.h
wx/gtk/font.h
- wx/gtk/gdiobj.h
wx/gtk/icon.h
wx/gtk/minifram.h
wx/gtk/pen.h
wx/gtk1/dcscreen.h
wx/gtk1/dnd.h
wx/gtk1/font.h
- wx/gtk1/gdiobj.h
wx/gtk1/icon.h
wx/gtk1/minifram.h
wx/gtk1/pen.h
wx/motif/font.h
wx/motif/frame.h
wx/motif/gauge.h
- wx/motif/gdiobj.h
wx/motif/icon.h
wx/motif/listbox.h
wx/motif/mdi.h
wx/x11/dcscreen.h
wx/x11/dnd.h
wx/x11/font.h
- wx/x11/gdiobj.h
wx/x11/icon.h
wx/x11/minifram.h
wx/x11/palette.h
wx/msw/frame.h
wx/msw/gauge95.h
wx/msw/gdiimage.h
- wx/msw/gdiobj.h
wx/msw/icon.h
wx/msw/imaglist.h
wx/msw/iniconf.h
wx/mgl/dcscreen.h
wx/mgl/font.h
wx/mgl/fontutil.h
- wx/mgl/gdiobj.h
wx/mgl/icon.h
wx/mgl/palette.h
wx/mgl/pen.h
wx/os2/frame.h
wx/os2/gauge.h
wx/os2/gdiimage.h
- wx/os2/gdiobj.h
wx/os2/helpwin.h
wx/os2/icon.h
wx/os2/iniconf.h
wx/mac/fontdlg.h
wx/mac/frame.h
wx/mac/gauge.h
- wx/mac/gdiobj.h
wx/mac/glcanvas.h
wx/mac/gsockmac.h
wx/mac/helpxxxx.h
wx/mac/carbon/fontdlg.h
wx/mac/carbon/frame.h
wx/mac/carbon/gauge.h
- wx/mac/carbon/gdiobj.h
wx/mac/carbon/gsockmac.h
wx/mac/carbon/helpxxxx.h
wx/mac/carbon/icon.h
wx/cocoa/fontdlg.h
wx/cocoa/frame.h
wx/cocoa/gauge.h
- wx/cocoa/gdiobj.h
wx/cocoa/icon.h
wx/cocoa/listbox.h
wx/cocoa/log.h
use the object pointer {\bf wxTheBrushList}.
-\membersection{wxBrushList::AddBrush}\label{wxbrushlistaddbrush}
-
-\func{void}{AddBrush}{\param{wxBrush *}{brush}}
-
-Used internally by wxWidgets to add a brush to the list.
-
-
\membersection{wxBrushList::FindOrCreateBrush}\label{wxbrushlistfindorcreatebrush}
\func{wxBrush *}{FindOrCreateBrush}{\param{const wxColour\& }{colour}, \param{int}{ style = wxSOLID}}
\docparam{style}{Brush style. See \helpref{wxBrush::SetStyle}{wxbrushsetstyle} for a list of styles.}
-\membersection{wxBrushList::RemoveBrush}\label{wxbrushlistremovebrush}
-
-\func{void}{RemoveBrush}{\param{wxBrush *}{brush}}
-
-Used by wxWidgets to remove a brush from the list.
-
-
Constructor. The application should not construct its own font list:
use the object pointer {\bf wxTheFontList}.
-\membersection{wxFontList::AddFont}\label{wxfontlistaddfont}
-
-\func{void}{AddFont}{\param{wxFont *}{font}}
-
-Used by wxWidgets to add a font to the list, called in the font constructor.
-
\membersection{wxFontList::FindOrCreateFont}\label{findorcreatefont}
\func{wxFont *}{FindOrCreateFont}{\param{int}{ point\_size}, \param{int}{ family}, \param{int}{ style}, \param{int}{ weight}, \param{bool}{ underline = false},
Finds a font of the given specification, or creates one and adds it to the list. See the \helpref{wxFont constructor}{wxfontctor} for
details of the arguments.
-\membersection{wxFontList::RemoveFont}\label{wxfontlistremovefont}
-
-\func{void}{RemoveFont}{\param{wxFont *}{font}}
-
-Used by wxWidgets to remove a font from the list.
-
-
Constructor. The application should not construct its own pen list:
use the object pointer {\bf wxThePenList}.
-\membersection{wxPenList::AddPen}\label{wxpenlistaddpen}
-
-\func{void}{AddPen}{\param{wxPen*}{ pen}}
-
-Used internally by wxWidgets to add a pen to the list.
-
\membersection{wxPenList::FindOrCreatePen}\label{wxpenlistfindorcreatepen}
\func{wxPen*}{FindOrCreatePen}{\param{const wxColour\& }{colour}, \param{int}{ width}, \param{int}{ style}}
\docparam{width}{Width of pen.}
\docparam{style}{Pen style. See \helpref{wxPen::wxPen}{wxpenctor} for a list of styles.}
-
-\membersection{wxPenList::RemovePen}\label{wxpenlistremovepen}
-
-\func{void}{RemovePen}{\param{wxPen*}{ pen}}
-
-Used by wxWidgets to remove a pen from the list.
typedef wxInt8 wxDash;
-class WXDLLEXPORT wxPenList : public wxList
-{
+class WXDLLIMPEXP_CORE wxGDIObjListBase {
public:
- wxPenList() { }
- ~wxPenList();
+ wxGDIObjListBase();
+ ~wxGDIObjListBase();
- void AddPen(wxPen *pen);
- void RemovePen(wxPen *pen);
- wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
+protected:
+ wxList list;
};
-class WXDLLEXPORT wxBrushList : public wxList
+class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase
{
public:
- wxBrushList() { }
- ~wxBrushList();
+ wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
+#if WXWIN_COMPATIBILITY_2_6
+ wxDEPRECATED( void AddPen(wxPen*) );
+ wxDEPRECATED( void RemovePen(wxPen*) );
+#endif
+};
- void AddBrush(wxBrush *brush);
- void RemoveBrush(wxBrush *brush);
+class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase
+{
+public:
wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID);
+#if WXWIN_COMPATIBILITY_2_6
+ wxDEPRECATED( void AddBrush(wxBrush*) );
+ wxDEPRECATED( void RemoveBrush(wxBrush*) );
+#endif
};
-class WXDLLEXPORT wxFontList : public wxList
+class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
{
public:
- wxFontList() { }
- ~wxFontList();
-
- void AddFont(wxFont *font);
- void RemoveFont(wxFont *font);
wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
bool underline = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
+#if WXWIN_COMPATIBILITY_2_6
+ wxDEPRECATED( void AddFont(wxFont*) );
+ wxDEPRECATED( void RemoveFont(wxFont*) );
+#endif
};
WX_DECLARE_STRING_HASH_MAP( wxColour *, wxStringToColourHashMap );
wxStringToColourHashMap *m_map;
};
-class WXDLLEXPORT wxBitmapList : public wxList
-{
-public:
- wxBitmapList(){}
- ~wxBitmapList();
-
- void AddBitmap(wxBitmap *bitmap);
- void RemoveBitmap(wxBitmap *bitmap);
-};
-
class WXDLLEXPORT wxResourceCache: public wxList
{
public:
extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList;
extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList;
extern WXDLLEXPORT_DATA(wxFontList*) wxTheFontList;
-extern WXDLLEXPORT_DATA(wxBitmapList*) wxTheBitmapList;
/* Stock objects
#ifndef _WX_GDIOBJ_H_BASE_
#define _WX_GDIOBJ_H_BASE_
-#include "wx/defs.h"
-
-#if defined(__WXPALMOS__)
-#include "wx/palmos/gdiobj.h"
-#elif defined(__WXMSW__)
-#include "wx/msw/gdiobj.h"
-#elif defined(__WXMOTIF__)
-#include "wx/motif/gdiobj.h"
-#elif defined(__WXGTK20__)
-#include "wx/gtk/gdiobj.h"
-#elif defined(__WXGTK__)
-#include "wx/gtk1/gdiobj.h"
-#elif defined(__WXX11__)
-#include "wx/x11/gdiobj.h"
-#elif defined(__WXMGL__)
-#include "wx/mgl/gdiobj.h"
-#elif defined(__WXMAC__)
-#include "wx/mac/gdiobj.h"
-#elif defined(__WXCOCOA__)
-#include "wx/cocoa/gdiobj.h"
-#elif defined(__WXPM__)
-#include "wx/os2/gdiobj.h"
-#endif
+#include "wx/object.h"
+
+// ----------------------------------------------------------------------------
+// wxGDIRefData is the base class for wxXXXData structures which contain the
+// real data for the GDI object and are shared among all wxWin objects sharing
+// the same native GDI object
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxGDIRefData: public wxObjectRefData { };
+
+// ----------------------------------------------------------------------------
+// wxGDIObject
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxGDIObject: public wxObject
+{
+public:
+ bool IsNull() const { return m_refData == NULL; }
+
+#if defined(__WXMSW__) || defined(__WXOS2__) || defined(__WXPALMOS__)
+ // Creates the resource
+ virtual bool RealizeResource() { return false; }
+
+ // Frees the resource
+ virtual bool FreeResource(bool WXUNUSED(force) = false) { return false; }
+
+ virtual bool IsFree() const { return false; }
+
+ // Returns handle.
+ virtual WXHANDLE GetResourceHandle() const { return 0; }
+#endif // defined(__WXMSW__) || defined(__WXOS2__)
+
+ DECLARE_DYNAMIC_CLASS(wxGDIObject)
+};
#endif
// _WX_GDIOBJ_H_BASE_
wxFont::~wxFont()
{
- if (wxTheFontList)
- wxTheFontList->DeleteObject(this);
}
bool wxFont::RealizeResource()
wxFontList *wxTheFontList = NULL;
wxPenList *wxThePenList = NULL;
wxBrushList *wxTheBrushList = NULL;
-wxBitmapList *wxTheBitmapList = NULL;
wxColourDatabase *wxTheColourDatabase = NULL;
// 'Null' objects
wxTheBrushList = new wxBrushList;
wxThePenList = new wxPenList;
wxTheFontList = new wxFontList;
- wxTheBitmapList = new wxBitmapList;
}
void wxDeleteStockLists()
wxDELETE(wxTheBrushList);
wxDELETE(wxThePenList);
wxDELETE(wxTheFontList);
- wxDELETE(wxTheBitmapList);
}
// ============================================================================
// wxTheXXXList stuff (semi-obsolete)
// ============================================================================
-wxBitmapList::~wxBitmapList ()
+wxGDIObjListBase::wxGDIObjListBase()
{
- wxList::compatibility_iterator node = GetFirst ();
- while (node)
- {
- wxBitmap *bitmap = (wxBitmap *) node->GetData ();
- wxList::compatibility_iterator next = node->GetNext ();
- if (bitmap->GetVisible())
- delete bitmap;
- node = next;
- }
}
-// Pen and Brush lists
-wxPenList::~wxPenList ()
+wxGDIObjListBase::~wxGDIObjListBase()
{
- wxList::compatibility_iterator node = GetFirst ();
- while (node)
+ for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext())
{
- wxPen *pen = (wxPen *) node->GetData ();
- wxList::compatibility_iterator next = node->GetNext ();
- if (pen->GetVisible())
- delete pen;
- node = next;
+ delete wx_static_cast(wxObject*, node->GetData());
}
}
-void wxPenList::AddPen (wxPen * pen)
-{
- Append (pen);
-}
-
-void wxPenList::RemovePen (wxPen * pen)
-{
- DeleteObject (pen);
-}
-
wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
{
- for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ())
+ for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext())
{
wxPen *each_pen = (wxPen *) node->GetData ();
- if (each_pen &&
- each_pen->GetVisible() &&
+ if (
each_pen->GetWidth () == width &&
each_pen->GetStyle () == style &&
each_pen->GetColour ().Red () == colour.Red () &&
return each_pen;
}
- wxPen *pen = new wxPen (colour, width, style);
- if ( !pen->Ok() )
+ wxPen* pen = NULL;
+ wxPen penTmp(colour, width, style);
+ if (penTmp.Ok())
{
- // don't save the invalid pens in the list
- delete pen;
-
- return NULL;
+ pen = new wxPen(penTmp);
+ list.Append(pen);
}
- AddPen(pen);
-
- // we'll delete it ourselves later
- pen->SetVisible(true);
-
return pen;
}
-wxBrushList::~wxBrushList ()
-{
- wxList::compatibility_iterator node = GetFirst ();
- while (node)
- {
- wxBrush *brush = (wxBrush *) node->GetData ();
- wxList::compatibility_iterator next = node->GetNext ();
- if (brush && brush->GetVisible())
- delete brush;
- node = next;
- }
-}
-
-void wxBrushList::AddBrush (wxBrush * brush)
-{
- Append (brush);
-}
-
wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
{
- for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ())
+ for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext())
{
wxBrush *each_brush = (wxBrush *) node->GetData ();
- if (each_brush &&
- each_brush->GetVisible() &&
+ if (
each_brush->GetStyle () == style &&
each_brush->GetColour ().Red () == colour.Red () &&
each_brush->GetColour ().Green () == colour.Green () &&
return each_brush;
}
- wxBrush *brush = new wxBrush (colour, style);
-
- if ( !brush->Ok() )
+ wxBrush* brush = NULL;
+ wxBrush brushTmp(colour, style);
+ if (brushTmp.Ok())
{
- // don't put the brushes we failed to create into the list
- delete brush;
-
- return NULL;
+ brush = new wxBrush(brushTmp);
+ list.Append(brush);
}
- AddBrush(brush);
-
- // we'll delete it ourselves later
- brush->SetVisible(true);
-
return brush;
}
-void wxBrushList::RemoveBrush (wxBrush * brush)
-{
- DeleteObject (brush);
-}
-
-wxFontList::~wxFontList ()
-{
- wxList::compatibility_iterator node = GetFirst ();
- while (node)
- {
- // Only delete objects that are 'visible', i.e.
- // that have been created using FindOrCreate...,
- // where the pointers are expected to be shared
- // (and therefore not deleted by any one part of an app).
- wxFont *font = (wxFont *) node->GetData ();
- wxList::compatibility_iterator next = node->GetNext ();
- if (font->GetVisible())
- delete font;
- node = next;
- }
-}
-
-void wxFontList::AddFont (wxFont * font)
-{
- Append (font);
-}
-
-void wxFontList::RemoveFont (wxFont * font)
-{
- DeleteObject (font);
-}
-
wxFont *wxFontList::FindOrCreateFont(int pointSize,
int family,
int style,
const wxString& facename,
wxFontEncoding encoding)
{
- wxFont *font = (wxFont *)NULL;
+ wxFont *font;
wxList::compatibility_iterator node;
- for ( node = GetFirst(); node; node = node->GetNext() )
+ for (node = list.GetFirst(); node; node = node->GetNext())
{
font = (wxFont *)node->GetData();
- if ( font->GetVisible() &&
- font->Ok() &&
+ if (
font->GetPointSize () == pointSize &&
font->GetStyle () == style &&
font->GetWeight () == weight &&
}
}
- if ( !node )
+ // font not found, create the new one
+ font = NULL;
+ wxFont fontTmp(pointSize, family, style, weight, underline, facename, encoding);
+ if (fontTmp.Ok())
{
- // font not found, create the new one
- font = new wxFont(pointSize, family, style, weight,
- underline, facename, encoding);
-
- AddFont(font);
-
- // and mark it as being cacheable
- font->SetVisible(true);
+ font = new wxFont(fontTmp);
+ list.Append(font);
}
return font;
}
-void wxBitmapList::AddBitmap(wxBitmap *bitmap)
-{
- Append(bitmap);
-}
-
-void wxBitmapList::RemoveBitmap(wxBitmap *bitmap)
-{
- DeleteObject(bitmap);
-}
+#if WXWIN_COMPATIBILITY_2_6
+void wxBrushList::AddBrush(wxBrush*) { }
+void wxBrushList::RemoveBrush(wxBrush*) { }
+void wxFontList::AddFont(wxFont*) { }
+void wxFontList::RemoveFont(wxFont*) { }
+void wxPenList::AddPen(wxPen*) { }
+void wxPenList::RemovePen(wxPen*) { }
+#endif
wxSize wxGetDisplaySize()
{
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
+#define M_GDIDATA wx_static_cast(wxGDIRefData*, m_refData)
+
/*
void wxGDIObject::IncrementResourceUsage(void)
{
//
wxBrush::wxBrush()
{
- if ( wxTheBrushList )
- wxTheBrushList->AddBrush(this);
} // end of wxBrush::wxBrush
wxBrush::~wxBrush()
{
- if ( wxTheBrushList )
- wxTheBrushList->RemoveBrush(this);
} // end of wxBrush::~wxBrush
wxBrush::wxBrush(
memset(&M_BRUSHDATA->m_vBundle, '\0', sizeof(AREABUNDLE));
RealizeResource();
-
- if ( wxTheBrushList )
- wxTheBrushList->AddBrush(this);
} // end of wxBrush::wxBrush
wxBrush::wxBrush(
memset(&M_BRUSHDATA->m_vBundle, '\0', sizeof(AREABUNDLE));
RealizeResource();
-
- if ( wxTheBrushList )
- wxTheBrushList->AddBrush(this);
} // end of wxBrush::wxBrush
bool wxBrush::RealizeResource()
//
wxPen::wxPen()
{
- if ( wxThePenList )
- wxThePenList->AddPen(this);
} // end of wxPen::wxPen
wxPen::~wxPen()
{
- if (wxThePenList)
- wxThePenList->RemovePen(this);
} // end of wxPen::wxPen
// Should implement Create
M_PENDATA->m_hPen = 0L;
RealizeResource();
-
- if ( wxThePenList )
- wxThePenList->AddPen(this);
} // end of wxPen::wxPen
wxPen::wxPen(
M_PENDATA->m_hPen = 0;
RealizeResource();
-
- if ( wxThePenList )
- wxThePenList->AddPen(this);
} // end of wxPen::wxPen
int wx2os2PenStyle(