Пример #1
0
 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]));
     }
 }
Пример #2
0
 public void SetChild(IWidgetBackend child)
 {
     var w = (IGtkWidgetBackend) child;
     if (alignment.Child != null)
         alignment.Remove (alignment.Child);
     alignment.Child = w.Widget;
 }
Пример #3
0
		public void SetContent(IWidgetBackend child)
		{
			if (child == null)
				Widget.Content = null;
			else
				Widget.Content = child.NativeWidget;
		}
Пример #4
0
		public void SetContent (IWidgetBackend widget)
		{
			if (widget == null)
				CheckBox.Content = null;
			else
				CheckBox.Content = widget.NativeWidget;
		}
Пример #5
0
        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 ();
        }
Пример #6
0
		public void SetContent(IWidgetBackend widget)
		{
			if (widget == null)
				RadioButton.Content = null;
			else
				RadioButton.Content = widget.NativeWidget;
		}
Пример #7
0
        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 ();
        }
Пример #8
0
		public void SetChild (IWidgetBackend child)
		{
			if (alignment.Child != null) {
				WidgetBackend.RemoveChildPlacement (alignment.Child);
				alignment.Remove (alignment.Child);
			}
			alignment.Child = WidgetBackend.GetWidgetWithPlacement (child);
		}
Пример #9
0
        public void RemoveChild(IWidgetBackend widget)
        {
            UIElement element = widget.NativeWidget as UIElement;
            if (element == null)
                throw new ArgumentException ();

            Canvas.Children.Remove (element);
        }
Пример #10
0
 public void SetContent(IWidgetBackend widget)
 {
     var newWidget = GetWidget (widget);
     var oldWidget = Widget.Child;
     if (oldWidget == null)
         Widget.Child = newWidget;
     else
         GtkEngine.ReplaceChild (oldWidget, newWidget);
 }
Пример #11
0
        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);
        }
Пример #12
0
		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);
			}
		}
Пример #13
0
 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);
     };
 }
Пример #14
0
		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);
		}
Пример #15
0
		public void SetContent (IWidgetBackend widget)
		{
			if (widget != null) {
				child = (Widget)((WidgetBackend)widget).Frontend;
				UserControl.Content = widget.NativeWidget;
			}
			else {
				child = null;
				UserControl.Content = null;
			}
		}
Пример #16
0
 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 ();
 }
Пример #17
0
 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 (); };
 }
Пример #18
0
		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 ());
		}
Пример #19
0
        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 ();
			}
		}
Пример #21
0
		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);
			}
		}
Пример #22
0
		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);
		}
Пример #23
0
		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;
			}
		}
Пример #24
0
		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;
				}
			}
		}
Пример #25
0
        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 ();
        }
Пример #26
0
        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;
        }
Пример #27
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 ();
		}
Пример #28
0
 public void Add(IWidgetBackend widget)
 {
     Widget.Add(GetWidget(widget));
 }
Пример #29
0
 public void SetContent(IWidgetBackend widget)
 {
 }
Пример #30
0
        public void SetChildBounds(IWidgetBackend widget, Rectangle bounds)
        {
            var w = ((IGtkWidgetBackend)widget).Widget;

            Widget.SetAllocation(w, bounds);
        }
Пример #31
0
        public void Initialize(IWidgetBackend parentWidget, IAccessibleEventSink eventSink)
        {
            var parentBackend = parentWidget as ViewBackend;

            Initialize(parentBackend?.Widget, eventSink);
        }
Пример #32
0
 public void Initialize(IWidgetBackend parentWidget, IAccessibleEventSink eventSink)
 {
 }
Пример #33
0
 public virtual void UpdateChildPlacement(IWidgetBackend childBackend)
 {
     SetChildPlacement(childBackend);
 }
Пример #34
0
        public void Add(IWidgetBackend widget)
        {
            ViewBackend b = (ViewBackend)widget;

            Widget.AddSubview(b.Widget);
        }
Пример #35
0
        public void RemoveChild(IWidgetBackend widget)
        {
            var v = GetWidget(widget);

            v.RemoveFromSuperview();
        }
Пример #36
0
        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();
             *    }*/
        }
Пример #37
0
 public void Remove(IWidgetBackend widget)
 {
     Widget.Remove(GetWidget(widget));
 }
Пример #38
0
        public void Add(IWidgetBackend widget)
        {
            WidgetBackend wb = (WidgetBackend)widget;

            Widget.Add(wb.Frontend, GetWidget(widget));
        }
Пример #39
0
        public void RemoveChild(IWidgetBackend widget)
        {
            var w = ((IGtkWidgetBackend)widget).Widget;

            Widget.Remove(w);
        }
Пример #40
0
 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;
 }
Пример #41
0
 public void Popup(IWidgetBackend widget, double x, double y)
 {
     NSMenu.PopUpContextMenu(this, NSApplication.SharedApplication.CurrentEvent, ((ViewBackend)widget).Widget, null);
 }
Пример #42
0
 public void Popup(IWidgetBackend widget, double x, double y)
 {
     throw new NotImplementedException();
 }
Пример #43
0
        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();
                }
            }
        }
Пример #44
0
 public void Popup(IWidgetBackend widget, double x, double y)
 {
     GtkWorkarounds.ShowContextMenu(Menu, ((WidgetBackend)widget).Widget, new Gdk.Rectangle((int)x, (int)y, 0, 0));
 }
Пример #45
0
        public void Add(IWidgetBackend widget)
        {
            IMacViewBackend b = (IMacViewBackend)widget;

            Widget.AddSubview(b.View);
        }
Пример #46
0
 public static Gtk.Widget GetWidget(IWidgetBackend w)
 {
     return(w != null ? ((IGtkWidgetBackend)w).Widget : null);
 }
Пример #47
0
 public void Remove(IWidgetBackend widget)
 {
     Widget.Remove(GetWidgetWithPlacement(widget));
 }
Пример #48
0
 public void Add(IWidgetBackend widget)
 {
     Widget.Children.Add(GetFrameworkElement(widget));
 }
Пример #49
0
        public void UpdateLabel(NotebookTab tab, string hint)
        {
            IWidgetBackend widget = (IWidgetBackend)WidgetRegistry.GetBackend(tab.Child);

            Widget.SetTabLabel(GetWidget(widget), CreateLabel(tab));
        }
Пример #50
0
 public void Add(IWidgetBackend widget, NotebookTab tab)
 {
     Widget.AppendPage(GetWidget(widget), CreateLabel(tab));
 }
Пример #51
0
        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();
                }
            }
        }
Пример #52
0
 public static FrameworkElement GetFrameworkElement(IWidgetBackend backend)
 {
     return(backend == null ? null : (FrameworkElement)backend.NativeWidget);
 }
Пример #53
0
 public static NSView GetWidget(IWidgetBackend w)
 {
     return(((IMacViewBackend)w).View);
 }
Пример #54
0
        public void SetAllocation(IWidgetBackend widget, Rectangle rect)
        {
            var w = GetWidget(widget);

            Widget.SetAllocation(w, rect);
        }
Пример #55
0
 public void SetContent(IWidgetBackend child)
 {
     Widget.Child = GetWidget (child);
 }
Пример #56
0
 public void Remove(IWidgetBackend widget)
 {
     Widget.Children.Remove(GetFrameworkElement(widget));
 }
Пример #57
0
        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);
        }
Пример #58
0
 public void Popup(IWidgetBackend widget, double x, double y)
 {
     NSMenu.PopUpContextMenu(this, null, ((IMacViewBackend)widget).View, null);
 }
Пример #59
0
 public static FrameworkElement GetFrameworkElement(IWidgetBackend backend)
 {
     return backend == null ? null : (FrameworkElement)backend.NativeWidget;
 }
Пример #60
0
        public void AddChild(IWidgetBackend widget)
        {
            var v = GetWidget(widget);

            view.AddSubview(v);
        }