Exemplo n.º 1
0
        public override void Refresh()
        {
            Gtk.Table table = (Gtk.Table)Parent;
            if (table == null)
            {
                return;
            }

            if (icon != null && icon.Parent != null)
            {
                table.Remove(icon);
            }
            if (label != null && label.Parent != null)
            {
                table.Remove(label);
            }
            if (accel != null && accel.Parent != null)
            {
                table.Remove(accel);
            }

            icon = label = accel = null;
            CreateControls();
            Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table[this];
            AttachChildren(table, tc.TopAttach, tc.LeftAttach);

            table.ShowAll();
        }
Exemplo n.º 2
0
        public void Detach()
        {
            if (disposed)
            {
                return;
            }

            Gtk.Table table = (Gtk.Table)Parent;
            if (table == null)
            {
                return;
            }
            if (icon != null)
            {
                table.Remove(icon);
            }
            if (label != null)
            {
                table.Remove(label);
            }
            if (accel != null)
            {
                table.Remove(accel);
            }
            table.Remove(this);
        }
Exemplo n.º 3
0
        public override void Dispose()
        {
            foreach (Gtk.Widget w in table.Children)
            {
                table.Remove(w);
                w.Destroy();
            }

            parentNode.ChildNodeAdded   -= OnChildAdded;
            parentNode.ChildNodeRemoved -= OnChildRemoved;
            parentNode = null;
            base.Dispose();
        }
        void Refresh()
        {
            IDesignArea    area    = wrapper.GetDesignArea();
            ActionTreeNode selNode = null;

            foreach (Gtk.Widget w in table.Children)
            {
                ActionMenuItem ami = w as ActionMenuItem;
                if (area.IsSelected(w) && ami != null)
                {
                    selNode = ami.Node;
                    area.ResetSelection(w);
                }
                table.Remove(w);
            }

            Fill();

            ActionMenuItem mi = FindMenuItem(selNode);

            if (mi != null)
            {
                mi.Select();
            }

            GLib.Timeout.Add(50, new GLib.TimeoutHandler(RepositionSubmenu));
        }
Exemplo n.º 5
0
        public void ReplaceWidget(int i, Gtk.Widget newWidget)
        {
            table.Remove(widgets[i]);
            var pos = widgetPositions[i];

            table.Attach(newWidget, pos.Item1 + 1, pos.Item1 + 2, pos.Item2, pos.Item2 + 1);
            widgets[i] = newWidget;
        }
Exemplo n.º 6
0
        void SetImagePosition(bool removeImage = true)
        {
            uint left, top;
            bool shouldHideLabel = false;

            switch (ImagePosition)
            {
            case ButtonImagePosition.Above:
                left            = 1;
                top             = 0;
                shouldHideLabel = true;
                break;

            case ButtonImagePosition.Below:
                left            = 1;
                top             = 2;
                shouldHideLabel = true;
                break;

            case ButtonImagePosition.Left:
                left = 0;
                top  = 1;
                break;

            case ButtonImagePosition.Right:
                left = 2;
                top  = 1;
                break;

            case ButtonImagePosition.Overlay:
                left = 1;
                top  = 1;
                break;

            default:
                throw new NotSupportedException();
            }
            shouldHideLabel &= string.IsNullOrEmpty(label.Text);
            if (shouldHideLabel)
            {
                label.Hide();
            }
            else
            {
                label.Show();
            }

            var right   = left + 1;
            var bottom  = top + 1;
            var options = shouldHideLabel ? Gtk.AttachOptions.Expand : Gtk.AttachOptions.Shrink;

            if (removeImage)
            {
                table.Remove(gtkimage);
            }
            table.Attach(gtkimage, left, right, top, bottom, options, options, 0, 0);
            Control.QueueResize();
        }
        protected override void DoSync()
        {
            if (!AllowPlaceholders)
            {
                return;
            }
            using (UndoManager.AtomicChange)
            {
                uint       left, right, top, bottom;
                uint       row, col;
                Gtk.Widget w;
                Gtk.Widget[,] grid;
                Gtk.Table.TableChild tc;
                Gtk.Widget[]         children;
                bool addedPlaceholders = false;

                children = table.Children;
                grid     = new Gtk.Widget[NRows, NColumns];

                // First fill in the placeholders in the grid. If we find any
                // placeholders covering more than one grid square, remove them.
                // (New ones will be created below.)
                foreach (Gtk.Widget child in children)
                {
                    if (!(child is Placeholder))
                    {
                        continue;
                    }

                    tc     = table[child] as Gtk.Table.TableChild;
                    left   = tc.LeftAttach;
                    right  = tc.RightAttach;
                    top    = tc.TopAttach;
                    bottom = tc.BottomAttach;

                    if (right == left + 1 && bottom == top + 1)
                    {
                        grid[top, left] = child;
                    }
                    else
                    {
                        table.Remove(child);
                        child.Destroy();
                    }
                }

                // Now fill in the real widgets, knocking out any placeholders
                // they overlap. (If there are real widgets that overlap
                // placeholders, neither will be knocked out, and the layout
                // will probably end up wrong as well. But this situation
                // happens at least temporarily during glade import.)
                foreach (Gtk.Widget child in children)
                {
                    if (child is Placeholder)
                    {
                        continue;
                    }

                    tc     = table[child] as Gtk.Table.TableChild;
                    left   = tc.LeftAttach;
                    right  = tc.RightAttach;
                    top    = tc.TopAttach;
                    bottom = tc.BottomAttach;

                    for (row = top; row < bottom; row++)
                    {
                        for (col = left; col < right; col++)
                        {
                            w = grid[row, col];
                            if (w is Placeholder)
                            {
                                table.Remove(w);
                                w.Destroy();
                            }
                            grid[row, col] = child;
                        }
                    }
                }

                // Scan each row; if there are any empty cells, fill them in
                // with placeholders. If a row contains only placeholders, then
                // set them all to expand vertically so the row won't collapse.
                // OTOH, if the row contains any real widget, set any placeholders
                // in that row to not expand vertically, so they don't force the
                // real widgets to expand further than they should. If any row
                // is vertically expandable, then the table as a whole is.
                vexpandable = false;
                for (row = 0; row < NRows; row++)
                {
                    bool allPlaceholders = true;

                    for (col = 0; col < NColumns; col++)
                    {
                        w = grid[row, col];
                        if (w == null)
                        {
                            w = CreatePlaceholder();
                            table.Attach(w, col, col + 1, row, row + 1);
                            NotifyChildAdded(w);
                            grid[row, col]    = w;
                            addedPlaceholders = true;
                        }
                        else if (!ChildVExpandable(w) || !AutoSize[w])
                        {
                            allPlaceholders = false;
                        }
                    }

                    for (col = 0; col < NColumns; col++)
                    {
                        w = grid[row, col];
                        if (!AutoSize[w])
                        {
                            continue;
                        }
                        tc = table[w] as Gtk.Table.TableChild;
                        // We can't play with the vertical expansion property of
                        // widgets which span more than one row
                        if (tc.BottomAttach != tc.TopAttach + 1)
                        {
                            continue;
                        }
                        Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts;
                        if (tc.YOptions != opts)
                        {
                            tc.YOptions = opts;
                        }
                    }

                    if (allPlaceholders)
                    {
                        vexpandable = true;
                    }
                }

                // Now do the same for columns and horizontal expansion (but we
                // don't have to worry about empty cells this time).
                hexpandable = false;
                for (col = 0; col < NColumns; col++)
                {
                    bool allPlaceholders = true;

                    for (row = 0; row < NRows; row++)
                    {
                        w = grid[row, col];
                        if (!ChildHExpandable(w) || !AutoSize[w])
                        {
                            allPlaceholders = false;
                            break;
                        }
                    }

                    for (row = 0; row < NRows; row++)
                    {
                        w = grid[row, col];
                        if (!AutoSize[w])
                        {
                            continue;
                        }
                        tc = table[w] as Gtk.Table.TableChild;
                        // We can't play with the horizontal expansion property of
                        // widgets which span more than one column
                        if (tc.RightAttach != tc.LeftAttach + 1)
                        {
                            continue;
                        }
                        Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts;
                        if (tc.XOptions != opts)
                        {
                            tc.XOptions = opts;
                        }
                    }

                    if (allPlaceholders)
                    {
                        hexpandable = true;
                    }
                }

                if (addedPlaceholders)
                {
                    EmitContentsChanged();
                }
            }
        }