Beispiel #1
0
        public static Xwt.Drawing.Image WithSize(this Xwt.Drawing.Image image, Gtk.IconSize size)
        {
            int w, h;

            size.GetSize(out w, out h);
            return(image.WithSize(w, h));
        }
Beispiel #2
0
 protected override bool OnExposeEvent(Gdk.EventExpose evnt)
 {
     if (TabStrip.VisualStyle.TabStyle == DockTabStyle.Normal)
     {
         using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) {
             ctx.DrawImage(this, tabbarBackImage.WithSize(Allocation.Width, Allocation.Height), 0, 0);
         }
     }
     return(base.OnExposeEvent(evnt));
 }
Beispiel #3
0
        public static Xwt.Drawing.Image WithSize(this Xwt.Drawing.Image image, Gtk.IconSize size)
        {
            int w, h;

            if (!Gtk.Icon.SizeLookup(size, out w, out h))
            {
                return(image);
            }
            return(image.WithSize(w, h));
        }
Beispiel #4
0
            public StatusIcon(StatusArea statusBar, Xwt.Drawing.Image icon)
            {
                if (!icon.HasFixedSize)
                {
                    icon = icon.WithSize(IconSize.Menu);
                }

                this.statusBar        = statusBar;
                this.icon             = icon;
                box                   = new EventBox();
                box.VisibleWindow     = false;
                image                 = new Xwt.ImageView(icon);
                box.Child             = image.ToGtkWidget();
                box.Events           |= Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
                box.EnterNotifyEvent += HandleEnterNotifyEvent;
                box.LeaveNotifyEvent += HandleLeaveNotifyEvent;
            }
Beispiel #5
0
            public StatusIcon(StatusArea statusBar, Xwt.Drawing.Image icon)
            {
                if (!icon.HasFixedSize)
                {
                    icon = icon.WithSize(IconSize.Menu);
                }

                this.statusBar        = statusBar;
                this.icon             = icon;
                box                   = new EventBox();
                box.VisibleWindow     = false;
                image                 = new Xwt.ImageView(icon);
                box.Child             = image.ToGtkWidget();
                box.Events           |= Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
                box.EnterNotifyEvent += HandleEnterNotifyEvent;
                box.LeaveNotifyEvent += HandleLeaveNotifyEvent;
                box.ButtonPressEvent += (o, e) => {
                    // TODO: Refactor this in Xwt as an extension method.
                    var m = Xwt.ModifierKeys.None;
                    if ((e.Event.State & Gdk.ModifierType.ShiftMask) != 0)
                    {
                        m |= Xwt.ModifierKeys.Shift;
                    }
                    if ((e.Event.State & Gdk.ModifierType.ControlMask) != 0)
                    {
                        m |= Xwt.ModifierKeys.Control;
                    }
                    if ((e.Event.State & Gdk.ModifierType.Mod1Mask) != 0)
                    {
                        m |= Xwt.ModifierKeys.Alt;
                    }
                    // TODO: Backport this one.
                    if ((e.Event.State & Gdk.ModifierType.Mod2Mask) != 0)
                    {
                        m |= Xwt.ModifierKeys.Command;
                    }

                    Clicked(o, new StatusBarIconClickedEventArgs {
                        Button    = (Xwt.PointerButton)e.Event.Button,
                        Modifiers = m,
                    });
                };
            }
Beispiel #6
0
        void Draw(Context ctx)
        {
            int              tabArea    = tabEndX - tabStartX;
            int              x          = GetRenderOffset();
            const int        y          = 0;
            int              n          = 0;
            Action <Context> drawActive = c => {
            };
            var drawCommands            = new List <Action <Context> > ();

            for (; n < notebook.Tabs.Count; n++)
            {
                if (x + TabWidth < tabStartX)
                {
                    x += TabWidth;
                    continue;
                }

                if (x > tabEndX)
                {
                    break;
                }

                int closingWidth;
                var cmd = DrawClosingTab(n, new Gdk.Rectangle(x, y, 0, Allocation.Height), out closingWidth);
                drawCommands.Add(cmd);
                x += closingWidth;

                var  tab    = (DockNotebookTab)notebook.Tabs [n];
                bool active = tab == notebook.CurrentTab;

                int width = Math.Min(TabWidth, Math.Max(50, tabEndX - x - 1));
                if (tab == notebook.Tabs.Last())
                {
                    width += LastTabWidthAdjustment;
                }
                width = (int)(width * tab.WidthModifier);

                if (active)
                {
                    int tmp = x;
                    drawActive     = c => DrawTab(c, tab, Allocation, new Gdk.Rectangle(tmp, y, width, Allocation.Height), true, true, draggingTab, CreateTabLayout(tab, true));
                    tab.Allocation = new Gdk.Rectangle(tmp, Allocation.Y, width, Allocation.Height);
                }
                else
                {
                    int  tmp         = x;
                    bool highlighted = tab == highlightedTab;

                    if (tab.SaveStrength > 0.0f)
                    {
                        tmp = (int)(tab.SavedAllocation.X + (tmp - tab.SavedAllocation.X) * (1.0f - tab.SaveStrength));
                    }

                    drawCommands.Add(c => DrawTab(c, tab, Allocation, new Gdk.Rectangle(tmp, y, width, Allocation.Height), highlighted, false, false, CreateTabLayout(tab)));
                    tab.Allocation = new Gdk.Rectangle(tmp, Allocation.Y, width, Allocation.Height);
                }

                x += width;
            }

            var allocation = Allocation;
            int tabWidth;

            drawCommands.Add(DrawClosingTab(n, new Gdk.Rectangle(x, y, 0, allocation.Height), out tabWidth));
            drawCommands.Reverse();

            ctx.DrawImage(this, tabbarBackImage.WithSize(allocation.Width, allocation.Height), 0, 0);

            // Draw breadcrumb bar header
//			if (notebook.Tabs.Count > 0) {
//				ctx.Rectangle (0, allocation.Height - BottomBarPadding, allocation.Width, BottomBarPadding);
//				ctx.SetSourceColor (Styles.BreadcrumbBackgroundColor);
//				ctx.Fill ();
//			}

            ctx.Rectangle(tabStartX - LeanWidth / 2, allocation.Y, tabArea + LeanWidth, allocation.Height);
            ctx.Clip();

            foreach (var cmd in drawCommands)
            {
                cmd(ctx);
            }

            ctx.ResetClip();

            // Redraw the dragging tab here to be sure its on top. We drew it before to get the sizing correct, this should be fixed.
            drawActive(ctx);
        }
Beispiel #7
0
 public static Gdk.Pixbuf ToPixbuf(this Xwt.Drawing.Image image, Gtk.IconSize size)
 {
     return((Gdk.Pixbuf)GtkToolkit.GetNativeImage(image.WithSize(size)));
 }