(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ScrollableControl.cs
blobfa7241ae1f0be4aad6a179e55ce3364f0a266ca9
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004 Novell, Inc.
22 // Authors:
23 // Peter Bartok pbartok@novell.com
26 // $Revision: 1.5 $
27 // $Modtime: $
28 // $Log: ScrollableControl.cs,v $
29 // Revision 1.5 2004/09/22 20:12:45 pbartok
30 // - Implemented DockPadding property
31 // - Implemented AutoScroll property
32 // - Implemented AutoScrollMargin property
33 // - Implemented AutoScrollMinSize property
34 // - Implemented AutoScrollPosition property
35 // - Implemented DisplayRectangle property (still incomplete)
36 // - Implemented CreateParams property
37 // - Implemented HScroll property
38 // - Implemented VScroll property
39 // - Implemented OnVisibleChanged property
41 // Revision 1.4 2004/09/09 03:01:35 ravindra
42 // Removed unreachable code.
44 // Revision 1.3 2004/08/12 15:25:49 jordi
45 // calls ctrlbase instead of exeception
47 // Revision 1.2 2004/08/11 22:20:59 pbartok
48 // - Signature fixes
50 // Revision 1.1 2004/07/09 05:21:25 pbartok
51 // - Initial check-in
55 // NOT COMPLETE
57 using System;
58 using System.ComponentModel;
59 using System.Drawing;
61 namespace System.Windows.Forms {
62 public class ScrollableControl : Control {
63 #region Local Variables
64 private bool auto_vscroll;
65 private bool auto_hscroll;
66 private bool hscroll_visible;
67 private bool vscroll_visible;
68 private bool auto_scroll;
69 private Size auto_scroll_margin;
70 private Size auto_scroll_min_size;
71 private Point auto_scroll_position;
72 private DockPaddingEdges dock_padding;
73 private ScrollBar hscrollbar;
74 private ScrollBar vscrollbar;
75 #endregion // Local Variables
77 [MonoTODO("Need to use the edge values when performing the layout")]
78 #region Subclass DockPaddingEdges
79 public class DockPaddingEdges : ICloneable {
80 #region DockPaddingEdges Local Variables
81 private int all;
82 private int left;
83 private int right;
84 private int top;
85 private int bottom;
86 #endregion // DockPaddingEdges Local Variables
88 #region DockPaddingEdges Constructor
89 internal DockPaddingEdges() {
90 all = 0;
91 left = 0;
92 right = 0;
93 top = 0;
94 bottom = 0;
96 #endregion // DockPaddingEdges Constructor
98 #region DockPaddingEdges Public Instance Properties
99 public int All {
100 get {
101 return all;
104 set {
105 all = value;
106 left = value;
107 right = value;
108 top = value;
109 bottom = value;
113 public int Bottom {
114 get {
115 return bottom;
118 set {
119 bottom = value;
120 all = 0;
124 public int Left {
125 get {
126 return left;
129 set {
130 left=value;
131 all = 0;
135 public int Right {
136 get {
137 return right;
140 set {
141 right=value;
142 all = 0;
146 public int Top {
147 get {
148 return top;
151 set {
152 top=value;
153 all = 0;
157 #endregion // DockPaddingEdges Public Instance Properties
159 // Public Instance Methods
160 public override bool Equals(object other) {
161 if (! (other is DockPaddingEdges)) {
162 return false;
165 if ( (this.all == ((DockPaddingEdges)other).all) && (this.left == ((DockPaddingEdges)other).left) &&
166 (this.right == ((DockPaddingEdges)other).right) && (this.top == ((DockPaddingEdges)other).top) &&
167 (this.bottom == ((DockPaddingEdges)other).bottom)) {
168 return true;
171 return false;
174 public override int GetHashCode() {
175 return all*top*bottom*right*left;
178 public override string ToString() {
179 return "All = "+all.ToString()+" Top = "+top.ToString()+" Left = "+left.ToString()+" Bottom = "+bottom.ToString()+" Right = "+right.ToString();
182 object ICloneable.Clone() {
183 DockPaddingEdges padding_edge;
185 padding_edge=new DockPaddingEdges();
187 padding_edge.all=all;
188 padding_edge.left=left;
189 padding_edge.right=right;
190 padding_edge.top=top;
191 padding_edge.bottom=bottom;
193 return padding_edge;
196 #endregion // Subclass DockPaddingEdges
198 #region Subclass DockPaddingEdgesConverter
199 public class DockPaddingEdgesConverter : System.ComponentModel.TypeConverter {
200 // Public Constructors
201 public DockPaddingEdgesConverter() {
204 // Public Instance Methods
205 public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, Attribute[] attributes) {
206 throw new NotImplementedException();
209 public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
210 throw new NotImplementedException();
213 #endregion // Subclass DockPaddingEdgesConverter
215 #region Public Constructors
216 public ScrollableControl() {
217 base.SetStyle(ControlStyles.ContainerControl, true);
218 auto_scroll = false;
219 auto_hscroll = false;
220 auto_vscroll = false;
221 hscroll_visible = false;
222 vscroll_visible = false;
223 auto_scroll_margin = new Size(0, 0);
224 auto_scroll_min_size = new Size(0, 0);
225 auto_scroll_position = new Point(0, 0);
226 dock_padding = new DockPaddingEdges();
228 hscrollbar = new ScrollBar();
229 hscrollbar.Visible = false;
231 vscrollbar = new ScrollBar();
232 vscrollbar.Visible = false;
234 #endregion // Public Constructors
236 #region Protected Static Fields
237 protected const int ScrollStateAutoScrolling = 1;
238 protected const int ScrollStateFullDrag = 16;
239 protected const int ScrollStateHScrollVisible = 2;
240 protected const int ScrollStateUserHasScrolled = 8;
241 protected const int ScrollStateVScrollVisible = 4;
242 #endregion // Protected Static Fields
244 #region Public Instance Properties
245 public virtual bool AutoScroll {
246 get {
247 return auto_scroll;
250 set {
251 if (auto_scroll == value) {
252 return;
255 auto_scroll = value;
259 public Size AutoScrollMargin {
260 get {
261 return auto_scroll_margin;
264 set {
265 if (value.Width < 0) {
266 throw new ArgumentException("Width is assigned less than 0", "value.Width");
269 if (value.Height < 0) {
270 throw new ArgumentException("Height is assigned less than 0", "value.Height");
273 auto_scroll_margin = value;
277 public Size AutoScrollMinSize {
278 get {
279 return auto_scroll_min_size;
282 set {
283 auto_scroll_min_size = value;
287 public Point AutoScrollPosition {
288 get {
289 return auto_scroll_position;
292 set {
293 auto_scroll_position = value;
297 public override Rectangle DisplayRectangle {
298 get {
299 Rectangle rect;
301 rect = base.DisplayRectangle;
303 if (vscroll_visible) {
304 rect.Width -= vscrollbar.Width;
305 if (rect.Width < 0) {
306 rect.Width = 0;
310 if (hscroll_visible) {
311 rect.Height -= hscrollbar.Height;
312 if (rect.Height < 0) {
313 rect.Height = 0;
316 return rect;
320 public DockPaddingEdges DockPadding {
321 get {
322 return dock_padding;
325 // DockPadding is documented as 'get' only ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsScrollableControlClassAutoScrollTopic.asp )
326 // but Microsoft's on that pageexamples show 'set' usage
327 set {
328 dock_padding = value;
331 #endregion // Public Instance Properties
333 #region Protected Instance Methods
334 protected override CreateParams CreateParams {
335 get {
336 CreateParams ret;
338 ret = base.CreateParams;
340 ret.Style |= (int)(WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_VISIBLE);
342 return ret;
346 protected bool HScroll {
347 get {
348 return hscroll_visible;
351 set {
352 if (hscroll_visible != value) {
353 hscroll_visible = value;
358 protected bool VScroll {
359 get {
360 return vscroll_visible;
363 set {
364 if (vscroll_visible != value) {
365 vscroll_visible = value;
369 #endregion // Protected Instance Methods
371 #region Public Instance Methods
372 public void ScrollControlIntoView(Control activeControl) {
375 public void SetAutoScrollMargin(int x, int y) {
377 #endregion // Public Instance Methods
379 #region Protected Instance Methods
380 protected virtual void AdjustFormScrollbars(bool displayScrollbars) {
383 protected bool GetScrollState(int bit) {
384 throw new NotImplementedException();
387 protected override void OnLayout(LayoutEventArgs levent) {
388 base.OnLayout(levent);
391 protected override void OnMouseWheel(MouseEventArgs e) {
392 base.OnMouseWheel(e);
395 protected override void OnVisibleChanged(EventArgs e) {
396 ;; // Nothing to do yet
399 protected override void ScaleCore(float dx, float dy) {
400 throw new NotImplementedException();
403 protected void SetDisplayRectLocation(int x, int y) {
404 throw new NotImplementedException();
407 protected void SetScrollState(int bit, bool value) {
408 throw new NotImplementedException();
411 protected override void WndProc(ref Message m) {
412 base.WndProc(ref m);
414 #endregion // Protected Instance Methods