X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/09a1dffa32ae09ea47789eb071a1fdac0d154dda..87f0b1323b7ac77f02133b836c8dfee63b0fd387:/src/x11/palette.cpp?ds=inline diff --git a/src/x11/palette.cpp b/src/x11/palette.cpp index 7a035ffd18..dc3f06801d 100644 --- a/src/x11/palette.cpp +++ b/src/x11/palette.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: palette.cpp +// Name: src/x11/palette.cpp // Purpose: wxPalette // Author: Julian Smart // Modified by: @@ -20,10 +20,10 @@ /* Wolfram Gloger I have implemented basic colormap support for the X11 versions of -wxWindows, notably wxPalette::Create(). The way I did it is to +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,14 +34,16 @@ recommended; only the window manager should do this... Also, it is not the functionality that wxPalette::Create() aims to provide. */ -#ifdef __GNUG__ -#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 @@ -66,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() @@ -75,9 +77,9 @@ wxPaletteRefData::wxPaletteRefData() wxPaletteRefData::~wxPaletteRefData() { - Display *display = (Display*) NULL; + Display *display = NULL; - wxNode *node, *next; + wxList::compatibility_iterator node, next; for (node = m_palettes.GetFirst(); node; node = next) { wxXPalette *c = (wxXPalette *)node->GetData(); @@ -101,12 +103,12 @@ wxPaletteRefData::~wxPaletteRefData() #endif delete [] pix_array; } - + if (destroyable) XFreeColormap(display, cmap); next = node->GetNext(); - m_palettes.DeleteNode(node); + m_palettes.Erase(node); delete c; } } @@ -129,7 +131,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; @@ -145,7 +147,7 @@ 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; @@ -162,31 +164,46 @@ 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; +} + +wxGDIRefData *wxPalette::CreateGDIRefData() const +{ + return new wxPaletteRefData; +} + +wxGDIRefData * +wxPalette::CloneGDIRefData(const wxGDIRefData * WXUNUSED(data)) const +{ + wxFAIL_MSG( wxS("Cloning palettes is not implemented in wxX11.") ); + + return new wxPaletteRefData; } -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 @@ -194,7 +211,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.GetCount() == 0)) return wxTheApp->GetMainColormap(display); - wxNode* node = M_PALETTEDATA->m_palettes.GetFirst(); + wxList::compatibility_iterator node = M_PALETTEDATA->m_palettes.GetFirst(); if (!display && node) { wxXPalette* p = (wxXPalette*) node->GetData(); @@ -219,7 +236,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; @@ -253,10 +270,10 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size) uptr++; } - return TRUE; + return true; } default: - return FALSE; + return false; } } @@ -310,16 +327,16 @@ 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) { if (!M_PALETTEDATA) return (unsigned long*) 0; - wxNode *node; + wxList::compatibility_iterator node; for (node = M_PALETTEDATA->m_palettes.GetFirst(); node; node = node->GetNext()) { @@ -355,4 +372,3 @@ void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp) M_PALETTEDATA->m_palettes.Append(c); } -