// FIXME: replace all invocations with direct call to ViewLayout
        protected int GetModelRowAt(int x, int y)
        {
            if (ViewLayout != null)
            {
                var child = ViewLayout.FindChildAtPoint(new Point(x, y));
                return(child == null ? -1 : ViewLayout.GetModelIndex(child));
            }
            else
            {
                if (y < 0 || ChildSize.Height <= 0)
                {
                    return(-1);
                }

                int v_page_offset = VadjustmentValue % ChildSize.Height;
                int first_row     = VadjustmentValue / ChildSize.Height;
                int row_offset    = (y + v_page_offset) / ChildSize.Height;
                return(first_row + row_offset);
            }
        }
 CanvasItem GetLayoutChildAt(Point point)
 {
     point.Offset(-list_interaction_alloc.X, -list_interaction_alloc.Y);
     return(ViewLayout.FindChildAtPoint(point));
 }
Exemple #3
0
        private void OnQueryTooltip(object o, Gtk.QueryTooltipArgs args)
        {
            if (!args.KeyboardTooltip)
            {
                if (ViewLayout != null)
                {
                    var pt    = new Point(args.X - list_interaction_alloc.X, args.Y - list_interaction_alloc.Y);
                    var child = ViewLayout.FindChildAtPoint(pt);
                    if (child != null)
                    {
                        string markup;
                        Rect   area;
                        pt.Offset(ViewLayout.ActualAllocation.Point);
                        if (child.GetTooltipMarkupAt(pt, out markup, out area))
                        {
                            area.Offset(-ViewLayout.ActualAllocation.X, -ViewLayout.ActualAllocation.Y);
                            area.Offset(list_interaction_alloc.X, list_interaction_alloc.Y);
                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = (Gdk.Rectangle)area;

                            /*if (!area.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("Tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", area, args.X, args.Y);
                             * }*/
                            args.RetVal = true;
                        }
                    }
                }
                else if (cell_context != null && cell_context.Layout != null)
                {
                    ITooltipCell cell;
                    Column       column;
                    int          row_index;

                    if (GetEventCell <ITooltipCell> (args.X, args.Y, out cell, out column, out row_index))
                    {
                        CachedColumn cached_column = GetCachedColumnForColumn(column);

                        string markup = cell.GetTooltipMarkup(cell_context, cached_column.Width);
                        if (!String.IsNullOrEmpty(markup))
                        {
                            Gdk.Rectangle rect = new Gdk.Rectangle();
                            rect.X = list_interaction_alloc.X + cached_column.X1;

                            // get the y of the event in list coords
                            rect.Y = args.Y - list_interaction_alloc.Y;

                            // get the top of the cell pointed to by list_y
                            rect.Y -= VadjustmentValue % ChildSize.Height;
                            rect.Y -= rect.Y % ChildSize.Height;

                            // convert back to widget coords
                            rect.Y += list_interaction_alloc.Y;

                            // TODO is this right even if the list is wide enough to scroll horizontally?
                            rect.Width = cached_column.Width;

                            // TODO not right - could be smaller if at the top/bottom and only partially showing
                            rect.Height = ChildSize.Height;

                            /*if (!rect.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("ListView tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", rect, args.X, args.Y);
                             * }*/

                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = rect;
                            args.RetVal          = true;
                        }
                    }
                }
            }

            // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9
            if (args.Tooltip != null)
            {
                args.Tooltip.Dispose();
            }
        }