X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/04ef50df3a0fa3c343800c554e609f98fc7575cc..2fb18bf45bcf391a8eb973886072dc67893e9bbe:/src/msw/palette.cpp diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp index 7d88c7fe72..dc9dfabf86 100644 --- a/src/msw/palette.cpp +++ b/src/msw/palette.cpp @@ -5,30 +5,24 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "palette.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif +#if wxUSE_PALETTE + #ifndef WX_PRECOMP -#include -#include "wx/setup.h" -#include "wx/palette.h" + #include "wx/palette.h" #endif -#include - -#include "assert.h" +#include "wx/msw/private.h" IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) @@ -44,8 +38,8 @@ wxPaletteRefData::wxPaletteRefData(void) wxPaletteRefData::~wxPaletteRefData(void) { - if ( m_hPalette ) - ::DeleteObject((HPALETTE) m_hPalette); + if ( m_hPalette ) + ::DeleteObject((HPALETTE) m_hPalette); } wxPalette::wxPalette(void) @@ -59,25 +53,25 @@ wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green wxPalette::~wxPalette(void) { -// FreeResource(TRUE); +// FreeResource(true); } bool wxPalette::FreeResource(bool WXUNUSED(force)) { - if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette) - { + if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette) + { DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette); - } - return TRUE; + } + return true; } bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { UnRef(); -#if defined(__WXWINE__) || defined(__WXMICROWIN__) +#if defined(__WXMICROWIN__) - return (FALSE); + return false; #else @@ -86,10 +80,10 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + (WORD)n * sizeof(PALETTEENTRY)); if (!npPal) - return(FALSE); + return false; npPal->palVersion = 0x300; - npPal->palNumEntries = n; + npPal->palNumEntries = (WORD)n; int i; for (i = 0; i < n; i ++) @@ -101,7 +95,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre } M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal); LocalFree((HANDLE)npPal); - return TRUE; + return true; #endif } @@ -109,10 +103,10 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const { #ifdef __WXMICROWIN__ - return FALSE; + return 0; #else if ( !m_refData ) - return FALSE; + return 0; return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue)); #endif @@ -121,13 +115,13 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const { #ifdef __WXMICROWIN__ - return FALSE; + return false; #else if ( !m_refData ) - return FALSE; + return false; if (index < 0 || index > 255) - return FALSE; + return false; PALETTEENTRY entry; if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry)) @@ -135,17 +129,19 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi *red = entry.peRed; *green = entry.peGreen; *blue = entry.peBlue; - return TRUE; + return true; } else - return FALSE; + return false; #endif } void wxPalette::SetHPALETTE(WXHPALETTE pal) { - if ( !m_refData ) - m_refData = new wxPaletteRefData; + if ( !m_refData ) + m_refData = new wxPaletteRefData; M_PALETTEDATA->m_hPalette = pal; } +#endif // wxUSE_PALETTE +