Inheritance: Gtk.ToolItem
Exemplo n.º 1
0
        public ViewActions()
        {
            Gtk.IconFactory fact = new Gtk.IconFactory ();
            fact.Add ("Menu.View.ActualSize.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ActualSize.png")));
            fact.Add ("Menu.View.Grid.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Grid.png")));
            fact.Add ("Menu.View.Rulers.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Rulers.png")));
            fact.Add ("Menu.View.ZoomIn.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomIn.png")));
            fact.Add ("Menu.View.ZoomOut.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomOut.png")));
            fact.Add ("Menu.View.ZoomToSelection.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToSelection.png")));
            fact.Add ("Menu.View.ZoomToWindow.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToWindow.png")));
            fact.AddDefault ();

            ZoomIn = new Gtk.Action ("ZoomIn", Mono.Unix.Catalog.GetString ("Zoom In"), null, "Menu.View.ZoomIn.png");
            ZoomOut = new Gtk.Action ("ZoomOut", Mono.Unix.Catalog.GetString ("Zoom Out"), null, "Menu.View.ZoomOut.png");
            ZoomToWindow = new Gtk.Action ("ZoomToWindow", Mono.Unix.Catalog.GetString ("Zoom to Window"), null, "Menu.View.ZoomToWindow.png");
            ZoomToSelection = new Gtk.Action ("ZoomToSelection", Mono.Unix.Catalog.GetString ("Zoom to Selection"), null, "Menu.View.ZoomToSelection.png");
            ActualSize = new Gtk.Action ("ActualSize", Mono.Unix.Catalog.GetString ("Actual Size"), null, "Menu.View.ActualSize.png");
            PixelGrid = new Gtk.ToggleAction ("PixelGrid", Mono.Unix.Catalog.GetString ("Pixel Grid"), null, "Menu.View.Grid.png");
            Rulers = new Gtk.ToggleAction ("Rulers", Mono.Unix.Catalog.GetString ("Rulers"), null, "Menu.View.Rulers.png");
            Pixels = new Gtk.Action ("Pixels", Mono.Unix.Catalog.GetString ("Pixels"), null, null);
            Inches = new Gtk.Action ("Inches", Mono.Unix.Catalog.GetString ("Inches"), null, null);
            Centimeters = new Gtk.Action ("Centimeters", Mono.Unix.Catalog.GetString ("Centimeters"), null, null);
            Fullscreen = new Gtk.Action ("Fullscreen", Catalog.GetString ("Fullscreen"), null, Gtk.Stock.Fullscreen);

            ZoomComboBox = new ToolBarComboBox (75, 11, true, "3600%", "2400%", "1600%", "1200%", "800%", "700%", "600%", "500%", "400%", "300%", "200%", "100%", "66%", "50%", "33%", "25%", "16%", "12%", "8%", "5%", "Window");
            UnitComboBox = new ToolBarComboBox (100, 0, false, "Pixels", "Inches", "Centimeters");
        }
Exemplo n.º 2
0
        public ViewActions()
        {
            Gtk.IconFactory fact = new Gtk.IconFactory ();
            fact.Add ("Menu.View.ActualSize.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ActualSize.png")));
            fact.Add ("Menu.View.Grid.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Grid.png")));
            fact.Add ("Menu.View.Rulers.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Rulers.png")));
            fact.Add ("Menu.View.ZoomIn.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomIn.png")));
            fact.Add ("Menu.View.ZoomOut.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomOut.png")));
            fact.Add ("Menu.View.ZoomToSelection.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToSelection.png")));
            fact.Add ("Menu.View.ZoomToWindow.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToWindow.png")));
            fact.AddDefault ();

            ZoomIn = new Gtk.Action ("ZoomIn", Catalog.GetString ("Zoom In"), null, Stock.ZoomIn);
            ZoomOut = new Gtk.Action ("ZoomOut", Catalog.GetString ("Zoom Out"), null, Stock.ZoomOut);
            ZoomToWindow = new Gtk.Action ("ZoomToWindow", Catalog.GetString ("Best Fit"), null, Stock.ZoomFit);
            ZoomToSelection = new Gtk.Action ("ZoomToSelection", Catalog.GetString ("Zoom to Selection"), null, "Menu.View.ZoomToSelection.png");
            ActualSize = new Gtk.Action ("ActualSize", Catalog.GetString ("Normal Size"), null, Stock.Zoom100);
            ToolBar = new Gtk.ToggleAction ("Toolbar", Catalog.GetString ("Toolbar"), null, null);
            PixelGrid = new Gtk.ToggleAction ("PixelGrid", Catalog.GetString ("Pixel Grid"), null, "Menu.View.Grid.png");
            Rulers = new Gtk.ToggleAction ("Rulers", Catalog.GetString ("Rulers"), null, "Menu.View.Rulers.png");
            Pixels = new Gtk.RadioAction ("Pixels", Catalog.GetString ("Pixels"), null, null, 0);
            Inches = new Gtk.RadioAction ("Inches", Catalog.GetString ("Inches"), null, null, 1);
            Centimeters = new Gtk.RadioAction ("Centimeters", Catalog.GetString ("Centimeters"), null, null, 2);
            Fullscreen = new Gtk.Action ("Fullscreen", Catalog.GetString ("Fullscreen"), null, Stock.Fullscreen);

            ZoomCollection = new string[] { "3600%", "2400%", "1600%", "1200%", "800%", "700%", "600%", "500%", "400%", "300%", "200%", "175%", "150%", "125%", "100%", "66%", "50%", "33%", "25%", "16%", "12%", "8%", "5%", "Window" };
            ZoomComboBox = new ToolBarComboBox (75, DefaultZoomIndex(), true, ZoomCollection);

            // Make sure these are the same group so only one will be selected at a time
            Inches.Group = Pixels.Group;
            Centimeters.Group = Pixels.Group;
        }
Exemplo n.º 3
0
		/// <summary>
		/// Sets up the DashPatternBox in the Toolbar.
		/// 
		/// Note that the dash pattern change event response code must be created manually outside of the DashPatternBox
		/// (using the returned Gtk.ComboBox from the SetupToolbar method) so that each tool that uses it
		/// can react to the change in pattern according to its usage.
		/// 
		/// Returns null if the DashPatternBox has already been setup; otherwise, returns the DashPatternBox itself.
		/// </summary>
		/// <param name="tb">The Toolbar to add the DashPatternBox to.</param>
		/// <returns>null if the DashPatternBox has already been setup; otherwise, returns the DashPatternBox itself.</returns>
		public Gtk.ComboBox SetupToolbar(Toolbar tb)
		{
			if (dashPatternSep == null)
			{
				dashPatternSep = new SeparatorToolItem();
			}

			tb.AppendItem(dashPatternSep);

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

			tb.AppendItem(dashPatternLabel);

			if (comboBox == null)
			{
				comboBox = new ToolBarComboBox(100, 0, true,
					"-", " -", " --", " ---", "  -", "   -", " - --", " - - --------", " - - ---- - ----");
			}

			tb.AppendItem(comboBox);

			if (dashChangeSetup)
			{
				return null;
			}
			else
			{
				dashChangeSetup = true;

				return comboBox.ComboBox;
			}
		}
Exemplo n.º 4
0
        public void BuildToolbar (Gtk.Toolbar tb)
        {
            if (selection_label == null)
                selection_label = new ToolBarLabel (Catalog.GetString (" Selection Mode: "));

            tb.AppendItem (selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox (170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) =>
                {
                    Gtk.TreeIter iter;
                    if (selection_combo_box.ComboBox.GetActiveIter (out iter))
                        selected_mode = (CombineMode)selection_combo_box.Model.GetValue (iter, 1);
                };

                foreach (var mode in combine_modes)
                    selection_combo_box.Model.AppendValues (mode.Value, mode.Key);

                selection_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem (selection_combo_box);
        }
Exemplo n.º 5
0
        public ViewActions()
        {
            ZoomIn          = new Command("ZoomIn", Translations.GetString("Zoom In"), null, Resources.StandardIcons.ZoomIn);
            ZoomOut         = new Command("ZoomOut", Translations.GetString("Zoom Out"), null, Resources.StandardIcons.ZoomOut);
            ZoomToWindow    = new Command("ZoomToWindow", Translations.GetString("Best Fit"), null, Resources.StandardIcons.ZoomFitBest);
            ZoomToSelection = new Command("ZoomToSelection", Translations.GetString("Zoom to Selection"), null, Resources.Icons.ViewZoomSelection);
            ActualSize      = new Command("ActualSize", Translations.GetString("Normal Size"), null, Resources.StandardIcons.ZoomOriginal);
            ToolBar         = new ToggleCommand("Toolbar", Translations.GetString("Toolbar"), null, null);
            ImageTabs       = new ToggleCommand("ImageTabs", Translations.GetString("Image Tabs"), null, null);
            PixelGrid       = new ToggleCommand("PixelGrid", Translations.GetString("Pixel Grid"), null, Resources.Icons.ViewGrid);
            StatusBar       = new ToggleCommand("Statusbar", Translations.GetString("Status Bar"), null, null);
            ToolBox         = new ToggleCommand("ToolBox", Translations.GetString("Tool Box"), null, null);
            Rulers          = new ToggleCommand("Rulers", Translations.GetString("Rulers"), null, Resources.Icons.ViewRulers);
            RulerMetric     = new GLib.SimpleAction("rulermetric", GLib.VariantType.Int32, new GLib.Variant(0));
            Fullscreen      = new Command("Fullscreen", Translations.GetString("Fullscreen"), null, Resources.StandardIcons.DocumentNew);

            ZoomCollection = new string[] {
                ToPercent(36),
                ToPercent(24),
                ToPercent(16),
                ToPercent(12),
                ToPercent(8),
                ToPercent(7),
                ToPercent(6),
                ToPercent(5),
                ToPercent(4),
                ToPercent(3),
                ToPercent(2),
                ToPercent(1.75),
                ToPercent(1.5),
                ToPercent(1.25),
                ToPercent(1),
                ToPercent(0.66),
                ToPercent(0.5),
                ToPercent(0.33),
                ToPercent(0.25),
                ToPercent(0.16),
                ToPercent(0.12),
                ToPercent(0.08),
                ToPercent(0.05),
                Translations.GetString("Window")
            };
            ZoomComboBox = new ToolBarComboBox(90, DefaultZoomIndex(), true, ZoomCollection)
            {
                Margin = 4
            };

            // The toolbar is shown by default.
            ToolBar.Value   = true;
            ImageTabs.Value = true;
            StatusBar.Value = true;
            ToolBox.Value   = true;
        }
Exemplo n.º 6
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (tool_select_label == null)
                tool_select_label = new ToolBarLabel (" After select:  ");

            tb.AppendItem (tool_select_label);

            // TODO: Enable when we have the Pencil tool
            if (tool_select == null)
                tool_select = new ToolBarComboBox (170, 0, false, "Do not switch tool", "Switch to previous tool");//, "Switch to Pencil tool");

            tb.AppendItem (tool_select);
        }
Exemplo n.º 7
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar(tb);

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

            tb.AppendItem(selection_sep);

            if (selection_label == null)
                selection_label = new ToolBarLabel(Catalog.GetString(" Selection Mode: "));

            tb.AppendItem(selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox(170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) =>
                {
                    Gtk.TreeIter iter;

                    if (selection_combo_box.ComboBox.GetActiveIter(out iter))
                    {
                        SelectionMode = ((KeyValuePair<int, string>)selection_combo_box.Model.GetValue(iter, 1)).Key;
                    }
                };

                foreach(KeyValuePair<int, string> sel in selectionCombinations)
                {
                    selection_combo_box.Model.AppendValues(sel.Value, sel);
                }

                selection_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem(selection_combo_box);
        }
Exemplo n.º 8
0
		public override void HandleBuildToolBar(Gtk.Toolbar tb)
		{
			base.HandleBuildToolBar(tb);


			#region Show Arrows

			//Arrow separator.

			if (arrowSep == null)
			{
				arrowSep = new Gtk.SeparatorToolItem();

				showOtherArrowOptions = false;
			}

			tb.AppendItem(arrowSep);


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

			tb.AppendItem(arrowLabel);


			//Show arrow 1.

			showArrowOneBox = new Gtk.CheckButton("1");
			showArrowOneBox.Active = previousSettings1.Show;

			showArrowOneBox.Toggled += (o, e) =>
			{
				//Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
				if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
				{
					if (showOtherArrowOptions)
					{
						tb.Remove(arrowSizeLabel);
						tb.Remove(arrowSizeMinus);
						tb.Remove(arrowSize);
						tb.Remove(arrowSizePlus);
						tb.Remove(arrowAngleOffsetLabel);
						tb.Remove(arrowAngleOffsetMinus);
						tb.Remove(arrowAngleOffset);
						tb.Remove(arrowAngleOffsetPlus);
						tb.Remove(arrowLengthOffsetLabel);
						tb.Remove(arrowLengthOffsetMinus);
						tb.Remove(arrowLengthOffset);
						tb.Remove(arrowLengthOffsetPlus);

						showOtherArrowOptions = false;
					}
				}
				else
				{
					if (!showOtherArrowOptions)
					{
						tb.Add(arrowSizeLabel);
						tb.Add(arrowSizeMinus);
						tb.Add(arrowSize);
						tb.Add(arrowSizePlus);
						tb.Add(arrowAngleOffsetLabel);
						tb.Add(arrowAngleOffsetMinus);
						tb.Add(arrowAngleOffset);
						tb.Add(arrowAngleOffsetPlus);
						tb.Add(arrowLengthOffsetLabel);
						tb.Add(arrowLengthOffsetMinus);
						tb.Add(arrowLengthOffset);
						tb.Add(arrowLengthOffsetPlus);

						showOtherArrowOptions = true;
					}
				}

				LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

				if (activeEngine != null)
				{
					activeEngine.Arrow1.Show = showArrowOneBox.Active;

					DrawActiveShape(false, false, true, false, false);

					StorePreviousSettings();
				}
			};

			tb.AddWidgetItem(showArrowOneBox);


			//Show arrow 2.

			showArrowTwoBox = new Gtk.CheckButton("2");
			showArrowTwoBox.Active = previousSettings2.Show;

			showArrowTwoBox.Toggled += (o, e) =>
			{
				//Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
				if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
				{
					if (showOtherArrowOptions)
					{
						tb.Remove(arrowSizeLabel);
						tb.Remove(arrowSizeMinus);
						tb.Remove(arrowSize);
						tb.Remove(arrowSizePlus);
						tb.Remove(arrowAngleOffsetLabel);
						tb.Remove(arrowAngleOffsetMinus);
						tb.Remove(arrowAngleOffset);
						tb.Remove(arrowAngleOffsetPlus);
						tb.Remove(arrowLengthOffsetLabel);
						tb.Remove(arrowLengthOffsetMinus);
						tb.Remove(arrowLengthOffset);
						tb.Remove(arrowLengthOffsetPlus);

						showOtherArrowOptions = false;
					}
				}
				else
				{
					if (!showOtherArrowOptions)
					{
						tb.Add(arrowSizeLabel);
						tb.Add(arrowSizeMinus);
						tb.Add(arrowSize);
						tb.Add(arrowSizePlus);
						tb.Add(arrowAngleOffsetLabel);
						tb.Add(arrowAngleOffsetMinus);
						tb.Add(arrowAngleOffset);
						tb.Add(arrowAngleOffsetPlus);
						tb.Add(arrowLengthOffsetLabel);
						tb.Add(arrowLengthOffsetMinus);
						tb.Add(arrowLengthOffset);
						tb.Add(arrowLengthOffsetPlus);

						showOtherArrowOptions = true;
					}
				}

				LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

				if (activeEngine != null)
				{
					activeEngine.Arrow2.Show = showArrowTwoBox.Active;

					DrawActiveShape(false, false, true, false, false);

					StorePreviousSettings();
				}
			};

			tb.AddWidgetItem(showArrowTwoBox);

			#endregion Show Arrows


			#region Arrow Size

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

			if (arrowSizeMinus == null)
			{
				arrowSizeMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease arrow size"));
				arrowSizeMinus.Clicked += new EventHandler(arrowSizeMinus_Clicked);
			}

			if (arrowSize == null)
			{
				arrowSize = new ToolBarComboBox(65, 7, true,
					"3", "4", "5", "6", "7", "8", "9", "10", "12", "15", "18",
					"20", "25", "30", "40", "50", "60", "70", "80", "90", "100");

				arrowSize.ComboBox.Changed += (o, e) =>
				{
					if (arrowSize.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else
					{
						double newSize = 10d;

						if (arrowSize.ComboBox.ActiveText == "-")
						{
							//The user is trying to enter a negative value: change it to 1.
							newSize = 1d;
						}
						else
						{
							if (Double.TryParse(arrowSize.ComboBox.ActiveText, out newSize))
							{
								if (newSize < 1d)
								{
									//Less than 1: change it to 1.
									newSize = 1d;
								}
								else if (newSize > 100d)
								{
									//Greater than 100: change it to 100.
									newSize = 100d;
								}
							}
							else
							{
								//Not a number: wait until the user enters something.
								return;
							}
						}

						(arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newSize.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.ArrowSize = newSize;
							activeEngine.Arrow2.ArrowSize = newSize;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowSizePlus == null)
			{
				arrowSizePlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase arrow size"));
				arrowSizePlus.Clicked += new EventHandler(arrowSizePlus_Clicked);
			}

			#endregion Arrow Size


			#region Angle Offset

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

			if (arrowAngleOffsetMinus == null)
			{
				arrowAngleOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease angle offset"));
				arrowAngleOffsetMinus.Clicked += new EventHandler(arrowAngleOffsetMinus_Clicked);
			}

			if (arrowAngleOffset == null)
			{
				arrowAngleOffset = new ToolBarComboBox(65, 9, true,
					"-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

				arrowAngleOffset.ComboBox.Changed += (o, e) =>
				{
					if (arrowAngleOffset.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else if (arrowAngleOffset.ComboBox.ActiveText == "-")
					{
						//The user is trying to enter a negative value: ignore the change until the user enters more.
						return;
					}
					else
					{
						double newAngle = 15d;

						if (Double.TryParse(arrowAngleOffset.ComboBox.ActiveText, out newAngle))
						{
							if (newAngle < -89d)
							{
								//Less than -89: change it to -89.
								newAngle = -89d;
							}
							else if (newAngle > 89d)
							{
								//Greater than 89: change it to 89.
								newAngle = 89d;
							}
						}
						else
						{
							//Not a number: wait until the user enters something.
							return;
						}

						(arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newAngle.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.AngleOffset = newAngle;
							activeEngine.Arrow2.AngleOffset = newAngle;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowAngleOffsetPlus == null)
			{
				arrowAngleOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase angle offset"));
				arrowAngleOffsetPlus.Clicked += new EventHandler(arrowAngleOffsetPlus_Clicked);
			}

			#endregion Angle Offset


			#region Length Offset

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

			if (arrowLengthOffsetMinus == null)
			{
				arrowLengthOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease length offset"));
				arrowLengthOffsetMinus.Clicked += new EventHandler(arrowLengthOffsetMinus_Clicked);
			}

			if (arrowLengthOffset == null)
			{
				arrowLengthOffset = new ToolBarComboBox(65, 8, true,
					"-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

				arrowLengthOffset.ComboBox.Changed += (o, e) =>
				{
					if (arrowLengthOffset.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else if (arrowLengthOffset.ComboBox.ActiveText == "-")
					{
						//The user is trying to enter a negative value: ignore the change until the user enters more.
						return;
					}
					else
					{
						double newLength = 10d;

						if (Double.TryParse(arrowLengthOffset.ComboBox.ActiveText, out newLength))
						{
							if (newLength < -100d)
							{
								//Less than -100: change it to -100.
								newLength = -100d;
							}
							else if (newLength > 100d)
							{
								//Greater than 100: change it to 100.
								newLength = 100d;
							}
						}
						else
						{
							//Not a number: wait until the user enters something.
							return;
						}

						(arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newLength.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.LengthOffset = newLength;
							activeEngine.Arrow2.LengthOffset = newLength;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowLengthOffsetPlus == null)
			{
				arrowLengthOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase length offset"));
				arrowLengthOffsetPlus.Clicked += new EventHandler(arrowLengthOffsetPlus_Clicked);
			}

			#endregion Length Offset

			
			if (showOtherArrowOptions)
			{
				tb.Add(arrowSizeLabel);
				tb.Add(arrowSizeMinus);
				tb.Add(arrowSize);
				tb.Add(arrowSizePlus);
				tb.Add(arrowAngleOffsetLabel);
				tb.Add(arrowAngleOffsetMinus);
				tb.Add(arrowAngleOffset);
				tb.Add(arrowAngleOffsetPlus);
				tb.Add(arrowLengthOffsetLabel);
				tb.Add(arrowLengthOffsetMinus);
				tb.Add(arrowLengthOffset);
				tb.Add(arrowLengthOffsetPlus);
			}
		}
Exemplo n.º 9
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (mode_label == null)
                mode_label = new ToolBarLabel (" Fill mode: ");

            tb.AppendItem (mode_label);

            if (mode_combo == null)
                mode_combo = new ToolBarComboBox (100, 0, false, "Contiguous", "Global");

            tb.AppendItem (mode_combo);

            if (tolerance_label == null)
                tolerance_label = new ToolBarLabel ("    Tolerance: ");

            tb.AppendItem (tolerance_label);

            if (tolerance_slider == null)
                tolerance_slider = new ToolBarSlider (0, 100, 1, 0);

            tb.AppendItem (tolerance_slider);
        }
Exemplo n.º 10
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar(tb);

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

            tb.AppendItem (spacer_label);

            if (fill_outline_image == null)
                fill_outline_image = new ToolBarImage ("ShapeTool.OutlineFill.png");

            tb.AppendItem (fill_outline_image);

            if (fill_outline_label == null)
                fill_outline_label = new ToolBarLabel (" : ");

            tb.AppendItem (fill_outline_label);

            if (fill_outline == null)
                fill_outline = new ToolBarComboBox (150, 0, false, "Outline Shape", "Fill Shape", "Fill and Outline Shape");

            tb.AppendItem (fill_outline);
        }
Exemplo n.º 11
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel (" Brush width: ");

            tb.AppendItem (brush_width_label);

            if (brush_width_minus == null) {
                brush_width_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", "Decrease brush size");
                brush_width_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_minus);

            if (brush_width == null)
                brush_width = new ToolBarComboBox (50, 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");

            tb.AppendItem (brush_width);

            if (brush_width_plus == null) {
                brush_width_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", "Increase brush size");
                brush_width_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_plus);
        }
Exemplo n.º 12
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (mode_label == null)
                mode_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Fill mode")));

            tb.AppendItem (mode_label);

            if (mode_combo == null)
                mode_combo = new ToolBarComboBox (100, 0, false, Catalog.GetString ("Contiguous"), Catalog.GetString ("Global"));

            tb.AppendItem (mode_combo);

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

            tb.AppendItem (tolerance_label);

            if (tolerance_slider == null)
                tolerance_slider = new ToolBarSlider (0, 100, 1, 0);

            tb.AppendItem (tolerance_slider);
        }
Exemplo n.º 13
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar(tb);

            if (label_type == null)
                label_type = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Type")));
            if (comboBox_type == null) {
                comboBox_type = new ToolBarComboBox (100, 0, false, Catalog.GetString ("Normal"), Catalog.GetString ("Smooth"));

                comboBox_type.ComboBox.Changed += (o, e) =>
                {
                    eraser_type = (EraserType)comboBox_type.ComboBox.Active;
                };
            }
            tb.AppendItem (label_type);
            tb.AppendItem (comboBox_type);
            // Change the cursor when the BrushWidth is changed.
            brush_width.ComboBox.Changed += (sender, e) => SetCursor (DefaultCursor);
        }
Exemplo n.º 14
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;
            }
        }
Exemplo n.º 15
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar (tb);

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

            if (brush_combo_box == null) {
                brush_combo_box = new ToolBarComboBox (100, 0, false);
                brush_combo_box.ComboBox.Changed += (o, e) => {
                    Gtk.TreeIter iter;
                    if (brush_combo_box.ComboBox.GetActiveIter (out iter)) {
                        active_brush = (PaintBrush)brush_combo_box.Model.GetValue (iter, 1);
                    } else {
                        active_brush = default_brush;
                    }
                };
                foreach (var brush in PintaCore.PaintBrushes) {
                    if (default_brush == null)
                        default_brush = (PaintBrush)brush;
                    brush_combo_box.Model.AppendValues (brush.Name, brush);
                }
                brush_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem (brush_label);
            tb.AppendItem (brush_combo_box);
        }
Exemplo n.º 16
0
		public ViewActions ()
		{
			Gtk.IconFactory fact = new Gtk.IconFactory ();
			fact.Add ("Menu.View.ActualSize.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ActualSize.png")));
			fact.Add ("Menu.View.Grid.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Grid.png")));
			fact.Add ("Menu.View.Rulers.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.Rulers.png")));
			fact.Add ("Menu.View.ZoomIn.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomIn.png")));
			fact.Add ("Menu.View.ZoomOut.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomOut.png")));
			fact.Add ("Menu.View.ZoomToSelection.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToSelection.png")));
			fact.Add ("Menu.View.ZoomToWindow.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Menu.View.ZoomToWindow.png")));
			fact.AddDefault ();
			
			ZoomIn = new Gtk.Action ("ZoomIn", Catalog.GetString ("Zoom In"), null, Stock.ZoomIn);
			ZoomOut = new Gtk.Action ("ZoomOut", Catalog.GetString ("Zoom Out"), null, Stock.ZoomOut);
			ZoomToWindow = new Gtk.Action ("ZoomToWindow", Catalog.GetString ("Best Fit"), null, Stock.ZoomFit);
			ZoomToSelection = new Gtk.Action ("ZoomToSelection", Catalog.GetString ("Zoom to Selection"), null, "Menu.View.ZoomToSelection.png");
			ActualSize = new Gtk.Action ("ActualSize", Catalog.GetString ("Normal Size"), null, Stock.Zoom100);
            ToolBar = new Gtk.ToggleAction ("Toolbar", Catalog.GetString ("Toolbar"), null, null);
            ImageTabs = new Gtk.ToggleAction ("ImageTabs", Catalog.GetString ("Image Tabs"), null, null);
            PixelGrid = new Gtk.ToggleAction ("PixelGrid", Catalog.GetString ("Pixel Grid"), null, "Menu.View.Grid.png");
			Rulers = new Gtk.ToggleAction ("Rulers", Catalog.GetString ("Rulers"), null, "Menu.View.Rulers.png");
			Pixels = new Gtk.RadioAction ("Pixels", Catalog.GetString ("Pixels"), null, null, 0);
			Inches = new Gtk.RadioAction ("Inches", Catalog.GetString ("Inches"), null, null, 1);
			Centimeters = new Gtk.RadioAction ("Centimeters", Catalog.GetString ("Centimeters"), null, null, 2);
			Fullscreen = new Gtk.Action ("Fullscreen", Catalog.GetString ("Fullscreen"), null, Stock.Fullscreen);

			ZoomCollection = new string[] {
				ToPercent (36),
				ToPercent (24),
				ToPercent (16),
				ToPercent (12),
				ToPercent (8),
				ToPercent (7),
				ToPercent (6),
				ToPercent (5),
				ToPercent (4),
				ToPercent (3),
				ToPercent (2),
				ToPercent (1.75),
				ToPercent (1.5),
				ToPercent (1.25),
				ToPercent (1),
				ToPercent (0.66),
				ToPercent (0.5),
				ToPercent (0.33),
				ToPercent (0.25),
				ToPercent (0.16),
				ToPercent (0.12),
				ToPercent (0.08),
				ToPercent (0.05),
				Catalog.GetString ("Window")
			};
			ZoomComboBox = new ToolBarComboBox (90, DefaultZoomIndex(), true, ZoomCollection);

			// Make sure these are the same group so only one will be selected at a time
			Inches.Group = Pixels.Group;
			Centimeters.Group = Pixels.Group;

            // The toolbar is shown by default.
            ToolBar.Active = true;
            ImageTabs.Active = true;
		}
Exemplo n.º 17
0
        protected override void BuildToolBar(Gtk.Toolbar tb)
        {
            base.BuildToolBar (tb);

            if (radius_label == null)
                radius_label = new ToolBarLabel ("  Radius: ");

            tb.AppendItem (radius_label);

            if (radius_minus == null) {
                radius_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", "Decrease rectangle's corner radius");
                radius_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem (radius_minus);

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

            tb.AppendItem (radius);

            if (radius_plus == null) {
                radius_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", "Increase rectangle's corner radius");
                radius_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem (radius_plus);
        }
Exemplo n.º 18
0
        public virtual void HandleBuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Brush width")));

            tb.AppendItem(brush_width_label);

            if (brush_width_minus == null)
            {
                brush_width_minus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease brush size"));
                brush_width_minus.Clicked += BrushMinusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_minus);

			if (brush_width == null)
			{
				brush_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");

				brush_width.ComboBox.Changed += (o, e) =>
				{
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						selEngine.BrushWidth = BrushWidth;
                        StorePreviousSettings ();
                        DrawActiveShape (false, false, true, false, false);
					}
				};
			}

            tb.AppendItem(brush_width);

            if (brush_width_plus == null)
            {
                brush_width_plus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase brush size"));
                brush_width_plus.Clicked += BrushPlusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_plus);

            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("Fill Style")));

            tb.AppendItem(fill_label);

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

                fill_button.AddItem(Catalog.GetString("Outline Shape"), "ShapeTool.Outline.png", 0);
                fill_button.AddItem(Catalog.GetString("Fill Shape"), "ShapeTool.Fill.png", 1);
                fill_button.AddItem(Catalog.GetString("Fill and Outline Shape"), "ShapeTool.OutlineFill.png", 2);
            }

            tb.AppendItem(fill_button);

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

			tb.AppendItem(shape_type_sep);

			if (shape_type_label == null)
				shape_type_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Shape Type")));

			tb.AppendItem(shape_type_label);

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

				shape_type_button.AddItem(Catalog.GetString("Open Line/Curve Series"), "Tools.Line.png", 0);
				shape_type_button.AddItem(Catalog.GetString("Closed Line/Curve Series"), "Tools.Rectangle.png", 1);
				shape_type_button.AddItem(Catalog.GetString("Ellipse"), "Tools.Ellipse.png", 2);
				shape_type_button.AddItem(Catalog.GetString("Rounded Line Series"), "Tools.RoundedRectangle.png", 3);

				shape_type_button.SelectedItemChanged += (o, e) =>
				{
					ShapeTypes newShapeType = ShapeType;
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						//Verify that the tool needs to be switched.
						if (GetCorrespondingTool(newShapeType) != this.owner)
						{
							//Create a new ShapesModifyHistoryItem so that the changing of the shape type can be undone.
							PintaCore.Workspace.ActiveDocument.History.PushNewItem(new ShapesModifyHistoryItem(
								this, owner.Icon, Catalog.GetString("Changed Shape Type")));

							//Clone the old shape; it should be automatically garbage-collected. newShapeType already has the updated value.
							selEngine = selEngine.Convert(newShapeType, SelectedShapeIndex);

							int previousSSI = SelectedShapeIndex;

							ActivateCorrespondingTool(selEngine.ShapeType, true);

							SelectedShapeIndex = previousSSI;

							//Draw the updated shape with organized points generation (for mouse detection). 
							DrawActiveShape(true, false, true, false, true);
						}
					}
				};
			}

			shape_type_button.SelectedItem = shape_type_button.Items[(int)owner.ShapeType];

			tb.AppendItem(shape_type_button);


            Gtk.ComboBox dpbBox = dash_pattern_box.SetupToolbar(tb);

            if (dpbBox != null)
            {
                dpbBox.Changed += (o, e) =>
                {
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						selEngine.DashPattern = dpbBox.ActiveText;
                        StorePreviousSettings ();
                        DrawActiveShape (false, false, true, false, false);
					}
                };
            }
        }
Exemplo n.º 19
0
        protected override void BuildToolBar(Gtk.Toolbar tb)
        {
            base.BuildToolBar (tb);

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

            tb.AppendItem (radius_sep);

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

            tb.AppendItem (radius_label);

            if (radius_minus == null) {
                radius_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", Catalog.GetString ("Decrease rectangle's corner radius"));
                radius_minus.Clicked += RadiusMinusButtonClickedEvent;
            }

            tb.AppendItem (radius_minus);

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

            tb.AppendItem (radius);

            if (radius_plus == null) {
                radius_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", Catalog.GetString ("Increase rectangle's corner radius"));
                radius_plus.Clicked += RadiusPlusButtonClickedEvent;
            }

            tb.AppendItem (radius_plus);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        protected override void OnBuildToolBar(Gtk.Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            if (tool_select_label == null)
                tool_select_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("After select")));

            tb.AppendItem (tool_select_label);

            // TODO: Enable when we have the Pencil tool
            if (tool_select == null)
                tool_select = new ToolBarComboBox (170, 0, false, Catalog.GetString ("Do not switch tool"), Catalog.GetString ("Switch to previous tool"), Catalog.GetString ("Switch to Pencil tool"));

            tb.AppendItem (tool_select);
        }
Exemplo n.º 22
0
		public override void HandleBuildToolBar(Gtk.Toolbar tb)
		{
			base.HandleBuildToolBar(tb);


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

			tb.AppendItem(radius_sep);

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

			tb.AppendItem(radius_label);

			if (radius_minus == null)
			{
				radius_minus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease shape's corner radius"));
				radius_minus.Clicked += RadiusMinusButtonClickedEvent;
			}

			tb.AppendItem(radius_minus);

			if (radius == null)
			{
				radius = new ToolBarComboBox(65, 16, true, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
				"10", "11", "12", "13", "14", "15", "20", "25", "30", "40",
				"50", "60", "70", "80");

				radius.ComboBox.Changed += (o, e) =>
				{
					//Go through the Get/Set routine.
					Radius = Radius;
				};
			}

			tb.AppendItem(radius);

			if (radius_plus == null)
			{
				radius_plus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase shape's corner radius"));
				radius_plus.Clicked += RadiusPlusButtonClickedEvent;
			}

			tb.AppendItem(radius_plus);
		}
Exemplo n.º 23
0
        public ViewActions()
        {
            Gtk.IconFactory fact = new Gtk.IconFactory();
            fact.Add("Menu.View.ActualSize.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.ActualSize.png")));
            fact.Add("Menu.View.Grid.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.Grid.png")));
            fact.Add("Menu.View.Rulers.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.Rulers.png")));
            fact.Add("Menu.View.ZoomIn.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.ZoomIn.png")));
            fact.Add("Menu.View.ZoomOut.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.ZoomOut.png")));
            fact.Add("Menu.View.ZoomToSelection.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.ZoomToSelection.png")));
            fact.Add("Menu.View.ZoomToWindow.png", new Gtk.IconSet(PintaCore.Resources.GetIcon("Menu.View.ZoomToWindow.png")));
            fact.AddDefault();

            ZoomIn          = new Gtk.Action("ZoomIn", Catalog.GetString("Zoom In"), null, Stock.ZoomIn);
            ZoomOut         = new Gtk.Action("ZoomOut", Catalog.GetString("Zoom Out"), null, Stock.ZoomOut);
            ZoomToWindow    = new Gtk.Action("ZoomToWindow", Catalog.GetString("Best Fit"), null, Stock.ZoomFit);
            ZoomToSelection = new Gtk.Action("ZoomToSelection", Catalog.GetString("Zoom to Selection"), null, "Menu.View.ZoomToSelection.png");
            ActualSize      = new Gtk.Action("ActualSize", Catalog.GetString("Normal Size"), null, Stock.Zoom100);
            ToolBar         = new Gtk.ToggleAction("Toolbar", Catalog.GetString("Toolbar"), null, null);
            ImageTabs       = new Gtk.ToggleAction("ImageTabs", Catalog.GetString("Image Tabs"), null, null);
            PixelGrid       = new Gtk.ToggleAction("PixelGrid", Catalog.GetString("Pixel Grid"), null, "Menu.View.Grid.png");
            Rulers          = new Gtk.ToggleAction("Rulers", Catalog.GetString("Rulers"), null, "Menu.View.Rulers.png");
            Pixels          = new Gtk.RadioAction("Pixels", Catalog.GetString("Pixels"), null, null, 0);
            Inches          = new Gtk.RadioAction("Inches", Catalog.GetString("Inches"), null, null, 1);
            Centimeters     = new Gtk.RadioAction("Centimeters", Catalog.GetString("Centimeters"), null, null, 2);
            Fullscreen      = new Gtk.Action("Fullscreen", Catalog.GetString("Fullscreen"), null, Stock.Fullscreen);

            ZoomCollection = new string[] {
                ToPercent(36),
                ToPercent(24),
                ToPercent(16),
                ToPercent(12),
                ToPercent(8),
                ToPercent(7),
                ToPercent(6),
                ToPercent(5),
                ToPercent(4),
                ToPercent(3),
                ToPercent(2),
                ToPercent(1.75),
                ToPercent(1.5),
                ToPercent(1.25),
                ToPercent(1),
                ToPercent(0.66),
                ToPercent(0.5),
                ToPercent(0.33),
                ToPercent(0.25),
                ToPercent(0.16),
                ToPercent(0.12),
                ToPercent(0.08),
                ToPercent(0.05),
                Catalog.GetString("Window")
            };
            ZoomComboBox = new ToolBarComboBox(90, DefaultZoomIndex(), true, ZoomCollection);

            // Make sure these are the same group so only one will be selected at a time
            Inches.Group      = Pixels.Group;
            Centimeters.Group = Pixels.Group;

            // The toolbar is shown by default.
            ToolBar.Active   = true;
            ImageTabs.Active = true;
        }
Exemplo n.º 24
0
        // Do this in a separate method so SelectTool can override it as
        // a no-op, but still get the BaseShape.OnBuildToolBar logic.
        protected virtual void BuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Brush width")));

            tb.AppendItem (brush_width_label);

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

            tb.AppendItem (brush_width_minus);

            if (brush_width == null)
                brush_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");

            tb.AppendItem (brush_width);

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

            tb.AppendItem (brush_width_plus);

            if (ShowStrokeComboBox) {
                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 ("Fill Style")));

                tb.AppendItem (fill_label);

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

                    fill_button.AddItem (Catalog.GetString ("Outline Shape"), "ShapeTool.Outline.png", 0);
                    fill_button.AddItem (Catalog.GetString ("Fill Shape"), "ShapeTool.Fill.png", 1);
                    fill_button.AddItem (Catalog.GetString ("Fill and Outline Shape"), "ShapeTool.OutlineFill.png", 2);
                }

                tb.AppendItem (fill_button);
            }
        }
Exemplo n.º 25
0
        // Do this in a separate method so SelectTool can override it as
        // a no-op, but still get the BaseShape.OnBuildToolBar logic.
        protected virtual void BuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel (" Brush width: ");

            tb.AppendItem (brush_width_label);

            if (brush_width_minus == null) {
                brush_width_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", "Decrease brush size");
                brush_width_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_minus);

            if (brush_width == null)
                brush_width = new ToolBarComboBox (50, 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");

            tb.AppendItem (brush_width);

            if (brush_width_plus == null) {
                brush_width_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", "Increase brush size");
                brush_width_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_plus);

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

                tb.AppendItem (spacer_label);

                if (fill_outline_image == null)
                    fill_outline_image = new ToolBarImage ("ShapeTool.OutlineFill.png");

                tb.AppendItem (fill_outline_image);

                if (fill_outline_label == null)
                    fill_outline_label = new ToolBarLabel (" : ");

                tb.AppendItem (fill_outline_label);

                if (fill_outline == null)
                    fill_outline = new ToolBarComboBox (150, 0, false, "Outline Shape", "Fill Shape", "Fill and Outline Shape");

                tb.AppendItem (fill_outline);
            }
        }
Exemplo n.º 26
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar (tb);

            // Change the cursor when the BrushWidth is changed.
            brush_width.ComboBox.Changed += (sender, e) => SetCursor (DefaultCursor);

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

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

            if (brush_combo_box == null) {
                brush_combo_box = new ToolBarComboBox (100, 0, false);
                brush_combo_box.ComboBox.Changed += (o, e) => {
                    Gtk.TreeIter iter;
                    if (brush_combo_box.ComboBox.GetActiveIter (out iter)) {
                        active_brush = (BasePaintBrush)brush_combo_box.Model.GetValue (iter, 1);
                    } else {
                        active_brush = default_brush;
                    }
                };

                RebuildBrushComboBox ();
            }

            tb.AppendItem (brush_label);
            tb.AppendItem (brush_combo_box);
        }