wxPalette unified. Source cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35811 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-10-06 14:37:43 +00:00
parent 2c01d33555
commit 88ef3a57a4
20 changed files with 173 additions and 176 deletions

View File

@@ -1,3 +1,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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
@@ -100,8 +111,8 @@ Returns number of entries in palette.
\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.
@@ -115,7 +126,7 @@ Returns a pixel value (index into the palette) for the given RGB values.
\wxheading{Return value}
The nearest palette index.
The nearest palette index or {\tt wxNOT\_FOUND} for unexpected errors.
\wxheading{See also}
@@ -177,5 +188,3 @@ fail the test.
Inequality operator. Two palettes are not equal if they contain pointers
to different underlying palette data. It does not compare each attribute.

View File

@@ -1,9 +1,9 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/generic/paletteg.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -43,7 +43,7 @@ class WXDLLIMPEXP_CORE wxPalette: public wxPaletteBase
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

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/mac/carbon/palette.h
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
@@ -45,7 +45,7 @@ public:
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) ; }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/mac/classic/palette.h
// Purpose: wxPalette class
// Author: Stefan Csomor
// Modified by:
@@ -45,7 +45,7 @@ public:
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) ; }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/mgl/palette.h
// Purpose:
// Author: Vaclav Slavik
// Created: 2001/03/11
@@ -42,7 +42,7 @@ public:
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

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/motif/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
@@ -56,7 +56,7 @@ public:
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) ; }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/msw/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
@@ -39,7 +39,7 @@ 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);
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) ; }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/os2/palette.h
// Purpose: wxPalette class
// Author: David Webster
// Modified by:
@@ -50,9 +50,9 @@ public:
,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
@@ -77,4 +77,3 @@ public:
#endif
// _WX_PALETTE_H_

View File

@@ -19,7 +19,7 @@
#include "wx/object.h"
#include "wx/gdiobj.h"
// wxBrushBase
// wxPaletteBase
class WXDLLEXPORT wxPaletteBase: public wxGDIObject
{
public:

View File

@@ -39,7 +39,7 @@ 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);
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) ; }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Name: wx/x11/palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
@@ -56,7 +56,7 @@ public:
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) ; }

View File

@@ -3,7 +3,7 @@
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling and Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -120,11 +120,11 @@ bool wxPalette::Create(int n,
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 false;
if (!m_refData) return wxNOT_FOUND;
int closest = 0;
double d,distance = 1000.0; // max. dist is 256
@@ -158,5 +158,3 @@ bool wxPalette::GetRGB(int pixel,
}
#endif // wxUSE_PALETTE

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/mac/carbon/palette.cpp
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
@@ -63,13 +63,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
return FALSE;
return false;
}
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 -1;
return wxNOT_FOUND;
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
@@ -94,19 +94,18 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
return FALSE;
return false;
if (index < 0 || index >= M_PALETTEDATA->m_count)
return FALSE;
return false;
const wxColour& col = M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
return TRUE;
return true;
}
#endif
// wxUSE_PALETTE

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/mac/classic/palette.cpp
// Purpose: wxPalette
// Author: Stefan Csomor
// Modified by:
@@ -63,13 +63,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
}
return FALSE;
return false;
}
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 -1;
return wxNOT_FOUND;
long bestdiff = 3 * 256 ;
long bestpos = 0 ;
@@ -94,19 +94,18 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
return FALSE;
return false;
if (index < 0 || index >= M_PALETTEDATA->m_count)
return FALSE;
return false;
const wxColour& col = &M_PALETTEDATA->m_palette[index] ;
*red = col.Red() ;
*green = col.Green() ;
*blue = col.Blue() ;
return TRUE;
return true;
}
#endif
// wxUSE_PALETTE

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/mgl/palette.cpp
// Author: Vaclav Slavik
// Created: 2001/03/11
// Id: $Id$
@@ -110,14 +110,14 @@ bool wxPalette::Create(int n,
e->alpha = 0;
}
return TRUE;
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 FALSE;
if (!m_refData) return wxNOT_FOUND;
int closest = 0;
double d, distance = 1000.0; // max. dist is 256
@@ -132,6 +132,7 @@ int wxPalette::GetPixel(const unsigned char red,
closest = i;
}
}
return closest;
}
@@ -140,14 +141,14 @@ bool wxPalette::GetRGB(int pixel,
unsigned char *green,
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;
return TRUE;
return true;
}
int wxPalette::GetColoursCount() const
@@ -161,4 +162,3 @@ palette_t *wxPalette::GetMGLpalette_t() const
wxCHECK_MSG( Ok(), NULL, wxT("invalid palette") );
return M_PALETTEDATA->m_entries;
}

View File

@@ -165,15 +165,15 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
return true;
}
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
{
if ( !m_refData )
return false;
return wxNOT_FOUND;
// TODO
return false;
return wxNOT_FOUND;
}
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
@@ -358,4 +358,3 @@ void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp)
M_PALETTEDATA->m_palettes.Append(c);
}

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/msw/palette.cpp
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
@@ -100,13 +100,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
#endif
}
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
{
#ifdef __WXMICROWIN__
return 0;
return wxNOT_FOUND;
#else
if ( !m_refData )
return 0;
return wxNOT_FOUND;
return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
#endif
@@ -130,7 +130,8 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
*green = entry.peGreen;
*blue = entry.peBlue;
return true;
} else
}
else
return false;
#endif
}
@@ -144,4 +145,3 @@ void wxPalette::SetHPALETTE(WXHPALETTE pal)
}
#endif // wxUSE_PALETTE

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/os2/palette.cpp
// Purpose: wxPalette
// Author: AUTHOR
// Modified by:
@@ -106,13 +106,11 @@ bool wxPalette::Create( int n,
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;
bool bFound = false;
PULONG pualTable = NULL;
ULONG ulNumEntries;
ULONG ulRGB = (PC_RESERVED * 16777216) +
@@ -121,7 +119,7 @@ int wxPalette::GetPixel(
(int)cBlue;
if (!m_refData)
return FALSE;
return wxNOT_FOUND;
//
// Get number of entries first
@@ -159,26 +157,24 @@ int wxPalette::GetPixel(
}
}
if (!bFound)
return 0;
return wxNOT_FOUND;
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)
return FALSE;
return false;
if (nIndex < 0 || nIndex > 255)
return FALSE;
return false;
//
// Get number of entries first
//
@@ -207,7 +203,7 @@ bool wxPalette::GetRGB(
*pBlue = vRGB.bBlue;
*pGreen = vRGB.bGreen;
*pRed = vRGB.bRed;
return TRUE;
return true;
} // end of wxPalette::GetRGB
void wxPalette::SetHPALETTE(

View File

@@ -61,9 +61,9 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
return false;
}
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
{
return 0;
return wxNOT_FOUND;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
@@ -76,4 +76,3 @@ void wxPalette::SetHPALETTE(WXHPALETTE pal)
}
#endif // wxUSE_PALETTE

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/x11/palette.cpp
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
@@ -164,13 +164,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
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 FALSE;
return wxNOT_FOUND;
// TODO
return FALSE;
return wxNOT_FOUND;
}
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
@@ -351,4 +351,3 @@ void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp)
M_PALETTEDATA->m_palettes.Append(c);
}