Author: joncham
Date: 2006-01-09 15:50:46 -0500 (Mon, 09 Jan 2006)
New Revision: 55259

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2006-01-9  Jonathan Chambers  <[EMAIL PROTECTED]>

        * XplatUI.cs, Form.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIOSX.cs, 
        XplatUIWin32.cs: Added support for Form TransparencyKey and Opacity on 
Windows.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-01-09 20:50:46 UTC (rev 55259)
@@ -1,5 +1,10 @@
-2006-01-10  Jonathan Chambers  <[EMAIL PROTECTED]>
+2006-01-9  Jonathan Chambers  <[EMAIL PROTECTED]>
 
+       * XplatUI.cs, Form.cs, XplatUIDriver.cs, XplatUIX11.cs, XplatUIOSX.cs, 
+       XplatUIWin32.cs: Added support for Form TransparencyKey and Opacity on 
Windows.
+
+2006-01-9  Jonathan Chambers  <[EMAIL PROTECTED]>
+
        * ComboBox.cs: Fix crash when there is no selected item (due to last 
commit)
 
 2006-01-09  Jonathan Chambers  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2006-01-09 20:50:46 UTC (rev 55259)
@@ -607,6 +607,10 @@
 
                        set {
                                opacity = value;
+
+                               UpdateStyles();
+                               if (Opacity < 1.0)
+                                       XplatUI.SetWindowTransparency(Handle, 
opacity, TransparencyKey);
                        }
                }
                        
@@ -768,7 +772,10 @@
                        set {
                                AllowTransparency = true;
                                transparency_key = value;
-                               // TODO: change window attributes; a new driver 
call
+
+                               UpdateStyles();
+                               if (TransparencyKey != Color.Empty)
+                                       XplatUI.SetWindowTransparency(Handle, 
Opacity, TransparencyKey);
                        }
                }
 
@@ -888,6 +895,10 @@
                                if (HelpButton) {
                                        cp.ExStyle |= 
(int)WindowStyles.WS_EX_CONTEXTHELP;
                                }
+                               
+                               if (Opacity < 1.0 || TransparencyKey != 
Color.Empty) {
+                                       cp.ExStyle |= 
(int)WindowStyles.WS_EX_LAYERED;
+                               }
 
                                return cp;
                        }

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2006-01-09 20:50:46 UTC (rev 55259)
@@ -741,6 +741,14 @@
                        driver.SetWindowStyle(handle, cp);
                }
 
+               internal static void SetWindowTransparency(IntPtr handle, 
double transparency, Color key) 
+               {
+                       #if DriverDebug
+                               
Console.WriteLine("SetWindowTransparency({0:X}): Called", handle.ToInt32());
+                       #endif
+                       driver.SetWindowTransparency(handle, transparency, key);
+               }
+
                internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, 
bool Top, bool Bottom) {
                        #if DriverDebug
                                Console.WriteLine("SetZOrder({0:X}, {1:X}, {2}, 
{3}): Called", handle.ToInt32(), AfterhWnd.ToInt32(), Top, Bottom);

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs 
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs 
2006-01-09 20:50:46 UTC (rev 55259)
@@ -120,6 +120,8 @@
 
                internal abstract void SetWindowStyle(IntPtr handle, 
CreateParams cp);
 
+               internal abstract void SetWindowTransparency(IntPtr handle, 
double transparency, Color key);
+
                internal virtual void SetAllowDrop (IntPtr handle, bool value)
                {
                        Console.Error.WriteLine ("Drag and Drop is currently " +

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs    
2006-01-09 20:50:46 UTC (rev 55259)
@@ -1668,6 +1668,9 @@
                                ChangeWindowAttributes ((IntPtr)WindowMapping 
[hwnd.Handle], attributes, outAttributes);
                        }
                }
+
+               internal override void SetWindowTransparency(IntPtr handle, 
double transparency, Color key) {
+               }
                
                internal override bool SetZOrder(IntPtr handle, IntPtr 
after_handle, bool Top, bool Bottom) {
                        Hwnd hwnd = Hwnd.ObjectFromHandle (handle);

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs  
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs  
2006-01-09 20:50:46 UTC (rev 55259)
@@ -308,9 +308,9 @@
                }
 
                internal struct COLORREF {
+                       internal byte                   R;
+                       internal byte                   G;
                        internal byte                   B;
-                       internal byte                   G;
-                       internal byte                   R;
                        internal byte                   A;
                }
 
@@ -615,6 +615,14 @@
                        SND_PURGE                       = 0x0040,
                        SND_APPLICATION                 = 0x0080,
                }
+
+               [Flags]
+               internal enum LayeredWindowAttributes : int {
+                       LWA_COLORKEY            = 0x1,
+                       LWA_ALPHA                       = 0x2,
+               }
+
+               
                #endregion
 
                #region Constructor & Destructor
@@ -1113,6 +1121,23 @@
                        Win32SetWindowLong(handle, WindowLong.GWL_EXSTYLE, 
(uint)cp.ExStyle);
                }
 
+               
+               internal override void SetWindowTransparency(IntPtr handle, 
double transparency, Color key) {
+                       LayeredWindowAttributes lwa = 
LayeredWindowAttributes.LWA_ALPHA;
+                       byte opacity = (byte)(transparency*255);
+                       COLORREF clrRef = new COLORREF();
+                       if (key != Color.Empty) {
+                               clrRef.R = key.R;
+                               clrRef.G = key.G;
+                               clrRef.B = key.B;
+                               lwa = (LayeredWindowAttributes)( (int)lwa | 
(int)LayeredWindowAttributes.LWA_COLORKEY );
+                       }
+                       RECT rc;
+                       rc.right = 1000;
+                       rc.bottom = 1000;
+                       uint error = Win32SetLayeredWindowAttributes(handle, 
clrRef, opacity, lwa);
+               }
+
                internal override void UpdateWindow(IntPtr handle) {
                        Win32UpdateWindow(handle);
                }
@@ -2276,6 +2301,9 @@
                [DllImport ("user32.dll", EntryPoint="GetWindowLong", 
CallingConvention=CallingConvention.StdCall)]
                private extern static uint Win32GetWindowLong(IntPtr hwnd, 
WindowLong index);
 
+               [DllImport ("user32.dll", 
EntryPoint="SetLayeredWindowAttributes", 
CallingConvention=CallingConvention.StdCall)]
+               private extern static uint Win32SetLayeredWindowAttributes 
(IntPtr hwnd, COLORREF crKey, byte bAlpha, LayeredWindowAttributes dwFlags);
+
                [DllImport ("gdi32.dll", EntryPoint="DeleteObject", 
CallingConvention=CallingConvention.StdCall)]
                private extern static bool Win32DeleteObject(IntPtr o);
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2006-01-09 19:43:45 UTC (rev 55258)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2006-01-09 20:50:46 UTC (rev 55259)
@@ -3642,6 +3642,10 @@
                        SetHwndStyles(hwnd, cp);
                        SetWMStyles(hwnd, cp);
                }
+
+               internal override void SetWindowTransparency(IntPtr handle, 
double transparency, Color key) {
+               }
+
                internal override bool SetZOrder(IntPtr handle, IntPtr 
after_handle, bool top, bool bottom) {
                        Hwnd    hwnd = Hwnd.ObjectFromHandle(handle);
 

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

Reply via email to