1. wxIcon/wxCursor change, wxGDIImage class added
2. wxCriticalSection doesn't alloc memory any more 3. many minor fixes in bitmap/icon code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,7 +50,8 @@ class WXDLLEXPORT wxString;
|
|||||||
// Bitmap flags
|
// Bitmap flags
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
wxBITMAP_TYPE_BMP = 1,
|
wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
|
||||||
|
wxBITMAP_TYPE_BMP,
|
||||||
wxBITMAP_TYPE_BMP_RESOURCE,
|
wxBITMAP_TYPE_BMP_RESOURCE,
|
||||||
wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
|
wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
|
||||||
wxBITMAP_TYPE_ICO,
|
wxBITMAP_TYPE_ICO,
|
||||||
@@ -77,7 +78,7 @@ enum
|
|||||||
wxBITMAP_TYPE_PICT_RESOURCE,
|
wxBITMAP_TYPE_PICT_RESOURCE,
|
||||||
wxBITMAP_TYPE_ICON,
|
wxBITMAP_TYPE_ICON,
|
||||||
wxBITMAP_TYPE_ICON_RESOURCE,
|
wxBITMAP_TYPE_ICON_RESOURCE,
|
||||||
wxBITMAP_TYPE_MACCURSOR ,
|
wxBITMAP_TYPE_MACCURSOR,
|
||||||
wxBITMAP_TYPE_MACCURSOR_RESOURCE,
|
wxBITMAP_TYPE_MACCURSOR_RESOURCE,
|
||||||
wxBITMAP_TYPE_ANY = 50
|
wxBITMAP_TYPE_ANY = 50
|
||||||
};
|
};
|
||||||
|
@@ -45,12 +45,7 @@ class WXDLLEXPORT wxMenu;
|
|||||||
class WXDLLEXPORT wxMenuItemBase : public wxObject
|
class WXDLLEXPORT wxMenuItemBase : public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// some compilers need a default constructor here, do not use
|
wxMenuItemBase() { }
|
||||||
wxMenuItemBase() {}
|
|
||||||
|
|
||||||
/* This makes no sense (lots of asserts on MSW) so commenting out -- JACS
|
|
||||||
{ wxFAIL_MSG( wxT("illegal call") ); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
// creation
|
// creation
|
||||||
static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
|
static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
|
||||||
|
@@ -83,7 +83,16 @@ public:
|
|||||||
virtual bool ProcessMessage(WXMSG* pMsg);
|
virtual bool ProcessMessage(WXMSG* pMsg);
|
||||||
void DeletePendingObjects();
|
void DeletePendingObjects();
|
||||||
bool ProcessIdle();
|
bool ProcessIdle();
|
||||||
int GetComCtl32Version() const;
|
|
||||||
|
#if wxUSE_RICHEDIT
|
||||||
|
// initialize the richedit DLL of (at least) given version, return TRUE if
|
||||||
|
// ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3)
|
||||||
|
static bool InitRichEdit(int version = 2);
|
||||||
|
#endif // wxUSE_RICHEDIT
|
||||||
|
|
||||||
|
// returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
|
||||||
|
// wasn't found at all
|
||||||
|
static int GetComCtl32Version();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int m_nCmdShow;
|
int m_nCmdShow;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: bitmap.h
|
// Name: wx/msw/bitmap.h
|
||||||
// Purpose: wxBitmap class
|
// Purpose: wxBitmap class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -16,109 +16,57 @@
|
|||||||
#pragma interface "bitmap.h"
|
#pragma interface "bitmap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/msw/gdiimage.h"
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/gdicmn.h"
|
||||||
#include "wx/palette.h"
|
#include "wx/palette.h"
|
||||||
|
|
||||||
// Bitmap
|
|
||||||
class WXDLLEXPORT wxDC;
|
class WXDLLEXPORT wxDC;
|
||||||
class WXDLLEXPORT wxControl;
|
class WXDLLEXPORT wxControl;
|
||||||
class WXDLLEXPORT wxBitmap;
|
class WXDLLEXPORT wxBitmap;
|
||||||
class WXDLLEXPORT wxBitmapHandler;
|
class WXDLLEXPORT wxBitmapHandler;
|
||||||
class WXDLLEXPORT wxIcon;
|
class WXDLLEXPORT wxIcon;
|
||||||
|
class WXDLLEXPORT wxMask;
|
||||||
class WXDLLEXPORT wxCursor;
|
class WXDLLEXPORT wxCursor;
|
||||||
class WXDLLEXPORT wxControl;
|
class WXDLLEXPORT wxControl;
|
||||||
|
|
||||||
// A mask is a mono bitmap used for drawing bitmaps
|
// ----------------------------------------------------------------------------
|
||||||
// transparently.
|
// Bitmap data
|
||||||
class WXDLLEXPORT wxMask: public wxObject
|
//
|
||||||
|
// NB: this class is private, but declared here to make it possible inline
|
||||||
|
// wxBitmap functions accessing it
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxMask();
|
|
||||||
|
|
||||||
// Construct a mask from a bitmap and a colour indicating
|
|
||||||
// the transparent area
|
|
||||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
|
||||||
|
|
||||||
// Construct a mask from a bitmap and a palette index indicating
|
|
||||||
// the transparent area
|
|
||||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
|
||||||
|
|
||||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
|
||||||
wxMask(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
~wxMask();
|
|
||||||
|
|
||||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
|
||||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
|
||||||
bool Create(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
// Implementation
|
|
||||||
WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
|
||||||
void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WXHBITMAP m_maskBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
|
||||||
{
|
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxIcon;
|
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
public:
|
||||||
wxBitmapRefData();
|
wxBitmapRefData();
|
||||||
~wxBitmapRefData();
|
virtual ~wxBitmapRefData() { Free(); }
|
||||||
|
|
||||||
|
virtual void Free();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int m_width;
|
|
||||||
int m_height;
|
|
||||||
int m_depth;
|
|
||||||
bool m_ok;
|
|
||||||
int m_numColors;
|
int m_numColors;
|
||||||
wxPalette m_bitmapPalette;
|
wxPalette m_bitmapPalette;
|
||||||
int m_quality;
|
int m_quality;
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
// MSW-specific
|
||||||
WXHBITMAP m_hBitmap;
|
// ------------
|
||||||
wxDC * m_selectedInto; // So bitmap knows whether it's been selected into
|
|
||||||
// a device context (for error checking)
|
// this field is solely for error checking: we detect selecting a bitmap
|
||||||
wxMask * m_bitmapMask; // Option mask
|
// into more than one DC at once or deleting a bitmap still selected into a
|
||||||
#endif
|
// DC (both are serious programming errors under Windows)
|
||||||
|
wxDC *m_selectedInto;
|
||||||
|
|
||||||
|
// optional mask for transparent drawing
|
||||||
|
wxMask *m_bitmapMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBitmap: a mono or colour bitmap
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapHandler: public wxObject
|
class WXDLLEXPORT wxBitmap : public wxGDIImage
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
|
||||||
public:
|
|
||||||
wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
|
|
||||||
|
|
||||||
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth, int desiredHeight);
|
|
||||||
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
|
|
||||||
|
|
||||||
void SetName(const wxString& name) { m_name = name; }
|
|
||||||
void SetExtension(const wxString& ext) { m_extension = ext; }
|
|
||||||
void SetType(long type) { m_type = type; }
|
|
||||||
wxString GetName() const { return m_name; }
|
|
||||||
wxString GetExtension() const { return m_extension; }
|
|
||||||
long GetType() const { return m_type; }
|
|
||||||
protected:
|
|
||||||
wxString m_name;
|
|
||||||
wxString m_extension;
|
|
||||||
long m_type;
|
|
||||||
};
|
|
||||||
#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmap: public wxGDIObject
|
|
||||||
{
|
|
||||||
friend class WXDLLEXPORT wxBitmapHandler;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// default ctor creates an invalid bitmap, you must Create() it later
|
// default ctor creates an invalid bitmap, you must Create() it later
|
||||||
wxBitmap() { Init(); }
|
wxBitmap() { Init(); }
|
||||||
@@ -159,82 +107,169 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBitmap& operator=(const wxCursor& cursor)
|
||||||
|
{
|
||||||
|
(void)CopyFromCursor(cursor);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~wxBitmap();
|
virtual ~wxBitmap();
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
bool CopyFromIcon(const wxIcon& icon);
|
bool CopyFromIcon(const wxIcon& icon);
|
||||||
|
|
||||||
|
// copies the contents and mask of the given cursor to the bitmap
|
||||||
|
bool CopyFromCursor(const wxCursor& cursor);
|
||||||
|
|
||||||
virtual bool Create(int width, int height, int depth = -1);
|
virtual bool Create(int width, int height, int depth = -1);
|
||||||
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
|
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
|
||||||
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
|
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
|
||||||
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
|
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
|
||||||
|
|
||||||
bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
|
wxBitmapRefData *GetBitmapData() const { return (wxBitmapRefData *)m_refData; }
|
||||||
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
|
|
||||||
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
|
int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); }
|
||||||
int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
|
|
||||||
int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
|
|
||||||
void SetWidth(int w);
|
|
||||||
void SetHeight(int h);
|
|
||||||
void SetDepth(int d);
|
|
||||||
void SetQuality(int q);
|
void SetQuality(int q);
|
||||||
void SetOk(bool isOk);
|
|
||||||
#if WXWIN_COMPATIBILITY
|
wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); }
|
||||||
wxPalette *GetColourMap() const { return GetPalette(); }
|
|
||||||
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
|
|
||||||
#endif
|
|
||||||
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
|
|
||||||
void SetPalette(const wxPalette& palette);
|
void SetPalette(const wxPalette& palette);
|
||||||
|
|
||||||
wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); }
|
wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); }
|
||||||
void SetMask(wxMask *mask) ;
|
void SetMask(wxMask *mask) ;
|
||||||
|
|
||||||
bool operator==(const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
|
bool operator==(const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
|
||||||
bool operator!=(const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
|
bool operator!=(const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
|
||||||
|
|
||||||
// Format handling
|
#if WXWIN_COMPATIBILITY_2
|
||||||
static wxList& GetHandlers() { return sm_handlers; }
|
void SetOk(bool isOk);
|
||||||
static void AddHandler(wxBitmapHandler *handler);
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
static void InsertHandler(wxBitmapHandler *handler);
|
|
||||||
static bool RemoveHandler(const wxString& name);
|
|
||||||
static wxBitmapHandler *FindHandler(const wxString& name);
|
|
||||||
static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
|
|
||||||
static wxBitmapHandler *FindHandler(long bitmapType);
|
|
||||||
|
|
||||||
static void InitStandardHandlers();
|
#if WXWIN_COMPATIBILITY
|
||||||
static void CleanUpHandlers();
|
wxPalette *GetColourMap() const { return GetPalette(); }
|
||||||
|
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
|
||||||
protected:
|
#endif // WXWIN_COMPATIBILITY
|
||||||
static wxList sm_handlers;
|
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
void SetHBITMAP(WXHBITMAP bmp);
|
void SetHBITMAP(WXHBITMAP bmp) { SetHandle((WXHANDLE)bmp); }
|
||||||
WXHBITMAP GetHBITMAP() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); }
|
WXHBITMAP GetHBITMAP() const { return (WXHBITMAP)GetHandle(); }
|
||||||
void SetSelectedInto(wxDC *dc) { if (M_BITMAPDATA) M_BITMAPDATA->m_selectedInto = dc; }
|
|
||||||
wxDC *GetSelectedInto() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_selectedInto : (wxDC*) NULL); }
|
|
||||||
bool FreeResource(bool force = FALSE);
|
|
||||||
|
|
||||||
// Creates a bitmap that matches the device context's depth, from
|
void SetSelectedInto(wxDC *dc) { if (GetBitmapData()) GetBitmapData()->m_selectedInto = dc; }
|
||||||
// an arbitray bitmap. At present, the original bitmap must have an
|
wxDC *GetSelectedInto() const { return (GetBitmapData() ? GetBitmapData()->m_selectedInto : (wxDC*) NULL); }
|
||||||
// associated palette. (TODO: use a default palette if no palette exists.)
|
|
||||||
// This function is necessary for you to Blit an arbitrary bitmap (which may have
|
// Creates a bitmap that matches the device context's depth, from an
|
||||||
// the wrong depth). wxDC::SelectObject will compare the depth of the bitmap
|
// arbitray bitmap. At present, the original bitmap must have an associated
|
||||||
// with the DC's depth, and create a new bitmap if the depths differ.
|
// palette. (TODO: use a default palette if no palette exists.) This
|
||||||
// Eventually we should perhaps make this a public API function so that
|
// function is necessary for you to Blit an arbitrary bitmap (which may
|
||||||
// an app can efficiently produce bitmaps of the correct depth.
|
// have the wrong depth). wxDC::SelectObject will compare the depth of the
|
||||||
// The Windows solution is to use SetDibBits to blit an arbotrary DIB directly to a DC, but
|
// bitmap with the DC's depth, and create a new bitmap if the depths
|
||||||
// this is too Windows-specific, hence this solution of quietly converting the wxBitmap.
|
// differ. Eventually we should perhaps make this a public API function so
|
||||||
// Contributed by Frederic Villeneuve <frederic.villeneuve@natinst.com>
|
// that an app can efficiently produce bitmaps of the correct depth. The
|
||||||
|
// Windows solution is to use SetDibBits to blit an arbotrary DIB directly
|
||||||
|
// to a DC, but this is too Windows-specific, hence this solution of
|
||||||
|
// quietly converting the wxBitmap. Contributed by Frederic Villeneuve
|
||||||
|
// <frederic.villeneuve@natinst.com>
|
||||||
wxBitmap GetBitmapForDC(wxDC& dc) const;
|
wxBitmap GetBitmapForDC(wxDC& dc) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
virtual wxGDIImageRefData *CreateData() const
|
||||||
|
{ return new wxBitmapRefData; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef __WIN32__
|
||||||
|
// common part of CopyFromIcon/CopyFromCursor for Win32
|
||||||
|
bool CopyFromIconOrCursor(const wxGDIImage& icon);
|
||||||
|
#endif // __WIN32__
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMask: a mono bitmap used for drawing bitmaps transparently.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxMask : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxMask();
|
||||||
|
|
||||||
|
// Construct a mask from a bitmap and a colour indicating the transparent
|
||||||
|
// area
|
||||||
|
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||||
|
|
||||||
|
// Construct a mask from a bitmap and a palette index indicating the
|
||||||
|
// transparent area
|
||||||
|
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
||||||
|
|
||||||
|
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||||
|
wxMask(const wxBitmap& bitmap);
|
||||||
|
|
||||||
|
// construct a mask from the givne bitmap handle
|
||||||
|
wxMask(WXHBITMAP hbmp) { m_maskBitmap = hbmp; }
|
||||||
|
|
||||||
|
virtual ~wxMask();
|
||||||
|
|
||||||
|
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||||
|
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||||
|
bool Create(const wxBitmap& bitmap);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
||||||
|
void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WXHBITMAP m_maskBitmap;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBitmapHandler is a class which knows how to load/save bitmaps to/from file
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxBitmapHandler : public wxGDIImageHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxBitmapHandler() { m_type = wxBITMAP_TYPE_INVALID; }
|
||||||
|
wxBitmapHandler(const wxString& name, const wxString& ext, long type)
|
||||||
|
: wxGDIImageHandler(name, ext, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep wxBitmapHandler derived from wxGDIImageHandler compatible with the
|
||||||
|
// old class which worked only with bitmaps
|
||||||
|
virtual bool Create(wxBitmap *bitmap,
|
||||||
|
void *data,
|
||||||
|
long flags,
|
||||||
|
int width, int height, int depth = 1);
|
||||||
|
virtual bool LoadFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight);
|
||||||
|
virtual bool SaveFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name,
|
||||||
|
int type,
|
||||||
|
const wxPalette *palette = NULL);
|
||||||
|
|
||||||
|
virtual bool Create(wxGDIImage *image,
|
||||||
|
void *data,
|
||||||
|
long flags,
|
||||||
|
int width, int height, int depth = 1);
|
||||||
|
virtual bool Load(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight);
|
||||||
|
virtual bool Save(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
int type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_BITMAP_H_
|
// _WX_BITMAP_H_
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: cursor.h
|
// Name: wx/msw/cursor.h
|
||||||
// Purpose: wxCursor class
|
// Purpose: wxCursor class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -13,55 +13,70 @@
|
|||||||
#define _WX_CURSOR_H_
|
#define _WX_CURSOR_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "cursor.h"
|
#pragma interface "cursor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/bitmap.h"
|
// compatible (even if incorrect) behaviour by default: derive wxCursor from
|
||||||
|
// wxBitmap
|
||||||
|
#ifndef wxICON_IS_BITMAP
|
||||||
|
#define wxICON_IS_BITMAP 1
|
||||||
|
#endif
|
||||||
|
|
||||||
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
#if wxICON_IS_BITMAP
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
|
#define wxCursorRefDataBase wxBitmapRefData
|
||||||
|
#define wxCursorBase wxBitmap
|
||||||
|
#else
|
||||||
|
#include "wx/msw/gdiimage.h"
|
||||||
|
|
||||||
|
#define wxCursorRefDataBase wxGDIImageRefData
|
||||||
|
#define wxCursorBase wxGDIImage
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxCursorRefData : public wxCursorRefDataBase
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
public:
|
||||||
wxCursorRefData(void);
|
wxCursorRefData();
|
||||||
~wxCursorRefData(void);
|
virtual ~wxCursorRefData() { Free(); }
|
||||||
|
|
||||||
protected:
|
virtual void Free();
|
||||||
WXHCURSOR m_hCursor;
|
|
||||||
|
// for compatibility
|
||||||
|
public:
|
||||||
bool m_destroyCursor;
|
bool m_destroyCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
|
||||||
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
|
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
class WXDLLEXPORT wxCursor: public wxBitmap
|
class WXDLLEXPORT wxCursor : public wxCursorBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxCursor)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxCursor(void);
|
wxCursor();
|
||||||
|
|
||||||
// Copy constructors
|
// Copy constructors
|
||||||
inline wxCursor(const wxCursor& cursor) { Ref(cursor); }
|
wxCursor(const wxCursor& cursor) { Ref(cursor); }
|
||||||
|
|
||||||
wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
|
wxCursor(const char bits[], int width, int height,
|
||||||
|
int hotSpotX = -1, int hotSpotY = -1,
|
||||||
const char maskBits[] = NULL);
|
const char maskBits[] = NULL);
|
||||||
wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_CUR_RESOURCE,
|
wxCursor(const wxString& name,
|
||||||
|
long flags = wxBITMAP_TYPE_CUR_RESOURCE,
|
||||||
int hotSpotX = 0, int hotSpotY = 0);
|
int hotSpotX = 0, int hotSpotY = 0);
|
||||||
wxCursor(int cursor_type);
|
wxCursor(int cursor_type);
|
||||||
~wxCursor(void);
|
virtual ~wxCursor();
|
||||||
|
|
||||||
virtual bool Ok(void) const { return (m_refData != NULL && M_CURSORDATA->m_hCursor) ; }
|
|
||||||
|
|
||||||
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
|
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
|
||||||
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
||||||
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
|
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
|
||||||
|
|
||||||
void SetHCURSOR(WXHCURSOR cursor);
|
void SetHCURSOR(WXHCURSOR cursor) { SetHandle((WXHANDLE)cursor); }
|
||||||
inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
|
WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); }
|
||||||
|
|
||||||
bool FreeResource(bool force = FALSE);
|
protected:
|
||||||
|
virtual wxGDIImageRefData *CreateData() const { return new wxCursorRefData; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxCursor)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: dib.h
|
// Name: wx/msw/dib.h
|
||||||
// Purpose: Routines for loading and saving DIBs
|
// Purpose: Routines for loading and saving DIBs
|
||||||
// Author: Various
|
// Author: Various
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -13,10 +13,29 @@
|
|||||||
#define _WX_DIB_H_
|
#define _WX_DIB_H_
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmap;
|
class WXDLLEXPORT wxBitmap;
|
||||||
class WXDLLEXPORT wxColourMap;
|
class WXDLLEXPORT wxPalette;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Functions for working with DIBs
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// VZ: we have 3 different sets of functions: from bitmap.cpp (wxCreateDIB and
|
||||||
|
// wxFreeDIB), from dib.cpp and from dataobj.cpp - surely there is some
|
||||||
|
// redundancy between them? (FIXME)
|
||||||
|
|
||||||
|
// defined in bitmap.cpp
|
||||||
|
extern bool wxCreateDIB(long xSize, long ySize, long bitsPerPixel,
|
||||||
|
HPALETTE hPal, LPBITMAPINFO* lpDIBHeader);
|
||||||
|
extern void wxFreeDIB(LPBITMAPINFO lpDIBHeader);
|
||||||
|
|
||||||
|
// defined in ole/dataobj.cpp
|
||||||
|
extern size_t wxConvertBitmapToDIB(LPBITMAPINFO pbi, const wxBitmap& bitmap);
|
||||||
|
extern wxBitmap wxConvertDIBToBitmap(const LPBITMAPINFO pbi);
|
||||||
|
|
||||||
|
// the rest is defined in dib.cpp
|
||||||
|
|
||||||
// Save (device dependent) wxBitmap as a DIB
|
// Save (device dependent) wxBitmap as a DIB
|
||||||
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxColourMap *colourmap = NULL);
|
bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap = NULL);
|
||||||
|
|
||||||
// Load device independent bitmap into device dependent bitmap
|
// Load device independent bitmap into device dependent bitmap
|
||||||
wxBitmap *wxLoadBitmap(wxChar *filename, wxColourMap **colourmap = NULL);
|
wxBitmap *wxLoadBitmap(wxChar *filename, wxColourMap **colourmap = NULL);
|
||||||
@@ -30,5 +49,5 @@ HANDLE wxReadDIB2(LPTSTR lpFileName);
|
|||||||
LPSTR wxFindDIBBits (LPSTR lpbi);
|
LPSTR wxFindDIBBits (LPSTR lpbi);
|
||||||
HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo);
|
HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo);
|
||||||
|
|
||||||
#endif
|
#endif // _WX_DIB_H_
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: gdiobj.h
|
// Name: wx/msw/gdiobj.h
|
||||||
// Purpose: wxGDIObject class: base class for other GDI classes
|
// Purpose: wxGDIObject class: base class for other GDI classes
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -12,55 +12,53 @@
|
|||||||
#ifndef _WX_GDIOBJ_H_
|
#ifndef _WX_GDIOBJ_H_
|
||||||
#define _WX_GDIOBJ_H_
|
#define _WX_GDIOBJ_H_
|
||||||
|
|
||||||
#include "wx/object.h"
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "gdiobj.h"
|
#pragma interface "gdiobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// wxGDIRefData is the reference-counted data part of a GDI object.
|
#include "wx/object.h" // base class
|
||||||
// It contains another counter, m_usageCount, which counts the number
|
|
||||||
// of times this object has been used; e.g. in SetFont, the count
|
|
||||||
// is incremented. This is different from reference counting,
|
|
||||||
// where only the constructors, destructors and (un)clone operations
|
|
||||||
// affect the reference count.
|
|
||||||
// THIS IS NOW BEING REMOVED AS REDUNDANT AND ERROR-PRONE
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGDIRefData: public wxObjectRefData {
|
// ----------------------------------------------------------------------------
|
||||||
public:
|
// wxGDIRefData is the base class for wxXXXData structures which contain the
|
||||||
inline wxGDIRefData(void)
|
// real data for the GDI object and are shared among all wxWin objects sharing
|
||||||
{
|
// the same native GDI object
|
||||||
}
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGDIRefData : public wxObjectRefData
|
||||||
|
{
|
||||||
|
// this class is intentionally left blank
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_GDIDATA ((wxGDIRefData *)m_refData)
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIObject
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxGDIObject: public wxObject
|
class WXDLLEXPORT wxGDIObject : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxGDIObject)
|
public:
|
||||||
public:
|
wxGDIObject() { m_visible = FALSE; };
|
||||||
inline wxGDIObject(void) { m_visible = FALSE; };
|
|
||||||
inline ~wxGDIObject(void) {};
|
|
||||||
|
|
||||||
// Creates the resource
|
// Creates the resource
|
||||||
virtual bool RealizeResource(void) { return FALSE; };
|
virtual bool RealizeResource() { return FALSE; };
|
||||||
|
|
||||||
// Frees the resource
|
// Frees the resource
|
||||||
virtual bool FreeResource(bool WXUNUSED(force) = FALSE) { return FALSE; };
|
virtual bool FreeResource(bool WXUNUSED(force) = FALSE) { return FALSE; }
|
||||||
|
|
||||||
virtual bool IsFree(void) const { return FALSE; };
|
virtual bool IsFree() const { return FALSE; }
|
||||||
|
|
||||||
inline bool IsNull(void) const { return (m_refData == 0); }
|
bool IsNull() const { return (m_refData == 0); }
|
||||||
|
|
||||||
// Returns handle.
|
// Returns handle.
|
||||||
virtual WXHANDLE GetResourceHandle(void) { return 0; }
|
virtual WXHANDLE GetResourceHandle() { return 0; }
|
||||||
|
|
||||||
virtual bool GetVisible(void) { return m_visible; }
|
virtual bool GetVisible() { return m_visible; }
|
||||||
virtual void SetVisible(bool v) { m_visible = v; }
|
virtual void SetVisible(bool v) { m_visible = v; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_visible; // Can a pointer to this object be safely taken?
|
bool m_visible; // TRUE only if we should delete this object ourselves
|
||||||
// - only if created within FindOrCreate...
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxGDIObject)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: icon.h
|
// Name: wx/msw/icon.h
|
||||||
// Purpose: wxIcon class
|
// Purpose: wxIcon class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -16,34 +16,49 @@
|
|||||||
#pragma interface "icon.h"
|
#pragma interface "icon.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/bitmap.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// compatible (even if incorrect) behaviour by default: derive wxIcon from
|
||||||
|
// wxBitmap
|
||||||
|
#ifndef wxICON_IS_BITMAP
|
||||||
|
#define wxICON_IS_BITMAP 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxICON_IS_BITMAP
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
|
#define wxIconRefDataBase wxBitmapRefData
|
||||||
|
#define wxIconBase wxBitmap
|
||||||
|
#else
|
||||||
|
#include "wx/msw/gdiimage.h"
|
||||||
|
|
||||||
|
#define wxIconRefDataBase wxGDIImageRefData
|
||||||
|
#define wxIconBase wxGDIImage
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// icon data
|
// icon data
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
|
|
||||||
|
// notice that although wxIconRefData inherits from wxBitmapRefData, it is not
|
||||||
|
// a valid wxBitmapRefData
|
||||||
|
class WXDLLEXPORT wxIconRefData : public wxIconRefDataBase
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxIcon;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxIconRefData();
|
wxIconRefData() { }
|
||||||
~wxIconRefData();
|
virtual ~wxIconRefData() { Free(); }
|
||||||
|
|
||||||
public:
|
virtual void Free();
|
||||||
WXHICON m_hIcon;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_ICONDATA ((wxIconRefData *)m_refData)
|
|
||||||
#define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Icon
|
// Icon
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxIcon : public wxBitmap
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxIcon : public wxIconBase
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxIcon();
|
wxIcon();
|
||||||
|
|
||||||
@@ -51,61 +66,35 @@ public:
|
|||||||
wxIcon(const wxIcon& icon) { Ref(icon); }
|
wxIcon(const wxIcon& icon) { Ref(icon); }
|
||||||
|
|
||||||
wxIcon(const char bits[], int width, int height);
|
wxIcon(const char bits[], int width, int height);
|
||||||
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
|
wxIcon(const wxString& name,
|
||||||
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
~wxIcon();
|
virtual ~wxIcon();
|
||||||
|
|
||||||
bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
|
virtual bool LoadFile(const wxString& name,
|
||||||
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
|
|
||||||
wxIcon& operator = (const wxIcon& icon)
|
wxIcon& operator = (const wxIcon& icon)
|
||||||
{ if (*this == icon) return (*this); Ref(icon); return *this; }
|
{ if ( *this != icon ) Ref(icon); return *this; }
|
||||||
bool operator == (const wxIcon& icon) const
|
bool operator == (const wxIcon& icon) const
|
||||||
{ return m_refData == icon.m_refData; }
|
{ return m_refData == icon.m_refData; }
|
||||||
bool operator != (const wxIcon& icon) const
|
bool operator != (const wxIcon& icon) const
|
||||||
{ return m_refData != icon.m_refData; }
|
{ return m_refData != icon.m_refData; }
|
||||||
|
|
||||||
void SetHICON(WXHICON ico);
|
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
|
||||||
WXHICON GetHICON() const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
|
|
||||||
|
|
||||||
bool Ok() const { return (m_refData != NULL && M_ICONDATA->m_hIcon != 0) ; }
|
void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
|
||||||
|
WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
|
||||||
|
|
||||||
bool FreeResource(bool force = FALSE);
|
protected:
|
||||||
};
|
virtual wxGDIImageRefData *CreateData() const
|
||||||
|
|
||||||
// TODO: Put these in separate, private header
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxICOFileHandler()
|
|
||||||
{
|
{
|
||||||
m_name = "ICO icon file";
|
return new wxIconRefData;
|
||||||
m_extension = "ico";
|
}
|
||||||
m_type = wxBITMAP_TYPE_ICO;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxICOResourceHandler()
|
|
||||||
{
|
|
||||||
m_name = "ICO resource";
|
|
||||||
m_extension = "ico";
|
|
||||||
m_type = wxBITMAP_TYPE_ICO_RESOURCE;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -220,6 +220,23 @@ inline void wxRGBToColour(wxColour& c, COLORREF rgb)
|
|||||||
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// small helper classes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// create an instance of this class and use it as the HDC for screen, will
|
||||||
|
// automatically release the DC going out of scope
|
||||||
|
class ScreenHDC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScreenHDC() { m_hdc = GetDC(NULL); }
|
||||||
|
~ScreenHDC() { ReleaseDC(NULL, m_hdc); }
|
||||||
|
operator HDC() const { return m_hdc; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
HDC m_hdc;
|
||||||
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
|
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
|
||||||
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
|
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
// define this to 0 when building wxBase library
|
// define this to 0 when building wxBase library
|
||||||
#define wxUSE_GUI 1
|
#define wxUSE_GUI 1
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// compatibility settings
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define WXWIN_COMPATIBILITY 0
|
#define WXWIN_COMPATIBILITY 0
|
||||||
// Compatibility with 1.68 API.
|
// Compatibility with 1.68 API.
|
||||||
// Level 0: no backward compatibility, all new features
|
// Level 0: no backward compatibility, all new features
|
||||||
@@ -26,6 +30,19 @@
|
|||||||
// the compatibility code is now very minimal so there
|
// the compatibility code is now very minimal so there
|
||||||
// is little advantage to setting it to 1.
|
// is little advantage to setting it to 1.
|
||||||
|
|
||||||
|
// in wxMSW version 2.1.11 and earlier, wxIcon always derives from wxBitmap,
|
||||||
|
// but this is very dangerous because you can mistakenly pass an icon instead
|
||||||
|
// of a bitmap to a function taking "const wxBitmap&" - which will *not* work
|
||||||
|
// because an icon is not a valid bitmap
|
||||||
|
//
|
||||||
|
// Starting from 2.1.12, you have the choice under this backwards compatible
|
||||||
|
// behaviour (your code will still compile, but probably won't behave as
|
||||||
|
// expected!) and not deriving wxIcon class from wxBitmap, but providing a
|
||||||
|
// conversion ctor wxBitmap(const wxIcon&) instead.
|
||||||
|
//
|
||||||
|
// Recommended setting: 0
|
||||||
|
#define wxICON_IS_BITMAP 0
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// General features
|
// General features
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -300,6 +317,13 @@
|
|||||||
// See note above about using FAFA and CTL3D.
|
// See note above about using FAFA and CTL3D.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// can we use RICHEDIT control?
|
||||||
|
#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__GNUWIN32_OLD__)
|
||||||
|
#define wxUSE_RICHEDIT 1
|
||||||
|
#else
|
||||||
|
#define wxUSE_RICHEDIT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define wxUSE_COMMON_DIALOGS 1
|
#define wxUSE_COMMON_DIALOGS 1
|
||||||
// On rare occasions (e.g. using DJGPP) may want
|
// On rare occasions (e.g. using DJGPP) may want
|
||||||
// to omit common dialogs
|
// to omit common dialogs
|
||||||
|
@@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
wxStaticBitmap(wxWindow *parent,
|
wxStaticBitmap(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxGDIImage& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxGDIImage& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -50,15 +50,15 @@ public:
|
|||||||
|
|
||||||
virtual ~wxStaticBitmap() { Free(); }
|
virtual ~wxStaticBitmap() { Free(); }
|
||||||
|
|
||||||
virtual void SetIcon(const wxIcon& icon) { SetBitmap(icon); }
|
void SetIcon(const wxIcon& icon) { SetImage(icon); }
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap);
|
void SetBitmap(const wxBitmap& bitmap) { SetImage(bitmap); }
|
||||||
|
|
||||||
// assert failure is provoked by an attempt to get an icon from bitmap or
|
// assert failure is provoked by an attempt to get an icon from bitmap or
|
||||||
// vice versa
|
// vice versa
|
||||||
const wxIcon& GetIcon() const
|
const wxIcon& GetIcon() const
|
||||||
{ wxASSERT( m_isIcon ); return *m_image.icon; }
|
{ wxASSERT( m_isIcon ); return *(wxIcon *)m_image; }
|
||||||
const wxBitmap& GetBitmap() const
|
const wxBitmap& GetBitmap() const
|
||||||
{ wxASSERT( !m_isIcon ); return *m_image.bitmap; }
|
{ wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; }
|
||||||
|
|
||||||
// overriden base class virtuals
|
// overriden base class virtuals
|
||||||
virtual bool AcceptsFocus() const { return FALSE; }
|
virtual bool AcceptsFocus() const { return FALSE; }
|
||||||
@@ -70,21 +70,19 @@ public:
|
|||||||
#endif // __WIN16__
|
#endif // __WIN16__
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init() { m_isIcon = TRUE; m_image.icon = NULL; }
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
void Init() { m_isIcon = TRUE; m_image = NULL; }
|
||||||
void Free();
|
void Free();
|
||||||
|
|
||||||
// TRUE if icon/bitmap is valid
|
// TRUE if icon/bitmap is valid
|
||||||
bool ImageIsOk() const;
|
bool ImageIsOk() const;
|
||||||
|
|
||||||
|
void SetImage(const wxGDIImage& image);
|
||||||
|
|
||||||
// we can have either an icon or a bitmap
|
// we can have either an icon or a bitmap
|
||||||
bool m_isIcon;
|
bool m_isIcon;
|
||||||
union
|
wxGDIImage *m_image;
|
||||||
{
|
|
||||||
wxIcon *icon;
|
|
||||||
wxBitmap *bitmap;
|
|
||||||
} m_image;
|
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: tbarbase.h
|
// Name: wx/tbarbase.h
|
||||||
// Purpose: Base class for toolbar classes
|
// Purpose: Base class for toolbar classes
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
|
@@ -21,7 +21,8 @@
|
|||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
/* otherwise we get undefined references for non-thread case (KB)*/
|
|
||||||
|
// only for wxUSE_THREADS - otherwise we'd get undefined symbols
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "thread.h"
|
#pragma interface "thread.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -37,28 +38,31 @@
|
|||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
typedef enum
|
enum wxMutexError
|
||||||
{
|
{
|
||||||
wxMUTEX_NO_ERROR = 0,
|
wxMUTEX_NO_ERROR = 0,
|
||||||
wxMUTEX_DEAD_LOCK, // Mutex has been already locked by THE CALLING thread
|
wxMUTEX_DEAD_LOCK, // Mutex has been already locked by THE CALLING thread
|
||||||
wxMUTEX_BUSY, // Mutex has been already locked by ONE thread
|
wxMUTEX_BUSY, // Mutex has been already locked by ONE thread
|
||||||
wxMUTEX_UNLOCKED,
|
wxMUTEX_UNLOCKED,
|
||||||
wxMUTEX_MISC_ERROR
|
wxMUTEX_MISC_ERROR
|
||||||
} wxMutexError;
|
};
|
||||||
|
|
||||||
typedef enum
|
enum wxThreadError
|
||||||
{
|
{
|
||||||
wxTHREAD_NO_ERROR = 0, // No error
|
wxTHREAD_NO_ERROR = 0, // No error
|
||||||
wxTHREAD_NO_RESOURCE, // No resource left to create a new thread
|
wxTHREAD_NO_RESOURCE, // No resource left to create a new thread
|
||||||
wxTHREAD_RUNNING, // The thread is already running
|
wxTHREAD_RUNNING, // The thread is already running
|
||||||
wxTHREAD_NOT_RUNNING, // The thread isn't running
|
wxTHREAD_NOT_RUNNING, // The thread isn't running
|
||||||
wxTHREAD_MISC_ERROR // Some other error
|
wxTHREAD_MISC_ERROR // Some other error
|
||||||
} wxThreadError;
|
};
|
||||||
|
|
||||||
// defines the interval of priority
|
// defines the interval of priority
|
||||||
#define WXTHREAD_MIN_PRIORITY 0u
|
enum
|
||||||
#define WXTHREAD_DEFAULT_PRIORITY 50u
|
{
|
||||||
#define WXTHREAD_MAX_PRIORITY 100u
|
WXTHREAD_MIN_PRIORITY = 0u,
|
||||||
|
WXTHREAD_DEFAULT_PRIORITY = 50u,
|
||||||
|
WXTHREAD_MAX_PRIORITY = 100u
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// A mutex object is a synchronization object whose state is set to signaled
|
// A mutex object is a synchronization object whose state is set to signaled
|
||||||
@@ -129,21 +133,24 @@ private:
|
|||||||
// Critical section: this is the same as mutex but is only visible to the
|
// Critical section: this is the same as mutex but is only visible to the
|
||||||
// threads of the same process. For the platforms which don't have native
|
// threads of the same process. For the platforms which don't have native
|
||||||
// support for critical sections, they're implemented entirely in terms of
|
// support for critical sections, they're implemented entirely in terms of
|
||||||
// mutexes
|
// mutexes.
|
||||||
|
//
|
||||||
|
// NB: wxCriticalSection object does not allocate any memory in its ctor
|
||||||
|
// which makes it possible to have static globals of this class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// in order to avoid any overhead under !MSW make all wxCriticalSection class
|
class WXDLLEXPORT wxCriticalSectionInternal;
|
||||||
// functions inline - but this can't be done under MSW
|
|
||||||
#if defined(__WXMSW__)
|
// in order to avoid any overhead under platforms where critical sections are
|
||||||
class WXDLLEXPORT wxCriticalSectionInternal;
|
// just mutexes make all wxCriticalSection class functions inline
|
||||||
#define WXCRITICAL_INLINE
|
#if !defined(__WXMSW__) && !defined(__WXPM__) && !defined(__WXMAC__)
|
||||||
#elif defined(__WXMAC__)
|
|
||||||
class WXDLLEXPORT wxCriticalSectionInternal;
|
|
||||||
#define WXCRITICAL_INLINE
|
|
||||||
#elif defined(__WXPM__)
|
|
||||||
#define WXCRITICAL_INLINE
|
|
||||||
#else // !MSW && !PM
|
|
||||||
#define WXCRITICAL_INLINE inline
|
#define WXCRITICAL_INLINE inline
|
||||||
|
|
||||||
|
#define wxCRITSECT_IS_MUTEX 1
|
||||||
|
#else // MSW || Mac || OS2
|
||||||
|
#define WXCRITICAL_INLINE
|
||||||
|
|
||||||
|
#define wxCRITSECT_IS_MUTEX 0
|
||||||
#endif // MSW/!MSW
|
#endif // MSW/!MSW
|
||||||
|
|
||||||
// you should consider wxCriticalSectionLocker whenever possible instead of
|
// you should consider wxCriticalSectionLocker whenever possible instead of
|
||||||
@@ -165,11 +172,18 @@ private:
|
|||||||
wxCriticalSection(const wxCriticalSection&);
|
wxCriticalSection(const wxCriticalSection&);
|
||||||
wxCriticalSection& operator=(const wxCriticalSection&);
|
wxCriticalSection& operator=(const wxCriticalSection&);
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
#if wxCRITSECT_IS_MUTEX
|
||||||
wxCriticalSectionInternal *m_critsect;
|
|
||||||
#else // !MSW
|
|
||||||
wxMutex m_mutex;
|
wxMutex m_mutex;
|
||||||
#endif // MSW/!MSW
|
#elif defined(__WXMSW__)
|
||||||
|
// we can't allocate any memory in the ctor, so use placement new -
|
||||||
|
// unfortunately, we have to hardcode the sizeof() here because we can't
|
||||||
|
// include windows.h from this public header
|
||||||
|
char m_buffer[24];
|
||||||
|
#elif !defined(__WXPM__)
|
||||||
|
wxCriticalSectionInternal *m_critsect;
|
||||||
|
#else
|
||||||
|
// nothing for OS/2
|
||||||
|
#endif // !Unix/Unix
|
||||||
};
|
};
|
||||||
|
|
||||||
// keep your preprocessor name space clean
|
// keep your preprocessor name space clean
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
#ifndef _TOOLBAR_H_BASE_
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
#define _TOOLBAR_H_BASE_
|
// Name: wx/toolbar.h
|
||||||
|
// Purpose: wxToolBar interface declaration
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 20.11.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_TOOLBAR_H_BASE_
|
||||||
|
#define _WX_TOOLBAR_H_BASE_
|
||||||
|
|
||||||
|
#include "wx/tbarbase.h" // the base class for all toolbars
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
class WXDLLEXPORT wxToolBar : public wxControl
|
||||||
|
{
|
||||||
|
};
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
#if defined(__WXMSW__) && defined(__WIN95__)
|
#if defined(__WXMSW__) && defined(__WIN95__)
|
||||||
# include "wx/msw/tbar95.h"
|
# include "wx/msw/tbar95.h"
|
||||||
@@ -20,4 +39,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _TOOLBAR_H_BASE_
|
// _WX_TOOLBAR_H_BASE_
|
||||||
|
@@ -499,7 +499,8 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
|
|||||||
for (wxNode * node = First (); node; node = node->Next ())
|
for (wxNode * node = First (); node; node = node->Next ())
|
||||||
{
|
{
|
||||||
wxPen *each_pen = (wxPen *) node->Data ();
|
wxPen *each_pen = (wxPen *) node->Data ();
|
||||||
if (each_pen && each_pen->GetVisible() &&
|
if (each_pen &&
|
||||||
|
each_pen->GetVisible() &&
|
||||||
each_pen->GetWidth () == width &&
|
each_pen->GetWidth () == width &&
|
||||||
each_pen->GetStyle () == style &&
|
each_pen->GetStyle () == style &&
|
||||||
each_pen->GetColour ().Red () == colour.Red () &&
|
each_pen->GetColour ().Red () == colour.Red () &&
|
||||||
@@ -514,6 +515,7 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
|
|||||||
// returning a pointer to an automatic variable and hanging on to it
|
// returning a pointer to an automatic variable and hanging on to it
|
||||||
// (dangling pointer).
|
// (dangling pointer).
|
||||||
pen->SetVisible(TRUE);
|
pen->SetVisible(TRUE);
|
||||||
|
|
||||||
return pen;
|
return pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,19 +544,23 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
|
|||||||
for (wxNode * node = First (); node; node = node->Next ())
|
for (wxNode * node = First (); node; node = node->Next ())
|
||||||
{
|
{
|
||||||
wxBrush *each_brush = (wxBrush *) node->Data ();
|
wxBrush *each_brush = (wxBrush *) node->Data ();
|
||||||
if (each_brush && each_brush->GetVisible() &&
|
if (each_brush &&
|
||||||
|
each_brush->GetVisible() &&
|
||||||
each_brush->GetStyle () == style &&
|
each_brush->GetStyle () == style &&
|
||||||
each_brush->GetColour ().Red () == colour.Red () &&
|
each_brush->GetColour ().Red () == colour.Red () &&
|
||||||
each_brush->GetColour ().Green () == colour.Green () &&
|
each_brush->GetColour ().Green () == colour.Green () &&
|
||||||
each_brush->GetColour ().Blue () == colour.Blue ())
|
each_brush->GetColour ().Blue () == colour.Blue ())
|
||||||
return each_brush;
|
return each_brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yes, we can return a pointer to this in a later FindOrCreateBrush call,
|
// Yes, we can return a pointer to this in a later FindOrCreateBrush call,
|
||||||
// because we created it within FindOrCreateBrush. Safeguards against
|
// because we created it within FindOrCreateBrush. Safeguards against
|
||||||
// returning a pointer to an automatic variable and hanging on to it
|
// returning a pointer to an automatic variable and hanging on to it
|
||||||
// (dangling pointer).
|
// (dangling pointer).
|
||||||
wxBrush *brush = new wxBrush (colour, style);
|
wxBrush *brush = new wxBrush (colour, style);
|
||||||
|
|
||||||
brush->SetVisible(TRUE);
|
brush->SetVisible(TRUE);
|
||||||
|
|
||||||
return brush;
|
return brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +583,7 @@ wxFontList::~wxFontList ()
|
|||||||
if (font->GetVisible())
|
if (font->GetVisible())
|
||||||
delete font;
|
delete font;
|
||||||
node = next;
|
node = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontList::AddFont (wxFont * font)
|
void wxFontList::AddFont (wxFont * font)
|
||||||
@@ -596,14 +602,13 @@ wxFont *wxFontList::
|
|||||||
for (wxNode * node = First (); node; node = node->Next ())
|
for (wxNode * node = First (); node; node = node->Next ())
|
||||||
{
|
{
|
||||||
wxFont *each_font = (wxFont *) node->Data ();
|
wxFont *each_font = (wxFont *) node->Data ();
|
||||||
if (each_font && each_font->GetVisible() && each_font->Ok() &&
|
if (each_font &&
|
||||||
|
each_font->GetVisible() &&
|
||||||
|
each_font->Ok() &&
|
||||||
each_font->GetPointSize () == PointSize &&
|
each_font->GetPointSize () == PointSize &&
|
||||||
each_font->GetStyle () == Style &&
|
each_font->GetStyle () == Style &&
|
||||||
each_font->GetWeight () == Weight &&
|
each_font->GetWeight () == Weight &&
|
||||||
each_font->GetUnderlined () == underline &&
|
each_font->GetUnderlined () == underline &&
|
||||||
//#if defined(__X__)
|
|
||||||
// each_font->GetFontId () == FamilyOrFontId) /* New font system */
|
|
||||||
//#else
|
|
||||||
#if defined(__WXGTK__)
|
#if defined(__WXGTK__)
|
||||||
(each_font->GetFamily() == FamilyOrFontId ||
|
(each_font->GetFamily() == FamilyOrFontId ||
|
||||||
(each_font->GetFamily() == wxSWISS && FamilyOrFontId == wxDEFAULT)) &&
|
(each_font->GetFamily() == wxSWISS && FamilyOrFontId == wxDEFAULT)) &&
|
||||||
@@ -612,11 +617,12 @@ wxFont *wxFontList::
|
|||||||
#endif
|
#endif
|
||||||
((each_font->GetFaceName() == wxT("")) || each_font->GetFaceName() == Face) &&
|
((each_font->GetFaceName() == wxT("")) || each_font->GetFaceName() == Face) &&
|
||||||
(encoding == wxFONTENCODING_DEFAULT || each_font->GetEncoding() == encoding))
|
(encoding == wxFONTENCODING_DEFAULT || each_font->GetEncoding() == encoding))
|
||||||
//#endif
|
|
||||||
return each_font;
|
return each_font;
|
||||||
}
|
}
|
||||||
wxFont *font = new wxFont (PointSize, FamilyOrFontId, Style, Weight, underline, Face, encoding);
|
wxFont *font = new wxFont (PointSize, FamilyOrFontId, Style, Weight, underline, Face, encoding);
|
||||||
|
|
||||||
font->SetVisible(TRUE);
|
font->SetVisible(TRUE);
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -894,11 +894,10 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
free(lpDIBh);
|
free(lpDIBh);
|
||||||
free(lpBits);
|
free(lpBits);
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
// check the wxBitmap object
|
// check the wxBitmap object
|
||||||
if( bitmap.GetHBITMAP() )
|
bitmap.GetBitmapData()->SetOk();
|
||||||
bitmap.SetOk( TRUE );
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
else
|
|
||||||
bitmap.SetOk( FALSE );
|
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
101
src/msw/app.cpp
101
src/msw/app.cpp
@@ -129,14 +129,10 @@ HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
|
|||||||
|
|
||||||
LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
|
LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
#if defined(__WIN95__) && !defined(__TWIN32__)
|
|
||||||
#define wxUSE_RICHEDIT 1
|
|
||||||
#else
|
|
||||||
#define wxUSE_RICHEDIT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
static HINSTANCE gs_hRichEdit = (HINSTANCE) NULL;
|
// the handle to richedit DLL and the version of the DLL loaded
|
||||||
|
static HINSTANCE gs_hRichEdit = (HINSTANCE)NULL;
|
||||||
|
static int gs_verRichEdit = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -193,15 +189,6 @@ bool wxApp::Initialize()
|
|||||||
#if defined(__WIN95__)
|
#if defined(__WIN95__)
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
#if wxUSE_RICHEDIT
|
|
||||||
gs_hRichEdit = LoadLibrary(wxT("RICHED32.DLL"));
|
|
||||||
|
|
||||||
if (gs_hRichEdit == (HINSTANCE) NULL)
|
|
||||||
{
|
|
||||||
wxLogError(_("Could not initialise Rich Edit DLL"));
|
|
||||||
}
|
|
||||||
#endif // wxUSE_RICHEDIT
|
|
||||||
|
|
||||||
#endif // __WIN95__
|
#endif // __WIN95__
|
||||||
|
|
||||||
#if wxUSE_OLE
|
#if wxUSE_OLE
|
||||||
@@ -517,15 +504,11 @@ void wxApp::CleanUp()
|
|||||||
|
|
||||||
wxSetKeyboardHook(FALSE);
|
wxSetKeyboardHook(FALSE);
|
||||||
|
|
||||||
#ifdef __WIN95__
|
|
||||||
|
|
||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
if (gs_hRichEdit != (HINSTANCE) NULL)
|
if (gs_hRichEdit != (HINSTANCE) NULL)
|
||||||
FreeLibrary(gs_hRichEdit);
|
FreeLibrary(gs_hRichEdit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_PENWINDOWS
|
#if wxUSE_PENWINDOWS
|
||||||
wxCleanUpPenWin();
|
wxCleanUpPenWin();
|
||||||
#endif
|
#endif
|
||||||
@@ -1098,21 +1081,77 @@ void wxApp::OnQueryEndSession(wxCloseEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxApp::GetComCtl32Version() const
|
#if wxUSE_RICHEDIT
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
bool wxApp::InitRichEdit(int version)
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( version >= 1 && version <= 3, FALSE,
|
||||||
|
_T("incorrect richedit control version requested") );
|
||||||
|
|
||||||
|
if ( version <= gs_verRichEdit )
|
||||||
|
{
|
||||||
|
// we've already got this or better
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( gs_hRichEdit )
|
||||||
|
{
|
||||||
|
::FreeLibrary(gs_hRichEdit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// always try load riched20.dll first - like this we won't have to reload
|
||||||
|
// it later if we're first asked for RE 1 and then for RE 2 or 3
|
||||||
|
wxString dllname = _T("riched20.dll");
|
||||||
|
gs_hRichEdit = ::LoadLibrary(dllname);
|
||||||
|
if ( !gs_hRichEdit && (version == 1) )
|
||||||
|
{
|
||||||
|
// fall back to RE 1
|
||||||
|
dllname = _T("riched32.dll");
|
||||||
|
gs_hRichEdit = ::LoadLibrary(dllname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !gs_hRichEdit )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Could not load Rich Edit DLL '%s'"), dllname.c_str());
|
||||||
|
|
||||||
|
gs_verRichEdit = -1;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gs_verRichEdit = version;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_RICHEDIT
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
int wxApp::GetComCtl32Version()
|
||||||
|
{
|
||||||
|
// TODO should use DllGetVersion() instead of this hack
|
||||||
|
|
||||||
|
// cache the result
|
||||||
|
static int s_verComCtl32 = -1; // MT-FIXME
|
||||||
|
|
||||||
|
if ( s_verComCtl32 == -1 )
|
||||||
|
{
|
||||||
|
s_verComCtl32 = 0;
|
||||||
|
|
||||||
// have we loaded COMCTL32 yet?
|
// have we loaded COMCTL32 yet?
|
||||||
HMODULE theModule = ::GetModuleHandle(wxT("COMCTL32"));
|
HMODULE theModule = ::GetModuleHandle(wxT("COMCTL32"));
|
||||||
int version = 0;
|
|
||||||
|
|
||||||
// if so, then we can check for the version
|
// if so, then we can check for the version
|
||||||
if (theModule)
|
if (theModule)
|
||||||
{
|
{
|
||||||
// InitCommonControlsEx is unique to 4.7 and later
|
// InitCommonControlsEx is unique to 4.7 and later
|
||||||
FARPROC theProc = ::GetProcAddress(theModule, "InitCommonControlsEx");
|
FARPROC theProc = ::GetProcAddress(theModule,
|
||||||
|
_T("InitCommonControlsEx"));
|
||||||
|
|
||||||
if (! theProc)
|
if ( !theProc )
|
||||||
{ // not found, must be 4.00
|
{ // not found, must be 4.00
|
||||||
version = 400;
|
s_verComCtl32 = 400;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1126,19 +1165,21 @@ int wxApp::GetComCtl32Version() const
|
|||||||
// InitializeFlatSB
|
// InitializeFlatSB
|
||||||
// UninitializeFlatSB
|
// UninitializeFlatSB
|
||||||
// we could check for any of these - I chose DllInstall
|
// we could check for any of these - I chose DllInstall
|
||||||
FARPROC theProc = ::GetProcAddress(theModule, "DllInstall");
|
FARPROC theProc = ::GetProcAddress(theModule, _T("DllInstall"));
|
||||||
if (! theProc)
|
if ( !theProc )
|
||||||
{
|
{
|
||||||
// not found, must be 4.70
|
// not found, must be 4.70
|
||||||
version = 470;
|
s_verComCtl32 = 470;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // found, must be 4.71
|
{ // found, must be 4.71
|
||||||
version = 471;
|
s_verComCtl32 = 471;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
}
|
||||||
|
|
||||||
|
return s_verComCtl32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExit()
|
void wxExit()
|
||||||
|
@@ -53,6 +53,8 @@
|
|||||||
#if !USE_SHARED_LIBRARIES
|
#if !USE_SHARED_LIBRARIES
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -65,35 +67,33 @@
|
|||||||
|
|
||||||
wxBitmapRefData::wxBitmapRefData()
|
wxBitmapRefData::wxBitmapRefData()
|
||||||
{
|
{
|
||||||
m_ok = FALSE;
|
|
||||||
m_width = 0;
|
|
||||||
m_height = 0;
|
|
||||||
m_depth = 0;
|
|
||||||
m_quality = 0;
|
m_quality = 0;
|
||||||
m_hBitmap = 0 ;
|
|
||||||
m_selectedInto = NULL;
|
m_selectedInto = NULL;
|
||||||
m_numColors = 0;
|
m_numColors = 0;
|
||||||
m_bitmapMask = NULL;
|
m_bitmapMask = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapRefData::~wxBitmapRefData()
|
void wxBitmapRefData::Free()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !m_selectedInto,
|
wxASSERT_MSG( !m_selectedInto,
|
||||||
wxT("deleting bitmap still selected into wxMemoryDC") );
|
wxT("deleting bitmap still selected into wxMemoryDC") );
|
||||||
|
|
||||||
if ( m_hBitmap)
|
if ( m_hBitmap)
|
||||||
DeleteObject((HBITMAP) m_hBitmap);
|
{
|
||||||
|
if ( !::DeleteObject((HBITMAP)m_hBitmap) )
|
||||||
|
{
|
||||||
|
wxLogLastError("DeleteObject(hbitmap)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_bitmapMask )
|
|
||||||
delete m_bitmapMask;
|
delete m_bitmapMask;
|
||||||
|
m_bitmapMask = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxBitmap
|
// wxBitmap creation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxList wxBitmap::sm_handlers;
|
|
||||||
|
|
||||||
// this function should be called from all wxBitmap ctors
|
// this function should be called from all wxBitmap ctors
|
||||||
void wxBitmap::Init()
|
void wxBitmap::Init()
|
||||||
{
|
{
|
||||||
@@ -103,6 +103,56 @@ void wxBitmap::Init()
|
|||||||
wxTheBitmapList->AddBitmap(this);
|
wxTheBitmapList->AddBitmap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
|
||||||
|
bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon)
|
||||||
|
{
|
||||||
|
// it may be either HICON or HCURSOR
|
||||||
|
HICON hicon = (HICON)icon.GetHandle();
|
||||||
|
|
||||||
|
ICONINFO iconInfo;
|
||||||
|
if ( !::GetIconInfo(hicon, &iconInfo) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetIconInfo");
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapRefData *refData = new wxBitmapRefData;
|
||||||
|
m_refData = refData;
|
||||||
|
|
||||||
|
refData->m_width = icon.GetWidth();
|
||||||
|
refData->m_height = icon.GetHeight();
|
||||||
|
refData->m_depth = wxDisplayDepth();
|
||||||
|
|
||||||
|
refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor;
|
||||||
|
refData->m_bitmapMask = new wxMask((WXHBITMAP)iconInfo.hbmMask);
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
refData->m_ok = TRUE;
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Win32
|
||||||
|
|
||||||
|
bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
|
||||||
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
|
if ( !cursor.Ok() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
#ifdef __WIN16__
|
||||||
|
wxFAIL_MSG( _T("don't know how to convert cursor to bitmap") );
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
#endif // Win16
|
||||||
|
|
||||||
|
return CopyFromIconOrCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
@@ -110,55 +160,41 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|||||||
if ( !icon.Ok() )
|
if ( !icon.Ok() )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
int width = icon.GetWidth(),
|
|
||||||
height = icon.GetHeight();
|
|
||||||
|
|
||||||
HICON hicon = (HICON) icon.GetHICON();
|
|
||||||
|
|
||||||
// GetIconInfo() doesn't exist under Win16 and I don't know any other way
|
// GetIconInfo() doesn't exist under Win16 and I don't know any other way
|
||||||
// to create a bitmap from icon there - but using this way we won't have
|
// to create a bitmap from icon there - but using this way we won't have
|
||||||
// the mask (FIXME)
|
// the mask (FIXME)
|
||||||
#ifdef __WIN16__
|
#ifdef __WIN16__
|
||||||
|
int width = icon.GetWidth(),
|
||||||
|
height = icon.GetHeight();
|
||||||
|
|
||||||
// copy the icon to the bitmap
|
// copy the icon to the bitmap
|
||||||
HDC hdcScreen = ::GetDC((HWND)NULL);
|
ScreenHDC hdcScreen;
|
||||||
HDC hdc = ::CreateCompatibleDC(hdcScreen);
|
HDC hdc = ::CreateCompatibleDC(hdcScreen);
|
||||||
HBITMAP hbitmap = ::CreateCompatibleBitmap(hdcScreen, width, height);
|
HBITMAP hbitmap = ::CreateCompatibleBitmap(hdcScreen, width, height);
|
||||||
HBITMAP hbmpOld = (HBITMAP)::SelectObject(hdc, hbitmap);
|
HBITMAP hbmpOld = (HBITMAP)::SelectObject(hdc, hbitmap);
|
||||||
|
|
||||||
::DrawIcon(hdc, 0, 0, hicon);
|
::DrawIcon(hdc, 0, 0, GetHiconOf(icon));
|
||||||
|
|
||||||
::SelectObject(hdc, hbmpOld);
|
::SelectObject(hdc, hbmpOld);
|
||||||
::DeleteDC(hdc);
|
::DeleteDC(hdc);
|
||||||
::ReleaseDC((HWND)NULL, hdcScreen);
|
|
||||||
#else // Win32
|
|
||||||
ICONINFO iconInfo;
|
|
||||||
if ( !GetIconInfo(hicon, &iconInfo) )
|
|
||||||
{
|
|
||||||
wxLogLastError("GetIconInfo");
|
|
||||||
|
|
||||||
return FALSE;
|
wxBitmapRefData *refData = new wxBitmapRefData;
|
||||||
}
|
m_refData = refData;
|
||||||
|
|
||||||
HBITMAP hbitmap = iconInfo.hbmColor;
|
refData->m_width = width;
|
||||||
|
refData->m_height = height;
|
||||||
|
refData->m_depth = wxDisplayDepth();
|
||||||
|
|
||||||
wxMask *mask = new wxMask;
|
refData->m_hBitmap = (WXHBITMAP)hbitmap;
|
||||||
mask->SetMaskBitmap((WXHBITMAP)iconInfo.hbmMask);
|
|
||||||
#endif // Win16/32
|
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
refData->m_ok = TRUE;
|
||||||
M_BITMAPDATA->m_width = width;
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
M_BITMAPDATA->m_height = height;
|
|
||||||
M_BITMAPDATA->m_depth = wxDisplayDepth();
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_hBitmap = (WXHBITMAP)hbitmap;
|
|
||||||
M_BITMAPDATA->m_ok = TRUE;
|
|
||||||
|
|
||||||
#ifndef __WIN16__
|
|
||||||
SetMask(mask);
|
|
||||||
#endif // !Win16
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#else // Win32
|
||||||
|
return CopyFromIconOrCursor(icon);
|
||||||
|
#endif // Win16/Win32
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::~wxBitmap()
|
wxBitmap::~wxBitmap()
|
||||||
@@ -167,50 +203,26 @@ wxBitmap::~wxBitmap()
|
|||||||
wxTheBitmapList->DeleteObject(this);
|
wxTheBitmapList->DeleteObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::FreeResource(bool WXUNUSED(force))
|
|
||||||
{
|
|
||||||
if ( !M_BITMAPDATA )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
wxASSERT_MSG( !M_BITMAPDATA->m_selectedInto,
|
|
||||||
wxT("freeing bitmap still selected into wxMemoryDC") );
|
|
||||||
|
|
||||||
if (M_BITMAPDATA->m_hBitmap)
|
|
||||||
{
|
|
||||||
DeleteObject((HBITMAP) M_BITMAPDATA->m_hBitmap);
|
|
||||||
}
|
|
||||||
M_BITMAPDATA->m_hBitmap = 0 ;
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (M_BITMAPDATA->m_bitmapPalette)
|
|
||||||
delete M_BITMAPDATA->m_bitmapPalette;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_bitmapPalette = NULL ;
|
|
||||||
*/
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
|
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
wxBitmapRefData *refData = new wxBitmapRefData;
|
||||||
|
m_refData = refData;
|
||||||
|
|
||||||
M_BITMAPDATA->m_width = the_width ;
|
refData->m_width = the_width;
|
||||||
M_BITMAPDATA->m_height = the_height ;
|
refData->m_height = the_height;
|
||||||
M_BITMAPDATA->m_depth = no_bits ;
|
refData->m_depth = no_bits;
|
||||||
M_BITMAPDATA->m_numColors = 0;
|
refData->m_numColors = 0;
|
||||||
|
refData->m_selectedInto = NULL;
|
||||||
|
|
||||||
M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(the_width, the_height, 1, no_bits, bits);
|
HBITMAP hbmp = ::CreateBitmap(the_width, the_height, 1, no_bits, bits);
|
||||||
|
if ( !hbmp )
|
||||||
|
{
|
||||||
|
wxLogLastError("CreateBitmap");
|
||||||
|
}
|
||||||
|
|
||||||
if (M_BITMAPDATA->m_hBitmap)
|
SetHBITMAP((WXHBITMAP)hbmp);
|
||||||
M_BITMAPDATA->m_ok = TRUE;
|
|
||||||
else
|
|
||||||
M_BITMAPDATA->m_ok = FALSE;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_selectedInto = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create from XPM data
|
// Create from XPM data
|
||||||
@@ -232,7 +244,7 @@ wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
|
|||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
(void) Create(data, type, width, height, depth);
|
(void)Create(data, type, width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap(const wxString& filename, long type)
|
wxBitmap::wxBitmap(const wxString& filename, long type)
|
||||||
@@ -248,221 +260,137 @@ bool wxBitmap::Create(int w, int h, int d)
|
|||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
m_refData = new wxBitmapRefData;
|
||||||
|
|
||||||
M_BITMAPDATA->m_width = w;
|
GetBitmapData()->m_width = w;
|
||||||
M_BITMAPDATA->m_height = h;
|
GetBitmapData()->m_height = h;
|
||||||
M_BITMAPDATA->m_depth = d;
|
GetBitmapData()->m_depth = d;
|
||||||
|
|
||||||
if (d > 0)
|
HBITMAP hbmp;
|
||||||
|
|
||||||
|
if ( d > 0 )
|
||||||
{
|
{
|
||||||
M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(w, h, 1, d, NULL);
|
hbmp = ::CreateBitmap(w, h, 1, d, NULL);
|
||||||
|
if ( !hbmp )
|
||||||
|
{
|
||||||
|
wxLogLastError("CreateBitmap");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HDC dc = GetDC((HWND) NULL);
|
ScreenHDC dc;
|
||||||
M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateCompatibleBitmap(dc, w, h);
|
hbmp = ::CreateCompatibleBitmap(dc, w, h);
|
||||||
ReleaseDC((HWND) NULL, dc);
|
if ( !hbmp )
|
||||||
M_BITMAPDATA->m_depth = wxDisplayDepth();
|
{
|
||||||
|
wxLogLastError("CreateCompatibleBitmap");
|
||||||
}
|
}
|
||||||
if (M_BITMAPDATA->m_hBitmap)
|
|
||||||
M_BITMAPDATA->m_ok = TRUE;
|
GetBitmapData()->m_depth = wxDisplayDepth();
|
||||||
else
|
}
|
||||||
M_BITMAPDATA->m_ok = FALSE;
|
|
||||||
return M_BITMAPDATA->m_ok;
|
SetHBITMAP((WXHBITMAP)hbmp);
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
GetBitmapData()->m_ok = hbmp != 0;
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
|
wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
|
||||||
|
|
||||||
|
if ( handler )
|
||||||
|
{
|
||||||
m_refData = new wxBitmapRefData;
|
m_refData = new wxBitmapRefData;
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
return handler->LoadFile(this, filename, type, -1, -1);
|
||||||
|
}
|
||||||
#if 0
|
else
|
||||||
if ( handler == NULL )
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
if ( handler == NULL ) {
|
|
||||||
wxImage image;
|
|
||||||
if (!image.LoadFile( filename, type )) return FALSE;
|
|
||||||
if (image.Ok())
|
|
||||||
{
|
{
|
||||||
|
wxImage image;
|
||||||
|
if ( !image.LoadFile( filename, type ) || !image.Ok() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
*this = image.ConvertToBitmap();
|
*this = image.ConvertToBitmap();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return handler->LoadFile(this, filename, type, -1, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
|
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
if ( !handler )
|
||||||
|
{
|
||||||
if ( handler == NULL ) {
|
wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for "
|
||||||
wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
|
"type %d defined."), type);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_refData = new wxBitmapRefData;
|
||||||
|
|
||||||
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 = FindHandler(type);
|
wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ( handler == NULL )
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
if ( handler == NULL ) { // try wxImage
|
|
||||||
wxImage image( *this );
|
|
||||||
if (image.Ok()) return image.SaveFile( filename, type );
|
|
||||||
else return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
if ( handler )
|
||||||
|
{
|
||||||
return handler->SaveFile(this, filename, type, palette);
|
return handler->SaveFile(this, filename, type, palette);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME what about palette? shouldn't we use it?
|
||||||
|
wxImage image( *this );
|
||||||
|
if (!image.Ok())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return image.SaveFile( filename, type );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetWidth(int w)
|
// ----------------------------------------------------------------------------
|
||||||
{
|
// wxBitmap accessors
|
||||||
if (!M_BITMAPDATA)
|
// ----------------------------------------------------------------------------
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_width = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::SetHeight(int h)
|
|
||||||
{
|
|
||||||
if (!M_BITMAPDATA)
|
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_height = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::SetDepth(int d)
|
|
||||||
{
|
|
||||||
if (!M_BITMAPDATA)
|
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_depth = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::SetQuality(int q)
|
void wxBitmap::SetQuality(int q)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
EnsureHasData();
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_quality = q;
|
GetBitmapData()->m_quality = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
void wxBitmap::SetOk(bool isOk)
|
void wxBitmap::SetOk(bool isOk)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
EnsureHasData();
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_ok = isOk;
|
GetBitmapData()->m_ok = isOk;
|
||||||
}
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
void wxBitmap::SetPalette(const wxPalette& palette)
|
void wxBitmap::SetPalette(const wxPalette& palette)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
EnsureHasData();
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_bitmapPalette = palette ;
|
GetBitmapData()->m_bitmapPalette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetMask(wxMask *mask)
|
void wxBitmap::SetMask(wxMask *mask)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
EnsureHasData();
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_bitmapMask = mask ;
|
GetBitmapData()->m_bitmapMask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
|
|
||||||
{
|
|
||||||
if (!M_BITMAPDATA)
|
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_hBitmap = bmp;
|
|
||||||
M_BITMAPDATA->m_ok = bmp != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::AddHandler(wxBitmapHandler *handler)
|
|
||||||
{
|
|
||||||
sm_handlers.Append(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::InsertHandler(wxBitmapHandler *handler)
|
|
||||||
{
|
|
||||||
sm_handlers.Insert(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxBitmap::RemoveHandler(const wxString& name)
|
|
||||||
{
|
|
||||||
wxBitmapHandler *handler = FindHandler(name);
|
|
||||||
if ( handler )
|
|
||||||
{
|
|
||||||
sm_handlers.DeleteObject(handler);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmapHandler *wxBitmap::FindHandler(const wxString& name)
|
|
||||||
{
|
|
||||||
wxNode *node = sm_handlers.First();
|
|
||||||
while ( node )
|
|
||||||
{
|
|
||||||
wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
|
|
||||||
if ( (handler->GetName().Cmp(name) == 0) )
|
|
||||||
return handler;
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmapHandler *wxBitmap::FindHandler(const wxString& extension, long bitmapType)
|
|
||||||
{
|
|
||||||
wxNode *node = sm_handlers.First();
|
|
||||||
while ( node )
|
|
||||||
{
|
|
||||||
wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
|
|
||||||
if ( (handler->GetExtension().Cmp(extension) == 0) &&
|
|
||||||
(bitmapType == -1 || (handler->GetType() == bitmapType)) )
|
|
||||||
return handler;
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmapHandler *wxBitmap::FindHandler(long bitmapType)
|
|
||||||
{
|
|
||||||
wxNode *node = sm_handlers.First();
|
|
||||||
while ( node )
|
|
||||||
{
|
|
||||||
wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
|
|
||||||
if (handler->GetType() == bitmapType)
|
|
||||||
return handler;
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// New Create/FreeDIB functions since ones in dibutils.cpp are confusing
|
|
||||||
static long createDIB(long xSize, long ySize, long bitsPerPixel,
|
|
||||||
HPALETTE hPal, LPBITMAPINFO* lpDIBHeader);
|
|
||||||
static long freeDIB(LPBITMAPINFO lpDIBHeader);
|
|
||||||
|
|
||||||
// Creates a bitmap that matches the device context, from
|
// Creates a bitmap that matches the device context, from
|
||||||
// an arbitray bitmap. At present, the original bitmap must have an
|
// an arbitray bitmap. At present, the original bitmap must have an
|
||||||
// associated palette. TODO: use a default palette if no palette exists.
|
// associated palette. TODO: use a default palette if no palette exists.
|
||||||
@@ -475,21 +403,12 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const
|
|||||||
LPBITMAPINFO lpDib;
|
LPBITMAPINFO lpDib;
|
||||||
void *lpBits = (void*) NULL;
|
void *lpBits = (void*) NULL;
|
||||||
|
|
||||||
/*
|
if( GetPalette() && GetPalette()->Ok() )
|
||||||
wxASSERT( this->GetPalette() && this->GetPalette()->Ok() && (this->GetPalette()->GetHPALETTE() != 0) );
|
|
||||||
|
|
||||||
tmpBitmap.SetPalette(this->GetPalette());
|
|
||||||
memDC.SelectObject(tmpBitmap);
|
|
||||||
memDC.SetPalette(this->GetPalette());
|
|
||||||
|
|
||||||
hPal = (HPALETTE) this->GetPalette()->GetHPALETTE();
|
|
||||||
*/
|
|
||||||
if( this->GetPalette() && this->GetPalette()->Ok() && (this->GetPalette()->GetHPALETTE() != 0) )
|
|
||||||
{
|
{
|
||||||
tmpBitmap.SetPalette(* this->GetPalette());
|
tmpBitmap.SetPalette(*GetPalette());
|
||||||
memDC.SelectObject(tmpBitmap);
|
memDC.SelectObject(tmpBitmap);
|
||||||
memDC.SetPalette(* this->GetPalette());
|
memDC.SetPalette(*GetPalette());
|
||||||
hPal = (HPALETTE) this->GetPalette()->GetHPALETTE();
|
hPal = (HPALETTE)GetPalette()->GetHPALETTE();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -501,25 +420,32 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const
|
|||||||
memDC.SetPalette( palette );
|
memDC.SetPalette( palette );
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the height negative because in a DIB the order of the lines is reversed
|
// set the height negative because in a DIB the order of the lines is
|
||||||
createDIB(this->GetWidth(), -this->GetHeight(), this->GetDepth(), hPal, &lpDib);
|
// reversed
|
||||||
|
if ( !wxCreateDIB(GetWidth(), -GetHeight(), GetDepth(), hPal, &lpDib) )
|
||||||
|
{
|
||||||
|
return wxNullBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
lpBits = malloc(lpDib->bmiHeader.biSizeImage);
|
lpBits = malloc(lpDib->bmiHeader.biSizeImage);
|
||||||
|
|
||||||
::GetBitmapBits((HBITMAP)GetHBITMAP(), lpDib->bmiHeader.biSizeImage, lpBits);
|
::GetBitmapBits(GetHbitmap(), lpDib->bmiHeader.biSizeImage, lpBits);
|
||||||
|
|
||||||
::SetDIBitsToDevice((HDC) memDC.GetHDC(), 0, 0, this->GetWidth(), this->GetHeight(),
|
::SetDIBitsToDevice(GetHdcOf(memDC), 0, 0,
|
||||||
0, 0, 0, this->GetHeight(), lpBits, lpDib, DIB_RGB_COLORS);
|
GetWidth(), GetHeight(),
|
||||||
|
0, 0, 0, GetHeight(),
|
||||||
|
lpBits, lpDib, DIB_RGB_COLORS);
|
||||||
|
|
||||||
free(lpBits);
|
free(lpBits);
|
||||||
|
|
||||||
freeDIB(lpDib);
|
wxFreeDIB(lpDib);
|
||||||
return (tmpBitmap);
|
|
||||||
|
return tmpBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* wxMask
|
// wxMask
|
||||||
*/
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxMask::wxMask()
|
wxMask::wxMask()
|
||||||
{
|
{
|
||||||
@@ -657,160 +583,71 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* wxBitmapHandler
|
// wxBitmapHandler
|
||||||
*/
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
|
bool wxBitmapHandler::Create(wxGDIImage *image,
|
||||||
|
void *data,
|
||||||
|
long flags,
|
||||||
|
int width, int height, int depth)
|
||||||
|
{
|
||||||
|
wxBitmap *bitmap = wxDynamicCast(image, wxBitmap);
|
||||||
|
|
||||||
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth))
|
return bitmap ? Create(bitmap, data, width, height, depth) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapHandler::Load(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
wxBitmap *bitmap = wxDynamicCast(image, wxBitmap);
|
||||||
|
|
||||||
|
return bitmap ? LoadFile(bitmap, name, flags, width, height) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapHandler::Save(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
int type)
|
||||||
|
{
|
||||||
|
wxBitmap *bitmap = wxDynamicCast(image, wxBitmap);
|
||||||
|
|
||||||
|
return bitmap ? SaveFile(bitmap, name, type) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
|
||||||
|
void *WXUNUSED(data),
|
||||||
|
long WXUNUSED(type),
|
||||||
|
int WXUNUSED(width),
|
||||||
|
int WXUNUSED(height),
|
||||||
|
int WXUNUSED(depth))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), long WXUNUSED(type),
|
bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap),
|
||||||
int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
|
const wxString& WXUNUSED(name),
|
||||||
|
long WXUNUSED(type),
|
||||||
|
int WXUNUSED(desiredWidth),
|
||||||
|
int WXUNUSED(desiredHeight))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type), const wxPalette *WXUNUSED(palette))
|
bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap),
|
||||||
|
const wxString& WXUNUSED(name),
|
||||||
|
int WXUNUSED(type),
|
||||||
|
const wxPalette *WXUNUSED(palette))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* Standard handlers
|
// DIB functions
|
||||||
*/
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler
|
bool wxCreateDIB(long xSize, long ySize, long bitsPerPixel,
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
|
|
||||||
public:
|
|
||||||
inline wxBMPResourceHandler()
|
|
||||||
{
|
|
||||||
m_name = "Windows bitmap resource";
|
|
||||||
m_extension = "";
|
|
||||||
m_type = wxBITMAP_TYPE_BMP_RESOURCE;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth, int desiredHeight);
|
|
||||||
};
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
|
|
||||||
|
|
||||||
bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags),
|
|
||||||
int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
|
|
||||||
{
|
|
||||||
// TODO: load colourmap.
|
|
||||||
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name);
|
|
||||||
if (M_BITMAPHANDLERDATA->m_hBitmap)
|
|
||||||
{
|
|
||||||
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
|
||||||
BITMAP bm;
|
|
||||||
GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm);
|
|
||||||
M_BITMAPHANDLERDATA->m_width = bm.bmWidth;
|
|
||||||
M_BITMAPHANDLERDATA->m_height = bm.bmHeight;
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = bm.bmBitsPixel;
|
|
||||||
|
|
||||||
if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// it's probably not found
|
|
||||||
wxLogError(wxT("Can't load bitmap '%s' from resources! Check .rc file."), name.c_str());
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBMPFileHandler: public wxBitmapHandler
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBMPFileHandler)
|
|
||||||
public:
|
|
||||||
inline wxBMPFileHandler()
|
|
||||||
{
|
|
||||||
m_name = "Windows bitmap file";
|
|
||||||
m_extension = "bmp";
|
|
||||||
m_type = wxBITMAP_TYPE_BMP;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth, int desiredHeight);
|
|
||||||
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
|
|
||||||
};
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler)
|
|
||||||
|
|
||||||
bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags),
|
|
||||||
int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
|
|
||||||
{
|
|
||||||
#if wxUSE_IMAGE_LOADING_IN_MSW
|
|
||||||
wxPalette *palette = NULL;
|
|
||||||
bool success = FALSE;
|
|
||||||
/*
|
|
||||||
if (type & wxBITMAP_DISCARD_COLOURMAP)
|
|
||||||
success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
|
|
||||||
if (!success && palette)
|
|
||||||
{
|
|
||||||
delete palette;
|
|
||||||
palette = NULL;
|
|
||||||
}
|
|
||||||
if (palette)
|
|
||||||
{
|
|
||||||
M_BITMAPHANDLERDATA->m_bitmapPalette = *palette;
|
|
||||||
delete palette;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int WXUNUSED(type), const wxPalette *pal)
|
|
||||||
{
|
|
||||||
#if wxUSE_IMAGE_LOADING_IN_MSW
|
|
||||||
wxPalette *actualPalette = (wxPalette *)pal;
|
|
||||||
if (!actualPalette && (!M_BITMAPHANDLERDATA->m_bitmapPalette.IsNull()))
|
|
||||||
actualPalette = & (M_BITMAPHANDLERDATA->m_bitmapPalette);
|
|
||||||
return (wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0);
|
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::CleanUpHandlers()
|
|
||||||
{
|
|
||||||
wxNode *node = sm_handlers.First();
|
|
||||||
while ( node )
|
|
||||||
{
|
|
||||||
wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
|
|
||||||
wxNode *next = node->Next();
|
|
||||||
delete handler;
|
|
||||||
delete node;
|
|
||||||
node = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmap::InitStandardHandlers()
|
|
||||||
{
|
|
||||||
AddHandler(new wxBMPResourceHandler);
|
|
||||||
AddHandler(new wxBMPFileHandler);
|
|
||||||
|
|
||||||
// Not added by default: include xpmhand.h in your app
|
|
||||||
// and call these in your wxApp::OnInit.
|
|
||||||
// AddHandler(new wxXPMFileHandler);
|
|
||||||
// AddHandler(new wxXPMDataHandler);
|
|
||||||
|
|
||||||
AddHandler(new wxICOResourceHandler);
|
|
||||||
AddHandler(new wxICOFileHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
static long createDIB(long xSize, long ySize, long bitsPerPixel,
|
|
||||||
HPALETTE hPal, LPBITMAPINFO* lpDIBHeader)
|
HPALETTE hPal, LPBITMAPINFO* lpDIBHeader)
|
||||||
{
|
{
|
||||||
unsigned long i, headerSize;
|
unsigned long i, headerSize;
|
||||||
@@ -825,10 +662,8 @@ static long createDIB(long xSize, long ySize, long bitsPerPixel,
|
|||||||
|
|
||||||
GetPaletteEntries(hPal, 0, 256, lpPe);
|
GetPaletteEntries(hPal, 0, 256, lpPe);
|
||||||
|
|
||||||
|
|
||||||
memset(lpDIBheader, 0x00, sizeof(BITMAPINFOHEADER));
|
memset(lpDIBheader, 0x00, sizeof(BITMAPINFOHEADER));
|
||||||
|
|
||||||
|
|
||||||
// Fill in the static parts of the DIB header
|
// Fill in the static parts of the DIB header
|
||||||
lpDIBheader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
lpDIBheader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
lpDIBheader->bmiHeader.biWidth = xSize;
|
lpDIBheader->bmiHeader.biWidth = xSize;
|
||||||
@@ -838,8 +673,7 @@ static long createDIB(long xSize, long ySize, long bitsPerPixel,
|
|||||||
// this value must be 1, 4, 8 or 24 so PixelDepth can only be
|
// this value must be 1, 4, 8 or 24 so PixelDepth can only be
|
||||||
lpDIBheader->bmiHeader.biBitCount = (WORD)(bitsPerPixel);
|
lpDIBheader->bmiHeader.biBitCount = (WORD)(bitsPerPixel);
|
||||||
lpDIBheader->bmiHeader.biCompression = BI_RGB;
|
lpDIBheader->bmiHeader.biCompression = BI_RGB;
|
||||||
lpDIBheader->bmiHeader.biSizeImage = xSize * abs(ySize) * bitsPerPixel >>
|
lpDIBheader->bmiHeader.biSizeImage = xSize * abs(ySize) * bitsPerPixel >> 3;
|
||||||
3;
|
|
||||||
lpDIBheader->bmiHeader.biClrUsed = 256;
|
lpDIBheader->bmiHeader.biClrUsed = 256;
|
||||||
|
|
||||||
|
|
||||||
@@ -853,21 +687,12 @@ static long createDIB(long xSize, long ySize, long bitsPerPixel,
|
|||||||
|
|
||||||
*lpDIBHeader = lpDIBheader;
|
*lpDIBHeader = lpDIBheader;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
return (0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFreeDIB(LPBITMAPINFO lpDIBHeader)
|
||||||
|
|
||||||
static long freeDIB(LPBITMAPINFO lpDIBHeader)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (lpDIBHeader != NULL) {
|
|
||||||
free(lpDIBHeader);
|
free(lpDIBHeader);
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -319,7 +319,9 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
|||||||
wxBM->SetWidth(bm.bmWidth);
|
wxBM->SetWidth(bm.bmWidth);
|
||||||
wxBM->SetHeight(bm.bmHeight);
|
wxBM->SetHeight(bm.bmHeight);
|
||||||
wxBM->SetDepth(bm.bmPlanes);
|
wxBM->SetDepth(bm.bmPlanes);
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
wxBM->SetOk(TRUE);
|
wxBM->SetOk(TRUE);
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
retval = wxBM;
|
retval = wxBM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user