CW5.2 Pro Adaptions, wxMac starting to move in
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -26,12 +26,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
||||
|
||||
wxPaletteRefData::wxPaletteRefData()
|
||||
{
|
||||
// TODO
|
||||
m_palette = NULL ;
|
||||
m_count = 0 ;
|
||||
}
|
||||
|
||||
wxPaletteRefData::~wxPaletteRefData()
|
||||
{
|
||||
// TODO
|
||||
delete[] m_palette ;
|
||||
}
|
||||
|
||||
wxPalette::wxPalette()
|
||||
@@ -53,7 +54,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
|
||||
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
// TODO
|
||||
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] ) ;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -61,10 +68,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
|
||||
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
|
||||
{
|
||||
if ( !m_refData )
|
||||
return FALSE;
|
||||
return -1;
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
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] ;
|
||||
currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ;
|
||||
if ( currentdiff < bestdiff )
|
||||
{
|
||||
bestdiff = currentdiff ;
|
||||
bestpos = i ;
|
||||
if ( bestdiff == 0 )
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return bestpos;
|
||||
}
|
||||
|
||||
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
|
||||
@@ -72,11 +95,15 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
|
||||
if ( !m_refData )
|
||||
return FALSE;
|
||||
|
||||
if (index < 0 || index > 255)
|
||||
if (index < 0 || index >= M_PALETTEDATA->m_count)
|
||||
return FALSE;
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
const wxColour& col = &M_PALETTEDATA->m_palette[index] ;
|
||||
*red = col.Red() ;
|
||||
*green = col.Green() ;
|
||||
*blue = col.Blue() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user