]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
Add support for GTK print, modified from patch 1782055
[wxWidgets.git] / include / wx / gtk / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
3 // Purpose:
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_BITMAP_H_
11 #define _WX_GTK_BITMAP_H_
12
13 typedef struct _GdkPixbuf GdkPixbuf;
14 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
15
16 //-----------------------------------------------------------------------------
17 // wxMask
18 //-----------------------------------------------------------------------------
19
20 class WXDLLIMPEXP_CORE wxMask: public wxObject
21 {
22 public:
23 wxMask();
24 wxMask( const wxBitmap& bitmap, const wxColour& colour );
25 #if wxUSE_PALETTE
26 wxMask( const wxBitmap& bitmap, int paletteIndex );
27 #endif // wxUSE_PALETTE
28 wxMask( const wxBitmap& bitmap );
29 virtual ~wxMask();
30
31 bool Create( const wxBitmap& bitmap, const wxColour& colour );
32 #if wxUSE_PALETTE
33 bool Create( const wxBitmap& bitmap, int paletteIndex );
34 #endif // wxUSE_PALETTE
35 bool Create( const wxBitmap& bitmap );
36
37 // implementation
38 GdkBitmap *m_bitmap;
39
40 GdkBitmap *GetBitmap() const;
41
42 private:
43 DECLARE_DYNAMIC_CLASS(wxMask)
44 };
45
46 //-----------------------------------------------------------------------------
47 // wxBitmap
48 //-----------------------------------------------------------------------------
49
50 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
51 {
52 public:
53 wxBitmap() { }
54 wxBitmap( int width, int height, int depth = -1 );
55 wxBitmap( const char bits[], int width, int height, int depth = 1 );
56 wxBitmap( const char* const* bits );
57 #ifdef wxNEEDS_CHARPP
58 // needed for old GCC
59 wxBitmap(char** data)
60 {
61 *this = wxBitmap(wx_const_cast(const char* const*, data));
62 }
63 #endif
64 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
65 #if wxUSE_IMAGE
66 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
67 #endif // wxUSE_IMAGE
68 virtual ~wxBitmap();
69 bool Ok() const { return IsOk(); }
70 bool IsOk() const;
71
72 bool Create(int width, int height, int depth = -1);
73
74 int GetHeight() const;
75 int GetWidth() const;
76 int GetDepth() const;
77
78 #if wxUSE_IMAGE
79 wxImage ConvertToImage() const;
80 #endif // wxUSE_IMAGE
81
82 // copies the contents and mask of the given (colour) icon to the bitmap
83 virtual bool CopyFromIcon(const wxIcon& icon);
84
85 wxMask *GetMask() const;
86 void SetMask( wxMask *mask );
87
88 wxBitmap GetSubBitmap( const wxRect& rect ) const;
89
90 bool SaveFile(const wxString &name, wxBitmapType type,
91 const wxPalette *palette = (wxPalette *)NULL) const;
92 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
93
94 #if wxUSE_PALETTE
95 wxPalette *GetPalette() const;
96 void SetPalette(const wxPalette& palette);
97 wxPalette *GetColourMap() const { return GetPalette(); };
98 #endif // wxUSE_PALETTE
99
100 static void InitStandardHandlers();
101
102 // implementation
103 // --------------
104
105 void SetHeight( int height );
106 void SetWidth( int width );
107 void SetDepth( int depth );
108 void SetPixmap( GdkPixmap *pixmap );
109 void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
110
111 GdkPixmap *GetPixmap() const;
112 bool HasPixmap() const;
113 bool HasPixbuf() const;
114 GdkPixbuf *GetPixbuf() const;
115
116 // Basically, this corresponds to Win32 StretchBlt()
117 wxBitmap Rescale(int clipx, int clipy, int clipwidth, int clipheight, int width, int height) const;
118
119 // raw bitmap access support functions
120 void *GetRawData(wxPixelDataBase& data, int bpp);
121 void UngetRawData(wxPixelDataBase& data);
122
123 bool HasAlpha() const;
124
125 protected:
126 #if wxUSE_IMAGE
127 bool CreateFromImage(const wxImage& image, int depth);
128 #endif // wxUSE_IMAGE
129
130 virtual wxObjectRefData* CreateRefData() const;
131 virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
132
133 private:
134 #if wxUSE_IMAGE
135 // to be called from CreateFromImage only!
136 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
137 bool CreateFromImageAsPixbuf(const wxImage& image);
138 #endif // wxUSE_IMAGE
139
140 enum Representation
141 {
142 Pixmap,
143 Pixbuf
144 };
145 // removes other representations from memory, keeping only 'keep'
146 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
147 void PurgeOtherRepresentations(Representation keep);
148
149 friend class wxMemoryDC;
150 friend class wxBitmapHandler;
151
152 private:
153 DECLARE_DYNAMIC_CLASS(wxBitmap)
154 };
155
156 //-----------------------------------------------------------------------------
157 // wxBitmapHandler
158 //-----------------------------------------------------------------------------
159
160 class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
161 {
162 DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
163 };
164
165 #endif // _WX_GTK_BITMAP_H_