X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..2cf3a6d7bef6f20bea35062dd3d4dbf0aec9efb5:/src/mac/carbon/palette.cpp?ds=sidebyside diff --git a/src/mac/carbon/palette.cpp b/src/mac/carbon/palette.cpp index 33cd9b972d..642af2b89b 100644 --- a/src/mac/carbon/palette.cpp +++ b/src/mac/carbon/palette.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: palette.cpp +// Name: src/mac/carbon/palette.cpp // 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" @@ -52,29 +52,29 @@ wxPalette::~wxPalette() bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { UnRef(); - + m_refData = new wxPaletteRefData; - + 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; + + 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 ; long currentdiff ; - + for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i ) { const wxColour& col = M_PALETTEDATA->m_palette[i] ; @@ -84,29 +84,28 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons bestdiff = currentdiff ; bestpos = i ; if ( bestdiff == 0 ) - break ; + break ; } } - + return bestpos; } 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 -