2002-02-05 11:34:33 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bitmap.h
|
|
|
|
// Purpose: wxBitmap class
|
2002-02-13 03:38:54 -05:00
|
|
|
// Author: Julian Smart, Robert Roebling
|
2002-02-05 11:34:33 -05:00
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
2002-02-13 03:38:54 -05:00
|
|
|
// Copyright: (c) Julian Smart, Robert Roebling
|
2002-02-05 11:34:33 -05:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_BITMAP_H_
|
|
|
|
#define _WX_BITMAP_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "bitmap.h"
|
|
|
|
#endif
|
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
2002-02-05 11:34:33 -05:00
|
|
|
#include "wx/palette.h"
|
2002-02-13 03:38:54 -05:00
|
|
|
#include "wx/gdiobj.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxMask;
|
|
|
|
class wxBitmap;
|
|
|
|
class wxImage;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxMask
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxMask: public wxObject
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxMask();
|
2002-02-13 03:38:54 -05:00
|
|
|
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
|
|
|
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
|
|
|
wxMask( const wxBitmap& bitmap );
|
2002-02-05 11:34:33 -05:00
|
|
|
~wxMask();
|
2002-02-13 03:38:54 -05:00
|
|
|
|
|
|
|
bool Create( const wxBitmap& bitmap, const wxColour& colour );
|
|
|
|
bool Create( const wxBitmap& bitmap, int paletteIndex );
|
|
|
|
bool Create( const wxBitmap& bitmap );
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
// implementation
|
|
|
|
WXPixmap GetBitmap() const { return m_bitmap; }
|
|
|
|
void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; }
|
|
|
|
|
|
|
|
WXDisplay *GetDisplay() const { return m_display; }
|
|
|
|
void SetDisplay( WXDisplay *display ) { m_display = display; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
WXPixmap m_bitmap;
|
|
|
|
WXDisplay *m_display;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
2002-02-05 11:34:33 -05:00
|
|
|
};
|
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxBitmap
|
|
|
|
//-----------------------------------------------------------------------------
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2003-04-05 07:11:05 -05:00
|
|
|
class WXDLLEXPORT wxBitmapHandler : public wxBitmapHandlerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxBitmapHandler() : wxBitmapHandlerBase() {}
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
|
|
|
};
|
|
|
|
|
|
|
|
class wxBitmap: public wxBitmapBase
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2002-02-13 03:38:54 -05:00
|
|
|
wxBitmap();
|
|
|
|
wxBitmap( int width, int height, int depth = -1 );
|
|
|
|
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
|
|
|
wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
|
|
|
|
wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
|
|
|
|
wxBitmap( const wxBitmap& bmp );
|
2003-04-05 07:11:05 -05:00
|
|
|
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
2002-02-13 03:38:54 -05:00
|
|
|
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
|
|
|
|
~wxBitmap();
|
|
|
|
wxBitmap& operator = ( const wxBitmap& bmp );
|
|
|
|
bool operator == ( const wxBitmap& bmp ) const;
|
|
|
|
bool operator != ( const wxBitmap& bmp ) const;
|
|
|
|
bool Ok() const;
|
|
|
|
|
2003-04-05 07:11:05 -05:00
|
|
|
static void InitStandardHandlers();
|
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
bool Create(int width, int height, int depth = -1);
|
2003-04-05 07:11:05 -05:00
|
|
|
bool Create(void* data, wxBitmapType type,
|
|
|
|
int width, int height, int depth = -1);
|
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
int GetHeight() const;
|
|
|
|
int GetWidth() const;
|
|
|
|
int GetDepth() const;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
wxImage ConvertToImage() const;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
|
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
wxMask *GetMask() const;
|
|
|
|
void SetMask( wxMask *mask );
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
2002-02-08 12:44:23 -05:00
|
|
|
|
2003-04-05 07:11:05 -05:00
|
|
|
bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = (wxPalette *) NULL ) const;
|
|
|
|
bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
|
2002-02-13 03:38:54 -05:00
|
|
|
|
|
|
|
wxPalette *GetPalette() const;
|
|
|
|
wxPalette *GetColourMap() const
|
|
|
|
{ return GetPalette(); };
|
2003-04-05 07:11:05 -05:00
|
|
|
virtual void SetPalette(const wxPalette& palette);
|
2002-02-13 03:38:54 -05:00
|
|
|
|
|
|
|
// implementation
|
|
|
|
// --------------
|
|
|
|
|
|
|
|
void SetHeight( int height );
|
|
|
|
void SetWidth( int width );
|
|
|
|
void SetDepth( int depth );
|
|
|
|
void SetPixmap( WXPixmap pixmap );
|
|
|
|
void SetBitmap( WXPixmap bitmap );
|
|
|
|
|
|
|
|
WXPixmap GetPixmap() const;
|
|
|
|
WXPixmap GetBitmap() const;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
WXDisplay *GetDisplay() const;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
protected:
|
2002-02-13 03:38:54 -05:00
|
|
|
bool CreateFromXpm(const char **bits);
|
2002-02-20 18:19:40 -05:00
|
|
|
bool CreateFromImage(const wxImage& image, int depth = -1);
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-13 03:38:54 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
|
|
|
};
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_BITMAP_H_
|