Beispiel #1
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (font_label == null)
                font_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Font")));

            tb.AppendItem (font_label);

            if (font_combo == null) {
                var fonts = PintaCore.System.Fonts.GetInstalledFonts ();
                fonts.Sort ();

                // Default to Arial or first in list
                int index = Math.Max (fonts.IndexOf ("Arial"), 0);

                font_combo = new ToolBarFontComboBox (150, index, fonts.ToArray ());
                font_combo.ComboBox.Changed += HandleFontChanged;
            }

            tb.AppendItem (font_combo);

            if (spacer_label == null)
                spacer_label = new ToolBarLabel (" ");

            tb.AppendItem (spacer_label);

            if (size_combo == null) {
                size_combo = new ToolBarComboBox (65, 0, true);

                size_combo.ComboBox.Changed += HandleSizeChanged;
                (size_combo.ComboBox as Gtk.ComboBoxEntry).Entry.FocusOutEvent += new Gtk.FocusOutEventHandler (HandleFontSizeFocusOut);
                (size_combo.ComboBox as Gtk.ComboBoxEntry).Entry.FocusInEvent += new Gtk.FocusInEventHandler (HandleFontSizeFocusIn);
            }

            tb.AppendItem (size_combo);

            tb.AppendItem (new SeparatorToolItem ());

            if (bold_btn == null) {
                bold_btn = new ToolBarToggleButton ("Toolbar.Bold.png", Catalog.GetString ("Bold"), Catalog.GetString ("Bold"));
                bold_btn.Toggled += HandleBoldButtonToggled;
            }

            tb.AppendItem (bold_btn);

            if (italic_btn == null) {
                italic_btn = new ToolBarToggleButton ("Toolbar.Italic.png", Catalog.GetString ("Italic"), Catalog.GetString ("Italic"));
                italic_btn.Toggled += HandleItalicButtonToggled;
            }

            tb.AppendItem (italic_btn);

            if (underscore_btn == null) {
                underscore_btn = new ToolBarToggleButton ("Toolbar.Underline.png", Catalog.GetString ("Underline"), Catalog.GetString ("Underline"));
                underscore_btn.Toggled += HandleUnderscoreButtonToggled;
            }

            tb.AppendItem (underscore_btn);

            tb.AppendItem (new SeparatorToolItem ());

            if (left_alignment_btn == null) {
                left_alignment_btn = new ToolBarToggleButton ("Toolbar.LeftAlignment.png", Catalog.GetString ("Left Align"), Catalog.GetString ("Left Align"));
                left_alignment_btn.Active = true;
                left_alignment_btn.Toggled += HandleLeftAlignmentButtonToggled;
            }

            tb.AppendItem (left_alignment_btn);

            if (center_alignment_btn == null) {
                center_alignment_btn = new ToolBarToggleButton ("Toolbar.CenterAlignment.png", Catalog.GetString ("Center Align"), Catalog.GetString ("Center Align"));
                center_alignment_btn.Toggled += HandleCenterAlignmentButtonToggled;
            }

            tb.AppendItem (center_alignment_btn);

            if (Right_alignment_btn == null) {
                Right_alignment_btn = new ToolBarToggleButton ("Toolbar.RightAlignment.png", Catalog.GetString ("Right Align"), Catalog.GetString ("Right Align"));
                Right_alignment_btn.Toggled += HandleRightAlignmentButtonToggled;
            }

            tb.AppendItem (Right_alignment_btn);

            if (fill_sep == null)
                fill_sep = new Gtk.SeparatorToolItem ();

            tb.AppendItem (fill_sep);

            if (fill_label == null)
                fill_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Text Style")));

            tb.AppendItem (fill_label);

            if (fill_button == null) {
                fill_button = new ToolBarDropDownButton ();

                fill_button.AddItem (Catalog.GetString ("Normal"), "ShapeTool.Fill.png", 0);
                fill_button.AddItem (Catalog.GetString ("Normal and Outline"), "ShapeTool.OutlineFill.png", 1);
                fill_button.AddItem (Catalog.GetString ("Outline"), "ShapeTool.Outline.png", 2);
                fill_button.AddItem (Catalog.GetString ("Fill Background"), "TextTool.FillBackground.png", 3);

                fill_button.SelectedItemChanged += HandleBoldButtonToggled;
            }

            tb.AppendItem (fill_button);

            if (outline_width_label == null)
                outline_width_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Outline width")));

            tb.AppendItem (outline_width_label);

            if (outline_width_minus == null) {
                outline_width_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", Catalog.GetString ("Decrease outline size"));
                outline_width_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem (outline_width_minus);

            if (outline_width == null) {
                outline_width = new ToolBarComboBox (65, 1, true, "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "10", "11", "12", "13", "14", "15", "20", "25", "30", "35",
                "40", "45", "50", "55");

                (outline_width.Child as ComboBoxEntry).Changed += HandleSizeChanged;
            }

            tb.AppendItem (outline_width);

            if (outline_width_plus == null) {
                outline_width_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", Catalog.GetString ("Increase outline size"));
                outline_width_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem (outline_width_plus);

            UpdateFontSizes ();

            if (PintaCore.Workspace.HasOpenDocuments) {
                //Make sure the event handler is never added twice.
                PintaCore.Workspace.ActiveDocument.LayerCloned -= FinalizeText;

                //When an ImageSurface is Cloned, finalize the re-editable text (if applicable).
                PintaCore.Workspace.ActiveDocument.LayerCloned += FinalizeText;
            }
        }
Beispiel #2
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (linear_gradient_btn == null) {
                linear_gradient_btn = new ToolBarToggleButton ("Toolbar.LinearGradient.png", Catalog.GetString ("Linear Gradient"), Catalog.GetString ("Linear Gradient"));
                linear_gradient_btn.Active = true;
                linear_gradient_btn.Toggled += HandleGradientTypeButtonToggled;;
            }

            tb.AppendItem (linear_gradient_btn);

            if (linear_reflected_gradient_btn == null) {
                linear_reflected_gradient_btn = new ToolBarToggleButton ("Toolbar.LinearReflectedGradient.png", Catalog.GetString ("Linear Reflected Gradient"), Catalog.GetString ("Linear Reflected Gradient"));
                linear_reflected_gradient_btn.Toggled += HandleGradientTypeButtonToggled;;
            }

            tb.AppendItem (linear_reflected_gradient_btn);

            if (diamond_gradient_btn == null) {
                diamond_gradient_btn = new ToolBarToggleButton ("Toolbar.DiamondGradient.png", Catalog.GetString ("Linear Diamond Gradient"), Catalog.GetString ("Linear Diamond Gradient"));
                diamond_gradient_btn.Toggled += HandleGradientTypeButtonToggled;;
            }

            tb.AppendItem (diamond_gradient_btn);

            if (radial_gradient_btn == null) {
                radial_gradient_btn = new ToolBarToggleButton ("Toolbar.RadialGradient.png", Catalog.GetString ("Radial Gradient"), Catalog.GetString ("Radial Gradient"));
                radial_gradient_btn.Toggled += HandleGradientTypeButtonToggled;;
            }

            tb.AppendItem (radial_gradient_btn);

            if (conical_gradient_btn == null) {
                conical_gradient_btn = new ToolBarToggleButton ("Toolbar.ConicalGradient.png", Catalog.GetString ("Conical Gradient"), Catalog.GetString ("Conical Gradient"));
                conical_gradient_btn.Toggled += HandleGradientTypeButtonToggled;;
            }

            tb.AppendItem (conical_gradient_btn);

            tb.AppendItem (new Gtk.SeparatorToolItem ());

            /***** ColorBgra mode *****/
            //TODO icons!
            if (color_mode_gradient_btn == null) {
                color_mode_gradient_btn = new ToolBarToggleButton ("ColorPalette.SwapIcon.png", Catalog.GetString ("Color Mode"), Catalog.GetString ("Color Mode"));
                color_mode_gradient_btn.Active = true;
                color_mode_gradient_btn.Toggled += HandleGradientColorModeButtonToggled;;
            }

            tb.AppendItem (color_mode_gradient_btn);

            if (transparency_mode_gradient_btn == null) {
                transparency_mode_gradient_btn = new ToolBarToggleButton ("ColorPalette.SwapIcon.png", Catalog.GetString ("Transparency Mode"), Catalog.GetString ("Transparency Mode"));
                transparency_mode_gradient_btn.Toggled += HandleGradientColorModeButtonToggled;;
            }

            tb.AppendItem (transparency_mode_gradient_btn);
        }
Beispiel #3
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            //TODO
            //fontSmoothing

            base.OnBuildToolBar (tb);

            if (font_label == null)
                font_label = new ToolBarLabel (" Font: ");

            tb.AppendItem (font_label);

            using (Pango.Context c = PangoHelper.ContextGet ()) {
                List<Pango.FontFamily> fonts = new List<Pango.FontFamily> (c.Families);

                List<string> entries = new List<string> ();
                fonts.ForEach (f => entries.Add (f.Name));
                entries.Sort ();

                //by default Arial!
                int index = entries.IndexOf ("Arial");
                if (index < 0)
                    index = 0;
                //FIXME: I put a try to handle a bug when I am debugging on monodevelop there is a an exception
                //this exception do not occure when I put a try catch ;(
                try {
                    if (font_combo == null) {
                        font_combo = new ToolBarComboBox (100, index, false, entries.ToArray ());
                        font_combo.ComboBox.Changed += HandleFontChanged;
                    }

                    tb.AppendItem (font_combo);

                    //size depend on font and modifier (italic, bold,...)
                    Pango.FontFamily fam = fonts.Find (f => f.Name == font_combo.ComboBox.ActiveText);

                    entries = new List<string> ();
                    foreach (int i in GetSizeList (fam.Faces[0])) {
                        entries.Add (i.ToString ());
                    }

                    //by default 11!
                    index = entries.IndexOf ("11");
                    if (index < 0)
                        index = 0;

                    if (size_combo == null) {
                        size_combo = new ToolBarComboBox (50, index, true, entries.ToArray ());

                        size_combo.ComboBox.Changed += HandleSizeChanged;
                        (size_combo.ComboBox as Gtk.ComboBoxEntry).Entry.FocusOutEvent += new Gtk.FocusOutEventHandler (HandleFontSizeFocusOut);
                        (size_combo.ComboBox as Gtk.ComboBoxEntry).Entry.FocusInEvent += new Gtk.FocusInEventHandler (HandleFontSizeFocusIn);
                    }

                    tb.AppendItem (size_combo);
                } catch (Exception e) {
                    Console.WriteLine (e.ToString ());
                }
            }
            tb.AppendItem (new SeparatorToolItem ());

            if (bold_btn == null) {
                bold_btn = new ToolBarToggleButton ("Toolbar.Bold.png", "Bold", "Bold the text");
                bold_btn.Toggled += HandleBoldButtonToggled;
            }

            tb.AppendItem (bold_btn);

            if (italic_btn == null) {
                italic_btn = new ToolBarToggleButton ("Toolbar.Italic.png", "Italic", "Italic the text");
                italic_btn.Toggled += HandleItalicButtonToggled;
                ;
            }

            tb.AppendItem (italic_btn);

            if (underscore_btn == null) {
                underscore_btn = new ToolBarToggleButton ("Toolbar.Underline.png", "Uncerline", "Underline the text");
                underscore_btn.Toggled += HandleUnderscoreButtonToggled;
            }

            tb.AppendItem (underscore_btn);

            tb.AppendItem (new SeparatorToolItem ());

            if (left_alignment_btn == null) {
                left_alignment_btn = new ToolBarToggleButton ("Toolbar.LeftAlignment.png", "Align left", "Align text to left");
                left_alignment_btn.Active = true;
                left_alignment_btn.Toggled += HandleLeftAlignmentButtonToggled;
                ;
            }

            tb.AppendItem (left_alignment_btn);

            if (center_alignment_btn == null) {
                center_alignment_btn = new ToolBarToggleButton ("Toolbar.CenterAlignment.png", "Align center", "Align text to center");
                center_alignment_btn.Toggled += HandleCenterAlignmentButtonToggled;
                ;
            }

            tb.AppendItem (center_alignment_btn);

            if (Right_alignment_btn == null) {
                Right_alignment_btn = new ToolBarToggleButton ("Toolbar.RightAlignment.png", "Align right", "Align text to right");
                Right_alignment_btn.Toggled += HandleRightAlignmentButtonToggled;
                ;
            }

            tb.AppendItem (Right_alignment_btn);
        }