2
// HScaleSpinButtonWidget.cs
7
// Copyright (c) 2010 Krzysztof Marecki <marecki.krzysztof@gmail.com>
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.ComponentModel;
30
namespace Pinta.Gui.Widgets
32
[System.ComponentModel.ToolboxItem(true)]
33
public partial class HScaleSpinButtonWidget : Gtk.Bin
35
[Category("Custom Properties")]
37
get { return label.Text; }
38
set { label.Text = value; }
41
[Category("Custom Properties")]
42
public int DefaultValue { get; set; }
44
private int max_value;
45
[Category("Custom Properties")]
46
public int MaximumValue {
47
get { return max_value; }
50
hscale.Adjustment.Upper = value;
51
spin.Adjustment.Upper = value;
55
private int min_value;
56
[Category("Custom Properties")]
57
public int MinimumValue {
58
get { return min_value; }
61
hscale.Adjustment.Lower = value;
62
spin.Adjustment.Lower = value;
66
[Category("Custom Properties")]
68
get { return spin.ValueAsInt; }
70
if (spin.Value != value) {
77
public HScaleSpinButtonWidget ()
81
hscale.ValueChanged += HandleHscaleValueChanged;
82
spin.ValueChanged += HandleSpinValueChanged;
83
button.Clicked += HandleButtonClicked;
86
protected override void OnShown ()
93
private void HandleHscaleValueChanged (object sender, EventArgs e)
95
if (spin.Value != hscale.Value) {
96
spin.Value = hscale.Value;
101
private void HandleSpinValueChanged (object sender, EventArgs e)
103
if (hscale.Value != spin.Value) {
104
hscale.Value = spin.Value;
109
private void HandleButtonClicked (object sender, EventArgs e)
111
Value = DefaultValue;
114
#region Protected Methods
115
protected void OnValueChanged ()
117
if (ValueChanged != null)
118
ValueChanged (this, EventArgs.Empty);
122
#region Public Events
123
public event EventHandler ValueChanged;