]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/cursor.cpp
Dialog processing updates and some timer fixes
[wxWidgets.git] / src / os2 / cursor.cpp
index b55237c68b4f067e6a7e3329f066e3ede13d8034..df148e17a381f111fbf85ec8582673cf80f7fc44 100644 (file)
 #endif
 
 #include "wx/os2/private.h"
+#include "wx/image.h"
 
 #include "assert.h"
 
-#if !USE_SHARED_LIBRARIES
 IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
-#endif
 
 wxCursorRefData::wxCursorRefData(void)
 {
-  m_width = 32; m_height = 32;
+  m_nWidth = 32;
+  m_nHeight = 32;
   m_hCursor = 0 ;
   m_destroyCursor = FALSE;
 }
@@ -53,15 +53,48 @@ wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSE
 {
 }
 
+wxCursor::wxCursor(
+  const wxImage&                    rImage
+)
+{
+    wxImage                         vImage32 = rImage.Scale(32,32);
+    int                             nWidth   = vImage32.GetWidth();
+    int                             nHeight  = vImage32.GetHeight();
+
+    //
+    // Need a bitmap handle somehow
+    //
+    HBITMAP                      hBitmap = wxBitmap(vImage32).GetHBITMAP();
+    int                          nHotSpotX = vImage32.GetOptionInt(wxCUR_HOTSPOT_X);
+    int                          nHotSpotY = vImage32.GetOptionInt(wxCUR_HOTSPOT_Y);
+
+    if (nHotSpotX < 0 || nHotSpotX >= nWidth)
+            nHotSpotX = 0;
+    if (nHotSpotY < 0 || nHotSpotY >= nHeight)
+            nHotSpotY = 0;
+
+
+    wxCursorRefData*                pRefData = new wxCursorRefData;
+
+    m_refData = pRefData;
+    pRefData->m_hCursor = (WXHCURSOR) ::WinCreatePointer( HWND_DESKTOP
+                                                         ,hBitmap
+                                                         ,TRUE
+                                                         ,nHotSpotY
+                                                         ,nHotSpotX
+                                                        );
+
+} // end of wxCursor::wxCursor
+
 wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
 {
   m_refData = new wxCursorRefData;
 
   M_CURSORDATA->m_destroyCursor = FALSE;
   M_CURSORDATA->m_hCursor = 0;
-  M_CURSORDATA->m_ok = FALSE;
 // TODO:
 /*
+  M_CURSORDATA->m_bOK = FALSE;
   if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
   {
     M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);