]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/bitmap.h
don't try to refresh the menu bar before showing it, fixes crash on startup with...
[wxWidgets.git] / include / wx / bitmap.h
... / ...
CommitLineData
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
12#ifndef _WX_BITMAP_H_BASE_
13#define _WX_BITMAP_H_BASE_
14
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/gdiobj.h"
27#include "wx/gdicmn.h" // for wxBitmapType
28
29class WXDLLEXPORT wxBitmap;
30class WXDLLEXPORT wxBitmapHandler;
31class WXDLLEXPORT wxImage;
32class WXDLLEXPORT wxMask;
33class WXDLLEXPORT wxPalette;
34
35#if defined(__WXMGL__) || defined(__WXMAC__)
36// Only used by some ports
37// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
38
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()
48 {
49 m_type = wxBITMAP_TYPE_INVALID;
50 }
51
52 virtual ~wxBitmapHandlerBase() { }
53
54 virtual bool Create(wxBitmap *bitmap, void *data, long flags,
55 int width, int height, int depth = 1) = 0;
56 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
57 int desiredWidth, int desiredHeight) = 0;
58 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
59 int type, const wxPalette *palette = NULL) = 0;
60
61 void SetName(const wxString& name) { m_name = name; }
62 void SetExtension(const wxString& ext) { m_extension = ext; }
63 void SetType(wxBitmapType type) { m_type = type; }
64 wxString GetName() const { return m_name; }
65 wxString GetExtension() const { return m_extension; }
66 wxBitmapType GetType() const { return m_type; }
67
68protected:
69 wxString m_name;
70 wxString m_extension;
71 wxBitmapType m_type;
72
73 DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
74};
75
76class WXDLLEXPORT wxBitmapBase : public wxGDIObject
77{
78public:
79 wxBitmapBase() : wxGDIObject() {}
80 virtual ~wxBitmapBase() {}
81
82 /*
83 Derived class must implement these:
84
85 wxBitmap();
86 wxBitmap(int width, int height, int depth = -1);
87 wxBitmap(const char bits[], int width, int height, int depth = 1);
88 wxBitmap(const char **bits);
89 wxBitmap(char **bits);
90 wxBitmap(const wxBitmap& bmp);
91 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
92 wxBitmap(const wxImage& image, int depth = -1);
93 wxBitmap& operator = (const wxBitmap& bmp);
94 bool operator == (const wxBitmap& bmp) const;
95 bool operator != (const wxBitmap& bmp) const;
96
97 bool Create(int width, int height, int depth = -1);
98
99 static void InitStandardHandlers();
100 */
101
102 virtual bool Ok() const = 0;
103
104 virtual int GetHeight() const = 0;
105 virtual int GetWidth() const = 0;
106 virtual int GetDepth() const = 0;
107
108 virtual wxImage ConvertToImage() const = 0;
109
110 virtual wxMask *GetMask() const = 0;
111 virtual void SetMask(wxMask *mask) = 0;
112
113 virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
114
115 virtual bool SaveFile(const wxString &name, wxBitmapType type,
116 const wxPalette *palette = (wxPalette *)NULL) const = 0;
117 virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
118
119 virtual wxPalette *GetPalette() const = 0;
120 virtual void SetPalette(const wxPalette& palette) = 0;
121
122#if WXWIN_COMPATIBILITY
123 wxPalette *GetColourMap() const { return GetPalette(); }
124 void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
125#endif // WXWIN_COMPATIBILITY
126
127 // copies the contents and mask of the given (colour) icon to the bitmap
128 virtual bool CopyFromIcon(const wxIcon& icon) = 0;
129
130 // implementation:
131 virtual void SetHeight(int height) = 0;
132 virtual void SetWidth(int width) = 0;
133 virtual void SetDepth(int depth) = 0;
134
135 // Format handling
136 static inline wxList& GetHandlers() { return sm_handlers; }
137 static void AddHandler(wxBitmapHandlerBase *handler);
138 static void InsertHandler(wxBitmapHandlerBase *handler);
139 static bool RemoveHandler(const wxString& name);
140 static wxBitmapHandler *FindHandler(const wxString& name);
141 static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
142 static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
143
144 //static void InitStandardHandlers();
145 // (wxBitmap must implement this one)
146
147 static void CleanUpHandlers();
148
149protected:
150 static wxList sm_handlers;
151
152 DECLARE_ABSTRACT_CLASS(wxBitmapBase)
153};
154#endif
155
156#if defined(__WXMSW__)
157#include "wx/msw/bitmap.h"
158#elif defined(__WXMOTIF__)
159#include "wx/motif/bitmap.h"
160#elif defined(__WXGTK__)
161#include "wx/gtk/bitmap.h"
162#elif defined(__WXMGL__)
163#include "wx/mgl/bitmap.h"
164#elif defined(__WXQT__)
165#include "wx/qt/bitmap.h"
166#elif defined(__WXMAC__)
167#include "wx/mac/bitmap.h"
168#elif defined(__WXPM__)
169#include "wx/os2/bitmap.h"
170#elif defined(__WXSTUBS__)
171#include "wx/stubs/bitmap.h"
172#endif
173
174#endif
175 // _WX_BITMAP_H_BASE_