]> git.saurik.com Git - wxWidgets.git/blame - include/wx/bitmap.h
Added wxUSE_NUMBERDLG to setup.h; added some files to VC++ project files;
[wxWidgets.git] / include / wx / bitmap.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/bitmap.h
3// Purpose: wxBitmap class interface
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 22.04.01
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_BITMAP_H_BASE_
13#define _WX_BITMAP_H_BASE_
c801d85f 14
1e6feb95
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#ifdef __GNUG__
20 #pragma interface "bitmapbase.h"
21#endif
22
23#include "wx/defs.h"
24#include "wx/object.h"
25#include "wx/string.h"
26#include "wx/palette.h"
27#include "wx/gdiobj.h"
28
29class WXDLLEXPORT wxImage;
30class WXDLLEXPORT wxMask;
31class WXDLLEXPORT wxBitmap;
32class WXDLLEXPORT wxBitmapHandler;
33
34// ----------------------------------------------------------------------------
35// wxBitmapHandler: class which knows how to create/load/save bitmaps in
36// different formats
37// ----------------------------------------------------------------------------
38
39class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
40{
41public:
42 wxBitmapHandlerBase()
43 {
44 m_type = wxBITMAP_TYPE_INVALID;
45 }
46
47 virtual ~wxBitmapHandlerBase() { }
48
49 virtual bool Create(wxBitmap *bitmap, void *data, long flags,
50 int width, int height, int depth = 1) = 0;
51 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
52 int desiredWidth, int desiredHeight) = 0;
53 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
54 int type, const wxPalette *palette = NULL) = 0;
55
56 void SetName(const wxString& name) { m_name = name; }
57 void SetExtension(const wxString& ext) { m_extension = ext; }
58 void SetType(wxBitmapType type) { m_type = type; }
59 wxString GetName() const { return m_name; }
60 wxString GetExtension() const { return m_extension; }
61 wxBitmapType GetType() const { return m_type; }
62
63protected:
64 wxString m_name;
65 wxString m_extension;
66 wxBitmapType m_type;
67
68 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
69};
70
71
72
73class WXDLLEXPORT wxBitmapBase : public wxGDIObject
74{
75public:
76 wxBitmapBase() : wxGDIObject() {}
77 virtual ~wxBitmapBase() {}
78
79 /*
80 Derived class must implement these:
81
82 wxBitmap();
83 wxBitmap(int width, int height, int depth = -1);
84 wxBitmap(const char bits[], int width, int height, int depth = 1);
85 wxBitmap(const char **bits);
86 wxBitmap(char **bits);
87 wxBitmap(const wxBitmap& bmp);
88 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
89 wxBitmap(const wxImage& image, int depth = -1);
90 wxBitmap& operator = (const wxBitmap& bmp);
91 bool operator == (const wxBitmap& bmp) const;
92 bool operator != (const wxBitmap& bmp) const;
93
94 bool Create(int width, int height, int depth = -1);
95
96 static void InitStandardHandlers();
97 */
98
99 virtual bool Ok() const = 0;
100
101 virtual int GetHeight() const = 0;
102 virtual int GetWidth() const = 0;
103 virtual int GetDepth() const = 0;
104
105 virtual wxImage ConvertToImage() const = 0;
106
107 virtual wxMask *GetMask() const = 0;
108 virtual void SetMask(wxMask *mask) = 0;
109
110 virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
111
112 virtual bool SaveFile(const wxString &name, wxBitmapType type,
113 const wxPalette *palette = (wxPalette *)NULL) const = 0;
114 virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
115
116 virtual wxPalette *GetPalette() const = 0;
117 virtual void SetPalette(const wxPalette& palette) = 0;
118
119#if WXWIN_COMPATIBILITY
120 wxPalette *GetColourMap() const { return GetPalette(); }
121 void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
122#endif // WXWIN_COMPATIBILITY
123
124 // copies the contents and mask of the given (colour) icon to the bitmap
125 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
126
127 // implementation:
128 virtual void SetHeight(int height) = 0;
129 virtual void SetWidth(int width) = 0;
130 virtual void SetDepth(int depth) = 0;
131
132 // Format handling
133 static inline wxList& GetHandlers() { return sm_handlers; }
134 static void AddHandler(wxBitmapHandlerBase *handler);
135 static void InsertHandler(wxBitmapHandlerBase *handler);
136 static bool RemoveHandler(const wxString& name);
137 static wxBitmapHandler *FindHandler(const wxString& name);
138 static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
139 static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
140
141 //static void InitStandardHandlers();
142 // (wxBitmap must implement this one)
143
144 static void CleanUpHandlers();
145
146protected:
147 static wxList sm_handlers;
148
149 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
150};
151
152
153
2049ba38 154#if defined(__WXMSW__)
c801d85f 155#include "wx/msw/bitmap.h"
2049ba38 156#elif defined(__WXMOTIF__)
34138703 157#include "wx/motif/bitmap.h"
2049ba38 158#elif defined(__WXGTK__)
c801d85f 159#include "wx/gtk/bitmap.h"
1e6feb95
VZ
160#elif defined(__WXMGL__)
161#include "wx/mgl/bitmap.h"
b4e76e0d
RR
162#elif defined(__WXQT__)
163#include "wx/qt/bitmap.h"
34138703
JS
164#elif defined(__WXMAC__)
165#include "wx/mac/bitmap.h"
1777b9bb
DW
166#elif defined(__WXPM__)
167#include "wx/os2/bitmap.h"
34138703
JS
168#elif defined(__WXSTUBS__)
169#include "wx/stubs/bitmap.h"
c801d85f
KB
170#endif
171
172#endif
34138703 173 // _WX_BITMAP_H_BASE_