X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..32b171bc0e6ba4b91c0c4b820b120a906c6dc646:/src/motif/palette.cpp diff --git a/src/motif/palette.cpp b/src/motif/palette.cpp index 39990d9020..378172ff5b 100644 --- a/src/motif/palette.cpp +++ b/src/motif/palette.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: palette.cpp +// Name: src/motif/palette.cpp // Purpose: wxPalette // Author: Julian Smart // Modified by: // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /* @@ -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 allocate additional read-only color cells in the default colormap. In 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 Create(). This is only implemented for the popular case of 8-bit depth. @@ -34,17 +34,16 @@ recommended; only the window manager should do this... Also, it is not the functionality that wxPalette::Create() aims to provide. */ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "palette.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #include "wx/palette.h" -#include "wx/window.h" -#include "wx/app.h" -#include "wx/utils.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/window.h" +#endif #ifdef __VMS__ #pragma message disable nosimpint @@ -69,7 +68,7 @@ wxXPalette::wxXPalette() m_pix_array_n = 0; m_pix_array = (unsigned long*) 0; m_display = (WXDisplay*) 0; - m_destroyable = FALSE; + m_destroyable = false; } wxPaletteRefData::wxPaletteRefData() @@ -130,7 +129,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre UnRef(); if (!n) { - return FALSE; + return false; } m_refData = new wxPaletteRefData; @@ -146,14 +145,14 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre pix_array = new unsigned long[n]; if (!pix_array) - return FALSE; + return false; pix_array_n = n; xcol.flags = DoRed | DoGreen | DoBlue; for(int i = 0; i < n; i++) { - xcol.red = (unsigned short)red[i] << 8; - xcol.green = (unsigned short)green[i] << 8; - xcol.blue = (unsigned short)blue[i] << 8; + xcol.red = (unsigned short)(red[i] << 8); + xcol.green = (unsigned short)(green[i] << 8); + xcol.blue = (unsigned short)(blue[i] << 8); pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel; } @@ -163,31 +162,33 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre c->m_pix_array = pix_array; c->m_cmap = (WXColormap) cmap; c->m_display = (WXDisplay*) display; - c->m_destroyable = FALSE; + c->m_destroyable = false; 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(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 { if ( !m_refData ) - return FALSE; + return false; if (index < 0 || index > 255) - return FALSE; + return false; // TODO - return FALSE; + return false; } WXColormap wxPalette::GetXColormap(WXDisplay* display) const @@ -221,7 +222,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const c->m_pix_array = new unsigned long[pix_array_n]; c->m_display = display; c->m_cmap = wxTheApp->GetMainColormap(display); - c->m_destroyable = FALSE; + c->m_destroyable = false; xcol.flags = DoRed | DoGreen | DoBlue; int i; @@ -257,10 +258,10 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size) uptr++; } - return TRUE; + return true; } default: - return FALSE; + return false; } } @@ -294,9 +295,9 @@ bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz, struct rgb24 { unsigned char r, g, b; } *dptr = (struct rgb24 *)dest; while(sz-- > 0) { if((int)*data < pix_array_n) { - dptr->r = pix_array[*data] & 0xFF; - dptr->g = (pix_array[*data] >> 8) & 0xFF; - dptr->b = (pix_array[*data] >> 16) & 0xFF; + dptr->r = (unsigned char)(pix_array[*data] & 0xFF); + dptr->g = (unsigned char)((pix_array[*data] >> 8) & 0xFF); + dptr->b = (unsigned char)((pix_array[*data] >> 16) & 0xFF); } data++; dptr++; @@ -314,9 +315,9 @@ bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz, break; } default: - return FALSE; + return false; } - return TRUE; + return true; } unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n) @@ -360,4 +361,3 @@ void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp) M_PALETTEDATA->m_palettes.Append(c); } -