added wxUSE_PALETTE and fixed compilation with it set to 0

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11749 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-09-30 22:06:39 +00:00
parent f1c1831fc5
commit d275c7eb84
21 changed files with 227 additions and 101 deletions

View File

@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Name: src/generic/paletteg.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -13,8 +13,16 @@
#pragma implementation "paletteg.h"
#endif
#include "wx/palette.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#if wxUSE_PALETTE
#include "wx/palette.h"
//-----------------------------------------------------------------------------
// wxPalette
@@ -96,13 +104,13 @@ bool wxPalette::Ok(void) const
bool wxPalette::Create(int n,
const unsigned char *red,
const unsigned char *green,
const unsigned char *green,
const unsigned char *blue)
{
UnRef();
m_refData = new wxPaletteRefData();
M_PALETTEDATA->m_count = n;
M_PALETTEDATA->m_count = n;
M_PALETTEDATA->m_entries = new wxPaletteEntry[n];
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
@@ -122,8 +130,8 @@ int wxPalette::GetPixel( const unsigned char red,
{
if (!m_refData) return FALSE;
int closest = 0;
double d,distance = 1000.0; // max. dist is 256
int closest = 0;
double d,distance = 1000.0; // max. dist is 256
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
@@ -135,17 +143,17 @@ int wxPalette::GetPixel( const unsigned char red,
closest = i;
}
}
return closest;
return closest;
}
bool wxPalette::GetRGB(int pixel,
bool wxPalette::GetRGB(int pixel,
unsigned char *red,
unsigned char *green,
unsigned char *green,
unsigned char *blue) const
{
if (!m_refData) return FALSE;
if (pixel >= M_PALETTEDATA->m_count) return FALSE;
wxPaletteEntry& p = M_PALETTEDATA->m_entries[pixel];
if (red) *red = p.red;
if (green) *green = p.green;
@@ -153,4 +161,6 @@ bool wxPalette::GetRGB(int pixel,
return TRUE;
}
#endif // wxUSE_PALETTE