git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35811
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
20 files changed:
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name: palette.tex
+%% Purpose: wxPalette docs
+%% Author:
+%% Modified by:
+%% Created:
+%% RCS-ID: $Id$
+%% Copyright: (c) wxWidgets
+%% License: wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\section{\class{wxPalette}}\label{wxpalette}
A palette is a table that maps pixel values to RGB colours. It allows the colours
\section{\class{wxPalette}}\label{wxpalette}
A palette is a table that maps pixel values to RGB colours. It allows the colours
\membersection{wxPalette::GetPixel}\label{wxpalettegetpixel}
\membersection{wxPalette::GetPixel}\label{wxpalettegetpixel}
-\constfunc{int}{GetPixel}{\param{const unsigned char }{red}, \param{const unsigned char }{green},\rtfsp
- \param{const unsigned char }{blue}}
+\constfunc{int}{GetPixel}{\param{unsigned char }{red}, \param{unsigned char }{green},\rtfsp
+ \param{unsigned char }{blue}}
Returns a pixel value (index into the palette) for the given RGB values.
Returns a pixel value (index into the palette) for the given RGB values.
-The nearest palette index.
+The nearest palette index or {\tt wxNOT\_FOUND} for unexpected errors.
Inequality operator. Two palettes are not equal if they contain pointers
to different underlying palette data. It does not compare each attribute.
Inequality operator. Two palettes are not equal if they contain pointers
to different underlying palette data. It does not compare each attribute.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/generic/paletteg.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
virtual bool Ok() const;
bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
virtual bool Ok() const;
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( unsigned char red, unsigned char green, unsigned char blue ) const;
bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const;
// no data
bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const;
// no data
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/mac/carbon/palette.h
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette();
bool Create(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();
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(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) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok() const { return (m_refData != NULL) ; }
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/mac/classic/palette.h
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette();
bool Create(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();
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(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) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok() const { return (m_refData != NULL) ; }
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/mgl/palette.h
// Purpose:
// Author: Vaclav Slavik
// Created: 2001/03/11
// Purpose:
// Author: Vaclav Slavik
// Created: 2001/03/11
virtual bool Ok() const;
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
virtual bool Ok() const;
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(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
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
// implementation
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/motif/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette();
bool Create(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();
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(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) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok() const { return (m_refData != NULL) ; }
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/msw/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette(void);
bool Create(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);
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(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(void) const { return (m_refData != NULL) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok(void) const { return (m_refData != NULL) ; }
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/os2/palette.h
// Purpose: wxPalette class
// Author: David Webster
// Modified by:
// Purpose: wxPalette class
// Author: David Webster
// Modified by:
,const unsigned char* pGreen
,const unsigned char* pBlue
);
,const unsigned char* pGreen
,const unsigned char* pBlue
);
- int GetPixel( const unsigned char cRed
- ,const unsigned char cGreen
- ,const unsigned char cBlue
+ int GetPixel( unsigned char cRed
+ ,unsigned char cGreen
+ ,unsigned char cBlue
) const;
bool GetRGB( int nPixel
,unsigned char* pRed
) const;
bool GetRGB( int nPixel
,unsigned char* pRed
#include "wx/object.h"
#include "wx/gdiobj.h"
#include "wx/object.h"
#include "wx/gdiobj.h"
class WXDLLEXPORT wxPaletteBase: public wxGDIObject
{
public:
class WXDLLEXPORT wxPaletteBase: public wxGDIObject
{
public:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette(void);
bool Create(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);
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(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(void) const { return (m_refData != NULL) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok(void) const { return (m_refData != NULL) ; }
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: wx/x11/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette();
bool Create(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();
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(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) ; }
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok() const { return (m_refData != NULL) ; }
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-int wxPalette::GetPixel( const unsigned char red,
- const unsigned char green,
- const unsigned char blue ) const
+int wxPalette::GetPixel( unsigned char red,
+ unsigned char green,
+ unsigned char blue ) const
- if (!m_refData) return false;
+ if (!m_refData) return wxNOT_FOUND;
int closest = 0;
double d,distance = 1000.0; // max. dist is 256
int closest = 0;
double d,distance = 1000.0; // max. dist is 256
}
#endif // wxUSE_PALETTE
}
#endif // wxUSE_PALETTE
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/mac/carbon/palette.cpp
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
m_refData = new wxPaletteRefData;
m_refData = new wxPaletteRefData;
M_PALETTEDATA->m_count = n ;
M_PALETTEDATA->m_palette = new wxColour[n] ;
M_PALETTEDATA->m_count = n ;
M_PALETTEDATA->m_palette = new wxColour[n] ;
for ( int i = 0 ; i < n ; ++i)
{
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
for ( int i = 0 ; i < n ; ++i)
{
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
-int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
long currentdiff ;
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
long currentdiff ;
for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i )
{
const wxColour& col = M_PALETTEDATA->m_palette[i] ;
for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i )
{
const wxColour& col = M_PALETTEDATA->m_palette[i] ;
bestdiff = currentdiff ;
bestpos = i ;
if ( bestdiff == 0 )
bestdiff = currentdiff ;
bestpos = i ;
if ( bestdiff == 0 )
return bestpos;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
return bestpos;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
if (index < 0 || index >= M_PALETTEDATA->m_count)
if (index < 0 || index >= M_PALETTEDATA->m_count)
const wxColour& col = M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
const wxColour& col = M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
}
#endif
// wxUSE_PALETTE
}
#endif
// wxUSE_PALETTE
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/mac/classic/palette.cpp
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h"
/////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h"
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
m_refData = new wxPaletteRefData;
m_refData = new wxPaletteRefData;
M_PALETTEDATA->m_count = n ;
M_PALETTEDATA->m_palette = new wxColour[n] ;
M_PALETTEDATA->m_count = n ;
M_PALETTEDATA->m_palette = new wxColour[n] ;
for ( int i = 0 ; i < n ; ++i)
{
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
for ( int i = 0 ; i < n ; ++i)
{
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
-int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
long currentdiff ;
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
long currentdiff ;
for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i )
{
const wxColour& col = &M_PALETTEDATA->m_palette[i] ;
for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i )
{
const wxColour& col = &M_PALETTEDATA->m_palette[i] ;
bestdiff = currentdiff ;
bestpos = i ;
if ( bestdiff == 0 )
bestdiff = currentdiff ;
bestpos = i ;
if ( bestdiff == 0 )
return bestpos;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
return bestpos;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
if (index < 0 || index >= M_PALETTEDATA->m_count)
if (index < 0 || index >= M_PALETTEDATA->m_count)
const wxColour& col = &M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
const wxColour& col = &M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
}
#endif
// wxUSE_PALETTE
}
#endif
// wxUSE_PALETTE
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/mgl/palette.cpp
// Author: Vaclav Slavik
// Created: 2001/03/11
// Id: $Id$
// Author: Vaclav Slavik
// Created: 2001/03/11
// Id: $Id$
public:
wxPaletteRefData(void);
~wxPaletteRefData(void);
public:
wxPaletteRefData(void);
~wxPaletteRefData(void);
int m_count;
palette_t *m_entries;
};
int m_count;
palette_t *m_entries;
};
bool wxPalette::Create(int n,
const unsigned char *red,
bool wxPalette::Create(int n,
const unsigned char *red,
- const unsigned char *green,
+ const unsigned char *green,
const unsigned char *blue)
{
UnRef();
m_refData = new wxPaletteRefData();
const unsigned char *blue)
{
UnRef();
m_refData = new wxPaletteRefData();
-
- M_PALETTEDATA->m_count = n;
+
+ M_PALETTEDATA->m_count = n;
M_PALETTEDATA->m_entries = new palette_t[n];
palette_t *e = M_PALETTEDATA->m_entries;
M_PALETTEDATA->m_entries = new palette_t[n];
palette_t *e = M_PALETTEDATA->m_entries;
-int wxPalette::GetPixel(const unsigned char red,
- const unsigned char green,
- const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red,
+ unsigned char green,
+ unsigned char blue) const
- if (!m_refData) return FALSE;
+ if (!m_refData) return wxNOT_FOUND;
- int closest = 0;
- double d,distance = 1000.0; // max. dist is 256
+ int closest = 0;
+ double d, distance = 1000.0; // max. dist is 256
palette_t *e = M_PALETTEDATA->m_entries;
for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
palette_t *e = M_PALETTEDATA->m_entries;
for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
-bool wxPalette::GetRGB(int pixel,
+bool wxPalette::GetRGB(int pixel,
unsigned char *blue) const
{
unsigned char *blue) const
{
- if (!m_refData) return FALSE;
- if (pixel >= M_PALETTEDATA->m_count) return FALSE;
-
+ if (!m_refData) return false;
+ if (pixel >= M_PALETTEDATA->m_count) return false;
+
palette_t& p = M_PALETTEDATA->m_entries[pixel];
if (red) *red = p.red;
if (green) *green = p.green;
if (blue) *blue = p.blue;
palette_t& p = M_PALETTEDATA->m_entries[pixel];
if (red) *red = p.red;
if (green) *green = p.green;
if (blue) *blue = p.blue;
}
int wxPalette::GetColoursCount() const
{
}
int wxPalette::GetColoursCount() const
{
- wxCHECK_MSG( Ok(), 0, wxT("invalid palette") );
+ wxCHECK_MSG( Ok(), 0, wxT("invalid palette") );
return M_PALETTEDATA->m_count;
}
palette_t *wxPalette::GetMGLpalette_t() const
{
return M_PALETTEDATA->m_count;
}
palette_t *wxPalette::GetMGLpalette_t() const
{
- wxCHECK_MSG( Ok(), NULL, wxT("invalid palette") );
+ wxCHECK_MSG( Ok(), NULL, wxT("invalid palette") );
return M_PALETTEDATA->m_entries;
}
return M_PALETTEDATA->m_entries;
}
-int wxPalette::GetPixel(const unsigned char WXUNUSED(red),
- const unsigned char WXUNUSED(green),
- const unsigned char WXUNUSED(blue)) const
+int wxPalette::GetPixel(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
}
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
M_PALETTEDATA->m_palettes.Append(c);
}
M_PALETTEDATA->m_palettes.Append(c);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/msw/palette.cpp
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
wxPaletteRefData::wxPaletteRefData(void)
{
wxPaletteRefData::wxPaletteRefData(void)
{
}
wxPaletteRefData::~wxPaletteRefData(void)
}
wxPaletteRefData::~wxPaletteRefData(void)
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
#if defined(__WXMICROWIN__)
#if defined(__WXMICROWIN__)
- m_refData = new wxPaletteRefData;
+ m_refData = new wxPaletteRefData;
- NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
- (WORD)n * sizeof(PALETTEENTRY));
- if (!npPal)
- return false;
+ NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
+ (WORD)n * sizeof(PALETTEENTRY));
+ if (!npPal)
+ return false;
- npPal->palVersion = 0x300;
- npPal->palNumEntries = (WORD)n;
-
- int i;
- for (i = 0; i < n; i ++)
- {
- npPal->palPalEntry[i].peRed = red[i];
- npPal->palPalEntry[i].peGreen = green[i];
- npPal->palPalEntry[i].peBlue = blue[i];
- npPal->palPalEntry[i].peFlags = 0;
- }
- M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
- LocalFree((HANDLE)npPal);
- return true;
+ npPal->palVersion = 0x300;
+ npPal->palNumEntries = (WORD)n;
+
+ int i;
+ for (i = 0; i < n; i ++)
+ {
+ npPal->palPalEntry[i].peRed = red[i];
+ npPal->palPalEntry[i].peGreen = green[i];
+ npPal->palPalEntry[i].peBlue = blue[i];
+ npPal->palPalEntry[i].peFlags = 0;
+ }
+ M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
+ LocalFree((HANDLE)npPal);
+ return true;
-int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
- if ( !m_refData )
- return 0;
+ if ( !m_refData )
+ return wxNOT_FOUND;
- return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
+ return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
#endif
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
#ifdef __WXMICROWIN__
#endif
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
#ifdef __WXMICROWIN__
- return false;
-#else
- if ( !m_refData )
+#else
+ if ( !m_refData )
+ return false;
+
+ if (index < 0 || index > 255)
+ return false;
- if (index < 0 || index > 255)
- return false;
-
- PALETTEENTRY entry;
- if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
- {
- *red = entry.peRed;
- *green = entry.peGreen;
- *blue = entry.peBlue;
- return true;
- } else
- return false;
+ PALETTEENTRY entry;
+ if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
+ {
+ *red = entry.peRed;
+ *green = entry.peGreen;
+ *blue = entry.peBlue;
+ return true;
+ }
+ else
+ return false;
}
#endif // wxUSE_PALETTE
}
#endif // wxUSE_PALETTE
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/os2/palette.cpp
// Purpose: wxPalette
// Author: AUTHOR
// Modified by:
// Purpose: wxPalette
// Author: AUTHOR
// Modified by:
return true;
} // end of wxPalette::Create
return true;
} // end of wxPalette::Create
-int wxPalette::GetPixel(
- const unsigned char cRed
-, const unsigned char cGreen
-, const unsigned char cBlue
-) const
+int wxPalette::GetPixel( unsigned char cRed,
+ unsigned char cGreen,
+ unsigned char cBlue) const
- bool bFound = FALSE;
- PULONG pualTable = NULL;
- ULONG ulNumEntries;
- ULONG ulRGB = (PC_RESERVED * 16777216) +
- ((int)cRed * 65536) +
- ((int)cGreen * 256) +
- (int)cBlue;
+ bool bFound = false;
+ PULONG pualTable = NULL;
+ ULONG ulNumEntries;
+ ULONG ulRGB = (PC_RESERVED * 16777216) +
+ ((int)cRed * 65536) +
+ ((int)cGreen * 256) +
+ (int)cBlue;
//
// Get number of entries first
//
// Get number of entries first
return (i + 1);
} // end of wxPalette::GetPixel
return (i + 1);
} // end of wxPalette::GetPixel
-bool wxPalette::GetRGB(
- int nIndex
-, unsigned char* pRed
-, unsigned char* pGreen
-, unsigned char* pBlue
-) const
+bool wxPalette::GetRGB( int nIndex,
+ unsigned char* pRed,
+ unsigned char* pGreen,
+ unsigned char* pBlue) const
{
PULONG pualTable = NULL;
RGB2 vRGB;
ULONG ulNumEntries;
if (!m_refData)
{
PULONG pualTable = NULL;
RGB2 vRGB;
ULONG ulNumEntries;
if (!m_refData)
if (nIndex < 0 || nIndex > 255)
if (nIndex < 0 || nIndex > 255)
//
// Get number of entries first
//
//
// Get number of entries first
//
*pBlue = vRGB.bBlue;
*pGreen = vRGB.bGreen;
*pRed = vRGB.bRed;
*pBlue = vRGB.bBlue;
*pGreen = vRGB.bGreen;
*pRed = vRGB.bRed;
} // end of wxPalette::GetRGB
void wxPalette::SetHPALETTE(
} // end of wxPalette::GetRGB
void wxPalette::SetHPALETTE(
-int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
}
#endif // wxUSE_PALETTE
}
#endif // wxUSE_PALETTE
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/x11/palette.cpp
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
-int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
+int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
}
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
M_PALETTEDATA->m_palettes.Append(c);
}
M_PALETTEDATA->m_palettes.Append(c);
}