]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mgl/bitmap.h
Made wxGTK's wxEventLoop::IsRunning a little more consistent with
[wxWidgets.git] / include / wx / mgl / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: bitmap.h
3 // Author: Vaclav Slavik
4 // RCS-ID: $Id$
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 #ifndef __WX_BITMAP_H__
11 #define __WX_BITMAP_H__
12
13 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
14 #pragma interface "bitmap.h"
15 #endif
16
17 #include "wx/defs.h"
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/palette.h"
21 #include "wx/gdiobj.h"
22
23
24 //-----------------------------------------------------------------------------
25 // classes
26 //-----------------------------------------------------------------------------
27
28 class WXDLLEXPORT wxMask;
29 class WXDLLEXPORT wxBitmap;
30 class WXDLLEXPORT wxImage;
31 class WXDLLEXPORT wxDC;
32 class WXDLLEXPORT wxMemoryDC;
33
34 class MGLDevCtx;
35 struct bitmap_t;
36
37 //-----------------------------------------------------------------------------
38 // wxMask
39 //-----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxMask: public wxObject
42 {
43 public:
44 wxMask();
45 wxMask(const wxBitmap& bitmap, const wxColour& colour);
46 wxMask(const wxBitmap& bitmap, int paletteIndex);
47 wxMask(const wxBitmap& bitmap);
48 ~wxMask();
49
50 bool Create(const wxBitmap& bitmap, const wxColour& colour);
51 bool Create(const wxBitmap& bitmap, int paletteIndex);
52 bool Create(const wxBitmap& bitmap);
53
54 // implementation
55 wxBitmap *m_bitmap;
56
57 wxBitmap *GetBitmap() const { return m_bitmap; }
58
59 private:
60 DECLARE_DYNAMIC_CLASS(wxMask)
61 };
62
63 //-----------------------------------------------------------------------------
64 // wxBitmap
65 //-----------------------------------------------------------------------------
66
67 class WXDLLEXPORT wxBitmapHandler : public wxBitmapHandlerBase
68 {
69 public:
70 wxBitmapHandler() : wxBitmapHandlerBase() {}
71 private:
72 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
73 };
74
75 class WXDLLEXPORT wxBitmap: public wxBitmapBase
76 {
77 public:
78 wxBitmap() {}
79 wxBitmap(int width, int height, int depth = -1);
80 wxBitmap(const char bits[], int width, int height, int depth = 1);
81 wxBitmap(const char **bits) { CreateFromXpm(bits); }
82 wxBitmap(char **bits) { CreateFromXpm((const char **)bits); }
83 wxBitmap(const wxBitmap& bmp);
84 wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
85 wxBitmap(const wxImage& image, int depth = -1);
86 ~wxBitmap() {}
87 wxBitmap& operator = (const wxBitmap& bmp);
88 bool operator == (const wxBitmap& bmp) const;
89 bool operator != (const wxBitmap& bmp) const;
90 bool Ok() const;
91
92 bool Create(int width, int height, int depth = -1);
93
94 virtual int GetHeight() const;
95 virtual int GetWidth() const;
96 virtual int GetDepth() const;
97
98 virtual wxImage ConvertToImage() const;
99
100 virtual wxMask *GetMask() const;
101 virtual void SetMask(wxMask *mask);
102
103 virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
104
105 virtual bool SaveFile(const wxString &name, wxBitmapType type, const wxPalette *palette = (wxPalette *) NULL) const;
106 virtual bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
107
108 virtual wxPalette *GetPalette() const;
109 virtual void SetPalette(const wxPalette& palette);
110
111 // copies the contents and mask of the given (colour) icon to the bitmap
112 virtual bool CopyFromIcon(const wxIcon& icon);
113
114 static void InitStandardHandlers();
115
116 // implementation:
117 virtual void SetHeight(int height);
118 virtual void SetWidth(int width);
119 virtual void SetDepth(int depth);
120
121 // get underlying native representation:
122 bitmap_t *GetMGLbitmap_t() const;
123
124 protected:
125 bool CreateFromXpm(const char **bits);
126
127 // creates temporary DC for access to bitmap's data:
128 MGLDevCtx *CreateTmpDC() const;
129 // sets fg & bg colours for 1bit bitmaps:
130 void SetMonoPalette(const wxColour& fg, const wxColour& bg);
131
132 private:
133 DECLARE_DYNAMIC_CLASS(wxBitmap)
134
135 friend class wxDC;
136 friend class wxMemoryDC;
137 };
138
139 #endif // __WX_BITMAP_H__