Author: gnorton
Date: 2007-10-18 15:34:27 -0400 (Thu, 18 Oct 2007)
New Revision: 87790

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
Log:
2007-10-17  Geoff Norton  <[EMAIL PROTECTED]>

    * XplatUIOSX.cs: Implement support for window icons in the dock.  Set
    the title caption of real window.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-10-18 19:33:59 UTC (rev 87789)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-10-18 19:34:27 UTC (rev 87790)
@@ -1,3 +1,8 @@
+2007-10-17  Geoff Norton  <[EMAIL PROTECTED]>
+
+       * XplatUIOSX.cs: Implement support for window icons in the dock.  Set
+       the title caption of real window.
+
 2007-10-17  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * ErrorProvider.cs: Add the error provider's internal window to a 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2007-10-18 19:33:59 UTC (rev 87789)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2007-10-18 19:34:27 UTC (rev 87790)
@@ -1412,9 +1412,11 @@
                                HIViewSetVisible (ClientWindow, false);
                                hwnd.visible = false;
                        }
+
+                       Text (hwnd.Handle, cp.Caption);
                        
                        SendMessage (hwnd.Handle, Msg.WM_CREATE, (IntPtr)1, 
IntPtr.Zero /* XXX unused */);
-                       SendMessage(hwnd.Handle, Msg.WM_SHOWWINDOW, (IntPtr)1, 
IntPtr.Zero);
+                       SendMessage (hwnd.Handle, Msg.WM_SHOWWINDOW, (IntPtr)1, 
IntPtr.Zero);
 
                        return hwnd.Handle;
                }
@@ -2031,8 +2033,45 @@
                        FocusWindow = handle;
                }
 
-               [MonoTODO]
                internal override void SetIcon(IntPtr handle, Icon icon) {
+                       Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+
+                       // FIXME: we need to map the icon for active window 
switches
+                       if (WindowMapping [hwnd.Handle] != null) {
+                               if (icon == null) { 
+                                       RestoreApplicationDockTileImage ();
+                               } else {
+                                       Bitmap          bitmap;
+                                       int             size;
+                                       IntPtr[]        data;
+                                       int             index;
+       
+                                       bitmap = new Bitmap (128, 128);
+                                       using (Graphics g = Graphics.FromImage 
(bitmap)) {
+                                               g.DrawImage (icon.ToBitmap (), 
0, 0, 128, 128);
+                                       }
+                                       index = 0;
+                                       size = bitmap.Width * bitmap.Height;
+                                       data = new IntPtr[size];
+       
+                                       for (int y = 0; y < bitmap.Height; y++) 
{
+                                               for (int x = 0; x < 
bitmap.Width; x++) {
+                                                       int pixel = 
bitmap.GetPixel (x, y).ToArgb ();
+                                                       byte a = (byte) ((pixel 
>> 24) & 0xFF);
+                                                       byte r = (byte) ((pixel 
>> 16) & 0xFF);
+                                                       byte g = (byte) ((pixel 
>> 8) & 0xFF);
+                                                       byte b = (byte) (pixel 
& 0xFF);
+                                                       data[index++] = 
(IntPtr)(a + (r << 8) + (g << 16) + (b << 24));
+                                               }
+                                       }
+
+                                       IntPtr provider = 
CGDataProviderCreateWithData (IntPtr.Zero, data, size*4, IntPtr.Zero);
+Console.WriteLine (provider);
+                                       IntPtr image = CGImageCreate (128, 128, 
8, 32, 4*128, CGColorSpaceCreateDeviceRGB (), 4, provider, IntPtr.Zero, 0, 0);
+Console.WriteLine (image);
+                                       SetApplicationDockTileImage (image);
+                               }
+                       }
                }
 
                
@@ -2665,5 +2704,18 @@
                
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                internal extern static int SetFrontProcess (ref 
ProcessSerialNumber psn);
                #endregion
+
+               #region Dock tile imports
+               
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal extern static IntPtr CGColorSpaceCreateDeviceRGB();
+               
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal extern static IntPtr CGDataProviderCreateWithData 
(IntPtr info, IntPtr [] data, int size, IntPtr releasefunc);
+               
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal extern static IntPtr CGImageCreate (int width, int 
height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, IntPtr 
colorspace, uint bitmapInfo, IntPtr provider, IntPtr decode, int 
shouldInterpolate, int intent);
+               
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal extern static void SetApplicationDockTileImage(IntPtr 
imageRef);
+               
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal extern static void RestoreApplicationDockTileImage();
+               #endregion
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to