internal const uint kEventParamDirectObject = 757935405;
internal const uint kEventParamControlPart = 1668313716;
internal const uint kEventParamControlLikesDrag = 1668047975;
+ internal const uint kEventParamRgnHandle = 1919381096;
internal const uint typeControlRef = 1668575852;
internal const uint typeCGContextRef = 1668183160;
internal const uint typeQDPoint = 1363439732;
+ internal const uint typeQDRgnHandle = 1919381096;
internal const uint typeControlPartCode = 1668313716;
internal const uint typeBoolean = 1651470188;
switch (kind) {
case kEventControlDraw: {
- //TODO: This is a hack which masks our over-redraw-expose problem
- if (client) {
- HIRect bounds = new HIRect ();
+ IntPtr rgn = IntPtr.Zero;
+ HIRect bounds = new HIRect ();
+
+ GetEventParameter (eventref, kEventParamRgnHandle, typeQDRgnHandle, IntPtr.Zero, (uint) Marshal.SizeOf (typeof (IntPtr)), IntPtr.Zero, ref rgn);
+
+ if (rgn != IntPtr.Zero) {
+ Rect rbounds = new Rect ();
+
+ GetRegionBounds (rgn, ref rbounds);
+
+ bounds.origin.x = rbounds.left;
+ bounds.origin.y = rbounds.top;
+ bounds.size.width = rbounds.right - rbounds.left;
+ bounds.size.height = rbounds.bottom - rbounds.top;
+ } else {
HIViewGetBounds (handle, ref bounds);
- Driver.AddExpose (hwnd, client, bounds);
}
if (!hwnd.visible) {
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: {
- HIRect bounds = new HIRect ();
-
- HIViewGetBounds (handle, ref bounds);
- Driver.AddExpose (hwnd, client, bounds);
if (client) {
msg.message = Msg.WM_SHOWWINDOW;
msg.lParam = (IntPtr) 0;
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: {
}
}
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetRegionBounds (IntPtr rgnhandle, ref Rect region);
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int GetEventParameter (IntPtr eventref, uint name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref IntPtr data);
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
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);
}
}