(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Windows.Forms / Gtk / ScrollBar.cs
blobda5d1fd06c082a86e53ea653a8160d593d7c6912
1 //
2 // System.Windows.Forms.Button.cs
3 //
4 // Author:
5 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 // implemented for Gtk+ by Philip Van Hoof (me@freax.org)
7 //
8 // (C) Ximian, Inc., 2002
9 //
11 using System.Drawing;
13 namespace System.Windows.Forms {
15 /// <summary>
16 /// </summary>
18 public class ScrollBar : Control {
19 internal Gtk.Adjustment adj;
20 private double val;
21 private double lower;
22 private double upper;
23 private double step_increment;
24 private double page_increment;
25 private double page_size;
28 // --- Constructor
31 public ScrollBar() : base(){
32 // Defaults
33 this.upper = 100;
34 this.lower = 0;
35 this.val = 0;
36 this.step_increment = 1;
37 this.page_increment = 10;
38 this.page_size = 10;
39 this.adj = new Gtk.Adjustment(val, lower, upper, step_increment, page_increment, page_size);
40 //spec says tabstop defaults to false.
41 base.TabStop = false;
42 ConnectToChanged();
46 // --- Public Properties
50 public int LargeChange {
51 get {return (int)page_increment;}
52 set {
53 if (value < 0){
54 String st = String.Format (
55 "'{0}' is not a valid value for LargeChange."+
56 "It should be >= 0", value
58 throw new ArgumentException (st);
60 page_increment = value;
61 UpdateGtkScroll();
65 public int Maximum {
66 get {return (int) upper;}
67 set {
68 upper = value;
69 if (value < lower)
70 lower = value;
71 if (value < this.Value)
72 this.Value = value;
74 UpdateGtkScroll();
78 public int Minimum {
79 get {return (int) lower;}
80 set {
81 lower = value;
82 if (value > upper)
83 upper = value;
84 if (value > val)
85 val = value;
86 UpdateGtkScroll();
89 public int SmallChange {
90 get { return (int) step_increment;}
91 set {
92 if (value < 0){
93 String st = String.Format (
94 "'{0}' is not a valid value for SmallChange."+
95 "It should be >= 0", value
97 throw new ArgumentException (st);
99 step_increment = value;
100 UpdateGtkScroll();
104 public int Value {
105 get {return (int) val; }
107 set {
108 if ((value > upper) || (value < lower)){
109 String st = String.Format (
110 "'{0}' is not a valid value for Minimum."+
111 " It should be betwen Minimum and Maximum", value);
113 throw new ArgumentException (st);
115 val = value;
116 UpdateGtkScroll();
121 // --- Public Events
124 public event ScrollEventHandler Scroll;
125 public event EventHandler ValueChanged;
127 protected virtual void OnValueChanged (EventArgs args){
128 if (ValueChanged != null)
129 ValueChanged (this, args);
131 protected virtual void OnScroll (ScrollEventArgs args){
132 if (Scroll != null)
133 Scroll (this, args);
135 [MonoTODO]
136 protected override void OnEnabledChanged(EventArgs e){
137 throw new NotImplementedException();
140 [MonoTODO]
141 protected override void OnHandleCreated(EventArgs e){
142 throw new NotImplementedException();
145 // FIXME:
147 internal protected void changed_cb (object o, EventArgs args){
148 val = this.adj.Value;
149 OnValueChanged(args);
150 OnScroll (new ScrollEventArgs(ScrollEventType.ThumbPosition ,(int) val));
153 internal protected void ConnectToChanged (){
154 this.adj.ValueChanged += new EventHandler (changed_cb);
157 internal protected void UpdateGtkScroll(){
158 this.adj.SetBounds (lower, upper, step_increment, page_increment, page_size);
159 if ((int) val != this.adj.Value)
160 this.adj.Value = (int) val;