public DropdownGroupTest()
            : base(WindowType.Toplevel)
        {
            AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            HBox master = new HBox ();
            master.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            Title = "Ribbons Sample";
            AppPaintable = true;

            Ribbons.Button button0 = new Ribbons.Button ("Hello World");

            RibbonGroup group0 = new RibbonGroup ();
            group0.Label = "Summer of Code";
            group0.Child = button0;
            group0.Expand += onClick;

            DropdownRibbonGroup dropGroup0 = new DropdownRibbonGroup ();
            dropGroup0.Group = group0;
            dropGroup0.Label = "Drop 1";

            DropdownRibbonGroup dropGroup1 = new DropdownRibbonGroup ();
            dropGroup1.Group = group0;
            dropGroup1.Label = "Drop 2";

            master.PackStart (dropGroup0, false, false, 0);
            master.PackStart (dropGroup1, false, false, 0);

            Add (master);

            ScreenChanged += Window_OnScreenChanged;
            Window_OnScreenChanged (this, null);
            ExposeEvent += Window_OnExpose;
            DeleteEvent += Window_OnDelete;

            this.Resize (200, 200);
            this.ShowAll ();
        }
Example #2
0
        private RibbonGroup CreateGroup2()
        {
            Gallery gallery = new Gallery ();
            gallery.AppendTile (new SampleTile ("1"));
            gallery.AppendTile (new SampleTile ("2"));
            gallery.AppendTile (new SampleTile ("3"));
            gallery.AppendTile (new SampleTile ("4"));
            gallery.AppendTile (new SampleTile ("5"));

            RibbonGroup group2 = new RibbonGroup ();
            group2.Label = "Gallery";
            group2.Child = gallery;

            return group2;
        }
Example #3
0
        public MainWindow()
            : base(WindowType.Toplevel)
        {
            AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            VBox master = new VBox ();
            master.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            Title = "Ribbons Sample";
            AppPaintable = true;

            VariantsCombinaisonSwitcher page0 = new VariantsCombinaisonSwitcher ();

            RibbonGroup group0 = CreateGroup0 ();
            RibbonGroup group1 = CreateGroup1 ();
            RibbonGroup group2 = CreateGroup2 ();
            DropdownRibbonGroup dgroup0 = CreateDropdownGroup0 ();
            dgroup0.Group = group0;
            DropdownRibbonGroup dgroup1 = CreateDropdownGroup1 ();
            dgroup1.Group = group1;
            DropdownRibbonGroup dgroup2 = CreateDropdownGroup2 ();
            dgroup2.Group = group2;

            VariantsCombinaison combi0 = new VariantsCombinaison ();
            combi0.Append (group0);
            combi0.Append (group1);
            combi0.Append (group2);
            page0.AddCombinaison (combi0);

            VariantsCombinaison combi1 = new VariantsCombinaison ();
            combi1.Append (group0);
            combi1.Append (group1);
            combi1.Append (dgroup2);
            page0.AddCombinaison (combi1);

            VariantsCombinaison combi2 = new VariantsCombinaison ();
            combi2.Append (dgroup0);
            combi2.Append (dgroup1);
            combi2.Append (dgroup2);
            page0.AddCombinaison (combi2);

            HBox page1 = new HBox (false, 2);
            RibbonGroup group10 = new RibbonGroup ();
            group10.Label = "Welcome on the second page";
            page1.PackStart (group10, false, false, 0);

            HBox page2 = new HBox (false, 2);

            Label pageLabel0 = new Label ("Page 1");
            pageLabel1 = new Label ("Page 2");
            Label pageLabel2 = new Label ("Page 3");

            Ribbons.Button shortcuts = new Ribbons.Button ("Menu");
            shortcuts.Child.ModifyFg (Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));

            Menu mainMenu = new Menu ();
            MenuItem mainMenu_quit = new MenuItem ("Quit");
            mainMenu_quit.Activated += delegate (object Sender, EventArgs e)
            {
                Application.Quit ();
            };
            mainMenu.Append (mainMenu_quit);

            shortcuts.Clicked += delegate (object Sender, EventArgs e)
            {
                mainMenu.Popup ();
                mainMenu.ShowAll ();
            };

            QuickAccessToolbar qat = new QuickAccessToolbar ();
            Ribbons.Button qatNew, qatSave;
            qat.Append (qatNew = Ribbons.Button.FromStockIcon (Gtk.Stock.New, false));
            qat.Append (qatSave = Ribbons.Button.FromStockIcon (Gtk.Stock.Save, false));

            ribbon = new Ribbon ();
            ribbon.ApplicationButton = new ApplicationButton ();
            ribbon.QuickAccessToolbar = qat;
            //ribbon.Shortcuts = shortcuts;
            ribbon.AppendPage (page0, pageLabel0);
            ribbon.AppendPage (page1, pageLabel1);
            ribbon.AppendPage (page2, pageLabel2);
            pageLabel1.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));
            pageLabel1.ButtonPressEvent += delegate (object sender, ButtonPressEventArgs e)
            {
                Console.WriteLine("label1 press");
            };
            pageLabel1.EnterNotifyEvent += delegate (object sender, EnterNotifyEventArgs e)
            {
                Console.WriteLine("label1 enter");
            };
            pageLabel1.LeaveNotifyEvent += delegate (object sender, LeaveNotifyEventArgs e)
            {
                Console.WriteLine("label1 leave");
            };

            ApplicationMenu appMenu = ribbon.ApplicationButton.Menu;
            TextView mnu = new TextView ();
            appMenu.DefaultMenu = mnu;
            mnu.Buffer.InsertAtCursor ("Default");
            ApplicationMenuItem mi = new ApplicationMenuItem ("Test 1");
            mnu = new TextView ();
            mi.Menu = mnu;
            mnu.Buffer.InsertAtCursor ("Test 1");
            appMenu.Append (mi);
            mi = new ApplicationMenuItem ("Test 2");
            appMenu.Append (mi);
            mi = new ApplicationMenuItem ("Test 3");
            appMenu.Append (mi);

            appMenu.OptionsButton = new Ribbons.Button ("Options");
            appMenu.ExitButton = new Ribbons.Button ("Exit");

            TextView txt = new TextView ();

            master.PackStart (ribbon, false, false, 0);
            master.PackStart (txt, true, true, 0);

            Add (master);

            ribbon.ApplicationButton.KeyTip = new KeyTip (appMenu, "A");
            qat.AddKeyTip (new KeyTip (qatNew, "B"));
            qat.AddKeyTip (new KeyTip (qatSave, "C"));
            ribbon.AddTabKeyTip (new KeyTip (pageLabel0, "D"));
            ribbon.AddTabKeyTip (new KeyTip (pageLabel1, "E"));
            ribbon.AddTabKeyTip (new KeyTip (pageLabel2, "F"));

            ScreenChanged += Window_OnScreenChanged;
            Window_OnScreenChanged (this, null);
            ExposeEvent += Window_OnExpose;
            DeleteEvent += Window_OnDelete;

            this.Resize (200, 200);
            this.ShowAll ();
        }
Example #4
0
        private RibbonGroup CreateGroup1()
        {
            Ribbons.Button button1 = new Ribbons.Button ("Menu Test");
            button1.Clicked += onClick;
            Menu button1_menu = new Menu ();
            MenuItem option1 = new MenuItem ("Option 1");
            button1_menu.Append (option1);
            button1.DropDownMenu = button1_menu;

            Menu openMenu = new Menu ();
            MenuItem abc_txt = new MenuItem ("abc.txt");
            openMenu.Append (abc_txt);
            MenuItem foo_txt = new MenuItem ("foo.txt");
            openMenu.Append (foo_txt);

            Ribbons.Button open = Ribbons.Button.FromStockIcon (Gtk.Stock.Open, "Open", false);
            open.DropDownMenu = openMenu;
            open.Clicked += onClick;

            Ribbons.ToolPack fileToolPack = new Ribbons.ToolPack ();
            fileToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.New, "New", false));
            fileToolPack.AppendButton (open);
            fileToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.Save, "Save", false));

            Ribbons.ToolPack printerToolPack = new Ribbons.ToolPack ();
            printerToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.Print, "Print", false));

            Ribbons.ToolPack fontToolPack = new Ribbons.ToolPack ();
            fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Bold, false));
            fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Italic, false));
            fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Underline, false));

            ComboBox font = new ComboBox (new string[] { "Arial", "Verdana" });
            font.Active = 0;

            Ribbons.ToolBox flow0 = new ToolBox ();
            flow0.Append (fileToolPack);
            flow0.Append (printerToolPack);
            flow0.Append (fontToolPack);
            flow0.Append (font);

            HBox btnFlowBox = new HBox (false, 2);
            btnFlowBox.Add (button1);
            btnFlowBox.Add (flow0);

            // Little hack because Gtk+ is not designed to support size negociations
            btnFlowBox.SizeAllocated += delegate(object Sender, SizeAllocatedArgs e)
            {
                flow0.HeightRequest = e.Allocation.Height;
            };

            RibbonGroup group1 = new RibbonGroup ();
            group1.Label = "I will be back";
            group1.Child = btnFlowBox;

            return group1;
        }
Example #5
0
        private RibbonGroup CreateGroup0()
        {
            Ribbons.Button button0 = new Ribbons.Button ("Hello World");

            RibbonGroup group0 = new RibbonGroup ();
            group0.Label = "Summer of Code";
            group0.Child = button0;
            group0.Expand += onClick;

            return group0;
        }
Example #6
0
		/// <summary>Draws a group.</summary>
		internal void DrawGroup (Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
		{
			double lineWidth05 = lineWidth/2, lineWidth15 = 3*lineWidth05;
			LinearGradient linGrad;
			
			double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
			double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;
			cr.Arc (x1, y1, roundSize - lineWidth05, 0, Math.PI/2);
			cr.Arc (x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
			cr.Arc (x0, y0, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
			cr.Arc (x1, y0 + lineWidth, roundSize - lineWidth05, 3*Math.PI/2, 0);
			cr.LineTo (x1 + roundSize - lineWidth05, y1);
			cr.LineWidth = lineWidth;
			cr.Color = colorScheme.Bright;
			cr.Stroke ();
			
			if(l != null)
			{
				int lblWidth, lblHeight;
				Pango.CairoHelper.UpdateLayout (cr, l);
				l.GetPixelSize(out lblWidth, out lblHeight);
				
				double bandHeight = lblHeight + 2*space;
				cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
				cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
				double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
				cr.LineTo (x0 - roundSize + lineWidth05, bandY);
				cr.LineTo (x1 + roundSize - lineWidth15, bandY);
				linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
				linGrad.AddColorStop (0.0, colorScheme.Dark);
				linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
				cr.Pattern = linGrad;
				cr.Fill ();
				
				double frameSize = 2*lineWidth + space;
				double availableHorizontalSpace = r.Width - 2 * frameSize;
				if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;
				
				cr.Save ();
				cr.Rectangle (r.X + frameSize, bandY, availableHorizontalSpace, bandHeight);
				cr.Clip ();
				
				cr.Color = new Color(1, 1, 1);
				Pango.CairoHelper.UpdateLayout (cr, l);
				cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), bandY + space);
				Pango.CairoHelper.ShowLayout (cr, l);
				
				cr.Restore();
			}
			
			cr.MoveTo (x1 + roundSize - lineWidth15, y1);
			cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
			cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
			cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
			cr.Arc (x1 - lineWidth, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
			cr.LineTo (x1 + roundSize - lineWidth15, y1);
			cr.LineWidth = lineWidth;
			linGrad = new LinearGradient (0, r.Y, 0, r.Y + r.Height - lineWidth);
			linGrad.AddColorStop (0.0, ColorScheme.GetColorRelative (colorScheme.PrettyDark, 0.1));
			linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
			cr.Pattern = linGrad;
			cr.Stroke ();
		}
Example #7
0
        /// <summary>Draws a group.</summary>
        internal void DrawGroup(Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
        {
            double lineWidth05 = lineWidth/2, lineWidth15 = 3*lineWidth05;
            LinearGradient linGrad;

            double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
            double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;
            cr.Arc (x1, y1, roundSize - lineWidth05, 0, Math.PI/2);
            cr.Arc (x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
            cr.Arc (x0, y0, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
            cr.Arc (x1, y0 + lineWidth, roundSize - lineWidth05, 3*Math.PI/2, 0);
            cr.LineTo (x1 + roundSize - lineWidth05, y1);
            cr.LineWidth = lineWidth;
            cr.Color = colorScheme.Bright;
            cr.Stroke ();

            if(l != null)
            {
                int lblWidth, lblHeight;
                Pango.CairoHelper.UpdateLayout (cr, l);
                l.GetPixelSize(out lblWidth, out lblHeight);

                if(w.LabelPosition == Position.Top || w.LabelPosition == Position.Bottom)
                {
                    double labelY;
                    double bandHeight = lblHeight + 2*space;

                    if(w.LabelPosition == Position.Top)
                    {
                        cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                        cr.Arc (x1, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
                        double bandY = y0 - roundSize + 2*lineWidth + bandHeight;
                        cr.LineTo (x1 + roundSize - lineWidth15, bandY);
                        cr.LineTo (x0 - roundSize + lineWidth05, bandY);
                        linGrad = new LinearGradient (0, bandY - bandHeight, 0, bandY);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelY = bandY - bandHeight - space;
                    }
                    else
                    {
                        cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
                        cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
                        double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
                        cr.LineTo (x0 - roundSize + lineWidth05, bandY);
                        cr.LineTo (x1 + roundSize - lineWidth15, bandY);
                        linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelY = bandY;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableHorizontalSpace = r.Width - 2 * frameSize;
                    if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;

                    cr.Save ();
                    cr.Rectangle (r.X + frameSize, labelY, availableHorizontalSpace, bandHeight);
                    cr.Clip ();

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), labelY + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
                else	// label at right or left
                {
                    double labelX;
                    double bandWidth = lblHeight + 2*space;

                    if(w.LabelPosition == Position.Left)
                    {
                        cr.Arc (x0, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
                        cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                        double bandX = x0 - roundSize + 2*lineWidth + bandWidth;
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        linGrad = new LinearGradient (bandX - bandWidth, 0, bandX, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX - bandWidth - space;
                    }
                    else
                    {
                        cr.Arc (x1, y0 - lineWidth05, roundSize - lineWidth15, 3*Math.PI/2, 0);
                        cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
                        double bandX = x1 + roundSize - 2*lineWidth - bandWidth;
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        linGrad = new LinearGradient (bandX, 0, bandX + bandWidth, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX + space;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableVerticalSpace = r.Height - 2 * frameSize;
                    if(expandButton.Visible) availableVerticalSpace -= expandButton.HeightRequest + space;

                    cr.Save ();
                    cr.Rectangle (labelX, r.Y + frameSize, bandWidth, availableVerticalSpace);
                    cr.Clip ();
                    cr.Rotate (-Math.PI / 2);

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    double shift = Math.Max(0, (availableVerticalSpace - lblWidth) / 2);
                    if(expandButton.Visible) shift += expandButton.HeightRequest + space;
                    cr.MoveTo (-(r.Y + r.Height - 2 * space - shift), labelX + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
            }

            cr.MoveTo (x1 + roundSize - lineWidth15, y1);
            cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
            cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
            cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
            cr.Arc (x1 - lineWidth, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
            cr.LineTo (x1 + roundSize - lineWidth15, y1);
            cr.LineWidth = lineWidth;
            linGrad = new LinearGradient (0, r.Y, 0, r.Y + r.Height - lineWidth);
            linGrad.AddColorStop (0.0, ColorScheme.GetColorRelative (colorScheme.PrettyDark, 0.1));
            linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
            cr.Pattern = linGrad;
            cr.Stroke ();
            linGrad.Destroy ();
        }