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