Exemplo n.º 1
0
        public ColorDialogHandler()
        {
#if GTK3
            if (Gtk.Global.MinorVersion >= 4)
            {
                Control = new Gtk.Dialog(NativeMethods.gtk_color_chooser_dialog_new("Choose Color", IntPtr.Zero));
            }
            else
#endif
            Control = new Gtk.ColorSelectionDialog(string.Empty);
        }
Exemplo n.º 2
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            if (swap_rect.ContainsPoint (ev.X, ev.Y)) {
                Color temp = PintaCore.Palette.PrimaryColor;
                PintaCore.Palette.PrimaryColor = PintaCore.Palette.SecondaryColor;
                PintaCore.Palette.SecondaryColor = temp;
                GdkWindow.Invalidate ();
            }

            if (primary_rect.ContainsPoint (ev.X, ev.Y)) {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Primary Color"));
                csd.ColorSelection.PreviousColor = PintaCore.Palette.PrimaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentColor = PintaCore.Palette.PrimaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentAlpha = PintaCore.Palette.PrimaryColor.GdkColorAlpha ();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run ();

                if (response == (int)Gtk.ResponseType.Ok) {
                    PintaCore.Palette.PrimaryColor = csd.ColorSelection.GetCairoColor ();
                }

                csd.Destroy ();
            } else if (secondary_rect.ContainsPoint (ev.X, ev.Y)) {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Secondary Color"));
                csd.ColorSelection.PreviousColor = PintaCore.Palette.SecondaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentColor = PintaCore.Palette.SecondaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentAlpha = PintaCore.Palette.SecondaryColor.GdkColorAlpha ();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run ();

                if (response == (int)Gtk.ResponseType.Ok) {
                    PintaCore.Palette.SecondaryColor = csd.ColorSelection.GetCairoColor ();
                }

                csd.Destroy ();
            }

            int pal = PointToPalette ((int)ev.X, (int)ev.Y);

            if (pal >= 0) {
                if (ev.Button == 3)
                    PintaCore.Palette.SecondaryColor = palette[pal];
                else if (ev.Button == 1)
                    PintaCore.Palette.PrimaryColor = palette[pal];
                else {
                    Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Palette Color"));
                    csd.ColorSelection.PreviousColor = palette[pal].ToGdkColor ();
                    csd.ColorSelection.CurrentColor = palette[pal].ToGdkColor ();
                    csd.ColorSelection.CurrentAlpha = palette[pal].GdkColorAlpha ();
                    csd.ColorSelection.HasOpacityControl = true;

                    int response = csd.Run ();

                    if (response == (int)Gtk.ResponseType.Ok) {
                        palette[pal] = csd.ColorSelection.GetCairoColor ();
                    }

                    csd.Destroy ();
                }

                GdkWindow.Invalidate ();
            }

            // Insert button press handling code here.
            return base.OnButtonPressEvent (ev);
        }
Exemplo n.º 3
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            if (swap_rect.ContainsPoint(ev.X, ev.Y))
            {
                Color temp = PintaCore.Palette.PrimaryColor;
                PintaCore.Palette.PrimaryColor   = PintaCore.Palette.SecondaryColor;
                PintaCore.Palette.SecondaryColor = temp;
                GdkWindow.Invalidate();
            }
            else if (reset_rect.ContainsPoint(ev.X, ev.Y))
            {
                PintaCore.Palette.PrimaryColor   = new Color(0, 0, 0);
                PintaCore.Palette.SecondaryColor = new Color(1, 1, 1);
                GdkWindow.Invalidate();
            }

            if (primary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Primary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.PrimaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.PrimaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }
            else if (secondary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Secondary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.SecondaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.SecondaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }

            int pal = PointToPalette((int)ev.X, (int)ev.Y);

            if (pal >= 0)
            {
                if (ev.Button == 3)
                {
                    PintaCore.Palette.SecondaryColor = palette[pal];
                }
                else if (ev.Button == 1)
                {
                    PintaCore.Palette.PrimaryColor = palette[pal];
                }
                else
                {
                    Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Palette Color"));
                    csd.TransientFor = PintaCore.Chrome.MainWindow;
                    csd.ColorSelection.PreviousColor     = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentColor      = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentAlpha      = palette[pal].GdkColorAlpha();
                    csd.ColorSelection.HasOpacityControl = true;

                    int response = csd.Run();

                    if (response == (int)Gtk.ResponseType.Ok)
                    {
                        palette[pal] = csd.ColorSelection.GetCairoColor();
                    }

                    csd.Destroy();
                }

                GdkWindow.Invalidate();
            }

            // Insert button press handling code here.
            return(base.OnButtonPressEvent(ev));
        }
Exemplo n.º 4
0
		public SelectColorDialogBackend ()
		{
			dlg = new Gtk.ColorSelectionDialog (null);
			defaultTitle = dlg.Title;
		}
Exemplo n.º 5
0
 public SelectColorDialogBackend()
 {
     dlg          = new Gtk.ColorSelectionDialog(null);
     defaultTitle = dlg.Title;
 }
Exemplo n.º 6
0
 public SelectColorDialogBackend()
 {
     dlg = new Gtk.ColorSelectionDialog("");
 }
Exemplo n.º 7
0
		public SelectColorDialogBackend ()
		{
			dlg = new Gtk.ColorSelectionDialog ("");
		}