Exemple #1
0
        public AddressEditor(AppConfig config, Gtk.Window parent, Gtk.Container cont, JObject data = null)
        {
            this.Build ();

            this.config = config;
            ParentWin = parent;
            Cont = cont;

            myComboState = new MyCombo (comboState);
            myComboMuni = new MyCombo (comboMuni);
            myComboAsenta = new MyCombo (comboAsenta);

            buttonDelete.ConfirmClick += OnDeleteConfirm;

            WidgetPath = Util.GtkGetWidgetPath (this, config);

            if (GlobalDefaultStateID == -1)
                config.LoadWindowKey (WidgetPath, "default_state_id", out GlobalDefaultStateID);
            DefaultStateID = GlobalDefaultStateID;

            if (GlobalDefaultMuniID == -1)
                config.LoadWindowKey (WidgetPath, "default_muni_id", out GlobalDefaultMuniID);
            DefaultMuniID = GlobalDefaultMuniID;

            if (GlobalDefaultAsentaID == -1)
                config.LoadWindowKey (WidgetPath, "default_asenta_id", out GlobalDefaultAsentaID);
            DefaultAsentaID = GlobalDefaultAsentaID;

            LoadData (data);
        }
Exemple #2
0
        public override CellBase GetCell(Cell item, Gtk.Container reusableView, Controls.ListView listView)
        {
            var gtkTextCell = base.GetCell(item, reusableView, listView) as TextCell;
            var textCell    = (Microsoft.Maui.Controls.Compatibility.TextCell)item;

            gtkTextCell.IsGroupHeader = textCell.GetIsGroupHeader <ItemsView <Cell>, Cell>();

            return(gtkTextCell);
        }
        // Works around BXC #3801 - Managed Container subclasses are incorrectly resurrected, then leak.
        // It does this by registering an alternative callback for gtksharp_container_override_forall, which
        // ignores callbacks if the wrapper no longer exists. This means that the objects no longer enter a
        // finalized->release->dispose->re-wrap resurrection cycle.
        // We use a dynamic method to access internal/private GTK# API in a performant way without having to track
        // per-instance delegates.
        public static void FixContainerLeak(Gtk.Container c)
        {
            if (containerLeakFixed)
            {
                return;
            }

            FixContainerLeak(c.GetType());
        }
Exemple #4
0
        public override CellBase GetCell(Cell item, Gtk.Container reusableView, Controls.ListView listView)
        {
            var gtkTextCell = base.GetCell(item, reusableView, listView) as TextCell;
            var textCell    = (Xamarin.Forms.TextCell)item;

            gtkTextCell.IsGroupHeader = textCell.GetIsGroupHeader <ItemsView <Cell>, Cell>();

            return(gtkTextCell);
        }
        public override CellBase GetCell(Cell item, Gtk.Container reusableView, Controls.ListView listView)
        {
            var switchCell = base.GetCell(item, reusableView, listView) as SwitchCell;

            switchCell.Toggled -= OnToggled;
            switchCell.Toggled += OnToggled;

            return(switchCell);
        }
Exemple #6
0
        static void GetFieldsToBind(List <ObjectBindInfo> tobind, ObjectWrapper wrapper)
        {
            string memberName = null;

            if (wrapper is Wrapper.Widget)
            {
                Wrapper.Widget ww = wrapper as Wrapper.Widget;

                if (!ww.IsTopLevel && ww.InternalChildProperty == null && !ww.Unselectable)
                {
                    memberName = ((Wrapper.Widget)wrapper).Wrapped.Name;
                }
            }
            else if (wrapper is Wrapper.Action)
            {
                memberName = ((Wrapper.Action)wrapper).Name;
            }

            if (memberName != null)
            {
                ObjectBindInfo binfo = new ObjectBindInfo(wrapper.WrappedTypeName, memberName);
                tobind.Add(binfo);
            }

            Wrapper.ActionGroup agroup = wrapper as Wrapper.ActionGroup;
            if (agroup != null)
            {
                foreach (Wrapper.Action ac in agroup.Actions)
                {
                    GetFieldsToBind(tobind, ac);
                }
            }

            Wrapper.Widget widget = wrapper as Wrapper.Widget;
            if (widget != null && widget.IsTopLevel)
            {
                // Generate fields for local actions
                foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups)
                {
                    GetFieldsToBind(tobind, grp);
                }
            }

            Gtk.Container cont = wrapper.Wrapped as Gtk.Container;
            if (cont != null)
            {
                foreach (Gtk.Widget child in cont.AllChildren)
                {
                    Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child);
                    if (ww != null)
                    {
                        GetFieldsToBind(tobind, ww);
                    }
                }
            }
        }
Exemple #7
0
        public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget)
        {
            Gtk.Container cont = oldWidget.Parent as Gtk.Container;
            if (cont == null)
            {
                return;
            }

            if (cont is IGtkContainer)
            {
                ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget);
            }
            else if (cont is Gtk.Notebook)
            {
                Gtk.Notebook notebook         = (Gtk.Notebook)cont;
                Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild)notebook [oldWidget];
                var detachable  = nc.Detachable;
                var pos         = nc.Position;
                var reorderable = nc.Reorderable;
                var tabExpand   = nc.TabExpand;
                var tabFill     = nc.TabFill;
                var label       = notebook.GetTabLabel(oldWidget);
                notebook.Remove(oldWidget);
                notebook.InsertPage(newWidget, label, pos);

                nc             = (Gtk.Notebook.NotebookChild)notebook [newWidget];
                nc.Detachable  = detachable;
                nc.Reorderable = reorderable;
                nc.TabExpand   = tabExpand;
                nc.TabFill     = tabFill;
            }
            else if (cont is Gtk.Paned)
            {
                var paned  = (Gtk.Paned)cont;
                var pc     = (Gtk.Paned.PanedChild)paned[oldWidget];
                var resize = pc.Resize;
                var shrink = pc.Shrink;
                var pos    = paned.Position;
                if (paned.Child1 == oldWidget)
                {
                    paned.Remove(oldWidget);
                    paned.Pack1(newWidget, resize, shrink);
                }
                else
                {
                    paned.Remove(oldWidget);
                    paned.Pack2(newWidget, resize, shrink);
                }
                paned.Position = pos;
            }
            else if (cont is Gtk.Bin)
            {
                ((Gtk.Bin)cont).Remove(oldWidget);
                ((Gtk.Bin)cont).Child = newWidget;
            }
        }
Exemple #8
0
 public static void SetRedrawOnFocusChildSet(Gtk.Container aContainer)
 {
     if (aContainer == null)
     {
         throw new Exception("Adding widget to null container");
     }
     aContainer.FocusChildSet += delegate(object o, FocusChildSetArgs args) {
         aContainer.QueueDraw();
     };
 }
        protected virtual void OnChildAdded(VisualElement view)
        {
            var viewRenderer = Platform.CreateRenderer(view);

            Platform.SetRenderer(view, viewRenderer);

            Gtk.Container container = Renderer.Container;
            container?.Add(viewRenderer.Container);
            viewRenderer.Container.ShowAll();
        }
Exemple #10
0
        private void WireUpForceUpdateSizeRequested(Cell cell, Gtk.Container nativeCell)
        {
            cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

            _onForceUpdateSizeRequested = (sender, e) =>
            {
                OnForceUpdateSizeRequest(cell, nativeCell);
            };

            cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
        }
Exemple #11
0
        public override CellBase GetCell(Cell item, Gtk.Container reusableView, Controls.ListView listView)
        {
            var gtkImageCell = base.GetCell(item, reusableView, listView) as ImageCell;
            var imageCell    = (Xamarin.Forms.ImageCell)item;

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            SetImage(imageCell, gtkImageCell);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            return(gtkImageCell);
        }
Exemple #12
0
        public override CellBase GetCell(Cell item, Gtk.Container reusableView, Controls.ListView listView)
        {
            var entryCell = base.GetCell(item, reusableView, listView) as EntryCell;

            entryCell.TextChanged -= OnTextChanged;
            entryCell.TextChanged += OnTextChanged;
            entryCell.EditingDone -= OnEditingDone;
            entryCell.EditingDone += OnEditingDone;

            return(entryCell);
        }
Exemple #13
0
 public static void Add(Gtk.Container aContainer, Widget aWidget)
 {
     if (aWidget == null)
     {
         return;
     }
     if (aContainer == null)
     {
         throw new Exception("Adding widget to null container");
     }
     aContainer.Add(aWidget);
 }
Exemple #14
0
        public PhoneEditor(AppConfig config, Gtk.Window parent, Gtk.Container cont, JObject data = null)
        {
            this.Build ();

            this.config = config;
            ParentWin = parent;
            Cont = cont;

            buttonDelete.ConfirmClick += OnDeleteConfirm;

            LoadData (data);
        }
Exemple #15
0
 public static void ReplaceChild(Gtk.Container cont, Gtk.Widget oldWidget, Gtk.Widget newWidget)
 {
     if (cont is IGtkContainer)
     {
         ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget);
     }
     else if (cont is Gtk.Bin)
     {
         ((Gtk.Bin)cont).Remove(oldWidget);
         ((Gtk.Bin)cont).Child = newWidget;
     }
 }
        // Check if there are entries that should have help buttons
        public void UpdateHelpButtons()
        {
            IList <ValueReference> refs = valueReferenceGroup.GetValueReferences();

            for (int i = 0; i < refs.Count; i++)
            {
                if (widgetLists[i][1] is ComboBoxFromConstants) // These deal with documentation themselves
                {
                    continue;
                }

                Gtk.Container container = widgetLists[i][2] as Gtk.Container;
                if (container == null)
                {
                    continue;
                }

                bool isHelpButton = true;

                // Remove previous help button
                foreach (Gtk.Widget widget in container.Children)
                {
                    // Really hacky way to check whether this is the help button as we expect, or
                    // whether the "AddWidgetToRight" function was called to replace it, in which
                    // case we don't try to add the help button at all
                    if (!(widget is Gtk.Button && (widget as Gtk.Button).Label == "?"))
                    {
                        isHelpButton = false;
                        continue;
                    }
                    container.Remove(widget);
                    widget.Dispose();
                }

                if (!isHelpButton)
                {
                    continue;
                }

                ValueReference r = refs[i];
                if (r.Documentation != null)
                {
                    Gtk.Button helpButton = new Gtk.Button("?");
                    helpButton.FocusOnClick = false;
                    helpButton.Clicked     += delegate(object sender, EventArgs e) {
                        DocumentationDialog d = new DocumentationDialog(r.Documentation);
                    };
                    container.Add(helpButton);
                }
            }
            this.ShowAll();
        }
Exemple #17
0
        protected void UpdateBackground(Gtk.Container tableViewCell, Cell cell)
        {
            var bgColor = Color.White.ToGtkColor();
            var element = cell.RealParent as VisualElement;

            if (element != null)
            {
                bgColor = element.BackgroundColor == Color.Default ? bgColor : element.BackgroundColor.ToGtkColor();
            }

            UpdateBackgroundChild(cell, bgColor);

            tableViewCell.ModifyBg(Gtk.StateType.Normal, bgColor);
        }
Exemple #18
0
        private Cell GetXamarinFormsCell(Gtk.Container cell)
        {
            try
            {
                var formsCell = cell
                                .GetType()
                                .GetProperty("Cell")
                                .GetValue(cell, null) as Cell;

                return(formsCell);
            }
            catch
            {
                return(null);
            }
        }
Exemple #19
0
        public static bool OnExposeEvent(Gtk.Container aContainer, Gdk.EventExpose ev)
        {
            if (aContainer == null)
            {
                return(true);
            }
            int x      = aContainer.Allocation.Left;
            int y      = aContainer.Allocation.Top;
            int width  = aContainer.Allocation.Width;
            int height = aContainer.Allocation.Height;

            Widget e = GetEntryStyle(aContainer);

            Gtk.Style s  = aContainer.Style;
            StateType st = aContainer.State;

            if (e != null)
            {
                s  = e.Style;
                st = e.State;
            }
            if (GetContainerFocus(aContainer) == true)
            {
                if ((e == null) || (e.HasFocus == false))
                {
                    st = StateType.Selected;
                }
                Gtk.Style.PaintFlatBox(s, aContainer.GdkWindow, st, Gtk.ShadowType.In,
                                       aContainer.Allocation, aContainer, "entry_bg", x, y, width, height);
                Gtk.Style.PaintFocus(s, aContainer.GdkWindow, st,
                                     ev.Area, aContainer, "entry", x, y, width, height);
                Gtk.Style.PaintShadow(s, aContainer.GdkWindow, st, Gtk.ShadowType.In,
                                      ev.Area, aContainer, "entry", x, y, width, height);
            }
            else
            {
                Gtk.Style.PaintFlatBox(s, aContainer.GdkWindow, st, Gtk.ShadowType.In,
                                       aContainer.Allocation, aContainer, "entry_bg", x, y, width, height);
                Gtk.Style.PaintShadow(s, aContainer.GdkWindow, st, Gtk.ShadowType.In,
                                      ev.Area, aContainer, "entry", x, y, width, height);
            }
            e = null;
            s = null;

            return(true);
        }
Exemple #20
0
        internal static void BindSignalHandlers(CodeExpression targetObjectVar, ObjectWrapper wrapper, Stetic.WidgetMap map, CodeStatementCollection statements, GenerationOptions options)
        {
            foreach (Signal signal in wrapper.Signals)
            {
                SignalDescriptor descriptor = signal.SignalDescriptor;

                CodeExpression createDelegate = new CodeDelegateCreateExpression(
                    new CodeTypeReference(descriptor.HandlerTypeName, CodeTypeReferenceOptions.GlobalReference),
                    new CodeThisReferenceExpression(),
                    signal.Handler);

                CodeAttachEventStatement cevent = new CodeAttachEventStatement(
                    new CodeEventReferenceExpression(
                        map.GetWidgetExp(wrapper),
                        descriptor.Name),
                    createDelegate);

                statements.Add(cevent);
            }

            Wrapper.Widget widget = wrapper as Wrapper.Widget;
            if (widget != null && widget.IsTopLevel)
            {
                // Bind local action signals
                foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups)
                {
                    foreach (Wrapper.Action ac in grp.Actions)
                    {
                        BindSignalHandlers(targetObjectVar, ac, map, statements, options);
                    }
                }
            }

            Gtk.Container cont = wrapper.Wrapped as Gtk.Container;
            if (cont != null)
            {
                foreach (Gtk.Widget child in cont.AllChildren)
                {
                    Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child);
                    if (ww != null)
                    {
                        BindSignalHandlers(targetObjectVar, ww, map, statements, options);
                    }
                }
            }
        }
Exemple #21
0
        private void RemoveGlobalStyleClass(Gtk.Container container, string style)
        {
            if (container == null)
            {
                return;
            }

            foreach (var child in container.AllChildren)
            {
                var childWidget = child as Gtk.Widget;

                if (childWidget != null)
                {
                    this.RemoveGlobalStyleClass(childWidget as Gtk.Container, style);
                    childWidget.StyleContext.RemoveClass(style);
                }
            }
        }
        void DisableChecks(Gtk.Widget w)
        {
            Gtk.CheckButton c = w as Gtk.CheckButton;
            if (c != null)
            {
                c.Active = false;
                return;
            }

            Gtk.Container co = w as Gtk.Container;
            if (co != null)
            {
                foreach (Gtk.Widget cw in co.Children)
                {
                    DisableChecks(cw);
                }
            }
        }
Exemple #23
0
        void UninterceptClicks(Gtk.Widget widget)
        {
            widget.WidgetEvent -= WidgetEvent;

            Gtk.Container container = widget as Gtk.Container;
            if (container != null)
            {
                container.Added   -= OnInterceptedChildAdded;
                container.Removed -= OnInterceptedChildRemoved;
                foreach (Gtk.Widget child in container.AllChildren)
                {
                    if (Lookup(child) == null)
                    {
                        UninterceptClicks(child);
                    }
                }
            }
        }
Exemple #24
0
        // Call this from a DragEnd event to check if the widget wasn't dropped
        public static Gtk.Widget Cancel()
        {
            if (dragWidget == null)
            {
                return(null);
            }

            Gtk.Widget w = dragWidget;
            dragWidget = null;

            // Remove the widget from its dragWindow
            Gtk.Container parent = w.Parent as Gtk.Container;
            if (parent != null)
            {
                parent.Remove(w);
                parent.Destroy();
            }
            return(w);
        }
Exemple #25
0
 internal void UpdateScrolledWindow()
 {
     if (ParentWrapper == null)
     {
         return;
     }
     if (boundToScrollWindow)
     {
         if (!(Wrapped.Parent is Gtk.Viewport) && !(Wrapped.Parent is Gtk.ScrolledWindow))
         {
             Gtk.ScrolledWindow scw = new Gtk.ScrolledWindow();
             scw.HscrollbarPolicy = scw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
             scw.ShadowType       = Gtk.ShadowType.In;
             ScrolledWindow wrapper = (ScrolledWindow)ObjectWrapper.Create(Project, scw, ParentWrapper);
             ParentWrapper.ReplaceChild(Wrapped, scw, false);
             if (Wrapped.SetScrollAdjustments(null, null))
             {
                 scw.Add(Wrapped);
             }
             else
             {
                 wrapper.AddWithViewport(Wrapped);
             }
             Select();
         }
     }
     else if (((Wrapped.Parent is Gtk.Viewport) || (Wrapped.Parent is Gtk.ScrolledWindow)) && ParentWrapper.ParentWrapper != null)
     {
         Gtk.Container parent = (Gtk.Container)Wrapped.Parent;
         parent.Remove(Wrapped);
         Container grandParent;
         if (parent is Gtk.Viewport)
         {
             parent      = (Gtk.Container)parent.Parent;
             grandParent = Container.LookupParent(parent);
         }
         else
         {
             grandParent = Container.LookupParent(parent);
         }
         grandParent.ReplaceChild(parent, Wrapped, true);
     }
 }
Exemple #26
0
        public static WidgetCollection GetChildren(this Gtk.Container container)
        {
            var gamlWidget = container as Internal.IGamlContainerCache;

            if (gamlWidget == null)
            {
                return(new WidgetCollection(container));
            }

            var children = gamlWidget.Children;

            if (children == null)
            {
                children            = new WidgetCollection(container);
                gamlWidget.Children = children;
            }

            return(children);
        }
 Gtk.Widget GetWidget(Gtk.Container container, string name)
 {
     foreach (Gtk.Widget child in container.Children)
     {
         if (child.Name == name)
         {
             return(child);
         }
         var childContainer = child as Gtk.Container;
         if (childContainer != null)
         {
             var c = GetWidget(childContainer, name);
             if (c != null)
             {
                 return(c);
             }
         }
     }
     return(null);
 }
Exemple #28
0
        internal static void SetFocus(Gtk.Widget w)
        {
            w.ChildFocus(Gtk.DirectionType.Down);

            Gtk.Window win = w.Toplevel as Gtk.Window;
            if (win == null)
            {
                return;
            }

            // Make sure focus is not given to internal children
            if (win.Focus != null)
            {
                Gtk.Container c = win.Focus.Parent as Gtk.Container;
                if (c.Children.Length == 0)
                {
                    win.Focus = c;
                }
            }
        }
Exemple #29
0
        protected override void Initialize()
        {
            base.Initialize();
            Control.KeyPressEvent += Connector.Control_KeyPressEvent;

            var vbox = new EtoVBox {
                Handler = this
            };

            vbox.PackStart(WindowActionControl, false, true, 0);
            vbox.PackStart(WindowContentControl, true, true, 0);

#pragma warning disable 612
            actionarea = Control.ActionArea;
#pragma warning restore 612

#if GTK2
            var content = Control.VBox;
            btcontainer = Control.ActionArea;
#else
            var content = Control.ContentArea;

            actionarea.NoShowAll = true;
            actionarea.Hide();

#if GTKCORE
            if (Helper.UseHeaderBar)
            {
                btcontainer = new Gtk.HeaderBar();

                var title = Control.Title;
                Control.Titlebar = btcontainer;
                Control.Title    = title;
            }
            else
#endif
            btcontainer = actionarea;
#endif

            content.PackStart(vbox, true, true, 0);
        }
Exemple #30
0
        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);
        }
        private Gtk.Expander GetFileChooserExpander(Gtk.Container parent)
        {
            if (parent is Gtk.Expander)
            {
                return(parent as Gtk.Expander);
            }

            foreach (Gtk.Widget child in parent.AllChildren)
            {
                if (child is Gtk.Container)
                {
                    Gtk.Container container = child as Gtk.Container;
                    Gtk.Expander  expander  = GetFileChooserExpander(container);
                    if (expander != null)
                    {
                        return(expander);
                    }
                }
            }

            return(null);
        }
Exemple #32
0
        public override object CreateInstance(Stetic.IProject proj)
        {
            Gtk.Widget res;

            if (useCustomWidgetBox)
            {
                res = CreateFakeWidget(wrapperClassDescriptor.Name);
                res.ShowAll();
            }
            else if (steticDefinition != null)
            {
                Gtk.Container w = Stetic.WidgetUtils.ImportWidget(proj, steticDefinition) as Gtk.Container;
                MakeChildrenUnselectable(w);
                res = w;
            }
            else
            {
                res = (Gtk.Widget)typeClassDescriptor.CreateInstance(proj);

                // If it is a custom widget and there is no stetic project for it, just
                // show it as a regular custom widget.
                Stetic.CustomWidget custom = res as Stetic.CustomWidget;
                if (custom != null)
                {
                    Stetic.Custom c = new Stetic.Custom();
                    // Give it some default size
                    c.WidthRequest  = 20;
                    c.HeightRequest = 20;
                    custom.Add(c);
                    custom.ShowAll();
                    res = custom;
                }
            }

            res.Name = widgetId;
            return(res);
        }