X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7266b6723573ce6317577226cb1e5d32826e24e8..1a1498c08b07625baa087622e75637a2f15325b6:/src/x11/palette.cpp?ds=sidebyside diff --git a/src/x11/palette.cpp b/src/x11/palette.cpp index eb5cb7bdf1..e03aed5237 100644 --- a/src/x11/palette.cpp +++ b/src/x11/palette.cpp @@ -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,10 +34,6 @@ 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 - #include "wx/palette.h" #include "wx/window.h" #include "wx/app.h" @@ -66,7 +62,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() @@ -77,10 +73,10 @@ wxPaletteRefData::~wxPaletteRefData() { Display *display = (Display*) NULL; - wxNode *node, *next; + wxList::compatibility_iterator node, next; - for (node = m_palettes.First(); node; node = next) { - wxXPalette *c = (wxXPalette *)node->Data(); + for (node = m_palettes.GetFirst(); node; node = next) { + wxXPalette *c = (wxXPalette *)node->GetData(); unsigned long *pix_array = c->m_pix_array; Colormap cmap = (Colormap) c->m_cmap; bool destroyable = c->m_destroyable; @@ -89,6 +85,7 @@ wxPaletteRefData::~wxPaletteRefData() if (pix_array_n > 0) { +#if !wxUSE_NANOX // XFreeColors(display, cmap, pix_array, pix_array_n, 0); // Be careful not to free '0' pixels... int i, j; @@ -97,14 +94,15 @@ wxPaletteRefData::~wxPaletteRefData() if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0); while(jNext(); - m_palettes.DeleteNode(node); + next = node->GetNext(); + m_palettes.Erase(node); delete c; } } @@ -127,7 +125,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; @@ -143,7 +141,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; @@ -160,10 +158,10 @@ 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 @@ -178,38 +176,38 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons 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 { - if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0)) + if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.GetCount() == 0)) return wxTheApp->GetMainColormap(display); - wxNode* node = M_PALETTEDATA->m_palettes.First(); + wxList::compatibility_iterator node = M_PALETTEDATA->m_palettes.GetFirst(); if (!display && node) { - wxXPalette* p = (wxXPalette*) node->Data(); + wxXPalette* p = (wxXPalette*) node->GetData(); return p->m_cmap; } while (node) { - wxXPalette* p = (wxXPalette*) node->Data(); + wxXPalette* p = (wxXPalette*) node->GetData(); if (p->m_display == display) return p->m_cmap; - node = node->Next(); + node = node->GetNext(); } /* Make a new one: */ wxXPalette *c = new wxXPalette; - wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data(); + wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.GetFirst()->GetData(); XColor xcol; int pix_array_n = first->m_pix_array_n; @@ -217,7 +215,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; @@ -251,10 +249,10 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size) uptr++; } - return TRUE; + return true; } default: - return FALSE; + return false; } } @@ -308,20 +306,20 @@ 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.First(); node; node = node->Next()) + for (node = M_PALETTEDATA->m_palettes.GetFirst(); node; node = node->GetNext()) { - wxXPalette *c = (wxXPalette *)node->Data(); + wxXPalette *c = (wxXPalette *)node->GetData(); if (c->m_display == display) { if (n)