]>
git.saurik.com Git - wxWidgets.git/blob - src/qt/bitmap.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "bitmap.h"
15 #include "wx/bitmap.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 IMPLEMENT_DYNAMIC_CLASS(wxMask
,wxObject
)
28 wxMask::wxMask( const wxBitmap
& WXUNUSED(bitmap
), const wxColour
& WXUNUSED(colour
) )
32 wxMask::wxMask( const wxBitmap
& WXUNUSED(bitmap
), int WXUNUSED(paletteIndex
) )
36 wxMask::wxMask( const wxBitmap
& WXUNUSED(bitmap
) )
44 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
48 class wxBitmapRefData
: public wxObjectRefData
52 wxBitmapRefData(void);
53 ~wxBitmapRefData(void);
62 wxBitmapRefData::wxBitmapRefData(void)
71 wxBitmapRefData::~wxBitmapRefData(void)
73 if (m_mask
) delete m_mask
;
74 if (m_palette
) delete m_palette
;
77 //-----------------------------------------------------------------------------
79 #define M_BMPDATA ((wxBitmapRefData *)m_refData)
81 IMPLEMENT_DYNAMIC_CLASS(wxBitmap
,wxGDIObject
)
83 wxBitmap::wxBitmap(void)
85 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
88 wxBitmap::wxBitmap( int width
, int height
, int depth
)
90 m_refData
= new wxBitmapRefData();
91 M_BMPDATA
->m_mask
= NULL
;
92 M_BMPDATA
->m_width
= width
;
93 M_BMPDATA
->m_height
= height
;
94 M_BMPDATA
->m_bpp
= depth
;
96 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
99 wxBitmap::wxBitmap( char **WXUNUSED(bits
) )
101 m_refData
= new wxBitmapRefData();
103 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
106 wxBitmap::wxBitmap( const wxBitmap
& bmp
)
110 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
113 wxBitmap::wxBitmap( const wxBitmap
* bmp
)
115 if (bmp
) Ref( *bmp
);
117 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
120 wxBitmap::wxBitmap( const wxString
&filename
, int type
)
122 LoadFile( filename
, type
);
125 wxBitmap::wxBitmap( const char WXUNUSED(bits
)[], int width
, int height
, int WXUNUSED(depth
))
127 m_refData
= new wxBitmapRefData();
129 M_BMPDATA
->m_mask
= NULL
;
130 M_BMPDATA
->m_width
= width
;
131 M_BMPDATA
->m_height
= height
;
132 M_BMPDATA
->m_bpp
= 1;
134 if (wxTheBitmapList
) wxTheBitmapList
->AddBitmap(this);
137 wxBitmap::~wxBitmap(void)
139 if (wxTheBitmapList
) wxTheBitmapList
->DeleteObject(this);
142 wxBitmap
& wxBitmap::operator = ( const wxBitmap
& bmp
)
144 if (*this == bmp
) return (*this);
149 bool wxBitmap::operator == ( const wxBitmap
& bmp
)
151 return m_refData
== bmp
.m_refData
;
154 bool wxBitmap::operator != ( const wxBitmap
& bmp
)
156 return m_refData
!= bmp
.m_refData
;
159 bool wxBitmap::Ok(void) const
161 return m_refData
!= NULL
;
164 int wxBitmap::GetHeight(void) const
167 return M_BMPDATA
->m_height
;
170 int wxBitmap::GetWidth(void) const
173 return M_BMPDATA
->m_width
;
176 int wxBitmap::GetDepth(void) const
179 return M_BMPDATA
->m_bpp
;
182 void wxBitmap::SetHeight( int height
)
185 M_BMPDATA
->m_height
= height
;
188 void wxBitmap::SetWidth( int width
)
191 M_BMPDATA
->m_width
= width
;
194 void wxBitmap::SetDepth( int depth
)
197 M_BMPDATA
->m_bpp
= depth
;
200 wxMask
*wxBitmap::GetMask(void) const
202 if (!Ok()) return NULL
;
204 return M_BMPDATA
->m_mask
;
207 void wxBitmap::SetMask( wxMask
*mask
)
211 if (M_BMPDATA
->m_mask
) delete M_BMPDATA
->m_mask
;
212 M_BMPDATA
->m_mask
= mask
;
215 void wxBitmap::Resize( int WXUNUSED(height
), int WXUNUSED(width
) )
221 bool wxBitmap::SaveFile( const wxString
&WXUNUSED(name
), int WXUNUSED(type
),
222 wxPalette
*WXUNUSED(palette
) )
227 bool wxBitmap::LoadFile( const wxString
&WXUNUSED(name
), int WXUNUSED(type
) )
232 wxPalette
*wxBitmap::GetPalette(void) const
234 if (!Ok()) return NULL
;
235 return M_BMPDATA
->m_palette
;