X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..309689b214a464ee0a85a8a40c3042b564b6343d:/src/os2/palette.cpp diff --git a/src/os2/palette.cpp b/src/os2/palette.cpp index f8db96f8d0..cab9adfc9d 100644 --- a/src/os2/palette.cpp +++ b/src/os2/palette.cpp @@ -9,11 +9,20 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "palette.h" -#endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" +#ifndef WX_PRECOMP +#include +#include "wx/setup.h" #include "wx/palette.h" +#endif + +#define INCL_PM +#define INCL_GPI +#include + +#include "assert.h" #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) @@ -26,12 +35,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) wxPaletteRefData::wxPaletteRefData() { - // TODO + m_hPalette = 0; } wxPaletteRefData::~wxPaletteRefData() { - // TODO + if ( m_hPalette ) + return; + // TODO: ::DeleteObject((HPALETTE) m_hPalette); } wxPalette::wxPalette() @@ -47,6 +58,15 @@ wxPalette::~wxPalette() { } +bool wxPalette::FreeResource(bool force) +{ + if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette) + { +// TODO: DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette); + } + return TRUE; +} + bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { UnRef(); @@ -54,7 +74,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre m_refData = new wxPaletteRefData; // TODO - +/* + NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + + (WORD)n * sizeof(PALETTEENTRY)); + if (!npPal) + return(FALSE); + + npPal->palVersion = 0x300; + npPal->palNumEntries = n; + + int i; + for (i = 0; i < n; i ++) + { + npPal->palPalEntry[i].peRed = red[i]; + npPal->palPalEntry[i].peGreen = green[i]; + npPal->palPalEntry[i].peBlue = blue[i]; + npPal->palPalEntry[i].peFlags = 0; + } + M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal); + LocalFree((HANDLE)npPal); +*/ return FALSE; } @@ -74,9 +113,27 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi if (index < 0 || index > 255) return FALSE; +// TODO +/* + PALETTEENTRY entry; + if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry)) + { + *red = entry.peRed; + *green = entry.peGreen; + *blue = entry.peBlue; + return TRUE; + } else + return FALSE; +*/ + return FALSE; +} - // TODO - return FALSE; +void wxPalette::SetHPALETTE(WXHPALETTE pal) +{ + if ( !m_refData ) + m_refData = new wxPaletteRefData; + + M_PALETTEDATA->m_hPalette = pal; }