Esempio n. 1
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }

/*			System.Console.WriteLine("Master: {0}", ((Gtk.Widget) Master).Allocation);
 *                      System.Console.WriteLine("Owner: {0}", ((IDrawingCell) Owner).Area);
 *                      System.Console.WriteLine("Arrow area: {0}", Area);
 *                      System.Console.WriteLine("Cell area: {0}", aArgs.CellArea);*/
            object wdg = Master;

            if (wdg is Gtk.Widget)
            {
                Style  style = Rc.GetStyle(ChameleonTemplates.Arrow);
                double x, y;
                MaxArrowSize(out x, out y);
                CellRectangle r = aArgs.CellArea.Copy();
                if (r.Height > r.Width)
                {
                    while (x < r.Width)
                    {
                        r.Shrink(1);
                    }
                }
                else
                {
                    while (y < r.Height)
                    {
                        r.Shrink(1);
                    }
                }
//				Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
                Gdk.Rectangle rect = r.CopyToGdkRectangle();
//				System.Console.WriteLine(rect);
                Style.PaintArrow(style, aArgs.Drawable, this.ResolveState(), ShadowType.In, rect,
                                 (wdg is Gtk.Widget) ? (Gtk.Widget)wdg : null, "arrow", ArrowType, true, rect.X, rect.Y, rect.Width, rect.Height);
                style.Dispose();
                r = null;
            }
            else
            {
//				System.Console.WriteLine("Arrow master={0}", Master.GetType());
            }
        }
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Area occupied by widget <see cref="CellRectangle"/>
        /// </param>
        protected virtual void CalculateCellAreas(CellRectangle aRect)
        {
//			Cairo.Rectangle rect = aRect.CopyAndShrink (Padding);
            CellRectangle rect = aRect.Copy();

            rect.Shrink(Padding);
            box.DoCalculateCellAreas(rect);
            rect = null;
        }
        /// <summary>
        /// Expose event handler, calls PaintBackground and then PaintCells
        /// </summary>
        /// <param name="evnt">
        /// Arguments <see cref="Gdk.EventExpose"/>
        /// </param>
        /// <returns>
        /// true if successful, false if not <see cref="System.Boolean"/>
        /// </returns>
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            base.OnExposeEvent(evnt);
            int x, y, w, h, d = 0;

            GdkWindow.GetGeometry(out x, out y, out w, out h, out d);
            CellRectangle r = new CellRectangle(0, 0, w, h);

            System.Console.WriteLine("Using cellrendererwindow=" + (IsCellRenderer == true));
            Gdk.Window    masterDrawable = (IsCellRenderer == true) ? cellRendererWindow : evnt.Window;
            Gdk.Drawable  buffer         = null;
            Cairo.Context context        = null;
            if (IsDoubleBuffered == true)
            {
                System.Console.WriteLine("DoubleBuffered");
                buffer  = new Gdk.Pixmap(masterDrawable, Allocation.Width, Allocation.Height, 24);
                context = Gdk.CairoHelper.Create(buffer);
            }
            else
            {
                masterDrawable.BeginPaintRect(evnt.Area);
                context = Gdk.CairoHelper.Create(masterDrawable);
            }

            Gdk.Color clr = Style.Backgrounds[(int)StateType.Normal];
//			context.Color = new Cairo.Color (0, 0, 1);
            context.Color = clr.GetCairoColor();
            r.DrawPath(context);
            context.Fill();
//			if ((BackgroundPainted == true) && (Sensitive == true))
//				PaintBackground (evnt, g, rect);
//			Cairo.Rectangle r = rect.CopyAndShrink (Padding);
            r.Shrink(Padding);

            CalculateCellAreas(r);
            if (IsDoubleBuffered == true)
            {
                PaintCells(evnt, buffer, context, r);
                evnt.Window.DrawDrawable(Style.BlackGC, buffer, evnt.Area.X, evnt.Area.Y, evnt.Area.X, evnt.Area.Y, evnt.Area.Width, evnt.Area.Height);
                buffer.Dispose();
            }
            else
            {
                PaintCells(evnt, masterDrawable, context, r);
                masterDrawable.EndPaint();
            }

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
            context = null;
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Bounding rectangle <see cref="Cairo.Rectangle"/>
        /// </param>
        public static void HBoxCalculateCellAreas(DrawingCellBox aBox, CellRectangle aRect)
        {
            CellRectangle rect = aRect.Copy();

            rect.Shrink(aBox.Padding);
            double start = rect.X;
            double end = System.Convert.ToInt32(rect.Width + rect.X);
            double w, h = 0;
            double cellTop    = rect.Y;
            double cellHeight = System.Convert.ToInt32(rect.Height);

            if (aBox.Homogeneous == true)
            {
                double cw, ch = cw = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    if (w > cw)
                    {
                        cw = w;
                    }
                    if (h > ch)
                    {
                        ch = h;
                    }
                }
                int j = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == true)
                    {
                        aBox.Cells[i].Area.Set(j * cw, cellTop, cw, cellHeight);
                        j++;
                    }
                }
                return;
            }

            IDrawingCell expandedCell = null;

            for (int i = 0; i < aBox.Count; i++)
            {
                if (aBox.Cells[i].IsVisible == false)
                {
                    aBox.Cells[i].Area.Set(0, 0, 0, 0);
                    continue;
                }
                if (aBox.Cells[i].Expanded == true)
                {
                    expandedCell = aBox.Cells[i];
                    break;
                }
                aBox.Cells[i].GetCellSize(out w, out h);
                aBox.Cells[i].Area.Set(start, cellTop, w, cellHeight);
                start += w + aBox.Spacing;
            }
            if (expandedCell != null)
            {
                for (int i = aBox.Count - 1; i > -1; i--)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    if (aBox.Cells[i].Expanded == true)
                    {
                        break;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    aBox.Cells[i].Area.Set(end - w, cellTop, w, cellHeight);
                    end -= w + aBox.Spacing;
                }
                if (expandedCell.IsVisible == true)
                {
                    expandedCell.Area.Set(start, cellTop, end - start, cellHeight);
                }
                else
                {
                    expandedCell.Area.Set(0, 0, 0, 0);
                }
            }
            aBox.RecalcChildren();
        }