Esempio n. 1
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            base.OnExposeEvent(evnt);
            Gdk.Rectangle rect = Allocation;
            col.CellSetCellData(tree.Model, iter, false, false);
            int x = 1;

            Gdk.Color save = Gdk.Color.Zero;
            foreach (CellRenderer cr in col.CellRenderers)
            {
                if (!cr.Visible)
                {
                    continue;
                }
                if (cr is CellRendererText)
                {
                    save = ((CellRendererText)cr).ForegroundGdk;
                    ((CellRendererText)cr).ForegroundGdk = Style.Foreground(State);
                }
                int sp, wi, he, xo, yo;
                col.CellGetPosition(cr, out sp, out wi);
                Gdk.Rectangle colcrect = new Gdk.Rectangle(x, rect.Y, wi, rect.Height - 2);
                cr.GetSize(tree, ref colcrect, out xo, out yo, out wi, out he);
                int           leftMargin  = (int)((colcrect.Width - wi) * cr.Xalign);
                int           rightMargin = (int)((colcrect.Height - he) * cr.Yalign);
                Gdk.Rectangle crect       = new Gdk.Rectangle(colcrect.X + leftMargin, colcrect.Y + rightMargin + 1, wi, he);
                cr.Render(this.GdkWindow, tree, colcrect, crect, rect, CellRendererState.Focused);
                x += colcrect.Width + col.Spacing + 1;
                if (cr is CellRendererText)
                {
                    ((CellRendererText)cr).ForegroundGdk = save;
                }
            }
            return(true);
        }
Esempio n. 2
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            base.OnExposeEvent(evnt);

            Gdk.Rectangle expose     = Allocation;
            Gdk.Color     save       = Gdk.Color.Zero;
            bool          hasFgColor = false;
            int           x          = 1;

            // Make sure that the row has not been removed inbetween.
            // If the model is a TreeStore, it can do the validation for us, otherwise we need to validate the path.
            if ((treeStore != null && treeStore.IterIsValid(iter) == false) || !tree.Model.GetIter(out iter, path))
            {
                GtkUtil.HideTooltip(tree);
                return(true);
            }
            col.CellSetCellData(tree.Model, iter, false, false);

            foreach (CellRenderer cr in col.CellRenderers)
            {
                if (!cr.Visible)
                {
                    continue;
                }

                if (cr is CellRendererText)
                {
                    hasFgColor = ((CellRendererText)cr).GetCellForegroundSet();
                    save       = ((CellRendererText)cr).ForegroundGdk;
                    ((CellRendererText)cr).ForegroundGdk = Style.Foreground(State);
                }

                int sp, wi, he, xo, yo;
                col.CellGetPosition(cr, out sp, out wi);
                Gdk.Rectangle bgrect = new Gdk.Rectangle(x, expose.Y, wi, expose.Height - 2);
                cr.GetSize(tree, ref bgrect, out xo, out yo, out wi, out he);
                int           leftMargin = (int)((bgrect.Width - wi) * cr.Xalign);
                int           topMargin  = (int)((bgrect.Height - he) * cr.Yalign);
                Gdk.Rectangle cellrect   = new Gdk.Rectangle(bgrect.X + leftMargin, bgrect.Y + topMargin + 1, wi, he);
                cr.Render(this.GdkWindow, this, bgrect, cellrect, expose, CellRendererState.Focused);
                x += bgrect.Width + col.Spacing + 1;

                if (cr is CellRendererText)
                {
                    ((CellRendererText)cr).ForegroundGdk = save;
                    ((CellRendererText)cr).SetCellForegroundSet(hasFgColor);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public CellTooltipWindow(TreeView tree, TreeViewColumn col, TreePath path)
        {
            this.tree      = tree;
            this.col       = col;
            this.treeStore = tree.Model as TreeStore;
            this.path      = path;

            NudgeHorizontal = true;

            Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;

            Gdk.Rectangle rect = tree.GetCellArea(path, col);
            rect.Inflate(2, 2);

            if (!tree.Model.GetIter(out iter, path))
            {
                Hide();
                return;
            }

            col.CellSetCellData(tree.Model, iter, false, false);
            int x  = 0;
            int th = 0;

            CellRenderer[] renderers = col.CellRenderers;
            foreach (CellRenderer cr in renderers)
            {
                int sp, wi, he, xo, yo;
                col.CellGetPosition(cr, out sp, out wi);
                Gdk.Rectangle crect = new Gdk.Rectangle(x, rect.Y, wi, rect.Height);
                cr.GetSize(tree, ref crect, out xo, out yo, out wi, out he);
                if (cr != renderers [renderers.Length - 1])
                {
                    x += crect.Width + col.Spacing + 1;
                }
                else
                {
                    x += wi + 1;
                }
                if (he > th)
                {
                    th = he;
                }
            }
            SetSizeRequest(x, th + 2);
        }