예제 #1
0
파일: ColorSelector.cs 프로젝트: m13253/xwt
		public DefaultColorSelectorBackend ()
		{
			HBox box = new HBox ();
			Table selBox = new Table ();
			hsBox = new HueBox ();
			hsBox.Light = 0.5;
			lightBox = new LightBox ();
			hsBox.SelectionChanged += delegate {
				lightBox.Hue = hsBox.SelectedColor.Hue;
				lightBox.Saturation = hsBox.SelectedColor.Saturation;
			};
			
			colorBox = new ColorSelectionBox () { MinHeight = 20 };
			
			selBox.Add (hsBox, 0, 0);
			selBox.Add (lightBox, 1, 0);
			
			box.PackStart (selBox);
			
			const int entryWidth = 40;
			VBox entryBox = new VBox ();
			Table entryTable = new Table ();
			
			entryTable.Add (new Label ("Color:"), 0, 0);
			entryTable.Add (colorBox, 1, 0, colspan:4);
			entryTable.Add (new HSeparator (), 0, 1, colspan:5);
			
			int r = 2;
			entryTable.Add (new Label ("Hue:"), 0, r);
			entryTable.Add (hueEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 360, Digits = 0, IncrementValue = 1 }, 1, r++);
			
			entryTable.Add (new Label ("Saturation:"), 0, r);
			entryTable.Add (satEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1 }, 1, r++);
			
			entryTable.Add (new Label ("Light:"), 0, r);
			entryTable.Add (lightEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1 }, 1, r++);
			
			r = 2;
			entryTable.Add (new Label ("Red:"), 3, r);
			entryTable.Add (redEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1 }, 4, r++);
			
			entryTable.Add (new Label ("Green:"), 3, r);
			entryTable.Add (greenEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1 }, 4, r++);
			
			entryTable.Add (new Label ("Blue:"), 3, r);
			entryTable.Add (blueEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1 }, 4, r++);
			
			Label label;
			entryTable.Add (alphaSeparator = new HSeparator (), 0, r++, colspan:5);
			entryTable.Add (label = new Label ("Opacity:"), 0, r);
			entryTable.Add (alphaSlider = new HSlider () {
				MinimumValue = 0, MaximumValue = 255,  }, 1, r, colspan: 3);
			entryTable.Add (alphaEntry = new SpinButton () { 
				MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1 }, 4, r);
			
			alphaControls.Add (alphaSeparator);
			alphaControls.Add (label);
			alphaControls.Add (alphaEntry);
			
			entryBox.PackStart (entryTable);
			box.PackStart (entryBox);
			Content = box;
			
			hsBox.SelectionChanged += delegate {
				HandleColorBoxSelectionChanged ();
			};
			lightBox.SelectionChanged += delegate {
				HandleColorBoxSelectionChanged ();
			};
			
			hueEntry.ValueChanged += HandleHslChanged;
			satEntry.ValueChanged += HandleHslChanged;
			lightEntry.ValueChanged += HandleHslChanged;
			redEntry.ValueChanged += HandleRgbChanged;
			greenEntry.ValueChanged += HandleRgbChanged;
			blueEntry.ValueChanged += HandleRgbChanged;
			alphaEntry.ValueChanged += HandleAlphaChanged;
			alphaSlider.ValueChanged += HandleAlphaChanged;
			
			Color = Colors.White;
		}
예제 #2
0
        public DefaultColorSelectorBackend()
        {
            HBox box = new HBox ();
            Table selBox = new Table ();
            hsBox = new HueBox ();
            hsBox.Light = 0.5;
            lightBox = new LightBox ();
            hsBox.SelectionChanged += delegate {
                lightBox.Hue = hsBox.SelectedColor.Hue;
                lightBox.Saturation = hsBox.SelectedColor.Saturation;
            };

            colorBox = new ColorSelectionBox () { MinHeight = 20 };

            selBox.Attach (hsBox, 0, 0);
            selBox.Attach (lightBox, 1, 0);

            box.PackStart (selBox);

            int entryWidth = 40;
            VBox entryBox = new VBox ();
            Table entryTable = new Table ();

            entryTable.Attach (new Label ("Color:"), 0, 0);
            entryTable.Attach (colorBox, 1, 5, 0, 1);
            entryTable.Attach (new HSeparator (), 0, 5, 1, 2);

            int r = 2;
            entryTable.Attach (new Label ("Hue:"), 0, r);
            entryTable.Attach (hueEntry = new TextEntry () { MinWidth = entryWidth }, 1, r++);

            entryTable.Attach (new Label ("Saturation:"), 0, r);
            entryTable.Attach (satEntry = new TextEntry () { MinWidth = entryWidth }, 1, r++);

            entryTable.Attach (new Label ("Light:"), 0, r);
            entryTable.Attach (lightEntry = new TextEntry () { MinWidth = entryWidth }, 1, r++);

            r = 2;
            entryTable.Attach (new Label ("Red:"), 3, r);
            entryTable.Attach (redEntry = new TextEntry () { MinWidth = entryWidth }, 4, r++);

            entryTable.Attach (new Label ("Green:"), 3, r);
            entryTable.Attach (greenEntry = new TextEntry () { MinWidth = entryWidth }, 4, r++);

            entryTable.Attach (new Label ("Blue:"), 3, r);
            entryTable.Attach (blueEntry = new TextEntry () { MinWidth = entryWidth }, 4, r++);

            Label label;
            entryTable.Attach (alphaSeparator = new HSeparator (), 0, 5, r, ++r);
            entryTable.Attach (label = new Label ("Opacity:"), 0, r);
            entryTable.Attach (alphaEntry = new TextEntry () { MinWidth = entryWidth }, 1, r);

            alphaControls.Add (alphaSeparator);
            alphaControls.Add (label);
            alphaControls.Add (alphaEntry);

            entryBox.PackStart (entryTable);
            box.PackStart (entryBox);
            Content = box;

            hsBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged ();
            };
            lightBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged ();
            };

            hueEntry.Changed += HandleHslChanged;
            satEntry.Changed += HandleHslChanged;
            lightEntry.Changed += HandleHslChanged;
            redEntry.Changed += HandleRgbChanged;
            greenEntry.Changed += HandleRgbChanged;
            blueEntry.Changed += HandleRgbChanged;
            alphaEntry.Changed += HandleAlphaChanged;

            Color = Colors.White;
        }
예제 #3
0
        public DefaultColorSelectorBackend()
        {
            HBox  box    = new HBox();
            Table selBox = new Table();

            hsBox                   = new HueBox();
            hsBox.Light             = 0.5;
            lightBox                = new LightBox();
            hsBox.SelectionChanged += delegate {
                lightBox.Hue        = hsBox.SelectedColor.Hue;
                lightBox.Saturation = hsBox.SelectedColor.Saturation;
            };

            colorBox = new ColorSelectionBox()
            {
                MinHeight = 20
            };

            selBox.Attach(hsBox, 0, 0);
            selBox.Attach(lightBox, 1, 0);

            box.PackStart(selBox);

            int   entryWidth = 40;
            VBox  entryBox   = new VBox();
            Table entryTable = new Table();

            entryTable.Attach(new Label("Color:"), 0, 0);
            entryTable.Attach(colorBox, 1, 5, 0, 1);
            entryTable.Attach(new HSeparator(), 0, 5, 1, 2);

            int r = 2;

            entryTable.Attach(new Label("Hue:"), 0, r);
            entryTable.Attach(hueEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 1, r++);

            entryTable.Attach(new Label("Saturation:"), 0, r);
            entryTable.Attach(satEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 1, r++);

            entryTable.Attach(new Label("Light:"), 0, r);
            entryTable.Attach(lightEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 1, r++);

            r = 2;
            entryTable.Attach(new Label("Red:"), 3, r);
            entryTable.Attach(redEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 4, r++);

            entryTable.Attach(new Label("Green:"), 3, r);
            entryTable.Attach(greenEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 4, r++);

            entryTable.Attach(new Label("Blue:"), 3, r);
            entryTable.Attach(blueEntry = new TextEntry()
            {
                MinWidth = entryWidth
            }, 4, r++);

            Label label;

            entryTable.Attach(alphaSeparator = new HSeparator(), 0, 5, r, ++r);
            entryTable.Attach(label          = new Label("Opacity:"), 0, r);
            entryTable.Attach(alphaEntry     = new TextEntry()
            {
                MinWidth = entryWidth
            }, 1, r);

            alphaControls.Add(alphaSeparator);
            alphaControls.Add(label);
            alphaControls.Add(alphaEntry);

            entryBox.PackStart(entryTable);
            box.PackStart(entryBox);
            Content = box;

            hsBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged();
            };
            lightBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged();
            };

            hueEntry.Changed   += HandleHslChanged;
            satEntry.Changed   += HandleHslChanged;
            lightEntry.Changed += HandleHslChanged;
            redEntry.Changed   += HandleRgbChanged;
            greenEntry.Changed += HandleRgbChanged;
            blueEntry.Changed  += HandleRgbChanged;
            alphaEntry.Changed += HandleAlphaChanged;

            Color = Colors.White;
        }
예제 #4
0
        public DefaultColorSelectorBackend()
        {
            HBox  box    = new HBox();
            Table selBox = new Table();

            hsBox                   = new HueBox();
            hsBox.Light             = 0.5;
            lightBox                = new LightBox();
            hsBox.SelectionChanged += delegate {
                lightBox.Hue        = hsBox.SelectedColor.Hue;
                lightBox.Saturation = hsBox.SelectedColor.Saturation;
            };

            colorBox = new ColorSelectionBox()
            {
                MinHeight = 20
            };

            selBox.Add(hsBox, 0, 0);
            selBox.Add(lightBox, 1, 0);

            box.PackStart(selBox);

            const int entryWidth = 40;
            VBox      entryBox   = new VBox();
            Table     entryTable = new Table();

            entryTable.Add(new Label("Color:"), 0, 0);
            entryTable.Add(colorBox, 1, 0, colspan: 4);
            entryTable.Add(new HSeparator(), 0, 1, colspan: 5);

            int r = 2;

            entryTable.Add(new Label("Hue:"), 0, r);
            entryTable.Add(hueEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 360, Digits = 0, IncrementValue = 1
            }, 1, r++);

            entryTable.Add(new Label("Saturation:"), 0, r);
            entryTable.Add(satEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1
            }, 1, r++);

            entryTable.Add(new Label("Light:"), 0, r);
            entryTable.Add(lightEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1
            }, 1, r++);

            r = 2;
            entryTable.Add(new Label("Red:"), 3, r);
            entryTable.Add(redEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);

            entryTable.Add(new Label("Green:"), 3, r);
            entryTable.Add(greenEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);

            entryTable.Add(new Label("Blue:"), 3, r);
            entryTable.Add(blueEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);

            Label label;

            entryTable.Add(alphaSeparator = new HSeparator(), 0, r++, colspan: 5);
            entryTable.Add(label          = new Label("Opacity:"), 0, r);
            entryTable.Add(alphaSlider    = new HSlider()
            {
                MinimumValue = 0, MaximumValue = 255,
            }, 1, r, colspan: 3);
            entryTable.Add(alphaEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r);

            alphaControls.Add(alphaSeparator);
            alphaControls.Add(label);
            alphaControls.Add(alphaEntry);

            entryBox.PackStart(entryTable);
            box.PackStart(entryBox);
            Content = box;

            hsBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged();
            };
            lightBox.SelectionChanged += delegate {
                HandleColorBoxSelectionChanged();
            };

            hueEntry.ValueChanged    += HandleHslChanged;
            satEntry.ValueChanged    += HandleHslChanged;
            lightEntry.ValueChanged  += HandleHslChanged;
            redEntry.ValueChanged    += HandleRgbChanged;
            greenEntry.ValueChanged  += HandleRgbChanged;
            blueEntry.ValueChanged   += HandleRgbChanged;
            alphaEntry.ValueChanged  += HandleAlphaChanged;
            alphaSlider.ValueChanged += HandleAlphaChanged;

            Color = Colors.White;
        }
예제 #5
0
        public DefaultColorSelectorBackend()
        {
            HBox  box    = new HBox();
            Table selBox = new Table();

            hsBox                   = new HueBox();
            hsBox.Light             = 0.5;
            lightBox                = new LightBox();
            hsBox.SelectionChanged += delegate {
                lightBox.Hue        = hsBox.SelectedColor.Hue;
                lightBox.Saturation = hsBox.SelectedColor.Saturation;
            };

            colorBox = new ColorSelectionBox()
            {
                MinHeight = 20
            };

            selBox.Add(hsBox, 0, 0);
            selBox.Add(lightBox, 1, 0);

            box.PackStart(selBox);

            const int entryWidth = 40;
            VBox      entryBox   = new VBox();
            Table     entryTable = new Table();

            entryTable.Add(CreateLabel(Application.TranslationCatalog.GetString("Color:")), 0, 0);
            entryTable.Add(colorBox, 1, 0, colspan: 4);
            entryTable.Add(new HSeparator(), 0, 1, colspan: 5);

            int r        = 2;
            var hueLabel = CreateLabel();

            entryTable.Add(hueLabel, 0, r);
            entryTable.Add(hueEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 360, Digits = 0, IncrementValue = 1
            }, 1, r++);
            SetupEntry(hueEntry, hueLabel, Application.TranslationCatalog.GetString("Hue"));

            var satLabel = CreateLabel();

            entryTable.Add(satLabel, 0, r);
            entryTable.Add(satEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1
            }, 1, r++);
            SetupEntry(satEntry, satLabel, Application.TranslationCatalog.GetString("Saturation"));

            var lightLabel = CreateLabel();

            entryTable.Add(lightLabel, 0, r);
            entryTable.Add(lightEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 100, Digits = 0, IncrementValue = 1
            }, 1, r++);
            SetupEntry(lightEntry, lightLabel, Application.TranslationCatalog.GetString("Light"));

            r = 2;
            var redLabel = CreateLabel();

            entryTable.Add(redLabel, 3, r);
            entryTable.Add(redEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);
            SetupEntry(redEntry, redLabel, Application.TranslationCatalog.GetString("Red"));

            var greenLabel = CreateLabel();

            entryTable.Add(greenLabel, 3, r);
            entryTable.Add(greenEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);
            SetupEntry(greenEntry, greenLabel, Application.TranslationCatalog.GetString("Green"));

            var blueLabel = CreateLabel();

            entryTable.Add(blueLabel, 3, r);
            entryTable.Add(blueEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r++);
            SetupEntry(blueEntry, blueLabel, Application.TranslationCatalog.GetString("Blue"));

            entryTable.Add(alphaSeparator = new HSeparator(), 0, r++, colspan: 5);
            var alphaLabel = CreateLabel();

            entryTable.Add(alphaLabel, 0, r);
            entryTable.Add(alphaSlider = new HSlider()
            {
                MinimumValue = 0, MaximumValue = 255,
            }, 1, r, colspan: 3);
            entryTable.Add(alphaEntry = new SpinButton()
            {
                MinWidth = entryWidth, MinimumValue = 0, MaximumValue = 255, Digits = 0, IncrementValue = 1
            }, 4, r);
            SetupEntry(alphaEntry, alphaLabel, Application.TranslationCatalog.GetString("Opacity"));

            // Don't allow the slider to get keyboard focus, as it doesn't really work with the keyboard and the opacity
            // spin button takes its place
            alphaSlider.CanGetFocus      = false;
            alphaSlider.Accessible.Label = Application.TranslationCatalog.GetString("Opacity");

            alphaControls.Add(alphaSeparator);
            alphaControls.Add(alphaLabel);
            alphaControls.Add(alphaEntry);

            entryBox.PackStart(entryTable);
            box.PackStart(entryBox);
            Content = box;

            hsBox.SelectionChanged    += HandleColorBoxSelectionChanged;
            lightBox.SelectionChanged += HandleColorBoxSelectionChanged;

            hueEntry.ValueChanged    += HandleHslChanged;
            satEntry.ValueChanged    += HandleHslChanged;
            lightEntry.ValueChanged  += HandleHslChanged;
            redEntry.ValueChanged    += HandleRgbChanged;
            greenEntry.ValueChanged  += HandleRgbChanged;
            blueEntry.ValueChanged   += HandleRgbChanged;
            alphaEntry.ValueChanged  += HandleAlphaChanged;
            alphaSlider.ValueChanged += HandleAlphaChanged;

            Color = Colors.White;
        }