Exemplo n.º 1
0
        public override void Render(Gdk.Drawable window, Cairo.Context ctx, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            var values = Enum.GetValues(Property.PropertyType);

            if (values.Length < MaxCheckCount)
            {
                if (style == null)
                {
                    InitializeStyle(Container);
                }

                var container = (Widget)Container;
                using (var layout = new Pango.Layout(container.PangoContext)) {
                    layout.Width           = -1;
                    layout.FontDescription = FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11);

                    ulong value = Convert.ToUInt64(Value);
                    int   dy    = 2;
                    foreach (var val in values)
                    {
                        ulong          uintVal = Convert.ToUInt64(val);
                        Gtk.ShadowType sh      = (value & uintVal) != 0 ? Gtk.ShadowType.In : Gtk.ShadowType.Out;
                        if (value == 0 && uintVal == 0)
                        {
                            sh = Gtk.ShadowType.In;
                        }
                        int s = indicatorSize - 1;
                        Gtk.Style.PaintCheck(style, window, state, sh, bounds, Container, "checkbutton", bounds.X + indicatorSpacing - 1, bounds.Y + dy, s, s);

                        layout.SetText(val.ToString());
                        int tw, th;
                        layout.GetPixelSize(out tw, out th);
                        ctx.Save();
                        ctx.SetSourceColor(container.Style.Text(state).ToCairoColor());
                        ctx.MoveTo(bounds.X + indicatorSize + indicatorSpacing, dy + bounds.Y + ((indicatorSize - th) / 2));
                        Pango.CairoHelper.ShowLayout(ctx, layout);
                        ctx.Restore();

                        dy += indicatorSize + CheckSpacing;
                    }
                }
            }
            else
            {
                base.Render(window, ctx, bounds, state);
                return;
            }
        }
Exemplo n.º 2
0
        void Render(Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            Gtk.ShadowType sh = (bool)Active ? Gtk.ShadowType.In : Gtk.ShadowType.Out;
            int            s  = (int)(scaleFactor * Size) - 1;

            if (s > bounds.Height)
            {
                s = bounds.Height;
            }
            if (s > bounds.Width)
            {
                s = bounds.Width;
            }

            Gtk.Style.PaintCheck(Container.Style, window, state, sh, bounds, Container, "checkbutton", bounds.X + indicatorSpacing - 1, bounds.Y + (bounds.Height - s) / 2, s, s);
        }
Exemplo n.º 3
0
        public static void PaintFlatBox(Gtk.Style style, Gdk.Drawable window, Gtk.StateType state_type, Gtk.ShadowType shadow_type, Gdk.Rectangle?area, Gtk.Widget widget, string detail, int x, int y, int width, int height)
        {
            IntPtr native_area   = area == null ? IntPtr.Zero : GLib.Marshaller.StructureToPtrAlloc(area);
            IntPtr native_detail = GLib.Marshaller.StringToPtrGStrdup(detail);

            gtk_paint_flat_box(style == null ? IntPtr.Zero : style.Handle, window == null ? IntPtr.Zero : window.Handle, (int)state_type, (int)shadow_type, native_area, widget == null ? IntPtr.Zero : widget.Handle, native_detail, x, y, width, height);
            if (area != null)
            {
                area = Gdk.Rectangle.New(native_area);
                Marshal.FreeHGlobal(native_area);
            }
            GLib.Marshaller.Free(native_detail);
        }