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) )
|
||||||
{
|
|
||||||
if (palette)
|
|
||||||
{
|
|
||||||
dest.SetPalette(* palette);
|
|
||||||
delete palette;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
if (palette)
|
||||||
|
{
|
||||||
|
dest.SetPalette(* palette);
|
||||||
|
delete palette;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: palette.cpp
|
// Name: src/generic/paletteg.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// Id:
|
// Id:
|
||||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -96,13 +104,13 @@ bool wxPalette::Ok(void) const
|
|||||||
|
|
||||||
bool wxPalette::Create(int n,
|
bool wxPalette::Create(int n,
|
||||||
const unsigned char *red,
|
const unsigned char *red,
|
||||||
const unsigned char *green,
|
const unsigned char *green,
|
||||||
const unsigned char *blue)
|
const unsigned char *blue)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
m_refData = new wxPaletteRefData();
|
m_refData = new wxPaletteRefData();
|
||||||
|
|
||||||
M_PALETTEDATA->m_count = n;
|
M_PALETTEDATA->m_count = n;
|
||||||
M_PALETTEDATA->m_entries = new wxPaletteEntry[n];
|
M_PALETTEDATA->m_entries = new wxPaletteEntry[n];
|
||||||
|
|
||||||
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
|
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
|
||||||
@@ -122,8 +130,8 @@ int wxPalette::GetPixel( const unsigned char red,
|
|||||||
{
|
{
|
||||||
if (!m_refData) return FALSE;
|
if (!m_refData) return FALSE;
|
||||||
|
|
||||||
int closest = 0;
|
int closest = 0;
|
||||||
double d,distance = 1000.0; // max. dist is 256
|
double d,distance = 1000.0; // max. dist is 256
|
||||||
|
|
||||||
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
|
wxPaletteEntry *e = M_PALETTEDATA->m_entries;
|
||||||
for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
|
for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
|
||||||
@@ -135,17 +143,17 @@ int wxPalette::GetPixel( const unsigned char red,
|
|||||||
closest = i;
|
closest = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPalette::GetRGB(int pixel,
|
bool wxPalette::GetRGB(int pixel,
|
||||||
unsigned char *red,
|
unsigned char *red,
|
||||||
unsigned char *green,
|
unsigned char *green,
|
||||||
unsigned char *blue) const
|
unsigned char *blue) const
|
||||||
{
|
{
|
||||||
if (!m_refData) return FALSE;
|
if (!m_refData) return FALSE;
|
||||||
if (pixel >= M_PALETTEDATA->m_count) return FALSE;
|
if (pixel >= M_PALETTEDATA->m_count) return FALSE;
|
||||||
|
|
||||||
wxPaletteEntry& p = M_PALETTEDATA->m_entries[pixel];
|
wxPaletteEntry& p = M_PALETTEDATA->m_entries[pixel];
|
||||||
if (red) *red = p.red;
|
if (red) *red = p.red;
|
||||||
if (green) *green = p.green;
|
if (green) *green = p.green;
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
103
src/msw/dc.cpp
103
src/msw/dc.cpp
@@ -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;
|
||||||
@@ -270,7 +277,7 @@ void wxDC::UpdateClipBox()
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClipBox(GetHdc(), &rect);
|
GetClipBox(GetHdc(), &rect);
|
||||||
|
|
||||||
@@ -285,7 +292,7 @@ void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_clipping = TRUE;
|
m_clipping = TRUE;
|
||||||
|
|
||||||
// the region coords are always the device ones, so do the translation
|
// the region coords are always the device ones, so do the translation
|
||||||
@@ -317,7 +324,7 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCHECK_RET( GetHrgnOf(region), wxT("invalid clipping region") );
|
wxCHECK_RET( GetHrgnOf(region), wxT("invalid clipping region") );
|
||||||
|
|
||||||
m_clipping = TRUE;
|
m_clipping = TRUE;
|
||||||
@@ -336,7 +343,7 @@ void wxDC::DestroyClippingRegion()
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_clipping && m_hDC)
|
if (m_clipping && m_hDC)
|
||||||
{
|
{
|
||||||
// TODO: this should restore the previous clipping region,
|
// TODO: this should restore the previous clipping region,
|
||||||
@@ -377,7 +384,7 @@ int wxDC::GetDepth() const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return 16;
|
if (!GetHDC()) return 16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
|
return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +397,7 @@ void wxDC::Clear()
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
if ( m_canvas )
|
if ( m_canvas )
|
||||||
{
|
{
|
||||||
@@ -428,7 +435,7 @@ void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
|
if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
|
||||||
col.GetPixel(),
|
col.GetPixel(),
|
||||||
style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
|
style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
|
||||||
@@ -457,7 +464,7 @@ bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return FALSE;
|
if (!GetHDC()) return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
|
wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
|
||||||
|
|
||||||
// get the color of the pixel
|
// get the color of the pixel
|
||||||
@@ -473,7 +480,7 @@ void wxDC::DoCrossHair(wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCoord x1 = x-VIEWPORT_EXTENT;
|
wxCoord x1 = x-VIEWPORT_EXTENT;
|
||||||
wxCoord y1 = y-VIEWPORT_EXTENT;
|
wxCoord y1 = y-VIEWPORT_EXTENT;
|
||||||
wxCoord x2 = x+VIEWPORT_EXTENT;
|
wxCoord x2 = x+VIEWPORT_EXTENT;
|
||||||
@@ -494,7 +501,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), NULL);
|
(void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), NULL);
|
||||||
(void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y2));
|
(void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y2));
|
||||||
|
|
||||||
@@ -515,7 +522,7 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
double dx = xc - x1;
|
double dx = xc - x1;
|
||||||
@@ -567,7 +574,7 @@ void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCoord x2 = x1 + width,
|
wxCoord x2 = x1 + width,
|
||||||
y2 = y1 + height;
|
y2 = y1 + height;
|
||||||
|
|
||||||
@@ -605,7 +612,7 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
COLORREF color = 0x00ffffff;
|
COLORREF color = 0x00ffffff;
|
||||||
if (m_pen.Ok())
|
if (m_pen.Ok())
|
||||||
{
|
{
|
||||||
@@ -622,7 +629,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffs
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
// Do things less efficiently if we have offsets
|
// Do things less efficiently if we have offsets
|
||||||
@@ -659,7 +666,7 @@ void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Do things less efficiently if we have offsets
|
// Do things less efficiently if we have offsets
|
||||||
if (xoffset != 0 || yoffset != 0)
|
if (xoffset != 0 || yoffset != 0)
|
||||||
{
|
{
|
||||||
@@ -690,7 +697,7 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
wxCoord x2 = x + width;
|
wxCoord x2 = x + width;
|
||||||
@@ -731,7 +738,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
// Now, a negative radius value is interpreted to mean
|
// Now, a negative radius value is interpreted to mean
|
||||||
@@ -771,7 +778,7 @@ void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
wxCoord x2 = (x+width);
|
wxCoord x2 = (x+width);
|
||||||
@@ -789,7 +796,7 @@ void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,d
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
|
||||||
|
|
||||||
wxCoord x2 = x + w;
|
wxCoord x2 = x + w;
|
||||||
@@ -836,7 +843,7 @@ void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCHECK_RET( icon.Ok(), wxT("invalid icon in DrawIcon") );
|
wxCHECK_RET( icon.Ok(), wxT("invalid icon in DrawIcon") );
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
@@ -854,7 +861,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") );
|
wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") );
|
||||||
|
|
||||||
int width = bmp.GetWidth(),
|
int width = bmp.GetWidth(),
|
||||||
@@ -945,7 +952,7 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DrawAnyText(text, x, y);
|
DrawAnyText(text, x, y);
|
||||||
|
|
||||||
// update the bounding box
|
// update the bounding box
|
||||||
@@ -961,7 +968,7 @@ void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// prepare for drawing the text
|
// prepare for drawing the text
|
||||||
if ( m_textForegroundColour.Ok() )
|
if ( m_textForegroundColour.Ok() )
|
||||||
SetTextColor(GetHdc(), m_textForegroundColour.GetPixel());
|
SetTextColor(GetHdc(), m_textForegroundColour.GetPixel());
|
||||||
@@ -997,7 +1004,7 @@ void wxDC::DoDrawRotatedText(const wxString& text,
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we test that we have some font because otherwise we should still use the
|
// we test that we have some font because otherwise we should still use the
|
||||||
// "else" part below to avoid that DrawRotatedText(angle = 180) and
|
// "else" part below to avoid that DrawRotatedText(angle = 180) and
|
||||||
// DrawRotatedText(angle = 0) use different fonts (we can't use the default
|
// DrawRotatedText(angle = 0) use different fonts (we can't use the default
|
||||||
@@ -1065,12 +1072,14 @@ 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__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the old object temporarily, in case the assignment deletes an object
|
// Set the old object temporarily, in case the assignment deletes an object
|
||||||
// that's not yet selected out.
|
// that's not yet selected out.
|
||||||
if (m_oldPalette)
|
if (m_oldPalette)
|
||||||
@@ -1104,12 +1113,14 @@ 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__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the old object temporarily, in case the assignment deletes an object
|
// Set the old object temporarily, in case the assignment deletes an object
|
||||||
// that's not yet selected out.
|
// that's not yet selected out.
|
||||||
if (m_oldFont)
|
if (m_oldFont)
|
||||||
@@ -1144,7 +1155,7 @@ void wxDC::SetPen(const wxPen& pen)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the old object temporarily, in case the assignment deletes an object
|
// Set the old object temporarily, in case the assignment deletes an object
|
||||||
// that's not yet selected out.
|
// that's not yet selected out.
|
||||||
if (m_oldPen)
|
if (m_oldPen)
|
||||||
@@ -1178,7 +1189,7 @@ void wxDC::SetBrush(const wxBrush& brush)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the old object temporarily, in case the assignment deletes an object
|
// Set the old object temporarily, in case the assignment deletes an object
|
||||||
// that's not yet selected out.
|
// that's not yet selected out.
|
||||||
if (m_oldBrush)
|
if (m_oldBrush)
|
||||||
@@ -1229,7 +1240,7 @@ void wxDC::SetBackground(const wxBrush& brush)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_backgroundBrush = brush;
|
m_backgroundBrush = brush;
|
||||||
|
|
||||||
if (!m_backgroundBrush.Ok())
|
if (!m_backgroundBrush.Ok())
|
||||||
@@ -1274,7 +1285,7 @@ void wxDC::SetBackgroundMode(int mode)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_backgroundMode = mode;
|
m_backgroundMode = mode;
|
||||||
|
|
||||||
// SetBackgroundColour now only refers to text background
|
// SetBackgroundColour now only refers to text background
|
||||||
@@ -1294,7 +1305,7 @@ void wxDC::SetLogicalFunction(int function)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_logicalFunction = function;
|
m_logicalFunction = function;
|
||||||
|
|
||||||
SetRop(m_hDC);
|
SetRop(m_hDC);
|
||||||
@@ -1361,7 +1372,7 @@ wxCoord wxDC::GetCharHeight() const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return 0;
|
if (!GetHDC()) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEXTMETRIC lpTextMetric;
|
TEXTMETRIC lpTextMetric;
|
||||||
|
|
||||||
GetTextMetrics(GetHdc(), &lpTextMetric);
|
GetTextMetrics(GetHdc(), &lpTextMetric);
|
||||||
@@ -1374,7 +1385,7 @@ wxCoord wxDC::GetCharWidth() const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return 0;
|
if (!GetHDC()) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEXTMETRIC lpTextMetric;
|
TEXTMETRIC lpTextMetric;
|
||||||
|
|
||||||
GetTextMetrics(GetHdc(), &lpTextMetric);
|
GetTextMetrics(GetHdc(), &lpTextMetric);
|
||||||
@@ -1396,7 +1407,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HFONT hfontOld;
|
HFONT hfontOld;
|
||||||
if ( font )
|
if ( font )
|
||||||
{
|
{
|
||||||
@@ -1431,7 +1442,7 @@ void wxDC::SetMapMode(int mode)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_mappingMode = mode;
|
m_mappingMode = mode;
|
||||||
|
|
||||||
int pixel_width = 0;
|
int pixel_width = 0;
|
||||||
@@ -1503,7 +1514,7 @@ void wxDC::SetUserScale(double x, double y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_userScaleX = x;
|
m_userScaleX = x;
|
||||||
m_userScaleY = y;
|
m_userScaleY = y;
|
||||||
|
|
||||||
@@ -1515,7 +1526,7 @@ void wxDC::SetAxisOrientation(bool xLeftRight, bool yBottomUp)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_signX = xLeftRight ? 1 : -1;
|
m_signX = xLeftRight ? 1 : -1;
|
||||||
m_signY = yBottomUp ? -1 : 1;
|
m_signY = yBottomUp ? -1 : 1;
|
||||||
|
|
||||||
@@ -1527,7 +1538,7 @@ void wxDC::SetSystemScale(double x, double y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_scaleX = x;
|
m_scaleX = x;
|
||||||
m_scaleY = y;
|
m_scaleY = y;
|
||||||
|
|
||||||
@@ -1539,7 +1550,7 @@ void wxDC::SetLogicalOrigin(wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_logicalOriginX = x;
|
m_logicalOriginX = x;
|
||||||
m_logicalOriginY = y;
|
m_logicalOriginY = y;
|
||||||
|
|
||||||
@@ -1551,7 +1562,7 @@ void wxDC::SetDeviceOrigin(wxCoord x, wxCoord y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_deviceOriginX = x;
|
m_deviceOriginX = x;
|
||||||
m_deviceOriginY = y;
|
m_deviceOriginY = y;
|
||||||
|
|
||||||
@@ -1619,7 +1630,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return FALSE;
|
if (!GetHDC()) return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxMask *mask = NULL;
|
wxMask *mask = NULL;
|
||||||
if ( useMask )
|
if ( useMask )
|
||||||
{
|
{
|
||||||
@@ -1803,7 +1814,7 @@ void wxDC::DoGetSize(int *w, int *h) const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZRES);
|
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZRES);
|
||||||
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTRES);
|
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTRES);
|
||||||
}
|
}
|
||||||
@@ -1813,7 +1824,7 @@ void wxDC::DoGetSizeMM(int *w, int *h) const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE);
|
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE);
|
||||||
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE);
|
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE);
|
||||||
}
|
}
|
||||||
@@ -1823,7 +1834,7 @@ wxSize wxDC::GetPPI() const
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return wxSize();
|
if (!GetHDC()) return wxSize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX);
|
int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX);
|
||||||
int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY);
|
int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY);
|
||||||
|
|
||||||
@@ -1836,7 +1847,7 @@ void wxDC::SetLogicalScale(double x, double y)
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_logicalScaleX = x;
|
m_logicalScaleX = x;
|
||||||
m_logicalScaleY = y;
|
m_logicalScaleY = y;
|
||||||
}
|
}
|
||||||
@@ -1849,7 +1860,7 @@ void wxDC::DoGetTextExtent(const wxString& string, float *x, float *y,
|
|||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCoord x1, y1, descent1, externalLeading1;
|
wxCoord x1, y1, descent1, externalLeading1;
|
||||||
GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
|
GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
|
||||||
*x = x1; *y = y1;
|
*x = x1; *y = y1;
|
||||||
|
@@ -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;
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@@ -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)
|
||||||
|
|
||||||
@@ -44,8 +42,8 @@ wxPaletteRefData::wxPaletteRefData(void)
|
|||||||
|
|
||||||
wxPaletteRefData::~wxPaletteRefData(void)
|
wxPaletteRefData::~wxPaletteRefData(void)
|
||||||
{
|
{
|
||||||
if ( m_hPalette )
|
if ( m_hPalette )
|
||||||
::DeleteObject((HPALETTE) m_hPalette);
|
::DeleteObject((HPALETTE) m_hPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPalette::wxPalette(void)
|
wxPalette::wxPalette(void)
|
||||||
@@ -59,16 +57,16 @@ wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green
|
|||||||
|
|
||||||
wxPalette::~wxPalette(void)
|
wxPalette::~wxPalette(void)
|
||||||
{
|
{
|
||||||
// FreeResource(TRUE);
|
// FreeResource(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPalette::FreeResource(bool WXUNUSED(force))
|
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);
|
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)
|
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
|
||||||
@@ -112,7 +110,7 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
#else
|
||||||
if ( !m_refData )
|
if ( !m_refData )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
|
return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
|
||||||
#endif
|
#endif
|
||||||
@@ -124,7 +122,7 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
#else
|
||||||
if ( !m_refData )
|
if ( !m_refData )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (index < 0 || index > 255)
|
if (index < 0 || index > 255)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -143,9 +141,11 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
|
|||||||
|
|
||||||
void wxPalette::SetHPALETTE(WXHPALETTE pal)
|
void wxPalette::SetHPALETTE(WXHPALETTE pal)
|
||||||
{
|
{
|
||||||
if ( !m_refData )
|
if ( !m_refData )
|
||||||
m_refData = new wxPaletteRefData;
|
m_refData = new wxPaletteRefData;
|
||||||
|
|
||||||
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