internal static IntPtr XCreateGC(IntPtr display, IntPtr window, IntPtr valuemask, ref XGCValues values) { DebugHelper.TraceWriteLine ("XCreateGC"); return _XCreateGC(display, window, valuemask, ref values); }
internal extern static IntPtr XCreateGC(IntPtr display, IntPtr window, IntPtr valuemask, ref XGCValues values);
internal override void ScrollWindow(IntPtr handle, Rectangle area, int XAmount, int YAmount, bool with_children) { Hwnd hwnd; IntPtr gc; XGCValues gc_values; hwnd = Hwnd.ObjectFromHandle(handle); Rectangle r = Rectangle.Intersect (hwnd.Invalid, area); if (!r.IsEmpty) { /* We have an invalid area in the window we're scrolling. Adjust our stored invalid rectangle to to match the scrolled amount */ r.X += XAmount; r.Y += YAmount; if (r.X < 0) { r.Width += r.X; r.X =0; } if (r.Y < 0) { r.Height += r.Y; r.Y =0; } if (area.Contains (hwnd.Invalid)) hwnd.ClearInvalidArea (); hwnd.AddInvalidArea(r); } gc_values = new XGCValues(); if (with_children) { gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; } gc = XCreateGC(DisplayHandle, hwnd.client_window, IntPtr.Zero, ref gc_values); Rectangle visible_rect = GetTotalVisibleArea (hwnd.client_window); visible_rect.Intersect (area); Rectangle dest_rect = visible_rect; dest_rect.Y += YAmount; dest_rect.X += XAmount; dest_rect.Intersect (area); Point src = new Point (dest_rect.X - XAmount, dest_rect.Y - YAmount); XCopyArea (DisplayHandle, hwnd.client_window, hwnd.client_window, gc, src.X, src.Y, dest_rect.Width, dest_rect.Height, dest_rect.X, dest_rect.Y); Rectangle dirty_area = GetDirtyArea (area, dest_rect, XAmount, YAmount); AddExpose (hwnd, true, dirty_area.X, dirty_area.Y, dirty_area.Width, dirty_area.Height); ProcessGraphicsExpose (hwnd); XFreeGC(DisplayHandle, gc); }
internal override void BlitFromOffscreen (IntPtr dest_handle, Graphics dest_dc, object offscreen_drawable, Graphics offscreen_dc, Rectangle r) { XGCValues gc_values; IntPtr gc; gc_values = new XGCValues(); gc = XCreateGC (DisplayHandle, dest_handle, IntPtr.Zero, ref gc_values); XCopyArea (DisplayHandle, (IntPtr)offscreen_drawable, dest_handle, gc, r.X, r.Y, r.Width, r.Height, r.X, r.Y); XFreeGC (DisplayHandle, gc); }
IntPtr GetReversibleScreenGC (Color backColor) { XGCValues gc_values; IntPtr gc; uint pixel; XColor xcolor = new XColor(); xcolor.red = (ushort)(backColor.R * 257); xcolor.green = (ushort)(backColor.G * 257); xcolor.blue = (ushort)(backColor.B * 257); XAllocColor(DisplayHandle, DefaultColormap, ref xcolor); pixel = (uint)xcolor.pixel.ToInt32(); gc_values = new XGCValues(); gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; gc_values.foreground = (IntPtr)pixel; gc = XCreateGC(DisplayHandle, RootWindow, new IntPtr ((int) (GCFunction.GCSubwindowMode | GCFunction.GCForeground)), ref gc_values); XSetForeground(DisplayHandle, gc, (UIntPtr)pixel); XSetFunction(DisplayHandle, gc, GXFunction.GXxor); return gc; }
IntPtr GetReversibleControlGC (Control control, int line_width) { XGCValues gc_values; IntPtr gc; gc_values = new XGCValues(); gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; gc_values.line_width = line_width; gc_values.foreground = XBlackPixel(DisplayHandle, ScreenNo); // This logic will give us true rubber bands: (libsx, SANE_XOR) //mask = foreground ^ background; //XSetForeground(DisplayHandle, gc, 0xffffffff); //XSetBackground(DisplayHandle, gc, background); //XSetFunction(DisplayHandle, gc, GXxor); //XSetPlaneMask(DisplayHandle, gc, mask); gc = XCreateGC(DisplayHandle, control.Handle, new IntPtr ((int) (GCFunction.GCSubwindowMode | GCFunction.GCLineWidth | GCFunction.GCForeground)), ref gc_values); uint foreground; uint background; XColor xcolor = new XColor(); xcolor.red = (ushort)(control.ForeColor.R * 257); xcolor.green = (ushort)(control.ForeColor.G * 257); xcolor.blue = (ushort)(control.ForeColor.B * 257); XAllocColor(DisplayHandle, DefaultColormap, ref xcolor); foreground = (uint)xcolor.pixel.ToInt32(); xcolor.red = (ushort)(control.BackColor.R * 257); xcolor.green = (ushort)(control.BackColor.G * 257); xcolor.blue = (ushort)(control.BackColor.B * 257); XAllocColor(DisplayHandle, DefaultColormap, ref xcolor); background = (uint)xcolor.pixel.ToInt32(); uint mask = foreground ^ background; XSetForeground(DisplayHandle, gc, (UIntPtr)0xffffffff); XSetBackground(DisplayHandle, gc, (UIntPtr)background); XSetFunction(DisplayHandle, gc, GXFunction.GXxor); XSetPlaneMask(DisplayHandle, gc, (IntPtr)mask); return gc; }
public void BlitFromOffscreen (IntPtr dest_handle, Graphics dest_dc, object offscreen_drawable, Graphics offscreen_dc, Rectangle r) { XGCValues gc_values; IntPtr gc; gc_values = new XGCValues(); gc = Xlib.XCreateGC (display, dest_handle, IntPtr.Zero, ref gc_values); Xlib.XCopyArea (display, (IntPtr)offscreen_drawable, dest_handle, gc, r.X, r.Y, r.Width, r.Height, r.X, r.Y); Xlib.XFreeGC (display, gc); }
internal override void CreateCaret (IntPtr handle, int width, int height) { XGCValues gc_values; Hwnd hwnd; hwnd = Hwnd.ObjectFromHandle(handle); if (Caret.Hwnd != IntPtr.Zero) { DestroyCaret(Caret.Hwnd); } Caret.Hwnd = handle; Caret.Window = hwnd.client_window; Caret.Width = width; Caret.Height = height; Caret.Visible = false; Caret.On = false; gc_values = new XGCValues(); gc_values.line_width = width; Caret.gc = XCreateGC(DisplayHandle, Caret.Window, new IntPtr ((int)GCFunction.GCLineWidth), ref gc_values); if (Caret.gc == IntPtr.Zero) { Caret.Hwnd = IntPtr.Zero; return; } XSetFunction(DisplayHandle, Caret.gc, GXFunction.GXinvert); }
// XXX this should take an X11Hwnd. public void CreateCaret (IntPtr handle, int width, int height) { XGCValues gc_values; X11Hwnd hwnd; hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle); if (Caret.Hwnd != IntPtr.Zero) DestroyCaret(Caret.Hwnd); Caret.Hwnd = handle; Caret.Window = hwnd.ClientWindow; Caret.Width = width; Caret.Height = height; Caret.Visible = false; Caret.On = false; gc_values = new XGCValues(); gc_values.line_width = width; Caret.gc = Xlib.XCreateGC (display, Caret.Window, new IntPtr ((int)GCFunction.GCLineWidth), ref gc_values); if (Caret.gc == IntPtr.Zero) { Caret.Hwnd = IntPtr.Zero; return; } Xlib.XSetFunction (display, Caret.gc, GXFunction.GXinvert); }
internal override void ScrollWindow (IntPtr handle, Rectangle area, int XAmount, int YAmount, bool with_children) { Hwnd hwnd; IntPtr gc; XGCValues gc_values; hwnd = Hwnd.ObjectFromHandle (handle); if (hwnd.invalid != Rectangle.Empty) { // BIG FAT WARNING. This only works with how we use this function right now // where we basically still scroll the whole window, but work around areas // that are covered by our children hwnd.invalid.X += XAmount; hwnd.invalid.Y += YAmount; if (hwnd.invalid.X < 0) { hwnd.invalid.Width += hwnd.invalid.X; hwnd.invalid.X = 0; } if (hwnd.invalid.Y < 0) { hwnd.invalid.Height += hwnd.invalid.Y; hwnd.invalid.Y = 0; } } gc_values = new XGCValues (); if (with_children) { gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; } gc = XCreateGC (DisplayHandle, hwnd.client_window, 0, ref gc_values); XCopyArea (DisplayHandle, hwnd.client_window, hwnd.client_window, gc, area.X - XAmount, area.Y - YAmount, area.Width, area.Height, area.X, area.Y); // Generate an expose for the area exposed by the horizontal scroll if (XAmount > 0) { hwnd.AddInvalidArea (area.X, area.Y, XAmount, area.Height); } else if (XAmount < 0) { hwnd.AddInvalidArea (XAmount + area.X + area.Width, area.Y, -XAmount, area.Height); } // Generate an expose for the area exposed by the vertical scroll if (YAmount > 0) { hwnd.AddInvalidArea (area.X, area.Y, area.Width, YAmount); } else if (YAmount < 0) { hwnd.AddInvalidArea (area.X, YAmount + area.Y + area.Height, area.Width, -YAmount); } XFreeGC (DisplayHandle, gc); UpdateWindow (handle); }
internal override void DrawReversibleRectangle (IntPtr handle, Rectangle rect, int line_width) { Hwnd hwnd; XGCValues gc_values; IntPtr gc; hwnd = Hwnd.ObjectFromHandle (handle); gc_values = new XGCValues (); gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; gc_values.line_width = line_width; gc_values.foreground = XBlackPixel (DisplayHandle, ScreenNo); // This logic will give us true rubber bands: (libsx, SANE_XOR) //mask = foreground ^ background; //XSetForeground(DisplayHandle, gc, 0xffffffff); //XSetBackground(DisplayHandle, gc, background); //XSetFunction(DisplayHandle, gc, GXxor); //XSetPlaneMask(DisplayHandle, gc, mask); gc = XCreateGC (DisplayHandle, hwnd.client_window, GCFunction.GCSubwindowMode | GCFunction.GCLineWidth | GCFunction.GCForeground, ref gc_values); uint foreground; uint background; Control control; control = Control.FromHandle (handle); XColor xcolor = new XColor (); xcolor.red = (ushort)(control.ForeColor.R * 257); xcolor.green = (ushort)(control.ForeColor.G * 257); xcolor.blue = (ushort)(control.ForeColor.B * 257); XAllocColor (DisplayHandle, DefaultColormap, ref xcolor); foreground = (uint)xcolor.pixel.ToInt32 (); xcolor.red = (ushort)(control.BackColor.R * 257); xcolor.green = (ushort)(control.BackColor.G * 257); xcolor.blue = (ushort)(control.BackColor.B * 257); XAllocColor (DisplayHandle, DefaultColormap, ref xcolor); background = (uint)xcolor.pixel.ToInt32 (); uint mask = foreground ^ background; XSetForeground (DisplayHandle, gc, 0xffffffff); XSetBackground (DisplayHandle, gc, background); XSetFunction (DisplayHandle, gc, GXFunction.GXxor); XSetPlaneMask (DisplayHandle, gc, mask); if ((rect.Width > 0) && (rect.Height > 0)) { XDrawRectangle (DisplayHandle, hwnd.client_window, gc, rect.Left, rect.Top, rect.Width, rect.Height); } else { if (rect.Width > 0) { XDrawLine (DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.Right, rect.Y); } else { XDrawLine (DisplayHandle, hwnd.client_window, gc, rect.X, rect.Y, rect.X, rect.Bottom); } } XFreeGC (DisplayHandle, gc); }
public void DrawReversibleRectangle (Rectangle rect, int line_width) { XGCValues gc_values; IntPtr gc; gc_values = new XGCValues (); gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; gc_values.line_width = line_width; // XXX multiscreen support gc_values.foreground = Xlib.XBlackPixel (display.Handle, display.DefaultScreen); // This logic will give us true rubber bands: (libsx, SANE_XOR) //mask = foreground ^ background; //XSetForeground(DisplayHandle, gc, 0xffffffff); //XSetBackground(DisplayHandle, gc, background); //XSetFunction(DisplayHandle, gc, GXxor); //XSetPlaneMask(DisplayHandle, gc, mask); gc = Xlib.XCreateGC (display.Handle, ClientWindow, new IntPtr ((int) (GCFunction.GCSubwindowMode | GCFunction.GCLineWidth | GCFunction.GCForeground)), ref gc_values); uint foreground; uint background; Control control; control = Control.FromHandle(Handle); XColor xcolor = new XColor(); xcolor.red = (ushort)(control.ForeColor.R * 257); xcolor.green = (ushort)(control.ForeColor.G * 257); xcolor.blue = (ushort)(control.ForeColor.B * 257); Xlib.XAllocColor (display.Handle, display.DefaultColormap, ref xcolor); foreground = (uint)xcolor.pixel.ToInt32(); xcolor.red = (ushort)(control.BackColor.R * 257); xcolor.green = (ushort)(control.BackColor.G * 257); xcolor.blue = (ushort)(control.BackColor.B * 257); Xlib.XAllocColor (display.Handle, display.DefaultColormap, ref xcolor); background = (uint)xcolor.pixel.ToInt32(); uint mask = foreground ^ background; Xlib.XSetForeground (display.Handle, gc, (UIntPtr)0xffffffff); Xlib.XSetBackground (display.Handle, gc, (UIntPtr)background); Xlib.XSetFunction (display.Handle, gc, GXFunction.GXxor); Xlib.XSetPlaneMask (display.Handle, gc, (IntPtr)mask); if ((rect.Width > 0) && (rect.Height > 0)) Xlib.XDrawRectangle (display.Handle, ClientWindow, gc, rect.Left, rect.Top, rect.Width, rect.Height); else if (rect.Width > 0) Xlib.XDrawLine (display.Handle, ClientWindow, gc, rect.X, rect.Y, rect.Right, rect.Y); else Xlib.XDrawLine (display.Handle, ClientWindow, gc, rect.X, rect.Y, rect.X, rect.Bottom); Xlib.XFreeGC (display.Handle, gc); }
public void ScrollWindow (Rectangle area, int XAmount, int YAmount, bool with_children) { IntPtr gc; XGCValues gc_values; Rectangle r = Rectangle.Intersect (Invalid, area); if (!r.IsEmpty) { /* We have an invalid area in the window we're scrolling. Adjust our stored invalid rectangle to to match the scrolled amount */ r.X += XAmount; r.Y += YAmount; if (r.X < 0) { r.Width += r.X; r.X =0; } if (r.Y < 0) { r.Height += r.Y; r.Y =0; } if (area.Contains (Invalid)) ClearInvalidArea(); AddInvalidArea(r); } gc_values = new XGCValues(); gc_values.graphics_exposures = false; if (with_children) gc_values.subwindow_mode = GCSubwindowMode.IncludeInferiors; gc = Xlib.XCreateGC (display.Handle, ClientWindow, IntPtr.Zero, ref gc_values); int src_x, src_y; int dest_x, dest_y; int width, height; if (YAmount > 0) { src_y = area.Y; height = area.Height - YAmount; dest_y = area.Y + YAmount; } else { src_y = area.Y - YAmount; height = area.Height + YAmount; dest_y = area.Y; } if (XAmount > 0) { src_x = area.X; width = area.Width - XAmount; dest_x = area.X + XAmount; } else { src_x = area.X - XAmount; width = area.Width + XAmount; dest_x = area.X; } Xlib.XCopyArea (display.Handle, ClientWindow, ClientWindow, gc, src_x, src_y, width, height, dest_x, dest_y); // Generate an expose for the area exposed by the horizontal scroll // We don't use AddExpose since we're if (XAmount > 0) { AddExpose (true, area.X, area.Y, XAmount, area.Height); } else if (XAmount < 0) { AddExpose (true, XAmount + area.X + area.Width, area.Y, -XAmount, area.Height); } // Generate an expose for the area exposed by the vertical scroll if (YAmount > 0) { AddExpose (true, area.X, area.Y, area.Width, YAmount); } else if (YAmount < 0) { AddExpose (true, area.X, YAmount + area.Y + area.Height, area.Width, -YAmount); } Xlib.XFreeGC (display.Handle, gc); }