]> git.saurik.com Git - wxWidgets.git/blob - include/wx/qt/bitmap.h
resizeable dialogs support
[wxWidgets.git] / include / wx / qt / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: bitmap.h
3 // Purpose: wxBitmap class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BITMAP_H_
13 #define _WX_BITMAP_H_
14
15 #ifdef __GNUG__
16 #pragma interface "bitmap.h"
17 #endif
18
19 #include "wx/gdiobj.h"
20 #include "wx/gdicmn.h"
21 #include "wx/palette.h"
22
23 // Bitmap
24 class WXDLLEXPORT wxDC;
25 class WXDLLEXPORT wxControl;
26 class WXDLLEXPORT wxBitmap;
27 class WXDLLEXPORT wxBitmapHandler;
28 class WXDLLEXPORT wxIcon;
29 class WXDLLEXPORT wxCursor;
30
31 // A mask is a mono bitmap used for drawing bitmaps
32 // transparently.
33 class WXDLLEXPORT wxMask: public wxObject
34 {
35 DECLARE_DYNAMIC_CLASS(wxMask)
36
37 public:
38 wxMask();
39
40 // Construct a mask from a bitmap and a colour indicating
41 // the transparent area
42 wxMask(const wxBitmap& bitmap, const wxColour& colour);
43
44 // Construct a mask from a bitmap and a palette index indicating
45 // the transparent area
46 wxMask(const wxBitmap& bitmap, int paletteIndex);
47
48 // Construct a mask from a mono bitmap (copies the bitmap).
49 wxMask(const wxBitmap& bitmap);
50
51 ~wxMask();
52
53 bool Create(const wxBitmap& bitmap, const wxColour& colour);
54 bool Create(const wxBitmap& bitmap, int paletteIndex);
55 bool Create(const wxBitmap& bitmap);
56
57 /* TODO: platform-specific data access
58 // Implementation
59 inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
60 inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
61 protected:
62 WXHBITMAP m_maskBitmap;
63 */
64 };
65
66 class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
67 {
68 friend class WXDLLEXPORT wxBitmap;
69 friend class WXDLLEXPORT wxIcon;
70 friend class WXDLLEXPORT wxCursor;
71 public:
72 wxBitmapRefData();
73 ~wxBitmapRefData();
74
75 public:
76 int m_width;
77 int m_height;
78 int m_depth;
79 bool m_ok;
80 int m_numColors;
81 wxPalette m_bitmapPalette;
82 int m_quality;
83
84 /* WXHBITMAP m_hBitmap; TODO: platform-specific handle */
85 wxMask * m_bitmapMask; // Optional mask
86 };
87
88 #define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
89
90 class WXDLLEXPORT wxBitmapHandler: public wxObject
91 {
92 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
93 public:
94 wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
95
96 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
97 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
98 int desiredWidth, int desiredHeight);
99 virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
100
101 inline void SetName(const wxString& name) { m_name = name; }
102 inline void SetExtension(const wxString& ext) { m_extension = ext; }
103 inline void SetType(long type) { m_type = type; }
104 inline wxString GetName() const { return m_name; }
105 inline wxString GetExtension() const { return m_extension; }
106 inline long GetType() const { return m_type; }
107 protected:
108 wxString m_name;
109 wxString m_extension;
110 long m_type;
111 };
112
113 #define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
114
115 class WXDLLEXPORT wxBitmap: public wxGDIObject
116 {
117 DECLARE_DYNAMIC_CLASS(wxBitmap)
118
119 friend class WXDLLEXPORT wxBitmapHandler;
120
121 public:
122 wxBitmap(); // Platform-specific
123
124 // Copy constructors
125 inline wxBitmap(const wxBitmap& bitmap)
126 { Ref(bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
127 inline wxBitmap(const wxBitmap* bitmap) { if (bitmap) Ref(*bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
128
129 // Initialize with raw data.
130 wxBitmap(const char bits[], int width, int height, int depth = 1);
131
132 /* TODO: maybe implement XPM reading
133 // Initialize with XPM data
134 wxBitmap(const char **data);
135 */
136
137 // Load a file or resource
138 // TODO: make default type whatever's appropriate for the platform.
139 wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
140
141 // Constructor for generalised creation from data
142 wxBitmap(void *data, long type, int width, int height, int depth = 1);
143
144 // If depth is omitted, will create a bitmap compatible with the display
145 wxBitmap(int width, int height, int depth = -1);
146 ~wxBitmap();
147
148 virtual bool Create(int width, int height, int depth = -1);
149 virtual bool Create(void *data, long type, int width, int height, int depth = 1);
150 virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
151 virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
152
153 inline bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
154 inline int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
155 inline int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
156 inline int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
157 inline int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
158 void SetWidth(int w);
159 void SetHeight(int h);
160 void SetDepth(int d);
161 void SetQuality(int q);
162 void SetOk(bool isOk);
163
164 inline wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : NULL); }
165 void SetPalette(const wxPalette& palette);
166
167 inline wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : NULL); }
168 void SetMask(wxMask *mask) ;
169
170 inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
171 inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
172 inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
173
174 // Format handling
175 static inline wxList& GetHandlers() { return sm_handlers; }
176 static void AddHandler(wxBitmapHandler *handler);
177 static void InsertHandler(wxBitmapHandler *handler);
178 static bool RemoveHandler(const wxString& name);
179 static wxBitmapHandler *FindHandler(const wxString& name);
180 static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
181 static wxBitmapHandler *FindHandler(long bitmapType);
182
183 static void InitStandardHandlers();
184 static void CleanUpHandlers();
185 protected:
186 static wxList sm_handlers;
187
188 /*
189 // TODO: Implementation
190 public:
191 void SetHBITMAP(WXHBITMAP bmp);
192 inline WXHBITMAP GetHBITMAP() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); }
193 bool FreeResource(bool force = FALSE);
194 */
195
196 };
197 #endif
198 // _WX_BITMAP_H_