X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88ef3a57a47f840adea9d38bc11cb30689a0838a..8064223b7b1b3657363b7a635c381b9269d95e55:/src/mac/carbon/palette.cpp?ds=inline diff --git a/src/mac/carbon/palette.cpp b/src/mac/carbon/palette.cpp index 642af2b89b..37b1826a80 100644 --- a/src/mac/carbon/palette.cpp +++ b/src/mac/carbon/palette.cpp @@ -14,28 +14,55 @@ #if wxUSE_PALETTE #include "wx/palette.h" +#include "wx/colour.h" IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) -/* - * Palette - * - */ +// ============================================================================ +// wxPaletteRefData +// ============================================================================ + +class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData +{ +public: + wxPaletteRefData(); + wxPaletteRefData(const wxPaletteRefData& data); + virtual ~wxPaletteRefData(); + + virtual bool IsOk() const { return m_count > 0; } + +protected: + wxColour* m_palette; + wxInt32 m_count; + + friend class WXDLLIMPEXP_FWD_CORE wxPalette; + + DECLARE_NO_ASSIGN_CLASS(wxPaletteRefData) +}; wxPaletteRefData::wxPaletteRefData() { - m_palette = NULL ; - m_count = 0 ; + m_palette = NULL; + m_count = 0; +} + +wxPaletteRefData::wxPaletteRefData(const wxPaletteRefData& data) +{ + m_count = data.m_count; + m_palette = new wxColour[m_count]; + for ( wxInt32 i = 0; i < m_count; i++ ) + m_palette[i] = data.m_palette[i]; } wxPaletteRefData::~wxPaletteRefData() { - if (m_palette != NULL) { - delete[] m_palette ; - m_palette = NULL; - } + delete[] m_palette; } +// ============================================================================ +// wxPalette +// ============================================================================ + wxPalette::wxPalette() { } @@ -107,5 +134,22 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi return true; } -#endif -// wxUSE_PALETTE +int wxPalette::GetColoursCount() const +{ + if (m_refData) + return M_PALETTEDATA->m_count; + + return 0; +} + +wxGDIRefData *wxPalette::CreateGDIRefData() const +{ + return new wxPaletteRefData; +} + +wxGDIRefData *wxPalette::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxPaletteRefData(*wx_static_cast(const wxPaletteRefData *, data)); +} + +#endif // wxUSE_PALETTE