]>
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); | |
d3c7fc99 | 43 | virtual ~wxMask(); |
32b8ec41 VZ |
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); } | |
32b8ec41 VZ |
78 | wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE); |
79 | wxBitmap(const wxImage& image, int depth = -1); | |
d3c7fc99 | 80 | virtual ~wxBitmap() {} |
32b8ec41 VZ |
81 | bool operator == (const wxBitmap& bmp) const; |
82 | bool operator != (const wxBitmap& bmp) const; | |
83 | bool Ok() const; | |
84 | ||
85 | bool Create(int width, int height, int depth = -1); | |
86 | ||
87 | virtual int GetHeight() const; | |
88 | virtual int GetWidth() const; | |
89 | virtual int GetDepth() const; | |
90 | ||
91 | virtual wxImage ConvertToImage() const; | |
92 | ||
93 | virtual wxMask *GetMask() const; | |
94 | virtual void SetMask(wxMask *mask); | |
95 | ||
96 | virtual wxBitmap GetSubBitmap(const wxRect& rect) const; | |
97 | ||
98 | virtual bool SaveFile(const wxString &name, wxBitmapType type, const wxPalette *palette = (wxPalette *) NULL) const; | |
99 | virtual bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_RESOURCE); | |
100 | ||
101 | virtual wxPalette *GetPalette() const; | |
102 | virtual void SetPalette(const wxPalette& palette); | |
103 | ||
104 | // copies the contents and mask of the given (colour) icon to the bitmap | |
105 | virtual bool CopyFromIcon(const wxIcon& icon); | |
106 | ||
107 | static void InitStandardHandlers(); | |
108 | ||
109 | // implementation: | |
110 | virtual void SetHeight(int height); | |
111 | virtual void SetWidth(int width); | |
112 | virtual void SetDepth(int depth); | |
113 | ||
114 | // get underlying native representation: | |
115 | bitmap_t *GetMGLbitmap_t() const; | |
116 | ||
117 | protected: | |
118 | bool CreateFromXpm(const char **bits); | |
119 | ||
120 | // creates temporary DC for access to bitmap's data: | |
121 | MGLDevCtx *CreateTmpDC() const; | |
122 | // sets fg & bg colours for 1bit bitmaps: | |
123 | void SetMonoPalette(const wxColour& fg, const wxColour& bg); | |
124 | ||
125 | private: | |
126 | DECLARE_DYNAMIC_CLASS(wxBitmap) | |
127 | ||
128 | friend class wxDC; | |
129 | friend class wxMemoryDC; | |
130 | }; | |
131 | ||
132 | #endif // __WX_BITMAP_H__ |