]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/bitmap.cpp
added some utils (tex2rtf, helpgen, makegen) to make system
[wxWidgets.git] / src / msw / bitmap.cpp
index 7f7aa14f75bd0a673e8aa3d46d5a09878d0d3039..e74cf073a4799b6a14ff355e9b1170861ad3bccb 100644 (file)
 // macros
 // ----------------------------------------------------------------------------
 
 // macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARIES
     IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
     IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
 
     IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
     IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
     IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
 
     IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
-#endif
 
 // ============================================================================
 // implementation
 
 // ============================================================================
 // implementation
@@ -174,9 +172,9 @@ bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
     wxFAIL_MSG( _T("don't know how to convert cursor to bitmap") );
 
     return FALSE;
     wxFAIL_MSG( _T("don't know how to convert cursor to bitmap") );
 
     return FALSE;
-#endif // Win16
-
+#else
     return CopyFromIconOrCursor(cursor);
     return CopyFromIconOrCursor(cursor);
+#endif // Win16
 }
 
 bool wxBitmap::CopyFromIcon(const wxIcon& icon)
 }
 
 bool wxBitmap::CopyFromIcon(const wxIcon& icon)
@@ -251,6 +249,46 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
     SetHBITMAP((WXHBITMAP)hbmp);
 }
 
     SetHBITMAP((WXHBITMAP)hbmp);
 }
 
+// GRG, Dic/99
+wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
+{
+    wxCHECK_MSG( Ok() &&
+                 (rect.x >= 0) && (rect.y >= 0) && 
+                 (rect.x+rect.width <= GetWidth()) &&
+                 (rect.y+rect.height <= GetHeight()),
+                 wxNullBitmap, wxT("Invalid bitmap or bitmap region") );
+    
+    wxBitmap ret( rect.width, rect.height, GetDepth() );
+    wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
+    
+    // copy bitmap data
+    HDC dcSrc = ::CreateCompatibleDC(NULL);
+    HDC dcDst = ::CreateCompatibleDC(NULL);
+    SelectObject(dcSrc, (HBITMAP) GetHBITMAP());
+    SelectObject(dcDst, (HBITMAP) ret.GetHBITMAP());
+    BitBlt(dcDst, 0, 0, rect.width, rect.height, dcSrc, rect.x, rect.y, SRCCOPY);
+
+    // copy mask if there is one
+    if (GetMask())
+    {
+        HBITMAP hbmpMask = ::CreateBitmap(rect.width, rect.height, 1, 1, 0);
+
+        SelectObject(dcSrc, (HBITMAP) GetMask()->GetMaskBitmap());
+        SelectObject(dcDst, (HBITMAP) hbmpMask);
+        BitBlt(dcDst, 0, 0, rect.width, rect.height, dcSrc, rect.x, rect.y, SRCCOPY);
+
+        wxMask *mask = new wxMask((WXHBITMAP) hbmpMask);
+        ret.SetMask(mask);
+    }
+
+    SelectObject(dcDst, NULL);
+    SelectObject(dcSrc, NULL);
+    DeleteDC(dcDst);
+    DeleteDC(dcSrc);
+
+    return ret;
+}
+
 // Create from XPM data
 wxBitmap::wxBitmap(char **data, wxControl *WXUNUSED(anItem))
 {
 // Create from XPM data
 wxBitmap::wxBitmap(char **data, wxControl *WXUNUSED(anItem))
 {