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:
@@ -774,6 +774,7 @@ if test $DEBUG_CONFIGURE = 1; then
|
|||||||
DEFAULT_wxUSE_UNICODE=no
|
DEFAULT_wxUSE_UNICODE=no
|
||||||
DEFAULT_wxUSE_WCSRTOMBS=no
|
DEFAULT_wxUSE_WCSRTOMBS=no
|
||||||
|
|
||||||
|
DEFAULT_wxUSE_PALETTE=no
|
||||||
DEFAULT_wxUSE_IMAGE=no
|
DEFAULT_wxUSE_IMAGE=no
|
||||||
DEFAULT_wxUSE_GIF=no
|
DEFAULT_wxUSE_GIF=no
|
||||||
DEFAULT_wxUSE_PCX=no
|
DEFAULT_wxUSE_PCX=no
|
||||||
@@ -933,6 +934,7 @@ else
|
|||||||
DEFAULT_wxUSE_UNICODE=no
|
DEFAULT_wxUSE_UNICODE=no
|
||||||
DEFAULT_wxUSE_WCSRTOMBS=no
|
DEFAULT_wxUSE_WCSRTOMBS=no
|
||||||
|
|
||||||
|
DEFAULT_wxUSE_PALETTE=yes
|
||||||
DEFAULT_wxUSE_IMAGE=yes
|
DEFAULT_wxUSE_IMAGE=yes
|
||||||
DEFAULT_wxUSE_GIF=yes
|
DEFAULT_wxUSE_GIF=yes
|
||||||
DEFAULT_wxUSE_PCX=yes
|
DEFAULT_wxUSE_PCX=yes
|
||||||
@@ -1290,6 +1292,7 @@ dnl ---------------------------------------------------------------------------
|
|||||||
dnl support for image formats that do not rely on external library
|
dnl support for image formats that do not rely on external library
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
WX_ARG_ENABLE(palette, [ --enable-palette use wxPalette class], wxUSE_PALETTE)
|
||||||
WX_ARG_ENABLE(image, [ --enable-image use wxImage class], wxUSE_IMAGE)
|
WX_ARG_ENABLE(image, [ --enable-image use wxImage class], wxUSE_IMAGE)
|
||||||
WX_ARG_ENABLE(gif, [ --enable-gif use gif images (GIF file format)], wxUSE_GIF)
|
WX_ARG_ENABLE(gif, [ --enable-gif use gif images (GIF file format)], wxUSE_GIF)
|
||||||
WX_ARG_ENABLE(pcx, [ --enable-pcx use pcx images (PCX file format)], wxUSE_PCX)
|
WX_ARG_ENABLE(pcx, [ --enable-pcx use pcx images (PCX file format)], wxUSE_PCX)
|
||||||
@@ -4258,6 +4261,10 @@ if test "$wxUSE_VALIDATORS" = "yes"; then
|
|||||||
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
|
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$wxUSE_PALETTE" = "yes" ; then
|
||||||
|
AC_DEFINE(wxUSE_PALETTE)
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$wxUSE_IMAGE" = "yes" ; then
|
if test "$wxUSE_IMAGE" = "yes" ; then
|
||||||
AC_DEFINE(wxUSE_IMAGE)
|
AC_DEFINE(wxUSE_IMAGE)
|
||||||
fi
|
fi
|
||||||
|
@@ -309,6 +309,14 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* !defined(wxUSE_NOTEBOOK) */
|
#endif /* !defined(wxUSE_NOTEBOOK) */
|
||||||
|
|
||||||
|
#ifndef wxUSE_PALETTE
|
||||||
|
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||||
|
# error "wxUSE_PALETTE must be defined."
|
||||||
|
# else
|
||||||
|
# define wxUSE_PALETTE 0
|
||||||
|
# endif
|
||||||
|
#endif /* !defined(wxUSE_PALETTE) */
|
||||||
|
|
||||||
#ifndef wxUSE_POPUPWIN
|
#ifndef wxUSE_POPUPWIN
|
||||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||||
# error "wxUSE_POPUPWIN must be defined."
|
# error "wxUSE_POPUPWIN must be defined."
|
||||||
|
@@ -316,7 +316,9 @@ public:
|
|||||||
virtual void SetBrush(const wxBrush& brush) = 0;
|
virtual void SetBrush(const wxBrush& brush) = 0;
|
||||||
virtual void SetBackground(const wxBrush& brush) = 0;
|
virtual void SetBackground(const wxBrush& brush) = 0;
|
||||||
virtual void SetBackgroundMode(int mode) = 0;
|
virtual void SetBackgroundMode(int mode) = 0;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
virtual void SetPalette(const wxPalette& palette) = 0;
|
virtual void SetPalette(const wxPalette& palette) = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// clipping region
|
// clipping region
|
||||||
// ---------------
|
// ---------------
|
||||||
@@ -588,12 +590,17 @@ public:
|
|||||||
#endif // !Win16
|
#endif // !Win16
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
|
virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
void GetTextExtent(const wxString& string, float *x, float *y,
|
void GetTextExtent(const wxString& string, float *x, float *y,
|
||||||
float *descent = NULL, float *externalLeading = NULL,
|
float *descent = NULL, float *externalLeading = NULL,
|
||||||
wxFont *theFont = NULL, bool use16bit = FALSE) const ;
|
wxFont *theFont = NULL, bool use16bit = FALSE) const ;
|
||||||
void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
|
void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
|
||||||
void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
|
void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
|
||||||
|
|
||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -731,7 +738,10 @@ protected:
|
|||||||
wxColour m_textForegroundColour;
|
wxColour m_textForegroundColour;
|
||||||
wxColour m_textBackgroundColour;
|
wxColour m_textBackgroundColour;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette m_palette;
|
wxPalette m_palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxDCBase)
|
DECLARE_NO_COPY_CLASS(wxDCBase)
|
||||||
|
@@ -185,10 +185,12 @@ public:
|
|||||||
void SetMask( bool mask = TRUE );
|
void SetMask( bool mask = TRUE );
|
||||||
bool HasMask() const;
|
bool HasMask() const;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
// Palette functions
|
// Palette functions
|
||||||
bool HasPalette() const;
|
bool HasPalette() const;
|
||||||
const wxPalette& GetPalette() const;
|
const wxPalette& GetPalette() const;
|
||||||
void SetPalette(const wxPalette& palette);
|
void SetPalette(const wxPalette& palette);
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// Option functions (arbitrary name/value mapping)
|
// Option functions (arbitrary name/value mapping)
|
||||||
void SetOption(const wxString& name, const wxString& value);
|
void SetOption(const wxString& name, const wxString& value);
|
||||||
|
@@ -29,6 +29,7 @@ class WXDLLEXPORT wxMask;
|
|||||||
class WXDLLEXPORT wxCursor;
|
class WXDLLEXPORT wxCursor;
|
||||||
class WXDLLEXPORT wxControl;
|
class WXDLLEXPORT wxControl;
|
||||||
class WXDLLEXPORT wxImage;
|
class WXDLLEXPORT wxImage;
|
||||||
|
class WXDLLEXPORT wxPalette;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Bitmap data
|
// Bitmap data
|
||||||
@@ -47,7 +48,9 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int m_numColors;
|
int m_numColors;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette m_bitmapPalette;
|
wxPalette m_bitmapPalette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
int m_quality;
|
int m_quality;
|
||||||
|
|
||||||
// MSW-specific
|
// MSW-specific
|
||||||
@@ -147,8 +150,10 @@ public:
|
|||||||
int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); }
|
int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); }
|
||||||
void SetQuality(int q);
|
void SetQuality(int q);
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); }
|
wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); }
|
||||||
void SetPalette(const wxPalette& palette);
|
void SetPalette(const wxPalette& palette);
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); }
|
wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); }
|
||||||
void SetMask(wxMask *mask) ;
|
void SetMask(wxMask *mask) ;
|
||||||
@@ -160,10 +165,12 @@ public:
|
|||||||
void SetOk(bool isOk);
|
void SetOk(bool isOk);
|
||||||
#endif // WXWIN_COMPATIBILITY_2
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
wxPalette *GetColourMap() const { return GetPalette(); }
|
wxPalette *GetColourMap() const { return GetPalette(); }
|
||||||
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
|
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
|
||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
|
@@ -115,7 +115,9 @@ public:
|
|||||||
virtual void SetBrush(const wxBrush& brush);
|
virtual void SetBrush(const wxBrush& brush);
|
||||||
virtual void SetBackground(const wxBrush& brush);
|
virtual void SetBackground(const wxBrush& brush);
|
||||||
virtual void SetBackgroundMode(int mode);
|
virtual void SetBackgroundMode(int mode);
|
||||||
|
#if wxUSE_PALETTE
|
||||||
virtual void SetPalette(const wxPalette& palette);
|
virtual void SetPalette(const wxPalette& palette);
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
virtual void DestroyClippingRegion();
|
virtual void DestroyClippingRegion();
|
||||||
|
|
||||||
@@ -255,7 +257,10 @@ protected:
|
|||||||
WXHPEN m_oldPen;
|
WXHPEN m_oldPen;
|
||||||
WXHBRUSH m_oldBrush;
|
WXHBRUSH m_oldBrush;
|
||||||
WXHFONT m_oldFont;
|
WXHFONT m_oldFont;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
WXHPALETTE m_oldPalette;
|
WXHPALETTE m_oldPalette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
#if wxUSE_DC_CACHEING
|
#if wxUSE_DC_CACHEING
|
||||||
static wxList sm_bitmapCache;
|
static wxList sm_bitmapCache;
|
||||||
|
@@ -890,6 +890,9 @@
|
|||||||
// Set to 1 for XPM format support
|
// Set to 1 for XPM format support
|
||||||
#define wxUSE_XPM 1
|
#define wxUSE_XPM 1
|
||||||
|
|
||||||
|
// Set to 1 to compile in wxPalette class
|
||||||
|
#define wxUSE_PALETTE 1
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Windows-only settings
|
// Windows-only settings
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -1,21 +1,25 @@
|
|||||||
#ifndef _WX_PALETTE_H_BASE_
|
#ifndef _WX_PALETTE_H_BASE_
|
||||||
#define _WX_PALETTE_H_BASE_
|
#define _WX_PALETTE_H_BASE_
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
#include "wx/msw/palette.h"
|
#include "wx/msw/palette.h"
|
||||||
#elif defined(__WXMOTIF__)
|
#elif defined(__WXMOTIF__)
|
||||||
#include "wx/motif/palette.h"
|
#include "wx/motif/palette.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
#include "wx/generic/paletteg.h"
|
#include "wx/generic/paletteg.h"
|
||||||
#elif defined(__WXMGL__)
|
#elif defined(__WXMGL__)
|
||||||
#include "wx/mgl/palette.h"
|
#include "wx/mgl/palette.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#include "wx/mac/palette.h"
|
#include "wx/mac/palette.h"
|
||||||
#elif defined(__WXPM__)
|
#elif defined(__WXPM__)
|
||||||
#include "wx/os2/palette.h"
|
#include "wx/os2/palette.h"
|
||||||
#elif defined(__WXSTUBS__)
|
#elif defined(__WXSTUBS__)
|
||||||
#include "wx/stubs/palette.h"
|
#include "wx/stubs/palette.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_PALETTE_H_BASE_
|
// _WX_PALETTE_H_BASE_
|
||||||
|
@@ -329,4 +329,6 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define wxUSE_PALETTE 0
|
||||||
|
|
||||||
#endif // _WX_UNIV_SETUP_H_
|
#endif // _WX_UNIV_SETUP_H_
|
||||||
|
@@ -762,6 +762,11 @@
|
|||||||
*/
|
*/
|
||||||
#define wxUSE_ZIPSTREAM 0
|
#define wxUSE_ZIPSTREAM 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wxPalette class
|
||||||
|
*/
|
||||||
|
#define wxUSE_PALETTE 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxImage support
|
* wxImage support
|
||||||
*/
|
*/
|
||||||
|
@@ -96,11 +96,14 @@ bool wxEffects::TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap)
|
|||||||
|
|
||||||
wxMemoryDC dcMem;
|
wxMemoryDC dcMem;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (bitmap.GetPalette() && !hiColour)
|
if (bitmap.GetPalette() && !hiColour)
|
||||||
{
|
{
|
||||||
dc.SetPalette(* bitmap.GetPalette());
|
dc.SetPalette(* bitmap.GetPalette());
|
||||||
dcMem.SetPalette(* bitmap.GetPalette());
|
dcMem.SetPalette(* bitmap.GetPalette());
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
dcMem.SelectObject(bitmap);
|
dcMem.SelectObject(bitmap);
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -111,11 +114,13 @@ bool wxEffects::TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap)
|
|||||||
}
|
}
|
||||||
dcMem.SelectObject(wxNullBitmap);
|
dcMem.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (bitmap.GetPalette() && !hiColour)
|
if (bitmap.GetPalette() && !hiColour)
|
||||||
{
|
{
|
||||||
dc.SetPalette(wxNullPalette);
|
dc.SetPalette(wxNullPalette);
|
||||||
dcMem.SetPalette(wxNullPalette);
|
dcMem.SetPalette(wxNullPalette);
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,9 @@ public:
|
|||||||
unsigned char m_maskRed,m_maskGreen,m_maskBlue;
|
unsigned char m_maskRed,m_maskGreen,m_maskBlue;
|
||||||
bool m_ok;
|
bool m_ok;
|
||||||
bool m_static;
|
bool m_static;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette m_palette;
|
wxPalette m_palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
wxArrayString m_optionNames;
|
wxArrayString m_optionNames;
|
||||||
wxArrayString m_optionValues;
|
wxArrayString m_optionValues;
|
||||||
};
|
};
|
||||||
@@ -718,6 +720,8 @@ int wxImage::GetHeight() const
|
|||||||
return M_IMGDATA->m_height;
|
return M_IMGDATA->m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
|
||||||
// Palette functions
|
// Palette functions
|
||||||
|
|
||||||
bool wxImage::HasPalette() const
|
bool wxImage::HasPalette() const
|
||||||
@@ -742,6 +746,8 @@ void wxImage::SetPalette(const wxPalette& palette)
|
|||||||
M_IMGDATA->m_palette = palette;
|
M_IMGDATA->m_palette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// Option functions (arbitrary name/value mapping)
|
// Option functions (arbitrary name/value mapping)
|
||||||
void wxImage::SetOption(const wxString& name, const wxString& value)
|
void wxImage::SetOption(const wxString& name, const wxString& value)
|
||||||
{
|
{
|
||||||
|
@@ -1483,8 +1483,11 @@ void wxQuantize::DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, uns
|
|||||||
// TODO: somehow make use of the Windows system colours, rather than ignoring them for the
|
// TODO: somehow make use of the Windows system colours, rather than ignoring them for the
|
||||||
// purposes of quantization.
|
// purposes of quantization.
|
||||||
|
|
||||||
bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours,
|
bool wxQuantize::Quantize(const wxImage& src, wxImage& dest,
|
||||||
unsigned char** eightBitData, int flags)
|
wxPalette** pPalette,
|
||||||
|
int desiredNoColours,
|
||||||
|
unsigned char** eightBitData,
|
||||||
|
int flags)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1559,6 +1562,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett
|
|||||||
else
|
else
|
||||||
delete[] data8bit;
|
delete[] data8bit;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
// Make a wxWindows palette
|
// Make a wxWindows palette
|
||||||
if (pPalette)
|
if (pPalette)
|
||||||
{
|
{
|
||||||
@@ -1604,6 +1608,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett
|
|||||||
delete[] g;
|
delete[] g;
|
||||||
delete[] b;
|
delete[] b;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1611,20 +1616,24 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett
|
|||||||
// This version sets a palette in the destination image so you don't
|
// This version sets a palette in the destination image so you don't
|
||||||
// have to manage it yourself.
|
// have to manage it yourself.
|
||||||
|
|
||||||
bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, int desiredNoColours,
|
bool wxQuantize::Quantize(const wxImage& src,
|
||||||
unsigned char** eightBitData, int flags)
|
wxImage& dest,
|
||||||
|
int desiredNoColours,
|
||||||
|
unsigned char** eightBitData,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
wxPalette* palette = NULL;
|
wxPalette* palette = NULL;
|
||||||
if (Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags))
|
if ( !Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags) )
|
||||||
{
|
return FALSE;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (palette)
|
if (palette)
|
||||||
{
|
{
|
||||||
dest.SetPalette(* palette);
|
dest.SetPalette(* palette);
|
||||||
delete palette;
|
delete palette;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: palette.cpp
|
// Name: src/generic/paletteg.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
@@ -13,8 +13,16 @@
|
|||||||
#pragma implementation "paletteg.h"
|
#pragma implementation "paletteg.h"
|
||||||
#endif
|
#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
|
// wxPalette
|
||||||
@@ -153,4 +161,6 @@ bool wxPalette::GetRGB(int pixel,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
|
|
||||||
|
@@ -467,12 +467,14 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight );
|
hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight );
|
||||||
::SelectObject( memdc, hbitmap);
|
::SelectObject( memdc, hbitmap);
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
HPALETTE hOldPalette = 0;
|
HPALETTE hOldPalette = 0;
|
||||||
if (image.GetPalette().Ok())
|
if (image.GetPalette().Ok())
|
||||||
{
|
{
|
||||||
hOldPalette = ::SelectPalette(memdc, (HPALETTE) image.GetPalette().GetHPALETTE(), FALSE);
|
hOldPalette = ::SelectPalette(memdc, (HPALETTE) image.GetPalette().GetHPALETTE(), FALSE);
|
||||||
::RealizePalette(memdc);
|
::RealizePalette(memdc);
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// copy image data into DIB data and then into DDB (in a loop)
|
// copy image data into DIB data and then into DDB (in a loop)
|
||||||
unsigned char *data = image.GetData();
|
unsigned char *data = image.GetData();
|
||||||
@@ -523,8 +525,10 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
}
|
}
|
||||||
SetHBITMAP( (WXHBITMAP) hbitmap );
|
SetHBITMAP( (WXHBITMAP) hbitmap );
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (hOldPalette)
|
if (hOldPalette)
|
||||||
SelectPalette(memdc, hOldPalette, FALSE);
|
SelectPalette(memdc, hOldPalette, FALSE);
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// similarly, created an mono-bitmap for the possible mask
|
// similarly, created an mono-bitmap for the possible mask
|
||||||
if( image.HasMask() )
|
if( image.HasMask() )
|
||||||
@@ -792,7 +796,9 @@ bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
|
|||||||
return handler->Create(this, data, type, width, height, depth);
|
return handler->Create(this, data, type, width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *palette)
|
bool wxBitmap::SaveFile(const wxString& filename,
|
||||||
|
int type,
|
||||||
|
const wxPalette *palette)
|
||||||
{
|
{
|
||||||
wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
|
wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
|
||||||
|
|
||||||
@@ -882,6 +888,8 @@ void wxBitmap::SetOk(bool isOk)
|
|||||||
}
|
}
|
||||||
#endif // WXWIN_COMPATIBILITY_2
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
|
||||||
void wxBitmap::SetPalette(const wxPalette& palette)
|
void wxBitmap::SetPalette(const wxPalette& palette)
|
||||||
{
|
{
|
||||||
EnsureHasData();
|
EnsureHasData();
|
||||||
@@ -889,6 +897,8 @@ void wxBitmap::SetPalette(const wxPalette& palette)
|
|||||||
GetBitmapData()->m_bitmapPalette = palette;
|
GetBitmapData()->m_bitmapPalette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
void wxBitmap::SetMask(wxMask *mask)
|
void wxBitmap::SetMask(wxMask *mask)
|
||||||
{
|
{
|
||||||
EnsureHasData();
|
EnsureHasData();
|
||||||
@@ -911,6 +921,7 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const
|
|||||||
LPBITMAPINFO lpDib;
|
LPBITMAPINFO lpDib;
|
||||||
void *lpBits = (void*) NULL;
|
void *lpBits = (void*) NULL;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if( GetPalette() && GetPalette()->Ok() )
|
if( GetPalette() && GetPalette()->Ok() )
|
||||||
{
|
{
|
||||||
tmpBitmap.SetPalette(*GetPalette());
|
tmpBitmap.SetPalette(*GetPalette());
|
||||||
@@ -927,6 +938,9 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const
|
|||||||
memDC.SelectObject(tmpBitmap);
|
memDC.SelectObject(tmpBitmap);
|
||||||
memDC.SetPalette( palette );
|
memDC.SetPalette( palette );
|
||||||
}
|
}
|
||||||
|
#else // !wxUSE_PALETTE
|
||||||
|
hPal = (HPALETTE) ::GetStockObject(DEFAULT_PALETTE);
|
||||||
|
#endif // wxUSE_PALETTE/!wxUSE_PALETTE
|
||||||
|
|
||||||
// set the height negative because in a DIB the order of the lines is
|
// set the height negative because in a DIB the order of the lines is
|
||||||
// reversed
|
// reversed
|
||||||
@@ -1032,6 +1046,8 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
|
|||||||
::DeleteObject((HBITMAP) m_maskBitmap);
|
::DeleteObject((HBITMAP) m_maskBitmap);
|
||||||
m_maskBitmap = 0;
|
m_maskBitmap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (bitmap.Ok() && bitmap.GetPalette()->Ok())
|
if (bitmap.Ok() && bitmap.GetPalette()->Ok())
|
||||||
{
|
{
|
||||||
unsigned char red, green, blue;
|
unsigned char red, green, blue;
|
||||||
@@ -1041,6 +1057,8 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
|
|||||||
return Create(bitmap, transparentColour);
|
return Create(bitmap, transparentColour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -96,7 +96,9 @@ wxIcon wxNullIcon;
|
|||||||
wxCursor wxNullCursor;
|
wxCursor wxNullCursor;
|
||||||
wxPen wxNullPen;
|
wxPen wxNullPen;
|
||||||
wxBrush wxNullBrush;
|
wxBrush wxNullBrush;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette wxNullPalette;
|
wxPalette wxNullPalette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
wxFont wxNullFont;
|
wxFont wxNullFont;
|
||||||
wxColour wxNullColour;
|
wxColour wxNullColour;
|
||||||
|
|
||||||
|
@@ -178,7 +178,9 @@ wxDC::wxDC()
|
|||||||
m_oldPen = 0;
|
m_oldPen = 0;
|
||||||
m_oldBrush = 0;
|
m_oldBrush = 0;
|
||||||
m_oldFont = 0;
|
m_oldFont = 0;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
m_oldPalette = 0;
|
m_oldPalette = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
m_bOwnsDC = FALSE;
|
m_bOwnsDC = FALSE;
|
||||||
m_hDC = 0;
|
m_hDC = 0;
|
||||||
@@ -246,16 +248,21 @@ void wxDC::SelectOldObjects(WXHDC dc)
|
|||||||
::SelectObject((HDC) dc, (HFONT) m_oldFont);
|
::SelectObject((HDC) dc, (HFONT) m_oldFont);
|
||||||
}
|
}
|
||||||
m_oldFont = 0;
|
m_oldFont = 0;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (m_oldPalette)
|
if (m_oldPalette)
|
||||||
{
|
{
|
||||||
::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
|
::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
|
||||||
}
|
}
|
||||||
m_oldPalette = 0;
|
m_oldPalette = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
|
|
||||||
m_brush = wxNullBrush;
|
m_brush = wxNullBrush;
|
||||||
m_pen = wxNullPen;
|
m_pen = wxNullPen;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
m_palette = wxNullPalette;
|
m_palette = wxNullPalette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
m_font = wxNullFont;
|
m_font = wxNullFont;
|
||||||
m_backgroundBrush = wxNullBrush;
|
m_backgroundBrush = wxNullBrush;
|
||||||
m_selectedBitmap = wxNullBitmap;
|
m_selectedBitmap = wxNullBitmap;
|
||||||
@@ -1065,6 +1072,8 @@ void wxDC::DoDrawRotatedText(const wxString& text,
|
|||||||
// set GDI objects
|
// set GDI objects
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
|
||||||
void wxDC::SetPalette(const wxPalette& palette)
|
void wxDC::SetPalette(const wxPalette& palette)
|
||||||
{
|
{
|
||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
@@ -1104,6 +1113,8 @@ void wxDC::SetPalette(const wxPalette& palette)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
void wxDC::SetFont(const wxFont& the_font)
|
void wxDC::SetFont(const wxFont& the_font)
|
||||||
{
|
{
|
||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
|
@@ -708,12 +708,14 @@ bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal)
|
|||||||
|
|
||||||
if (hPalette)
|
if (hPalette)
|
||||||
{
|
{
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (pal)
|
if (pal)
|
||||||
{
|
{
|
||||||
*pal = new wxPalette;
|
*pal = new wxPalette;
|
||||||
(*pal)->SetHPALETTE((WXHPALETTE) hPalette);
|
(*pal)->SetHPALETTE((WXHPALETTE) hPalette);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
DeleteObject(hPalette);
|
DeleteObject(hPalette);
|
||||||
}
|
}
|
||||||
else if (pal)
|
else if (pal)
|
||||||
@@ -928,8 +930,10 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal)
|
|||||||
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap)
|
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap)
|
||||||
{
|
{
|
||||||
HPALETTE hPalette = 0;
|
HPALETTE hPalette = 0;
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (colourmap)
|
if (colourmap)
|
||||||
hPalette = (HPALETTE) colourmap->GetHPALETTE();
|
hPalette = (HPALETTE) colourmap->GetHPALETTE();
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
|
HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
|
||||||
if (dibHandle)
|
if (dibHandle)
|
||||||
|
@@ -355,6 +355,8 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap,
|
|||||||
#if wxUSE_IMAGE_LOADING_IN_MSW
|
#if wxUSE_IMAGE_LOADING_IN_MSW
|
||||||
wxPalette *palette = NULL;
|
wxPalette *palette = NULL;
|
||||||
bool success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0;
|
bool success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if ( success && palette )
|
if ( success && palette )
|
||||||
{
|
{
|
||||||
bitmap->SetPalette(*palette);
|
bitmap->SetPalette(*palette);
|
||||||
@@ -362,6 +364,7 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap,
|
|||||||
|
|
||||||
// it was copied by the bitmap if it was loaded successfully
|
// it was copied by the bitmap if it was loaded successfully
|
||||||
delete palette;
|
delete palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
#else
|
#else
|
||||||
@@ -375,9 +378,15 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap,
|
|||||||
const wxPalette *pal)
|
const wxPalette *pal)
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE_LOADING_IN_MSW
|
#if wxUSE_IMAGE_LOADING_IN_MSW
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
wxPalette *actualPalette = (wxPalette *)pal;
|
wxPalette *actualPalette = (wxPalette *)pal;
|
||||||
if ( !actualPalette )
|
if ( !actualPalette )
|
||||||
actualPalette = bitmap->GetPalette();
|
actualPalette = bitmap->GetPalette();
|
||||||
|
#else
|
||||||
|
wxPalette *actualPalette = NULL;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
return wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0;
|
return wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0;
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -17,18 +17,16 @@
|
|||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
#include "wx/palette.h"
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/palette.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
||||||
|
|
||||||
@@ -149,3 +147,5 @@ void wxPalette::SetHPALETTE(WXHPALETTE pal)
|
|||||||
M_PALETTEDATA->m_hPalette = pal;
|
M_PALETTEDATA->m_hPalette = pal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
|
@@ -240,8 +240,7 @@ bool wxPen::RealizeResource()
|
|||||||
if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
|
if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
|
||||||
{
|
{
|
||||||
real_dash = new wxMSWDash[M_PENDATA->m_nbDash];
|
real_dash = new wxMSWDash[M_PENDATA->m_nbDash];
|
||||||
int i, dsh;
|
for ( int i = 0; i < M_PENDATA->m_nbDash; i++ )
|
||||||
for (i=0; i<M_PENDATA->m_nbDash; i++)
|
|
||||||
real_dash[i] = M_PENDATA->m_dash[i] * M_PENDATA->m_width;
|
real_dash[i] = M_PENDATA->m_dash[i] * M_PENDATA->m_width;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user