From df816ad92f556233cc6346e74dbbdb0317f442cd Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 24 Sep 2006 10:27:12 +0000 Subject: [PATCH] Updated wxPallete information. Added GetColourCount() implementation to Carbon (I wonder why it doesnt just use the generic implementation). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/image.tex | 6 +++--- docs/latex/wx/palette.tex | 14 ++++++++++++-- include/wx/mac/carbon/palette.h | 29 ++++++++++++++--------------- src/mac/carbon/palette.cpp | 9 +++++++++ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index 88068a73d4..198750f426 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -579,9 +579,9 @@ used as a mask colour. Returns {\tt true} if the image currently has a mask. \constfunc{const wxPalette\&}{GetPalette}{\void} Returns the palette associated with the image. Currently the palette is only -used when converting to wxBitmap under Windows. - -Eventually wxImage handlers will set the palette if one exists in the image file. +used when converting to wxBitmap under Windows. Some of the wxImage handlers +have been modified to set the palette if one exists in the image file (usually +256 or less colour images in GIF or PNG format). \membersection{wxImage::GetRed}\label{wximagegetred} diff --git a/docs/latex/wx/palette.tex b/docs/latex/wx/palette.tex index f46329e085..2b2eeefbac 100644 --- a/docs/latex/wx/palette.tex +++ b/docs/latex/wx/palette.tex @@ -11,8 +11,18 @@ \section{\class{wxPalette}}\label{wxpalette} -A palette is a table that maps pixel values to RGB colours. It allows the colours -of a low-depth bitmap, for example, to be mapped to the available colours in a display. +A palette is a table that maps pixel values to RGB colours. It allows the +colours of a low-depth bitmap, for example, to be mapped to the available +colours in a display. The notion of palettes is becoming more and more +obsolete nowadays and only the MSW port is still using a native palette. +All other ports use generic code which is basically just an array of +colours. + +It is likely that in the future the only use for palettes within wxWidgets +will be for representing colour indeces from images (such as GIF or PNG). +The image handlers for these formats have been modified to create a palette +if there is such information in the original image file (usually 256 or less +colour images). See \helpref{wxImage}{wximage} for more information. %TODO: topic overview for wxPalette. \wxheading{Derived from} diff --git a/include/wx/mac/carbon/palette.h b/include/wx/mac/carbon/palette.h index 53cbb2f579..b28de1c40b 100644 --- a/include/wx/mac/carbon/palette.h +++ b/include/wx/mac/carbon/palette.h @@ -34,26 +34,25 @@ protected: class WXDLLEXPORT wxPalette: public wxPaletteBase { - DECLARE_DYNAMIC_CLASS(wxPalette) - public: - wxPalette(); + wxPalette(); - wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); - virtual ~wxPalette(); - bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); - int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const; - bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; + wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + virtual ~wxPalette(); + bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + + int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const; + bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; - virtual bool Ok() const { return (m_refData != NULL) ; } + virtual bool Ok() const { return (m_refData != NULL) ; } - inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } - inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } + inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } + inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } -/* TODO: implementation - inline WXHPALETTE GetHPALETTE() const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); } - void SetHPALETTE(WXHPALETTE pal); -*/ + virtual int GetColoursCount() const; + +private: + DECLARE_DYNAMIC_CLASS(wxPalette) }; #endif diff --git a/src/mac/carbon/palette.cpp b/src/mac/carbon/palette.cpp index 642af2b89b..cb5ca9487b 100644 --- a/src/mac/carbon/palette.cpp +++ b/src/mac/carbon/palette.cpp @@ -107,5 +107,14 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi return true; } +int wxPalette::GetColoursCount() const +{ + if (m_refData) + return M_PALETTEDATA->m_count; + + return 0; +} + + #endif // wxUSE_PALETTE -- 2.45.2