]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/icon.cpp
now we initialize wxListEvent correctly
[wxWidgets.git] / src / msw / icon.cpp
index 93293f2814383109f8239dc42b6783715c0639d7..a788d29ed15ce87b2ae397816a4982a0f1ac2ce5 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
 #include "wx/msw/private.h"
 #include "assert.h"
 
-#if USE_XPM_IN_MSW
-#define FOR_MSW 1
-#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
-#endif
-
-#if USE_RESOURCE_LOADING_IN_MSW
+#if wxUSE_RESOURCE_LOADING_IN_MSW
 #include "wx/msw/curico.h"
 #include "wx/msw/curicop.h"
 #endif
@@ -60,19 +55,19 @@ wxIconRefData::wxIconRefData(void)
 
 wxIconRefData::~wxIconRefData(void)
 {
-       if ( m_hIcon )
-               ::DestroyIcon((HICON) m_hIcon);
+  if ( m_hIcon )
+    ::DestroyIcon((HICON) m_hIcon);
 }
 
 wxIcon::wxIcon(void)
 {
 }
 
-wxIcon::wxIcon(const char WXUNUSED(bits)[], const int WXUNUSED(width), const int WXUNUSED(height))
+wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
 {
 }
 
-wxIcon::wxIcon(const wxString& icon_file, const long flags,
+wxIcon::wxIcon(const wxString& icon_file, long flags,
     int desiredWidth, int desiredHeight)
 
 {
@@ -88,12 +83,12 @@ bool wxIcon::FreeResource(bool force)
   if (M_ICONDATA && M_ICONDATA->m_hIcon)
   {
     DestroyIcon((HICON) M_ICONDATA->m_hIcon);
-       M_ICONDATA->m_hIcon = (WXHICON) NULL;
+  M_ICONDATA->m_hIcon = (WXHICON) NULL;
   }
   return TRUE;
 }
 
-bool wxIcon::LoadFile(const wxString& filename, const long type,
+bool wxIcon::LoadFile(const wxString& filename, long type,
     int desiredWidth, int desiredHeight)
 {
   UnRef();
@@ -103,46 +98,46 @@ bool wxIcon::LoadFile(const wxString& filename, const long type,
   wxBitmapHandler *handler = FindHandler(type);
 
   if ( handler )
-       return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
+  return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
   else
-       return FALSE;
+  return FALSE;
 }
 
 void wxIcon::SetHICON(WXHICON ico)
 {
   if ( !M_ICONDATA )
-       m_refData = new wxIconRefData;
+  m_refData = new wxIconRefData;
 
   M_ICONDATA->m_hIcon = ico;
 }
 
-bool wxICOFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+bool wxICOFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
     int desiredWidth, int desiredHeight)
 {
-#if USE_RESOURCE_LOADING_IN_MSW
-       if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
-       {
-               wxIcon *icon = (wxIcon *)bitmap;
-        int width, height;
-        WXHICON hIcon = (WXHICON) ReadIconFile((char *)(const char *)name, wxGetInstance(), &width, &height);
-
-       ((wxIconRefData *)icon->GetRefData())->m_hIcon = hIcon;
-       ((wxIconRefData *)icon->GetRefData())->m_ok = (((wxIconRefData *)icon->GetRefData())->m_hIcon != 0);
-       return ((wxIconRefData *)icon->GetRefData())->m_ok;
-       }
-       else
-               return FALSE;
+#if wxUSE_RESOURCE_LOADING_IN_MSW
+  if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
+  {
+    wxIcon *icon = (wxIcon *)bitmap;
+    wxIconRefData *data = (wxIconRefData *)icon->GetRefData();
+    data->m_hIcon = (WXHICON)ReadIconFile((wxChar *)name.c_str(), wxGetInstance(),
+                                          &data->m_width, &data->m_height);
+
+    data->m_ok = data->m_hIcon != 0;
+    return data->m_ok;
+  }
+  else
+    return FALSE;
 #else
-       return FALSE;
+  return FALSE;
 #endif
 }
 
-bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const long flags,
+bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
     int desiredWidth, int desiredHeight)
 {
-       if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
-       {
-#if defined(__WIN32__)
+  if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
+  {
+#if defined(__WIN32__) && !defined(__SC__)
     if (desiredWidth > -1 && desiredHeight > -1)
     {
         M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadImage(wxGetInstance(), name, IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR);
@@ -150,38 +145,45 @@ bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, cons
     else
 #endif
     {
-       M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
+      M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
     }
 
 #ifdef __WIN32__
-       // Win32s doesn't have GetIconInfo function...
-       if (M_ICONHANDLERDATA->m_hIcon && wxGetOsVersion()!=wxWIN32S)
-       {
-               ICONINFO info ;
-               if (::GetIconInfo((HICON) M_ICONHANDLERDATA->m_hIcon, &info))
-               {
-                       HBITMAP ms_bitmap = info.hbmMask ;
-                       if (ms_bitmap)
-                       {
-                               BITMAP bm;
-                               ::GetObject(ms_bitmap, sizeof(BITMAP), (LPSTR) &bm);
-                               M_ICONHANDLERDATA->m_width = bm.bmWidth;
-                               M_ICONHANDLERDATA->m_height = bm.bmHeight;
-                       }
-                       if (info.hbmMask)
-                               ::DeleteObject(info.hbmMask) ;
-                       if (info.hbmColor)
-                               ::DeleteObject(info.hbmColor) ;
-               }
-       }
+      // Win32s doesn't have GetIconInfo function...
+      if (M_ICONHANDLERDATA->m_hIcon && wxGetOsVersion()!=wxWIN32S)
+      {
+          ICONINFO info ;
+          if (::GetIconInfo((HICON) M_ICONHANDLERDATA->m_hIcon, &info))
+          {
+            HBITMAP ms_bitmap = info.hbmMask ;
+            if (ms_bitmap)
+            {
+                BITMAP bm;
+                ::GetObject(ms_bitmap, sizeof(BITMAP), (LPSTR) &bm);
+                M_ICONHANDLERDATA->m_width = bm.bmWidth;
+                M_ICONHANDLERDATA->m_height = bm.bmHeight;
+            }
+            if (info.hbmMask)
+                ::DeleteObject(info.hbmMask) ;
+            if (info.hbmColor)
+                ::DeleteObject(info.hbmColor) ;
+          }
+      }
 #else
-       M_ICONHANDLERDATA->m_width = 32;
-       M_ICONHANDLERDATA->m_height = 32;
+      M_ICONHANDLERDATA->m_width = 32;
+      M_ICONHANDLERDATA->m_height = 32;
 #endif
-       M_ICONHANDLERDATA->m_ok = (M_ICONHANDLERDATA->m_hIcon != 0);
-       return M_ICONHANDLERDATA->m_ok;
-       }
-       else
-           return FALSE;
+      // Override the found values with desired values
+      if (desiredWidth > -1 && desiredHeight > -1)
+      {
+          M_ICONHANDLERDATA->m_width = desiredWidth;
+          M_ICONHANDLERDATA->m_height = desiredHeight;
+      }
+
+      M_ICONHANDLERDATA->m_ok = (M_ICONHANDLERDATA->m_hIcon != 0);
+      return M_ICONHANDLERDATA->m_ok;
+  }
+  else
+      return FALSE;
 }