public void SetAllocation(IWidgetBackend [] widget, Rectangle [] rect) { for (int i = 0; i < widget.Length; i++) { var e = GetFrameworkElement (widget [i]); e.Arrange (DataConverter.ToWpfRect (rect [i])); } }
public void SetChild(IWidgetBackend child) { var w = (IGtkWidgetBackend) child; if (alignment.Child != null) alignment.Remove (alignment.Child); alignment.Child = w.Widget; }
public void SetContent(IWidgetBackend child) { if (child == null) Widget.Content = null; else Widget.Content = child.NativeWidget; }
public void SetContent (IWidgetBackend widget) { if (widget == null) CheckBox.Content = null; else CheckBox.Content = widget.NativeWidget; }
public void SetChildBounds(IWidgetBackend widget, Rectangle bounds) { FrameworkElement element = widget.NativeWidget as FrameworkElement; if (element == null) throw new ArgumentException (); SWC.Canvas.SetTop (element, bounds.Top); SWC.Canvas.SetLeft (element, bounds.Left); var h = bounds.Height; var w = bounds.Width; h = (h > 0) ? h : 0; w = (w > 0) ? w : 0; // Measure the widget again using the allocation constraints. This is necessary // because WPF widgets my cache some measurement information based on the // constraints provided in the last Measure call (which when calculating the // preferred size is normally set to infinite. element.InvalidateMeasure (); element.Measure (new System.Windows.Size (w, h)); element.Height = h; element.Width = w; element.UpdateLayout (); }
public void SetContent(IWidgetBackend widget) { if (widget == null) RadioButton.Content = null; else RadioButton.Content = widget.NativeWidget; }
public void SetChildBounds(IWidgetBackend widget, Rectangle bounds) { FrameworkElement element = widget.NativeWidget as FrameworkElement; if (element == null) throw new ArgumentException (); SWC.Canvas.SetTop (element, bounds.Top); SWC.Canvas.SetLeft (element, bounds.Left); // We substract the widget margin here because the size we are assigning is the actual size, not including the WPF marings var h = bounds.Height - ((WidgetBackend)widget).Frontend.Margin.VerticalSpacing; var w = bounds.Width - ((WidgetBackend)widget).Frontend.Margin.HorizontalSpacing; h = (h > 0) ? h : 0; w = (w > 0) ? w : 0; // Measure the widget again using the allocation constraints. This is necessary // because WPF widgets my cache some measurement information based on the // constraints provided in the last Measure call (which when calculating the // preferred size is normally set to infinite. element.InvalidateMeasure (); element.Measure (new System.Windows.Size (w, h)); element.Height = h; element.Width = w; element.UpdateLayout (); }
public void SetChild (IWidgetBackend child) { if (alignment.Child != null) { WidgetBackend.RemoveChildPlacement (alignment.Child); alignment.Remove (alignment.Child); } alignment.Child = WidgetBackend.GetWidgetWithPlacement (child); }
public void RemoveChild(IWidgetBackend widget) { UIElement element = widget.NativeWidget as UIElement; if (element == null) throw new ArgumentException (); Canvas.Children.Remove (element); }
public void SetContent(IWidgetBackend widget) { var newWidget = GetWidget (widget); var oldWidget = Widget.Child; if (oldWidget == null) Widget.Child = newWidget; else GtkEngine.ReplaceChild (oldWidget, newWidget); }
public void SetChild(IWidgetBackend child) { if (widget != null) rootPanel.Children.Remove(widget); widget = ((IWpfWidgetBackend)child).Widget; DockPanel.SetDock (widget, Dock.Bottom); rootPanel.Children.Add(widget); }
public void SetPanel (int panel, IWidgetBackend widget, bool resize, bool shrink) { if (panel == 1) { RemoveChildPlacement (Widget.Child1); Widget.Pack1 (GetWidgetWithPlacement (widget), resize, shrink); } else { RemoveChildPlacement (Widget.Child2); Widget.Pack2 (GetWidgetWithPlacement (widget), resize, shrink); } }
public void Init(IWindowFrameBackend parent, IWidgetBackend child, Xwt.Popover.Position orientation) { popover = new PopoverWindow ((Gtk.Widget)child.NativeWidget, orientation); popover.TransientFor = ((WindowFrameBackend)parent).Window; popover.DestroyWithParent = true; popover.Hidden += (o, args) => { if (Closed != null) Closed (this, EventArgs.Empty); }; }
public void AddChild (IWidgetBackend widget, Rectangle bounds) { UIElement element = widget.NativeWidget as UIElement; if (element == null) throw new ArgumentException (); if (!Canvas.Children.Contains (element)) Canvas.Children.Add (element); SetChildBounds (widget, bounds); }
public void SetContent (IWidgetBackend widget) { if (widget != null) { child = (Widget)((WidgetBackend)widget).Frontend; UserControl.Content = widget.NativeWidget; } else { child = null; UserControl.Content = null; } }
public void SetAllocation(IWidgetBackend[] widgets, Rectangle[] rects) { bool changed = false; for (int n=0; n<widgets.Length; n++) { var w = GetWidget (widgets[n]); if (Widget.SetAllocation (w, rects[n])) changed = true; } if (changed && !Widget.IsReallocating) Widget.QueueResize (); }
public void Run(IWidgetBackend referenceWidget) { var reference = ((WidgetBackend)referenceWidget).Frontend; var position = new Point (reference.ScreenBounds.Center.X, popover.ArrowPosition == Popover.Position.Top ? reference.ScreenBounds.Bottom : reference.ScreenBounds.Top); popover.ShowAll (); popover.GrabFocus (); int w, h; popover.GetSize (out w, out h); popover.Move ((int)position.X - w / 2, (int)position.Y); popover.SizeAllocated += (o, args) => { popover.Move ((int)position.X - args.Allocation.Width / 2, (int)position.Y); popover.GrabFocus (); }; }
public void SetChildBounds (IWidgetBackend widget, Rectangle bounds) { int i = children.IndexOf (widget); if (i == -1) { children.Add (widget); childrenBounds.Add (bounds); } else { childrenBounds[i] = bounds; } Canvas.SetAllocation (children.ToArray (), childrenBounds.ToArray ()); }
public void RemoveChild(IWidgetBackend widget) { UIElement element = widget.NativeWidget as UIElement; if (element == null) throw new ArgumentException (); Canvas.Children.Remove (element); int i = children.IndexOf (widget); if (i != -1) { children.RemoveAt (i); childrenBounds.RemoveAt (i); } }
public void SetHeaderContent (IWidgetBackend backend) { if (toolbar.Child != null) { WidgetBackend.RemoveChildPlacement (toolbar.Child); toolbar.Remove (toolbar.Child); } if (backend != null) { toolbar.Child = WidgetBackend.GetWidgetWithPlacement (backend); toolbar.Show (); } else { toolbar.Hide (); } }
public void SetContent (IWidgetBackend widget) { childBackend = (WidgetBackend)widget; var newWidget = GetWidgetWithPlacement (widget); var oldWidget = Widget.Child; if (oldWidget == null) Widget.Child = newWidget; else { GtkEngine.ReplaceChild (oldWidget, newWidget); RemoveChildPlacement (oldWidget); } }
public void SetChildBounds (IWidgetBackend widget, Rectangle bounds) { int i = children.IndexOf (widget); if (i == -1) { children.Add (widget); childrenBounds.Add (bounds); i = children.Count - 1; } else { childrenBounds[i] = bounds; } // calling this normally causes the every existing child to be remeasured again // instead tell it which child specifically needs to be placed Canvas.SetAllocation (children.ToArray (), childrenBounds.ToArray (), i); }
public void SetContent (IWidgetBackend child) { Gtk.Bin parent = paddingAlign != null ? paddingAlign : Widget; if (parent.Child != null) { RemoveChildPlacement (parent.Child); parent.Remove (parent.Child); } if (child != null) { var w = GetWidgetWithPlacement (child); parent.Child = w; } else { parent.Child = null; } }
public void Remove (IWidgetBackend widget) { UIElement element = widget.NativeWidget as UIElement; if (element == null) throw new ArgumentException (); FrameworkElement felement = element as FrameworkElement; if (felement != null) felement.Loaded -= OnContentLoaded; for (int i = 0; i < TabControl.Items.Count; ++i) { TabItem tab = (TabItem)TabControl.Items [i]; if (tab.Content == widget.NativeWidget) { TabControl.Items.RemoveAt (i); break; } } }
public void SetChildBounds(IWidgetBackend widget, Rectangle bounds) { FrameworkElement element = widget.NativeWidget as FrameworkElement; if (element == null) throw new ArgumentException (); SWC.Canvas.SetTop (element, bounds.Top); SWC.Canvas.SetLeft (element, bounds.Left); // We substract the widget margin here because the size we are assigning is the actual size, not including the WPF marings var h = bounds.Height - ((WidgetBackend)widget).Frontend.Margin.VerticalSpacing; var w = bounds.Width - ((WidgetBackend)widget).Frontend.Margin.HorizontalSpacing; element.Height = (h > 0) ? h : 0; element.Width = (w > 0) ? w : 0; ((FrameworkElement)widget.NativeWidget).UpdateLayout (); }
public void Add(IWidgetBackend widget, NotebookTab tab) { UIElement element = (UIElement)widget.NativeWidget; TabItem ti = new TabItem { Content = element, Header = tab.Label, Tag = tab }; FrameworkElement felement = element as FrameworkElement; if (felement != null) { felement.Tag = widget; felement.Loaded += OnContentLoaded; } TabControl.Items.Add (ti); if (TabControl.SelectedIndex == -1) TabControl.SelectedIndex = 0; }
public void SetChild (IWidgetBackend child) { RemoveChildPlacement (currentChild); if (Widget.Child != null) { if (Widget.Child is Gtk.Bin) { Gtk.Bin vp = (Gtk.Bin) Widget.Child; vp.Remove (vp.Child); } Widget.Remove (Widget.Child); } if (child != null) { var w = currentChild = GetWidgetWithPlacement (child); WidgetBackend wb = (WidgetBackend) child; if (wb.EventSink.SupportsCustomScrolling ()) { CustomViewPort vp = new CustomViewPort (wb.EventSink); vp.Show (); vp.Add (w); Widget.Child = vp; } else if (w is Gtk.Viewport) Widget.Child = w; else { Gtk.Viewport vp = new Gtk.Viewport (); vp.Show (); vp.Add (w); Widget.Child = vp; } } UpdateBorder (); }
public void Add(IWidgetBackend widget) { Widget.Add(GetWidget(widget)); }
public void SetContent(IWidgetBackend widget) { }
public void SetChildBounds(IWidgetBackend widget, Rectangle bounds) { var w = ((IGtkWidgetBackend)widget).Widget; Widget.SetAllocation(w, bounds); }
public void Initialize(IWidgetBackend parentWidget, IAccessibleEventSink eventSink) { var parentBackend = parentWidget as ViewBackend; Initialize(parentBackend?.Widget, eventSink); }
public void Initialize(IWidgetBackend parentWidget, IAccessibleEventSink eventSink) { }
public virtual void UpdateChildPlacement(IWidgetBackend childBackend) { SetChildPlacement(childBackend); }
public void Add(IWidgetBackend widget) { ViewBackend b = (ViewBackend)widget; Widget.AddSubview(b.Widget); }
public void RemoveChild(IWidgetBackend widget) { var v = GetWidget(widget); v.RemoveFromSuperview(); }
public void OnReallocate() { var size = Backend.Size; var placements = (ChildrenCollection <BoxPlacement>)GetFieldValuePrivate(typeof(Box), owner, "children"); double spacing = owner.Spacing; var visibleChildren = placements.Where(c => c.Child.Visible).ToArray(); IWidgetBackend[] widgets = new IWidgetBackend[visibleChildren.Length]; Rectangle[] rects = new Rectangle[visibleChildren.Length]; if (size.Width <= 0 || size.Height <= 0) { var ws = visibleChildren.Select(bp => bp.Child.GetBackend()).ToArray(); Backend.SetAllocation(ws, new Rectangle[visibleChildren.Length]); return; } else { if (direction == Orientation.Horizontal) { var nextsize = CalcDefaultSizes(size.Width, size.Height, true); double xs = 0; double xe = size.Width + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren[n]; double availableWidth = nextsize[bp] >= 0 ? nextsize[bp] : 0; if (bp.PackOrigin == PackOrigin.End) { xe -= availableWidth + spacing; } var slot = new Rectangle(bp.PackOrigin == PackOrigin.Start ? xs : xe, 0, availableWidth, size.Height); widgets[n] = bp.Child.GetBackend(); rects[n] = bp.Child.Surface.GetPlacementInRect(slot).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { xs += availableWidth + spacing; } } } else { var nextsize = CalcDefaultSizes(size.Width, size.Height, true); double ys = 0; double ye = size.Height + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren[n]; double availableHeight = nextsize[bp] >= 0 ? nextsize[bp] : 0; if (bp.PackOrigin == PackOrigin.End) { ye -= availableHeight + spacing; } var slot = new Rectangle(0, bp.PackOrigin == PackOrigin.Start ? ys : ye, size.Width, availableHeight); widgets[n] = bp.Child.GetBackend(); rects[n] = bp.Child.Surface.GetPlacementInRect(slot).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { ys += availableHeight + spacing; } } } Backend.SetAllocation(widgets, rects); } /* foreach (var w in visibleChildren.Select(bp => bp.Child)) * { * w.QueueForReallocate(); * }*/ }
public void Remove(IWidgetBackend widget) { Widget.Remove(GetWidget(widget)); }
public void Add(IWidgetBackend widget) { WidgetBackend wb = (WidgetBackend)widget; Widget.Add(wb.Frontend, GetWidget(widget)); }
public void RemoveChild(IWidgetBackend widget) { var w = ((IGtkWidgetBackend)widget).Widget; Widget.Remove(w); }
public void SetChild(IWidgetBackend child) { if (child != null) { var w = GetWidget (child); if (w is Gtk.Viewport) Widget.Child = w; else Widget.AddWithViewport (w); } else Widget.Child = null; }
public void Popup(IWidgetBackend widget, double x, double y) { NSMenu.PopUpContextMenu(this, NSApplication.SharedApplication.CurrentEvent, ((ViewBackend)widget).Widget, null); }
public void Popup(IWidgetBackend widget, double x, double y) { throw new NotImplementedException(); }
protected override void OnReallocate() { var size = Backend.Size; if (size.Width <= 0 || size.Height <= 0) { return; } var visibleChildren = children.Where(c => c.Child.Visible).ToArray(); IWidgetBackend[] widgets = new IWidgetBackend [visibleChildren.Length]; Rectangle[] rects = new Rectangle [visibleChildren.Length]; if (direction == Orientation.Horizontal) { CalcDefaultSizes(size.Width, size.Height); double xs = 0; double xe = size.Width + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; if (bp.PackOrigin == PackOrigin.End) { xe -= bp.NextSize + spacing; } double width = bp.NextSize >= 0 ? bp.NextSize : 0; double height = size.Height - bp.Child.Margin.VerticalSpacing; if (bp.Child.VerticalPlacement != WidgetPlacement.Fill) { height = Math.Min(bp.Child.Surface.GetPreferredSize(width, SizeConstraint.Unconstrained).Height, height); } double x = bp.PackOrigin == PackOrigin.Start ? xs : xe; double y = (size.Height - bp.Child.Margin.VerticalSpacing - height) * bp.Child.VerticalPlacement.GetValue(); widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = new Rectangle(x + bp.Child.MarginLeft, y + bp.Child.MarginTop, width, height).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { xs += bp.NextSize + bp.Child.Margin.HorizontalSpacing + spacing; } } } else { CalcDefaultSizes(size.Width, size.Height); double ys = 0; double ye = size.Height + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; if (bp.PackOrigin == PackOrigin.End) { ye -= bp.NextSize + spacing; } double height = bp.NextSize >= 0 ? bp.NextSize : 0; double width = size.Width - bp.Child.Margin.HorizontalSpacing; if (bp.Child.HorizontalPlacement != WidgetPlacement.Fill) { width = Math.Min(bp.Child.Surface.GetPreferredSize(SizeConstraint.Unconstrained, height).Width, width); } double x = (size.Width - bp.Child.Margin.HorizontalSpacing - width) * bp.Child.HorizontalPlacement.GetValue(); double y = bp.PackOrigin == PackOrigin.Start ? ys : ye; widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = new Rectangle(x + bp.Child.MarginLeft, y + bp.Child.MarginTop, width, height).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { ys += bp.NextSize + bp.Child.Margin.VerticalSpacing + spacing; } } } Backend.SetAllocation(widgets, rects); if (!BackendHost.EngineBackend.HandlesSizeNegotiation) { foreach (var bp in visibleChildren) { bp.Child.Surface.Reallocate(); } } }
public void Popup(IWidgetBackend widget, double x, double y) { GtkWorkarounds.ShowContextMenu(Menu, ((WidgetBackend)widget).Widget, new Gdk.Rectangle((int)x, (int)y, 0, 0)); }
public void Add(IWidgetBackend widget) { IMacViewBackend b = (IMacViewBackend)widget; Widget.AddSubview(b.View); }
public static Gtk.Widget GetWidget(IWidgetBackend w) { return(w != null ? ((IGtkWidgetBackend)w).Widget : null); }
public void Remove(IWidgetBackend widget) { Widget.Remove(GetWidgetWithPlacement(widget)); }
public void Add(IWidgetBackend widget) { Widget.Children.Add(GetFrameworkElement(widget)); }
public void UpdateLabel(NotebookTab tab, string hint) { IWidgetBackend widget = (IWidgetBackend)WidgetRegistry.GetBackend(tab.Child); Widget.SetTabLabel(GetWidget(widget), CreateLabel(tab)); }
public void Add(IWidgetBackend widget, NotebookTab tab) { Widget.AppendPage(GetWidget(widget), CreateLabel(tab)); }
protected override void OnReallocate() { var size = Backend.Size; var visibleChildren = children.Where(c => c.Child.Visible).ToArray(); IWidgetBackend[] widgets = new IWidgetBackend [visibleChildren.Length]; Rectangle[] rects = new Rectangle [visibleChildren.Length]; if (direction == Orientation.Horizontal) { CalcDefaultSizes(((IWidgetSurface)this).SizeRequestMode, size.Width, size.Height); double xs = 0; double xe = size.Width + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; if (bp.PackOrigin == PackOrigin.End) { xe -= bp.NextSize + spacing; } double x = bp.PackOrigin == PackOrigin.Start ? xs : xe; widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = new Rectangle(x, 0, bp.NextSize, size.Height); if (bp.PackOrigin == PackOrigin.Start) { xs += bp.NextSize + spacing; } } } else { CalcDefaultSizes(((IWidgetSurface)this).SizeRequestMode, size.Height, size.Width); double ys = 0; double ye = size.Height + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; if (bp.PackOrigin == PackOrigin.End) { ye -= bp.NextSize + spacing; } double y = bp.PackOrigin == PackOrigin.Start ? ys : ye; widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = new Rectangle(0, y, size.Width, bp.NextSize); if (bp.PackOrigin == PackOrigin.Start) { ys += bp.NextSize + spacing; } } } Backend.SetAllocation(widgets, rects); if (!Application.EngineBackend.HandlesSizeNegotiation) { foreach (var bp in visibleChildren) { ((IWidgetSurface)bp.Child).Reallocate(); } } }
public static FrameworkElement GetFrameworkElement(IWidgetBackend backend) { return(backend == null ? null : (FrameworkElement)backend.NativeWidget); }
public static NSView GetWidget(IWidgetBackend w) { return(((IMacViewBackend)w).View); }
public void SetAllocation(IWidgetBackend widget, Rectangle rect) { var w = GetWidget(widget); Widget.SetAllocation(w, rect); }
public void SetContent(IWidgetBackend child) { Widget.Child = GetWidget (child); }
public void Remove(IWidgetBackend widget) { Widget.Children.Remove(GetFrameworkElement(widget)); }
protected override void OnReallocate() { var size = Backend.Size; var visibleChildren = children.Where(c => c.Child.Visible).ToArray(); IWidgetBackend[] widgets = new IWidgetBackend [visibleChildren.Length]; Rectangle[] rects = new Rectangle [visibleChildren.Length]; if (size.Width <= 0 || size.Height <= 0) { var ws = visibleChildren.Select(bp => bp.Child.GetBackend()).ToArray(); Backend.SetAllocation(ws, new Rectangle[visibleChildren.Length]); return; } if (direction == Orientation.Horizontal) { CalcDefaultSizes(size.Width, size.Height, true); double xs = 0; double xe = size.Width + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; double availableWidth = bp.NextSize >= 0 ? bp.NextSize : 0; if (bp.PackOrigin == PackOrigin.End) { xe -= availableWidth + spacing; } var slot = new Rectangle(bp.PackOrigin == PackOrigin.Start ? xs : xe, 0, availableWidth, size.Height); widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = bp.Child.Surface.GetPlacementInRect(slot).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { xs += availableWidth + spacing; } } } else { CalcDefaultSizes(size.Width, size.Height, true); double ys = 0; double ye = size.Height + spacing; for (int n = 0; n < visibleChildren.Length; n++) { var bp = visibleChildren [n]; double availableHeight = bp.NextSize >= 0 ? bp.NextSize : 0; if (bp.PackOrigin == PackOrigin.End) { ye -= availableHeight + spacing; } var slot = new Rectangle(0, bp.PackOrigin == PackOrigin.Start ? ys : ye, size.Width, availableHeight); widgets[n] = (IWidgetBackend)GetBackend(bp.Child); rects[n] = bp.Child.Surface.GetPlacementInRect(slot).Round().WithPositiveSize(); if (bp.PackOrigin == PackOrigin.Start) { ys += availableHeight + spacing; } } } Backend.SetAllocation(widgets, rects); }
public void Popup(IWidgetBackend widget, double x, double y) { NSMenu.PopUpContextMenu(this, null, ((IMacViewBackend)widget).View, null); }
public static FrameworkElement GetFrameworkElement(IWidgetBackend backend) { return backend == null ? null : (FrameworkElement)backend.NativeWidget; }
public void AddChild(IWidgetBackend widget) { var v = GetWidget(widget); view.AddSubview(v); }