X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b254edf9cb508b48bfd3f9cf76d46f7cf1e1f5b..d61c1a6f21202a9c9927452574cd5c6939255850:/include/wx/msw/dib.h diff --git a/include/wx/msw/dib.h b/include/wx/msw/dib.h index f4f0bf0a86..7f0d2ecb07 100644 --- a/include/wx/msw/dib.h +++ b/include/wx/msw/dib.h @@ -17,6 +17,8 @@ class WXDLLEXPORT wxPalette; #include "wx/msw/private.h" +#if wxUSE_WXDIB + // ---------------------------------------------------------------------------- // wxDIB: represents a DIB section // ---------------------------------------------------------------------------- @@ -151,30 +153,10 @@ public: private: // common part of all ctors - void Init() - { - m_handle = 0; - - m_data = NULL; - - m_width = - m_height = - m_depth = 0; - } + void Init(); // free resources - void Free() - { - if ( m_handle ) - { - if ( !::DeleteObject(m_handle) ) - { - wxLogLastError(wxT("DeleteObject(hDIB)")); - } - - Init(); - } - } + void Free(); // the DIB section handle, 0 if invalid HBITMAP m_handle; @@ -198,6 +180,11 @@ private: m_height, m_depth; + // in some cases we could be using a handle which we didn't create and in + // this case we shouldn't free it neither -- this flag tell us if this is + // the case + bool m_ownsHandle; + // DIBs can't be copied wxDIB(const wxDIB&); @@ -208,10 +195,40 @@ private: // inline functions implementation // ---------------------------------------------------------------------------- +inline +void wxDIB::Init() +{ + m_handle = 0; + m_ownsHandle = true; + + m_data = NULL; + + m_width = + m_height = + m_depth = 0; +} + +inline +void wxDIB::Free() +{ + if ( m_handle && m_ownsHandle ) + { + if ( !::DeleteObject(m_handle) ) + { + wxLogLastError(wxT("DeleteObject(hDIB)")); + } + + Init(); + } +} + inline wxDIB::~wxDIB() { Free(); } +#endif + // wxUSE_WXDIB + #endif // _WX_MSW_DIB_H_