Beispiel #1
0
        private void PaintView(Cairo.Context cr, Rect clip)
        {
            clip.Intersect((Rect)list_rendering_alloc);
            cr.Rectangle((Cairo.Rectangle)clip);
            cr.Clip();

            cell_context.Clip             = (Gdk.Rectangle)clip;
            cell_context.TextAsForeground = false;

            selected_rows.Clear();

            for (int layout_index = 0; layout_index < ViewLayout.ChildCount; layout_index++)
            {
                var layout_child     = ViewLayout[layout_index];
                var child_allocation = layout_child.Allocation;

                if (!child_allocation.IntersectsWith(clip) || ViewLayout.GetModelIndex(layout_child) >= Model.Count)
                {
                    continue;
                }

                if (Selection != null && Selection.Contains(ViewLayout.GetModelIndex(layout_child)))
                {
                    selected_rows.Add(ViewLayout.GetModelIndex(layout_child));

                    var selection_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Selected));
                    if (!HasFocus || HeaderFocused)
                    {
                        selection_color = CairoExtensions.ColorShade(selection_color, 1.1);
                    }

                    Theme.DrawRowSelection(cr,
                                           (int)child_allocation.X, (int)child_allocation.Y,
                                           (int)child_allocation.Width, (int)child_allocation.Height,
                                           true, true, selection_color, CairoCorners.All);

                    cell_context.State = StateFlags.Selected;
                }
                else
                {
                    cell_context.State = StateFlags.Normal;
                }

                //cr.Save ();
                //cr.Translate (child_allocation.X, child_allocation.Y);
                //cr.Rectangle (0, 0, child_allocation.Width, child_allocation.Height);
                //cr.Clip ();
                layout_child.Render(cell_context);
                //cr.Restore ();
            }

            cr.ResetClip();
        }
        // 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);
            }
        }
Beispiel #3
0
        private void PaintView(Cairo.Context cr, Rect clip)
        {
            clip.Intersect((Rect)list_rendering_alloc);
            cr.Rectangle((Cairo.Rectangle)clip);
            cr.Clip();

            cell_context.Clip             = (Gdk.Rectangle)clip;
            cell_context.TextAsForeground = false;

            selected_rows.Clear();

            for (int layout_index = 0; layout_index < ViewLayout.ChildCount; layout_index++)
            {
                var layout_child     = ViewLayout[layout_index];
                var child_allocation = layout_child.Allocation;

                if (!child_allocation.IntersectsWith(clip) || ViewLayout.GetModelIndex(layout_child) >= Model.Count)
                {
                    continue;
                }

                if (Selection != null && Selection.Contains(ViewLayout.GetModelIndex(layout_child)))
                {
                    selected_rows.Add(ViewLayout.GetModelIndex(layout_child));

                    PaintRowSelection(cr, (int)child_allocation.X, (int)child_allocation.Y,
                                      (int)child_allocation.Width, (int)child_allocation.Height);

                    cell_context.Selected = true;
                }
                else
                {
                    cell_context.Selected = false;
                }

                layout_child.Render(cell_context);
            }

            cr.ResetClip();
        }