DEFAULT_wxUSE_UNICODE=no
DEFAULT_wxUSE_WCSRTOMBS=no
+ DEFAULT_wxUSE_PALETTE=no
DEFAULT_wxUSE_IMAGE=no
DEFAULT_wxUSE_GIF=no
DEFAULT_wxUSE_PCX=no
DEFAULT_wxUSE_UNICODE=no
DEFAULT_wxUSE_WCSRTOMBS=no
+ DEFAULT_wxUSE_PALETTE=yes
DEFAULT_wxUSE_IMAGE=yes
DEFAULT_wxUSE_GIF=yes
DEFAULT_wxUSE_PCX=yes
dnl support for image formats that do not rely on external library
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(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)
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
fi
+if test "$wxUSE_PALETTE" = "yes" ; then
+ AC_DEFINE(wxUSE_PALETTE)
+fi
+
if test "$wxUSE_IMAGE" = "yes" ; then
AC_DEFINE(wxUSE_IMAGE)
fi
# endif
#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
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_POPUPWIN must be defined."
virtual void SetBrush(const wxBrush& brush) = 0;
virtual void SetBackground(const wxBrush& brush) = 0;
virtual void SetBackgroundMode(int mode) = 0;
+#if wxUSE_PALETTE
virtual void SetPalette(const wxPalette& palette) = 0;
+#endif // wxUSE_PALETTE
// clipping region
// ---------------
#endif // !Win16
#if WXWIN_COMPATIBILITY
+
+#if wxUSE_PALETTE
virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
+#endif // wxUSE_PALETTE
+
void GetTextExtent(const wxString& string, float *x, float *y,
float *descent = NULL, float *externalLeading = NULL,
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 GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
+
#endif // WXWIN_COMPATIBILITY
protected:
wxColour m_textForegroundColour;
wxColour m_textBackgroundColour;
wxFont m_font;
+
+#if wxUSE_PALETTE
wxPalette m_palette;
+#endif // wxUSE_PALETTE
private:
DECLARE_NO_COPY_CLASS(wxDCBase)
void SetMask( bool mask = TRUE );
bool HasMask() const;
+#if wxUSE_PALETTE
// Palette functions
bool HasPalette() const;
const wxPalette& GetPalette() const;
void SetPalette(const wxPalette& palette);
+#endif // wxUSE_PALETTE
// Option functions (arbitrary name/value mapping)
void SetOption(const wxString& name, const wxString& value);
class WXDLLEXPORT wxCursor;
class WXDLLEXPORT wxControl;
class WXDLLEXPORT wxImage;
+class WXDLLEXPORT wxPalette;
// ----------------------------------------------------------------------------
// Bitmap data
public:
int m_numColors;
+#if wxUSE_PALETTE
wxPalette m_bitmapPalette;
+#endif // wxUSE_PALETTE
int m_quality;
// MSW-specific
int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); }
void SetQuality(int q);
+#if wxUSE_PALETTE
wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); }
void SetPalette(const wxPalette& palette);
+#endif // wxUSE_PALETTE
wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); }
void SetMask(wxMask *mask) ;
void SetOk(bool isOk);
#endif // WXWIN_COMPATIBILITY_2
+#if wxUSE_PALETTE
#if WXWIN_COMPATIBILITY
wxPalette *GetColourMap() const { return GetPalette(); }
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
#endif // WXWIN_COMPATIBILITY
+#endif // wxUSE_PALETTE
// Implementation
public:
virtual void SetBrush(const wxBrush& brush);
virtual void SetBackground(const wxBrush& brush);
virtual void SetBackgroundMode(int mode);
+#if wxUSE_PALETTE
virtual void SetPalette(const wxPalette& palette);
+#endif // wxUSE_PALETTE
virtual void DestroyClippingRegion();
WXHPEN m_oldPen;
WXHBRUSH m_oldBrush;
WXHFONT m_oldFont;
+
+#if wxUSE_PALETTE
WXHPALETTE m_oldPalette;
+#endif // wxUSE_PALETTE
#if wxUSE_DC_CACHEING
static wxList sm_bitmapCache;
// Set to 1 for XPM format support
#define wxUSE_XPM 1
+// Set to 1 to compile in wxPalette class
+#define wxUSE_PALETTE 1
+
// ----------------------------------------------------------------------------
// Windows-only settings
// ----------------------------------------------------------------------------
#ifndef _WX_PALETTE_H_BASE_
#define _WX_PALETTE_H_BASE_
+#if wxUSE_PALETTE
+
#if defined(__WXMSW__)
-#include "wx/msw/palette.h"
+ #include "wx/msw/palette.h"
#elif defined(__WXMOTIF__)
-#include "wx/motif/palette.h"
+ #include "wx/motif/palette.h"
#elif defined(__WXGTK__)
-#include "wx/generic/paletteg.h"
+ #include "wx/generic/paletteg.h"
#elif defined(__WXMGL__)
-#include "wx/mgl/palette.h"
+ #include "wx/mgl/palette.h"
#elif defined(__WXMAC__)
-#include "wx/mac/palette.h"
+ #include "wx/mac/palette.h"
#elif defined(__WXPM__)
-#include "wx/os2/palette.h"
+ #include "wx/os2/palette.h"
#elif defined(__WXSTUBS__)
-#include "wx/stubs/palette.h"
+ #include "wx/stubs/palette.h"
#endif
+#endif // wxUSE_PALETTE
+
#endif
// _WX_PALETTE_H_BASE_
#endif
+#define wxUSE_PALETTE 0
+
#endif // _WX_UNIV_SETUP_H_
*/
#define wxUSE_ZIPSTREAM 0
+/*
+ * wxPalette class
+ */
+#define wxUSE_PALETTE 0
+
/*
* wxImage support
*/
wxMemoryDC dcMem;
+#if wxUSE_PALETTE
if (bitmap.GetPalette() && !hiColour)
{
dc.SetPalette(* bitmap.GetPalette());
dcMem.SetPalette(* bitmap.GetPalette());
}
+#endif // wxUSE_PALETTE
+
dcMem.SelectObject(bitmap);
int i, j;
}
dcMem.SelectObject(wxNullBitmap);
+#if wxUSE_PALETTE
if (bitmap.GetPalette() && !hiColour)
{
dc.SetPalette(wxNullPalette);
dcMem.SetPalette(wxNullPalette);
}
+#endif // wxUSE_PALETTE
return TRUE;
}
unsigned char m_maskRed,m_maskGreen,m_maskBlue;
bool m_ok;
bool m_static;
+#if wxUSE_PALETTE
wxPalette m_palette;
+#endif // wxUSE_PALETTE
wxArrayString m_optionNames;
wxArrayString m_optionValues;
};
return M_IMGDATA->m_height;
}
+#if wxUSE_PALETTE
+
// Palette functions
bool wxImage::HasPalette() const
M_IMGDATA->m_palette = palette;
}
+#endif // wxUSE_PALETTE
+
// Option functions (arbitrary name/value mapping)
void wxImage::SetOption(const wxString& name, const wxString& value)
{
// TODO: somehow make use of the Windows system colours, rather than ignoring them for the
// purposes of quantization.
-bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours,
- unsigned char** eightBitData, int flags)
+bool wxQuantize::Quantize(const wxImage& src, wxImage& dest,
+ wxPalette** pPalette,
+ int desiredNoColours,
+ unsigned char** eightBitData,
+ int flags)
{
int i;
else
delete[] data8bit;
+#if wxUSE_PALETTE
// Make a wxWindows palette
if (pPalette)
{
delete[] g;
delete[] b;
}
+#endif // wxUSE_PALETTE
return TRUE;
}
// This version sets a palette in the destination image so you don't
// have to manage it yourself.
-bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, int desiredNoColours,
- unsigned char** eightBitData, int flags)
+bool wxQuantize::Quantize(const wxImage& src,
+ wxImage& dest,
+ int desiredNoColours,
+ unsigned char** eightBitData,
+ int flags)
{
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);
- delete palette;
- }
- return TRUE;
+ dest.SetPalette(* palette);
+ delete palette;
}
- else
- return FALSE;
+#endif // wxUSE_PALETTE
+
+ return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
-// 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
/////////////////////////////////////////////////////////////////////////////
#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
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;
{
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++)
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;
return TRUE;
}
+#endif // wxUSE_PALETTE
+
hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight );
::SelectObject( memdc, hbitmap);
+#if wxUSE_PALETTE
HPALETTE hOldPalette = 0;
if (image.GetPalette().Ok())
{
hOldPalette = ::SelectPalette(memdc, (HPALETTE) image.GetPalette().GetHPALETTE(), FALSE);
::RealizePalette(memdc);
}
+#endif // wxUSE_PALETTE
// copy image data into DIB data and then into DDB (in a loop)
unsigned char *data = image.GetData();
}
SetHBITMAP( (WXHBITMAP) hbitmap );
+#if wxUSE_PALETTE
if (hOldPalette)
SelectPalette(memdc, hOldPalette, FALSE);
+#endif // wxUSE_PALETTE
// similarly, created an mono-bitmap for the possible mask
if( image.HasMask() )
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);
}
#endif // WXWIN_COMPATIBILITY_2
+#if wxUSE_PALETTE
+
void wxBitmap::SetPalette(const wxPalette& palette)
{
EnsureHasData();
GetBitmapData()->m_bitmapPalette = palette;
}
+#endif // wxUSE_PALETTE
+
void wxBitmap::SetMask(wxMask *mask)
{
EnsureHasData();
LPBITMAPINFO lpDib;
void *lpBits = (void*) NULL;
+#if wxUSE_PALETTE
if( GetPalette() && GetPalette()->Ok() )
{
tmpBitmap.SetPalette(*GetPalette());
memDC.SelectObject(tmpBitmap);
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
// reversed
::DeleteObject((HBITMAP) m_maskBitmap);
m_maskBitmap = 0;
}
+
+#if wxUSE_PALETTE
if (bitmap.Ok() && bitmap.GetPalette()->Ok())
{
unsigned char red, green, blue;
return Create(bitmap, transparentColour);
}
}
+#endif // wxUSE_PALETTE
+
return FALSE;
}
wxCursor wxNullCursor;
wxPen wxNullPen;
wxBrush wxNullBrush;
+#if wxUSE_PALETTE
wxPalette wxNullPalette;
+#endif // wxUSE_PALETTE
wxFont wxNullFont;
wxColour wxNullColour;
m_oldPen = 0;
m_oldBrush = 0;
m_oldFont = 0;
+#if wxUSE_PALETTE
m_oldPalette = 0;
+#endif // wxUSE_PALETTE
m_bOwnsDC = FALSE;
m_hDC = 0;
::SelectObject((HDC) dc, (HFONT) m_oldFont);
}
m_oldFont = 0;
+
+#if wxUSE_PALETTE
if (m_oldPalette)
{
::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
}
m_oldPalette = 0;
+#endif // wxUSE_PALETTE
}
m_brush = wxNullBrush;
m_pen = wxNullPen;
+#if wxUSE_PALETTE
m_palette = wxNullPalette;
+#endif // wxUSE_PALETTE
m_font = wxNullFont;
m_backgroundBrush = wxNullBrush;
m_selectedBitmap = wxNullBitmap;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
RECT rect;
GetClipBox(GetHdc(), &rect);
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_clipping = TRUE;
// the region coords are always the device ones, so do the translation
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCHECK_RET( GetHrgnOf(region), wxT("invalid clipping region") );
m_clipping = TRUE;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
if (m_clipping && m_hDC)
{
// TODO: this should restore the previous clipping region,
#ifdef __WXMICROWIN__
if (!GetHDC()) return 16;
#endif
-
+
return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
}
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
RECT rect;
if ( m_canvas )
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
col.GetPixel(),
style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
#ifdef __WXMICROWIN__
if (!GetHDC()) return FALSE;
#endif
-
+
wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
// get the color of the pixel
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCoord x1 = x-VIEWPORT_EXTENT;
wxCoord y1 = y-VIEWPORT_EXTENT;
wxCoord x2 = x+VIEWPORT_EXTENT;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
(void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), NULL);
(void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y2));
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
double dx = xc - x1;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCoord x2 = x1 + width,
y2 = y1 + height;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
COLORREF color = 0x00ffffff;
if (m_pen.Ok())
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
// Do things less efficiently if we have offsets
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// Do things less efficiently if we have offsets
if (xoffset != 0 || yoffset != 0)
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
wxCoord x2 = x + width;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
// Now, a negative radius value is interpreted to mean
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
wxCoord x2 = (x+width);
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
wxCoord x2 = x + w;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCHECK_RET( icon.Ok(), wxT("invalid icon in DrawIcon") );
#ifdef __WIN32__
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") );
int width = bmp.GetWidth(),
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
DrawAnyText(text, x, y);
// update the bounding box
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// prepare for drawing the text
if ( m_textForegroundColour.Ok() )
SetTextColor(GetHdc(), m_textForegroundColour.GetPixel());
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// we test that we have some font because otherwise we should still use the
// "else" part below to avoid that DrawRotatedText(angle = 180) and
// DrawRotatedText(angle = 0) use different fonts (we can't use the default
// set GDI objects
// ---------------------------------------------------------------------------
+#if wxUSE_PALETTE
+
void wxDC::SetPalette(const wxPalette& palette)
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
if (m_oldPalette)
}
}
+#endif // wxUSE_PALETTE
+
void wxDC::SetFont(const wxFont& the_font)
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
if (m_oldFont)
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
if (m_oldPen)
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
if (m_oldBrush)
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_backgroundBrush = brush;
if (!m_backgroundBrush.Ok())
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_backgroundMode = mode;
// SetBackgroundColour now only refers to text background
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_logicalFunction = function;
SetRop(m_hDC);
#ifdef __WXMICROWIN__
if (!GetHDC()) return 0;
#endif
-
+
TEXTMETRIC lpTextMetric;
GetTextMetrics(GetHdc(), &lpTextMetric);
#ifdef __WXMICROWIN__
if (!GetHDC()) return 0;
#endif
-
+
TEXTMETRIC lpTextMetric;
GetTextMetrics(GetHdc(), &lpTextMetric);
return;
}
#endif
-
+
HFONT hfontOld;
if ( font )
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_mappingMode = mode;
int pixel_width = 0;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_userScaleX = x;
m_userScaleY = y;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_signX = xLeftRight ? 1 : -1;
m_signY = yBottomUp ? -1 : 1;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_scaleX = x;
m_scaleY = y;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_logicalOriginX = x;
m_logicalOriginY = y;
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_deviceOriginX = x;
m_deviceOriginY = y;
#ifdef __WXMICROWIN__
if (!GetHDC()) return FALSE;
#endif
-
+
wxMask *mask = NULL;
if ( useMask )
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZRES);
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTRES);
}
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE);
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE);
}
#ifdef __WXMICROWIN__
if (!GetHDC()) return wxSize();
#endif
-
+
int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX);
int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY);
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
m_logicalScaleX = x;
m_logicalScaleY = y;
}
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
#endif
-
+
wxCoord x1, y1, descent1, externalLeading1;
GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
*x = x1; *y = y1;
if (hPalette)
{
+#if wxUSE_PALETTE
if (pal)
{
*pal = new wxPalette;
(*pal)->SetHPALETTE((WXHPALETTE) hPalette);
}
else
+#endif // wxUSE_PALETTE
DeleteObject(hPalette);
}
else if (pal)
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap)
{
HPALETTE hPalette = 0;
+#if wxUSE_PALETTE
if (colourmap)
hPalette = (HPALETTE) colourmap->GetHPALETTE();
+#endif // wxUSE_PALETTE
HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette);
if (dibHandle)
#if wxUSE_IMAGE_LOADING_IN_MSW
wxPalette *palette = NULL;
bool success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0;
+
+#if wxUSE_PALETTE
if ( success && palette )
{
bitmap->SetPalette(*palette);
// it was copied by the bitmap if it was loaded successfully
delete palette;
+#endif // wxUSE_PALETTE
return success;
#else
const wxPalette *pal)
{
#if wxUSE_IMAGE_LOADING_IN_MSW
+
+#if wxUSE_PALETTE
wxPalette *actualPalette = (wxPalette *)pal;
if ( !actualPalette )
actualPalette = bitmap->GetPalette();
+#else
+ wxPalette *actualPalette = NULL;
+#endif // wxUSE_PALETTE
+
return wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0;
#else
return FALSE;
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
+#if wxUSE_PALETTE
+
#ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/setup.h"
-#include "wx/palette.h"
+ #include "wx/palette.h"
#endif
-#include <windows.h>
-
-#include "assert.h"
+#include "wx/msw/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
wxPaletteRefData::~wxPaletteRefData(void)
{
- if ( m_hPalette )
- ::DeleteObject((HPALETTE) m_hPalette);
+ if ( m_hPalette )
+ ::DeleteObject((HPALETTE) m_hPalette);
}
wxPalette::wxPalette(void)
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)
return FALSE;
#else
if ( !m_refData )
- return FALSE;
+ return FALSE;
return ::GetNearestPaletteIndex((HPALETTE) M_PALETTEDATA->m_hPalette, PALETTERGB(red, green, blue));
#endif
return FALSE;
#else
if ( !m_refData )
- return FALSE;
+ return FALSE;
if (index < 0 || index > 255)
return FALSE;
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
+
if (M_PENDATA->m_style==wxUSER_DASH && M_PENDATA->m_nbDash && M_PENDATA->m_dash)
{
real_dash = new wxMSWDash[M_PENDATA->m_nbDash];
- int i, dsh;
- for (i=0; i<M_PENDATA->m_nbDash; i++)
+ for ( int i = 0; i < M_PENDATA->m_nbDash; i++ )
real_dash[i] = M_PENDATA->m_dash[i] * M_PENDATA->m_width;
}
else