internal override void OnMotionNotify(int x, int y, Gdk.ModifierType mod) { bool prev = prevButtonRect.Contains(x, y); bool next = nextButtonRect.Contains(x, y); if (prev != prevHovered || next != nextHovered) { prevHovered = prev; nextHovered = next; ResetButtons(); QueueRepaint(); } }
private void OnAddinSizeAllocated(object o, SizeAllocatedArgs args) { ScrolledWindow scroll; if (Parent == null || (scroll = Parent.Parent as ScrolledWindow) == null) { return; } AddinTile tile = (AddinTile)o; if (tiles.IndexOf(tile) != selected_index) { return; } Gdk.Rectangle ta = ((AddinTile)o).Allocation; Gdk.Rectangle va = new Gdk.Rectangle(0, (int)scroll.Vadjustment.Value, Allocation.Width, Parent.Allocation.Height); if (!va.Contains(ta)) { double delta = 0.0; if (ta.Bottom > va.Bottom) { delta = ta.Bottom - va.Bottom; } else if (ta.Top < va.Top) { delta = ta.Top - va.Top; } scroll.Vadjustment.Value += delta; QueueDraw(); } }
public bool Contains(int x, int y, Atk.CoordType coordType) { int x_extents, y_extents, w, h; GetExtents(out x_extents, out y_extents, out w, out h, coordType); Gdk.Rectangle extents = new Gdk.Rectangle(x_extents, y_extents, w, h); return(extents.Contains(x, y)); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt) { var so = starRect.Contains(Allocation.X + (int)evnt.X, Allocation.Y + (int)evnt.Y); if (so != mouseOverStar) { mouseOverStar = so; QueueDraw(); } return(base.OnMotionNotifyEvent(evnt)); }
public bool GetDockTarget(DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect) { dockDelegate = null; if (item != this.item && this.item.Visible && rect.Contains(px, py)) { int xdockMargin = (int)((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2; int ydockMargin = (int)((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2; DockPosition pos; /* if (ParentGroup.Type == DockGroupType.Tabbed) { * rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2); * pos = DockPosition.CenterAfter; * } */ if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) { outrect = new Gdk.Rectangle(rect.X, rect.Y, xdockMargin, rect.Height); pos = DockPosition.Left; } else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) { outrect = new Gdk.Rectangle(rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height); pos = DockPosition.Right; } else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical) { outrect = new Gdk.Rectangle(rect.X, rect.Y, rect.Width, ydockMargin); pos = DockPosition.Top; } else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical) { outrect = new Gdk.Rectangle(rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin); pos = DockPosition.Bottom; } else { outrect = new Gdk.Rectangle(rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin * 2, rect.Height - ydockMargin * 2); pos = DockPosition.Center; } dockDelegate = delegate(DockItem dit) { DockGroupItem it = ParentGroup.AddObject(dit, pos, Id); it.SetVisible(true); ParentGroup.FocusItem(it); }; return(true); } outrect = Gdk.Rectangle.Zero; return(false); }
int HitGripper(int x) { int[] gripper = GripperPositions(); for (int i = 0; i < gripper.Length; i++) { Gdk.Rectangle rect = new Gdk.Rectangle(gripper[i], 0, 5, TotalHeight); if (rect.Contains(x, 0)) { return(i); } } return(-1); }
int HitGripper(int x) { var gripper = GripperPositions(); foreach (var g in gripper) { int xv = g.Value; Gdk.Rectangle rect = new Gdk.Rectangle(xv - GripperWidth, 0, GripperWidth, TotalHeight); if (rect.Contains(x, 0)) { return(g.Key); } } return(-1); }
protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { bool ret = base.OnButtonPressEvent(evnt); state = Theme.ButtonState.Pressed; if (!enable) { state = Theme.ButtonState.Default; } this.QueueDraw(); if (dropDownMenu != null && arrowAllocation.Contains((int)evnt.X, (int)evnt.Y)) { Popup(); } return(ret); }
Widget FindWrapper(Gtk.Widget top, int x, int y) { Widget wrapper; Gtk.Container container = top as Gtk.Container; if (container != null) { foreach (Gtk.Widget child in container.AllChildren) { if (!child.IsDrawable) { continue; } Gdk.Rectangle alloc = child.Allocation; if (alloc.Contains(x, y)) { if (child.GdkWindow == top.GdkWindow) { wrapper = FindWrapper(child, x, y); } else { wrapper = FindWrapper(child, x - alloc.X, y - alloc.Y); } if (wrapper != null) { return(wrapper); } } } } wrapper = Lookup(top); if (wrapper == null || wrapper.Unselectable) { return(null); } return(wrapper); }
public unsafe override void Render(ImageSurface src, ImageSurface dst, Gdk.Rectangle[] rois) { if (Data.Amount == 0) { // Copy src to dest return; } int src_width = src.Width; ColorBgra *src_data_ptr = (ColorBgra *)src.DataPtr; int dst_width = dst.Width; ColorBgra *dst_data_ptr = (ColorBgra *)dst.DataPtr; Gdk.Rectangle src_bounds = src.GetBounds(); long w = dst.Width; long h = dst.Height; long fox = (long)(dst.Width * Data.Offset.X * 32768.0); long foy = (long)(dst.Height * Data.Offset.Y * 32768.0); long fcx = fox + (w << 15); long fcy = foy + (h << 15); long fz = Data.Amount; const int n = 64; foreach (Gdk.Rectangle rect in rois) { for (int y = rect.Top; y <= rect.GetBottom(); ++y) { ColorBgra *dstPtr = dst.GetPointAddressUnchecked(dst_data_ptr, dst_width, rect.Left, y); ColorBgra *srcPtr = src.GetPointAddressUnchecked(src_data_ptr, src_width, rect.Left, y); for (int x = rect.Left; x <= rect.GetRight(); ++x) { long fx = (x << 16) - fcx; long fy = (y << 16) - fcy; int sr = 0; int sg = 0; int sb = 0; int sa = 0; int sc = 0; sr += srcPtr->R * srcPtr->A; sg += srcPtr->G * srcPtr->A; sb += srcPtr->B * srcPtr->A; sa += srcPtr->A; ++sc; for (int i = 0; i < n; ++i) { fx -= ((fx >> 4) * fz) >> 10; fy -= ((fy >> 4) * fz) >> 10; int u = (int)(fx + fcx + 32768 >> 16); int v = (int)(fy + fcy + 32768 >> 16); if (src_bounds.Contains(u, v)) { ColorBgra *srcPtr2 = src.GetPointAddressUnchecked(src_data_ptr, src_width, u, v); sr += srcPtr2->R * srcPtr2->A; sg += srcPtr2->G * srcPtr2->A; sb += srcPtr2->B * srcPtr2->A; sa += srcPtr2->A; ++sc; } } if (sa != 0) { *dstPtr = ColorBgra.FromBgra( Utility.ClampToByte(sb / sa), Utility.ClampToByte(sg / sa), Utility.ClampToByte(sr / sa), Utility.ClampToByte(sa / sc)); } else { dstPtr->Bgra = 0; } ++srcPtr; ++dstPtr; } } } }
public bool Contains (int x, int y, Atk.CoordType coordType) { int x_extents, y_extents, w, h; GetExtents (out x_extents, out y_extents, out w, out h, coordType); Gdk.Rectangle extents = new Gdk.Rectangle (x_extents, y_extents, w, h); return extents.Contains (x, y); }
private void OnTileSizeAllocated (object o, SizeAllocatedArgs args) { ScrolledWindow scroll; if (Parent == null || (scroll = Parent.Parent as ScrolledWindow) == null) { return; } Tile tile = (Tile)o; if (tiles.IndexOf (tile) != selected_index) { return; } Gdk.Rectangle ta = ((Tile)o).Allocation; Gdk.Rectangle va = new Gdk.Rectangle (0, (int)scroll.Vadjustment.Value, Allocation.Width, Parent.Allocation.Height); if (!va.Contains (ta)) { double delta = 0.0; if (ta.Bottom > va.Bottom) { delta = ta.Bottom - va.Bottom; } else if (ta.Top < va.Top) { delta = ta.Top - va.Top; } scroll.Vadjustment.Value += delta; QueueDraw(); } }
int HitGripper(int x) { var gripper = GripperPositions(); foreach (var g in gripper) { int xv = g.Value; Gdk.Rectangle rect = new Gdk.Rectangle(xv - GripperWidth, 0, GripperWidth, TotalHeight); if (rect.Contains(x, 0)) return g.Key; } return -1; }
public virtual void DrawTicks(Gdk.Rectangle allocation, Cairo.Context cr) { if (!show_ticks) { return; } // no data in plots if (min == Double.PositiveInfinity && max == Double.NegativeInfinity) { return; } // recalculate the tick interval, since our available // width probably has changed since SizeRequest double interval, start; GetTickStartAndInterval(allocation, out start, out interval); sig_figs = Math.Max(GetSignificantFigures(start), GetSignificantFigures(interval)) + 2; for (double tick = start; tick < max; tick += interval) { int x = 0, y = 0; if (location == AxisLocation.Top) { x = Convert.ToInt32((((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Width) + allocation.X); y = allocation.Y + allocation.Height; style.DrawAxisTick(cr, x, y, location); } else if (location == AxisLocation.Bottom) { x = Convert.ToInt32((((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Width) + allocation.X); y = allocation.Y; style.DrawAxisTick(cr, x, y, location); } else if (location == AxisLocation.Left) { x = allocation.X + allocation.Width - style.TickLineSize; y = allocation.Y + allocation.Height - Convert.ToInt32(((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Height); style.DrawAxisTick(cr, x, y, AxisLocation.Left); } else if (location == AxisLocation.Right) { x = allocation.X; y = allocation.Y + allocation.Height - Convert.ToInt32(((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Height); style.DrawAxisTick(cr, x, y, AxisLocation.Left); } if (!show_tick_labels) { continue; } int width, height; style.GetAxisLabelMetrics(GetTickLabelName(tick), out width, out height); int label_x = 0, label_y = 0; if (location == AxisLocation.Top) { label_x = x - (width / 2); label_y = y - style.TickLineSize - height; } else if (location == AxisLocation.Bottom) { label_x = x - (width / 2); label_y = y + style.TickLineSize + padding; } else if (location == AxisLocation.Left) { label_x = x - padding - width; label_y = y - (height / 2); } else if (location == AxisLocation.Right) { label_x = x + style.TickLineSize + padding; label_y = y - (height / 2); } // Don't draw an axis label if it won't // completely fit in the allocation if (allocation.Contains(label_x, label_y) && allocation.Contains(label_x + width, label_y + height)) { style.DrawAxisLabel(cr, GetTickLabelName(tick), label_x, label_y); } } }
public void DrawTicks(Gdk.Rectangle allocation, Cairo.Context cr) { if (!show_ticks) { return; } // no data in plots if (min == DateTime.MaxValue && max == DateTime.MinValue) { return; } // recalculate the tick interval, since our available // width probably has changed since SizeRequest DateTime start = real_min; TimeSpan interval = new TimeSpan(DateTime.DaysInMonth(start.Year, start.Month), 0, 0, 0); //GetTickStartAndInterval (allocation, out start, out interval); for (DateTime tick = start; tick < max; tick += interval) { int x = 0, y = 0; if (location == AxisLocation.Top) { x = Convert.ToInt32((((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Width) + allocation.X); y = allocation.Y + allocation.Height; style.DrawAxisTick(cr, x, y, location); } else if (location == AxisLocation.Bottom) { x = Convert.ToInt32((((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Width) + allocation.X); y = allocation.Y; style.DrawAxisTick(cr, x, y, location); } else if (location == AxisLocation.Left) { x = allocation.X + allocation.Width - style.TickLineSize; y = allocation.Y + allocation.Height - Convert.ToInt32(((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Height); style.DrawAxisTick(cr, x, y, location); } else if (location == AxisLocation.Right) { x = allocation.X; y = allocation.Y + allocation.Height - Convert.ToInt32(((double)ValueToGridCoords(tick) / GRID_MAX) * allocation.Height); style.DrawAxisTick(cr, x, y, location); } if (!show_tick_labels) { continue; } int width, height; style.GetAxisLabelMetrics(GetTickLabelName(tick), out width, out height); int label_x = 0, label_y = 0; if (location == AxisLocation.Top) { label_x = x - (width / 2); label_y = y - style.TickLineSize - height; } else if (location == AxisLocation.Bottom) { label_x = x - (width / 2); label_y = y + style.TickLineSize + padding; } else if (location == AxisLocation.Left) { label_x = x - padding - width; label_y = y - (height / 2); } else if (location == AxisLocation.Right) { label_x = x + style.TickLineSize + padding; label_y = y - (height / 2); } // Don't draw an axis label if it won't // completely fit in the allocation if (allocation.Contains(label_x, label_y) && allocation.Contains(label_x + width, label_y + height)) { style.DrawAxisLabel(cr, GetTickLabelName(tick), label_x, label_y); } interval = new TimeSpan(DateTime.DaysInMonth(tick.Year, tick.Month), 0, 0, 0); } }