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