[winforms] Small optimizations, use properties that do not compute values
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.CarbonInternal / ControlHandler.cs
index 055d6ff3046c02c66f9170c22c704a604ec570d2..9064c27291aa6eb374a2363e3d191241539d2824 100644 (file)
@@ -130,8 +130,6 @@ namespace System.Windows.Forms.CarbonInternal {
                                                HIViewGetBounds (handle, ref bounds);
                                        }
 
-                                       Driver.AddExpose (hwnd, client, bounds, false);
-
                                        if (!hwnd.visible) {
                                                if (client) {
                                                        hwnd.expose_pending = false;
@@ -141,24 +139,12 @@ namespace System.Windows.Forms.CarbonInternal {
                                                 return false;
                                        }
 
-                                       if (client) {
-                                               if (!hwnd.expose_pending) {
-                                                       return false;
-                                               }
-                                                msg.message = Msg.WM_PAINT;
-                                       } else {
-                                               if (!hwnd.nc_expose_pending) {
-                                                       return false;
-                                               }
-                                               //DrawBackground here
+                                       if (!client) {
                                                DrawBorders (hwnd);
-                                               Region region = new Region (hwnd.Invalid);
-                                               IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
-                                               msg.message = Msg.WM_NCPAINT;
-                                               msg.wParam = hrgn == IntPtr.Zero ? (IntPtr)1 : hrgn;
-                                               msg.refobject = region;
-                                               
                                        }
+
+                                       Driver.AddExpose (hwnd, client, bounds);
+
                                        return true;
                                }
                                case kEventControlVisibilityChanged: {
@@ -201,18 +187,6 @@ namespace System.Windows.Forms.CarbonInternal {
                        return false;
                }
 
-               private void DrawBackground (Hwnd hwnd, IntPtr eventref, HIRect bounds) {
-                       if (XplatUICarbon.WindowBackgrounds [hwnd] != null) {
-                               IntPtr context = IntPtr.Zero;
-                               Color color = (Color) XplatUICarbon.WindowBackgrounds [hwnd];
-
-                               GetEventParameter (eventref, kEventParamCGContextRef, typeCGContextRef, IntPtr.Zero, (uint) Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref context); 
-                               
-                               CGContextSetRGBFillColor (context, (float) color.R / 255, (float) color.G / 255, (float) color.B / 255, (float) color.A / 255);
-                               CGContextFillRect (context, bounds);
-                       }
-               }
-
                private void DrawBorders (Hwnd hwnd) {
                        switch (hwnd.border_style) {
                                case FormBorderStyle.Fixed3D: {
@@ -251,10 +225,5 @@ namespace System.Windows.Forms.CarbonInternal {
                static extern int HIViewGetFrame (IntPtr handle, ref HIRect rect);
                [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                extern static bool HIViewIsVisible (IntPtr vHnd);
-
-               [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
-               static extern int CGContextSetRGBFillColor (IntPtr cgContext, float r, float g, float b, float alpha);
-               [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
-               static extern int CGContextFillRect (IntPtr context, HIRect rect);
        }
 }