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