From 8bb6da4ae69b4b16982a1cf7a7284c44b98e4e21 Mon Sep 17 00:00:00 2001
From: David Webster <Dave.Webster@bhmi.com>
Date: Mon, 29 Jan 2001 05:46:06 +0000
Subject: [PATCH] Bitmap and icon updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9205 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/os2/bitmap.h   | 24 ++++++++++--------------
 include/wx/os2/gdiimage.h | 19 +++++++++++++++++++
 include/wx/os2/icon.h     |  4 ++++
 include/wx/os2/private.h  | 13 +++++++++++++
 include/wx/os2/taskbar.h  | 14 +++++++-------
 5 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/include/wx/os2/bitmap.h b/include/wx/os2/bitmap.h
index 0908e667d5..baacd60aa8 100644
--- a/include/wx/os2/bitmap.h
+++ b/include/wx/os2/bitmap.h
@@ -54,12 +54,12 @@ public:
     // ------------
 
     wxDC*                           m_pSelectedInto;
-    HPS                             m_hPresentationSpace;
-    LONG                            m_lId;
 
-    // optional mask for transparent drawing
+    //
+    // Optional mask for transparent drawing
+    //
     wxMask*                         m_pBitmapMask;
-};
+}; // end of CLASS wxBitmapRefData
 
 // ----------------------------------------------------------------------------
 // wxBitmap: a mono or colour bitmap
@@ -83,9 +83,8 @@ public:
             );
 
     // Initialize with XPM data
-    wxBitmap( char**     ppData
-             ,wxControl* pAnItem = NULL
-            );
+    wxBitmap(const char** ppData);
+    wxBitmap(char** ppData);
 
     // Load a file or resource
     wxBitmap( const wxString& rName
@@ -214,8 +213,8 @@ public:
     // An OS/2 version that probably doesn't do anything like the msw version
     wxBitmap GetBitmapForDC(wxDC& rDc) const;
 
-    inline LONG GetId() const
-      { return (GetBitmapData() ? GetBitmapData()->m_lId : 0L); }
+//    inline LONG GetId() const
+//      { return (GetBitmapData() ? GetBitmapData()->m_lId : 0L); }
 
 
 protected:
@@ -281,10 +280,7 @@ public:
 protected:
     WXHBITMAP                       m_hMaskBitmap;
     DECLARE_DYNAMIC_CLASS(wxMask)
-private:
-    HDC                             m_hDc;
-    HPS                             m_hPs;
-}; // end of wxMask
+}; // end of CLASS wxMask
 
 // ----------------------------------------------------------------------------
 // wxBitmapHandler is a class which knows how to load/save bitmaps to/from file
@@ -348,7 +344,7 @@ public:
                      );
 private:
     DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
-}; // end of wxBitmapHandler
+}; // end of CLASS wxBitmapHandler
 
 #endif
   // _WX_BITMAP_H_
diff --git a/include/wx/os2/gdiimage.h b/include/wx/os2/gdiimage.h
index 2dff008de0..18a301cef5 100644
--- a/include/wx/os2/gdiimage.h
+++ b/include/wx/os2/gdiimage.h
@@ -87,6 +87,7 @@ public:
 
     bool                            m_bOk;
 #endif // WXWIN_COMPATIBILITY_2
+    UINT                            m_uId;
 };
 
 // ----------------------------------------------------------------------------
@@ -212,6 +213,24 @@ public:
     }
     void SetSize(const wxSize& rSize) { SetSize(rSize.x, rSize.y); }
 
+    UINT GetId(void) const
+    {
+        wxGDIImageRefData*          pData;
+
+        pData = GetGDIImageData();
+        if (!pData)
+            return 0;
+        else
+            return pData->m_uId;
+    } // end of WxWinGdi_CGDIImage::GetId
+    void SetId(UINT uId)
+    {
+        wxGDIImageRefData*          pData;
+
+        EnsureHasData();
+        pData = GetGDIImageData();
+        pData->m_uId = uId;
+    }
     // forward some of base class virtuals to wxGDIImageRefData
     bool             FreeResource(bool bForce = FALSE);
     virtual WXHANDLE GetResourceHandle();
diff --git a/include/wx/os2/icon.h b/include/wx/os2/icon.h
index 383fd39e16..22160f236a 100644
--- a/include/wx/os2/icon.h
+++ b/include/wx/os2/icon.h
@@ -59,6 +59,8 @@ public:
            ,int        nWidth
            ,int        nHeight
           );
+    inline wxIcon(const char** ppData) { CreateIconFromXpm(ppData); }
+    inline wxIcon(char** ppData) { CreateIconFromXpm((const char**)ppData); }
     wxIcon( const wxString& rName
            ,long            lFlags = wxBITMAP_TYPE_ICO_RESOURCE
            ,int             nDesiredWidth = -1
@@ -84,11 +86,13 @@ public:
     inline void SetHICON(WXHICON hIcon) { SetHandle((WXHANDLE)hIcon); }
     inline WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
 
+    void CopyFromBitmap(const wxBitmap& rBmp);
 protected:
     virtual wxGDIImageRefData* CreateData() const
     {
         return new wxIconRefData;
     }
+    void    CreateIconFromXpm(const char **ppData);
 
 private:
     DECLARE_DYNAMIC_CLASS(wxIcon)
diff --git a/include/wx/os2/private.h b/include/wx/os2/private.h
index d42540d24b..3b943d0329 100644
--- a/include/wx/os2/private.h
+++ b/include/wx/os2/private.h
@@ -143,6 +143,9 @@ extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message
 #define GetHdc()                ((HDC)GetHDC())
 #define GetHdcOf(dc)            ((HDC)(dc).GetHDC())
 
+#define GetHbitmap()            ((HBITMAP)GetHBITMAP())
+#define GetHbitmapOf(bmp)       ((HBITMAP)(bmp).GetHBITMAP())
+
 #define GetHicon()              ((HICON)GetHICON())
 #define GetHiconOf(icon)        ((HICON)(icon).GetHICON())
 
@@ -152,6 +155,16 @@ extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message
 #define GetHmenu()              ((HMENU)GetHMenu())
 #define GetHmenuOf(menu)        ((HMENU)menu->GetHMenu())
 
+#define GetHcursor()            ((HCURSOR)GetHCURSOR())
+#define GetHcursorOf(cursor)    ((HCURSOR)(cursor).GetHCURSOR())
+
+#define GetHfont()              ((HFONT)GetHFONT())
+#define GetHfontOf(font)        ((HFONT)(font).GetHFONT())
+
+// OS/2 convention of the mask is opposed to the wxWindows one, so we need
+// to invert the mask each time we pass one/get one to/from Windows
+extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
+
 // ---------------------------------------------------------------------------
 // global data
 // ---------------------------------------------------------------------------
diff --git a/include/wx/os2/taskbar.h b/include/wx/os2/taskbar.h
index aa25c67c41..12cb28a0d7 100644
--- a/include/wx/os2/taskbar.h
+++ b/include/wx/os2/taskbar.h
@@ -78,13 +78,13 @@ const wxEventType wxEVT_TASKBAR_RIGHT_UP =              wxEVT_FIRST + 1554;
 const wxEventType wxEVT_TASKBAR_LEFT_DCLICK =           wxEVT_FIRST + 1555;
 const wxEventType wxEVT_TASKBAR_RIGHT_DCLICK =          wxEVT_FIRST + 1556;
 
-#define EVT_TASKBAR_MOVE(fn)         { wxEVT_TASKBAR_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_LEFT_DOWN(fn)    { wxEVT_TASKBAR_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_LEFT_UP(fn)      { wxEVT_TASKBAR_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_RIGHT_DOWN(fn)   { wxEVT_TASKBAR_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_RIGHT_UP(fn)     { wxEVT_TASKBAR_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_LEFT_DCLICK(fn)  { wxEVT_TASKBAR_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
-#define EVT_TASKBAR_RIGHT_DCLICK(fn) { wxEVT_TASKBAR_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
+#define EVT_TASKBAR_MOVE(fn)         wxEventTableEntry(wxEVT_TASKBAR_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_LEFT_DOWN(fn)    wxEventTableEntry(wxEVT_TASKBAR_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_LEFT_UP(fn)      wxEventTableEntry(wxEVT_TASKBAR_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_RIGHT_DOWN(fn)   wxEventTableEntry(wxEVT_TASKBAR_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_RIGHT_UP(fn)     wxEventTableEntry(wxEVT_TASKBAR_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_LEFT_DCLICK(fn)  wxEventTableEntry(wxEVT_TASKBAR_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
+#define EVT_TASKBAR_RIGHT_DCLICK(fn) wxEventTableEntry(wxEVT_TASKBAR_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
 
 
 #endif
-- 
2.47.2