wxPaletteBase introduction. wxPalette::GetColoursCount() in interface of all platforms. wxColourMap definition centralized and 2.4 only. Source cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30901 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-12-08 17:43:18 +00:00
parent 767e3be0fa
commit 917be7ed06
13 changed files with 94 additions and 86 deletions

View File

@@ -92,6 +92,12 @@ true if the creation was successful, false otherwise.
\helpref{wxPalette::wxPalette}{wxpalettector} \helpref{wxPalette::wxPalette}{wxpalettector}
\membersection{wxPalette::GetColoursCount}\label{wxpalettegetcolourscount}
\constfunc{int}{GetColoursCount}{\void}
Returns number of entries in palette.
\membersection{wxPalette::GetPixel}\label{wxpalettegetpixel} \membersection{wxPalette::GetPixel}\label{wxpalettegetpixel}
\constfunc{int}{GetPixel}{\param{const unsigned char }{red}, \param{const unsigned char }{green},\rtfsp \constfunc{int}{GetPixel}{\param{const unsigned char }{red}, \param{const unsigned char }{green},\rtfsp

View File

@@ -31,7 +31,7 @@ class wxPalette;
// wxPalette // wxPalette
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxPalette: public wxGDIObject class wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
@@ -44,7 +44,7 @@ class wxPalette: public wxGDIObject
wxPalette& operator = ( const wxPalette& palette ); wxPalette& operator = ( const wxPalette& palette );
bool operator == ( const wxPalette& palette ); bool operator == ( const wxPalette& palette );
bool operator != ( const wxPalette& palette ); bool operator != ( const wxPalette& palette );
bool Ok() const; virtual bool Ok() const;
bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const; int GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const;
@@ -53,7 +53,4 @@ class wxPalette: public wxGDIObject
// no data // no data
}; };
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif // __WX_PALETTEG_H__ #endif // __WX_PALETTEG_H__

View File

@@ -24,7 +24,7 @@ class WXDLLEXPORT wxPalette;
class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
{ {
DECLARE_NO_COPY_CLASS(wxPaletteRefData) DECLARE_NO_COPY_CLASS(wxPaletteRefData)
friend class WXDLLEXPORT wxPalette; friend class WXDLLEXPORT wxPalette;
public: public:
wxPaletteRefData(); wxPaletteRefData();
@@ -36,14 +36,14 @@ protected:
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
public: public:
wxPalette(); wxPalette();
wxPalette(const wxPalette& palette) wxPalette(const wxPalette& palette)
: wxGDIObject() : wxPaletteBase()
{ Ref(palette); } { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);

View File

@@ -24,7 +24,7 @@ class WXDLLEXPORT wxPalette;
class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
{ {
DECLARE_NO_COPY_CLASS(wxPaletteRefData) DECLARE_NO_COPY_CLASS(wxPaletteRefData)
friend class WXDLLEXPORT wxPalette; friend class WXDLLEXPORT wxPalette;
public: public:
wxPaletteRefData(); wxPaletteRefData();
@@ -36,14 +36,14 @@ protected:
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
public: public:
wxPalette(); wxPalette();
wxPalette(const wxPalette& palette) wxPalette(const wxPalette& palette)
: wxGDIObject() : wxPaletteBase()
{ Ref(palette); } { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);

View File

@@ -32,7 +32,7 @@ struct palette_t;
// wxPalette // wxPalette
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
@@ -44,21 +44,16 @@ public:
wxPalette& operator = (const wxPalette& palette); wxPalette& operator = (const wxPalette& palette);
bool operator == (const wxPalette& palette) const; bool operator == (const wxPalette& palette) const;
bool operator != (const wxPalette& palette) const; bool operator != (const wxPalette& palette) const;
bool Ok() const; virtual bool Ok() const;
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const;
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
// implementation // implementation
int GetColoursCount() const; virtual int GetColoursCount() const;
// FIXME_MGL -- make this method standard part of wx API
// FIXME_MGL -- create wxXXXBase classes for all GDI stuff (Vadim wants that)
palette_t *GetMGLpalette_t() const; palette_t *GetMGLpalette_t() const;
}; };
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif // __WX_PALETTE_H__ #endif // __WX_PALETTE_H__

View File

@@ -25,10 +25,10 @@ class WXDLLEXPORT wxPalette;
class wxXPalette : public wxObject class wxXPalette : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxXPalette) DECLARE_DYNAMIC_CLASS(wxXPalette)
public: public:
wxXPalette(); wxXPalette();
WXDisplay* m_display; WXDisplay* m_display;
int m_pix_array_n; int m_pix_array_n;
unsigned long* m_pix_array; unsigned long* m_pix_array;
@@ -42,33 +42,33 @@ class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
public: public:
wxPaletteRefData(); wxPaletteRefData();
~wxPaletteRefData(); ~wxPaletteRefData();
protected: protected:
wxList m_palettes; wxList m_palettes;
}; };
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
public: public:
wxPalette(); wxPalette();
wxPalette(const wxPalette& palette) { Ref(palette); } wxPalette(const wxPalette& palette) { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette(); ~wxPalette();
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const;
bool GetRGB(int pixel, 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) ; }
wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; }
bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
// Motif-specific // Motif-specific
WXColormap GetXColormap(WXDisplay* display = NULL) const; WXColormap GetXColormap(WXDisplay* display = NULL) const;
bool TransferBitmap(void *data, int depth, int size); bool TransferBitmap(void *data, int depth, int size);

View File

@@ -32,13 +32,13 @@ protected:
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
public: public:
wxPalette(void); wxPalette(void);
inline wxPalette(const wxPalette& palette) : wxGDIObject(palette) { Ref(palette); } inline wxPalette(const wxPalette& palette) : wxPaletteBase(palette) { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette(void); ~wxPalette(void);
@@ -58,8 +58,5 @@ public:
void SetHPALETTE(WXHPALETTE pal); void SetHPALETTE(WXHPALETTE pal);
}; };
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif #endif
// _WX_PALETTE_H_ // _WX_PALETTE_H_

View File

@@ -30,7 +30,7 @@ public:
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
@@ -68,16 +68,13 @@ public:
inline bool operator != (const wxPalette& rPalette) const inline bool operator != (const wxPalette& rPalette) const
{ return m_refData != rPalette.m_refData; } { return m_refData != rPalette.m_refData; }
virtual bool FreeResource(bool bForce = FALSE); virtual bool FreeResource(bool bForce = false);
inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); } inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
void SetHPALETTE(WXHPALETTE hPalette); void SetHPALETTE(WXHPALETTE hPalette);
void SetPS(HPS hPS); void SetPS(HPS hPS);
}; // end of CLASS wxPalette }; // end of CLASS wxPalette
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif #endif
// _WX_PALETTE_H_ // _WX_PALETTE_H_

View File

@@ -1,12 +1,26 @@
#ifndef _WX_PALETTE_H_BASE_ #ifndef _WX_PALETTE_H_BASE_
#define _WX_PALETTE_H_BASE_ #define _WX_PALETTE_H_BASE_
// include it to get wxUSE_PALETTE value #include "wx/defs.h"
#include "wx/setup.h"
#if wxUSE_PALETTE #if wxUSE_PALETTE
#if defined(__WXMSW__) #include "wx/object.h"
#include "wx/gdiobj.h"
// wxBrushBase
class WXDLLEXPORT wxPaletteBase: public wxGDIObject
{
public:
virtual ~wxPaletteBase() { }
virtual bool Ok() const = 0;
virtual int GetColoursCount() const { wxFAIL_MSG( _T("not implemented") ); return 0; };
};
#if defined(__PALMOS__)
#include "wx/palmos/palette.h"
#elif defined(__WXMSW__)
#include "wx/msw/palette.h" #include "wx/msw/palette.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/palette.h" #include "wx/motif/palette.h"
@@ -22,6 +36,11 @@
#include "wx/os2/palette.h" #include "wx/os2/palette.h"
#endif #endif
#if WXWIN_COMPATIBILITY_2_4
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif
#endif // wxUSE_PALETTE #endif // wxUSE_PALETTE
#endif #endif

View File

@@ -4,7 +4,7 @@
// Author: William Osborne // Author: William Osborne
// Modified by: // Modified by:
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id: // RCS-ID: $Id:
// Copyright: (c) William Osborne // Copyright: (c) William Osborne
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -32,7 +32,7 @@ protected:
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
@@ -52,14 +52,11 @@ public:
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; }
virtual bool FreeResource(bool force = FALSE); virtual bool FreeResource(bool force = false);
inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); } inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
void SetHPALETTE(WXHPALETTE pal); void SetHPALETTE(WXHPALETTE pal);
}; };
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif #endif
// _WX_PALETTE_H_ // _WX_PALETTE_H_

View File

@@ -25,10 +25,10 @@ class WXDLLEXPORT wxPalette;
class wxXPalette : public wxObject class wxXPalette : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxXPalette) DECLARE_DYNAMIC_CLASS(wxXPalette)
public: public:
wxXPalette(); wxXPalette();
WXDisplay* m_display; WXDisplay* m_display;
int m_pix_array_n; int m_pix_array_n;
unsigned long* m_pix_array; unsigned long* m_pix_array;
@@ -42,33 +42,33 @@ class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
public: public:
wxPaletteRefData(); wxPaletteRefData();
~wxPaletteRefData(); ~wxPaletteRefData();
protected: protected:
wxList m_palettes; wxList m_palettes;
}; };
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) #define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject class WXDLLEXPORT wxPalette: public wxPaletteBase
{ {
DECLARE_DYNAMIC_CLASS(wxPalette) DECLARE_DYNAMIC_CLASS(wxPalette)
public: public:
wxPalette(); wxPalette();
wxPalette(const wxPalette& palette) { Ref(palette); } wxPalette(const wxPalette& palette) { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette(); ~wxPalette();
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const;
bool GetRGB(int pixel, 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) ; }
wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; }
bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
// X-specific // X-specific
WXColormap GetXColormap(WXDisplay* display = NULL) const; WXColormap GetXColormap(WXDisplay* display = NULL) const;
bool TransferBitmap(void *data, int depth, int size); bool TransferBitmap(void *data, int depth, int size);

View File

@@ -23,7 +23,7 @@ I have implemented basic colormap support for the X11 versions of
wxWidgets, notably wxPalette::Create(). The way I did it is to wxWidgets, notably wxPalette::Create(). The way I did it is to
allocate additional read-only color cells in the default colormap. In allocate additional read-only color cells in the default colormap. In
general you will get arbitrary pixel values assigned to these new general you will get arbitrary pixel values assigned to these new
cells and therefore I added a method wxColourMap::TransferBitmap() cells and therefore I added a method wxPalette::TransferBitmap()
which maps the pixel values 0..n to the real ones obtained with which maps the pixel values 0..n to the real ones obtained with
Create(). This is only implemented for the popular case of 8-bit Create(). This is only implemented for the popular case of 8-bit
depth. depth.
@@ -69,7 +69,7 @@ wxXPalette::wxXPalette()
m_pix_array_n = 0; m_pix_array_n = 0;
m_pix_array = (unsigned long*) 0; m_pix_array = (unsigned long*) 0;
m_display = (WXDisplay*) 0; m_display = (WXDisplay*) 0;
m_destroyable = FALSE; m_destroyable = false;
} }
wxPaletteRefData::wxPaletteRefData() wxPaletteRefData::wxPaletteRefData()
@@ -130,7 +130,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
UnRef(); UnRef();
if (!n) { if (!n) {
return FALSE; return false;
} }
m_refData = new wxPaletteRefData; m_refData = new wxPaletteRefData;
@@ -146,7 +146,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
pix_array = new unsigned long[n]; pix_array = new unsigned long[n];
if (!pix_array) if (!pix_array)
return FALSE; return false;
pix_array_n = n; pix_array_n = n;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
@@ -163,10 +163,10 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
c->m_pix_array = pix_array; c->m_pix_array = pix_array;
c->m_cmap = (WXColormap) cmap; c->m_cmap = (WXColormap) cmap;
c->m_display = (WXDisplay*) display; c->m_display = (WXDisplay*) display;
c->m_destroyable = FALSE; c->m_destroyable = false;
M_PALETTEDATA->m_palettes.Append(c); M_PALETTEDATA->m_palettes.Append(c);
return TRUE; return true;
} }
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
@@ -181,13 +181,13 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
{ {
if ( !m_refData ) if ( !m_refData )
return FALSE; return false;
if (index < 0 || index > 255) if (index < 0 || index > 255)
return FALSE; return false;
// TODO // TODO
return FALSE; return false;
} }
WXColormap wxPalette::GetXColormap(WXDisplay* display) const WXColormap wxPalette::GetXColormap(WXDisplay* display) const
@@ -221,7 +221,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
c->m_pix_array = new unsigned long[pix_array_n]; c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display; c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display); c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE; c->m_destroyable = false;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
int i; int i;
@@ -257,10 +257,10 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size)
uptr++; uptr++;
} }
return TRUE; return true;
} }
default: default:
return FALSE; return false;
} }
} }
@@ -314,9 +314,9 @@ bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
break; break;
} }
default: default:
return FALSE; return false;
} }
return TRUE; return true;
} }
unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n) unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)

View File

@@ -23,7 +23,7 @@ I have implemented basic colormap support for the X11 versions of
wxWidgets, notably wxPalette::Create(). The way I did it is to wxWidgets, notably wxPalette::Create(). The way I did it is to
allocate additional read-only color cells in the default colormap. In allocate additional read-only color cells in the default colormap. In
general you will get arbitrary pixel values assigned to these new general you will get arbitrary pixel values assigned to these new
cells and therefore I added a method wxColourMap::TransferBitmap() cells and therefore I added a method wxPalette::TransferBitmap()
which maps the pixel values 0..n to the real ones obtained with which maps the pixel values 0..n to the real ones obtained with
Create(). This is only implemented for the popular case of 8-bit Create(). This is only implemented for the popular case of 8-bit
depth. depth.
@@ -66,7 +66,7 @@ wxXPalette::wxXPalette()
m_pix_array_n = 0; m_pix_array_n = 0;
m_pix_array = (unsigned long*) 0; m_pix_array = (unsigned long*) 0;
m_display = (WXDisplay*) 0; m_display = (WXDisplay*) 0;
m_destroyable = FALSE; m_destroyable = false;
} }
wxPaletteRefData::wxPaletteRefData() wxPaletteRefData::wxPaletteRefData()
@@ -101,7 +101,7 @@ wxPaletteRefData::~wxPaletteRefData()
#endif #endif
delete [] pix_array; delete [] pix_array;
} }
if (destroyable) if (destroyable)
XFreeColormap(display, cmap); XFreeColormap(display, cmap);
@@ -129,7 +129,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
UnRef(); UnRef();
if (!n) { if (!n) {
return FALSE; return false;
} }
m_refData = new wxPaletteRefData; m_refData = new wxPaletteRefData;
@@ -145,7 +145,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
pix_array = new unsigned long[n]; pix_array = new unsigned long[n];
if (!pix_array) if (!pix_array)
return FALSE; return false;
pix_array_n = n; pix_array_n = n;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
@@ -162,10 +162,10 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
c->m_pix_array = pix_array; c->m_pix_array = pix_array;
c->m_cmap = (WXColormap) cmap; c->m_cmap = (WXColormap) cmap;
c->m_display = (WXDisplay*) display; c->m_display = (WXDisplay*) display;
c->m_destroyable = FALSE; c->m_destroyable = false;
M_PALETTEDATA->m_palettes.Append(c); M_PALETTEDATA->m_palettes.Append(c);
return TRUE; return true;
} }
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
@@ -180,13 +180,13 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
{ {
if ( !m_refData ) if ( !m_refData )
return FALSE; return false;
if (index < 0 || index > 255) if (index < 0 || index > 255)
return FALSE; return false;
// TODO // TODO
return FALSE; return false;
} }
WXColormap wxPalette::GetXColormap(WXDisplay* display) const WXColormap wxPalette::GetXColormap(WXDisplay* display) const
@@ -219,7 +219,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
c->m_pix_array = new unsigned long[pix_array_n]; c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display; c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display); c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE; c->m_destroyable = false;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
int i; int i;
@@ -253,10 +253,10 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size)
uptr++; uptr++;
} }
return TRUE; return true;
} }
default: default:
return FALSE; return false;
} }
} }
@@ -310,9 +310,9 @@ bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
break; break;
} }
default: default:
return FALSE; return false;
} }
return TRUE; return true;
} }
unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n) unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)