// Authors:
// Peter Bartok pbartok@novell.com
//
-//
-// $Revision: 1.1 $
-// $Modtime: $
-// $Log: ScrollableControl.cs,v $
-// Revision 1.1 2004/07/09 05:21:25 pbartok
-// - Initial check-in
-//
-//
+
// NOT COMPLETE
namespace System.Windows.Forms {
public class ScrollableControl : Control {
- #region Public Constructors
- public ScrollableControl() {
- }
- #endregion // Public Constructors
-
- #region Protected Static Fields
- protected const int ScrollStateAutoScrolling = 1;
- protected const int ScrollStateFullDrag = 16;
- protected const int ScrollStateHScrollVisible = 2;
- protected const int ScrollStateUserHasScrolled = 8;
- protected const int ScrollStateVScrollVisible= 4;
- #endregion // Protected Static Fields
-
+ #region Local Variables
+ private bool auto_vscroll;
+ private bool auto_hscroll;
+ private bool hscroll_visible;
+ private bool vscroll_visible;
+ private bool auto_scroll;
+ private Size auto_scroll_margin;
+ private Size auto_scroll_min_size;
+ private Point auto_scroll_position;
+ private DockPaddingEdges dock_padding;
+ private ScrollBar hscrollbar;
+ private ScrollBar vscrollbar;
+ #endregion // Local Variables
+
+ [MonoTODO("Need to use the edge values when performing the layout")]
#region Subclass DockPaddingEdges
public class DockPaddingEdges : ICloneable {
- // Local Variables;
+ #region DockPaddingEdges Local Variables
private int all;
private int left;
private int right;
private int top;
private int bottom;
+ #endregion // DockPaddingEdges Local Variables
+
+ #region DockPaddingEdges Constructor
+ internal DockPaddingEdges() {
+ all = 0;
+ left = 0;
+ right = 0;
+ top = 0;
+ bottom = 0;
+ }
+ #endregion // DockPaddingEdges Constructor
- // Public Instance Properties
+ #region DockPaddingEdges Public Instance Properties
public int All {
get {
return all;
}
set {
- all=value;
+ all = value;
+ left = value;
+ right = value;
+ top = value;
+ bottom = value;
}
}
}
set {
- bottom=value;
+ bottom = value;
+ all = 0;
}
}
set {
left=value;
+ all = 0;
}
}
set {
right=value;
+ all = 0;
}
}
set {
top=value;
+ all = 0;
}
}
- public static bool operator == (DockPaddingEdges obj_a, DockPaddingEdges obj_b) {
- if ( (obj_a.all == obj_b.all) && (obj_a.left == obj_b.left) &&
- (obj_a.right == obj_b.right) && (obj_a.top == obj_b.top) &&
- (obj_a.bottom == obj_b.bottom)) {
- return true;
- }
-
- return false;
- }
-
- public static bool operator != (DockPaddingEdges obj_a, DockPaddingEdges obj_b) {
- return !(obj_a==obj_b);
- }
+ #endregion // DockPaddingEdges Public Instance Properties
// Public Instance Methods
public override bool Equals(object other) {
return false;
}
- return (this==(DockPaddingEdges)other);
+ if ( (this.all == ((DockPaddingEdges)other).all) && (this.left == ((DockPaddingEdges)other).left) &&
+ (this.right == ((DockPaddingEdges)other).right) && (this.top == ((DockPaddingEdges)other).top) &&
+ (this.bottom == ((DockPaddingEdges)other).bottom)) {
+ return true;
+ }
+
+ return false;
}
public override int GetHashCode() {
return padding_edge;
}
}
- #endregion
+ #endregion // Subclass DockPaddingEdges
#region Subclass DockPaddingEdgesConverter
public class DockPaddingEdgesConverter : System.ComponentModel.TypeConverter {
throw new NotImplementedException();
}
}
- #endregion
+ #endregion // Subclass DockPaddingEdgesConverter
+
+ #region Public Constructors
+ public ScrollableControl() {
+ SetStyle(ControlStyles.ContainerControl, true);
+ auto_scroll = false;
+ auto_hscroll = false;
+ auto_vscroll = false;
+ hscroll_visible = false;
+ vscroll_visible = false;
+ auto_scroll_margin = new Size(0, 0);
+ auto_scroll_min_size = new Size(0, 0);
+ auto_scroll_position = new Point(0, 0);
+ dock_padding = new DockPaddingEdges();
+ }
+ #endregion // Public Constructors
+
+ #region Protected Static Fields
+ protected const int ScrollStateAutoScrolling = 1;
+ protected const int ScrollStateFullDrag = 16;
+ protected const int ScrollStateHScrollVisible = 2;
+ protected const int ScrollStateUserHasScrolled = 8;
+ protected const int ScrollStateVScrollVisible = 4;
+ #endregion // Protected Static Fields
#region Public Instance Properties
public virtual bool AutoScroll {
get {
- throw new NotImplementedException();
+ return auto_scroll;
}
set {
- throw new NotImplementedException();
+ if (auto_scroll == value) {
+ return;
+ }
+
+ auto_scroll = value;
}
}
public Size AutoScrollMargin {
get {
- throw new NotImplementedException();
+ return auto_scroll_margin;
}
set {
- throw new NotImplementedException();
+ if (value.Width < 0) {
+ throw new ArgumentException("Width is assigned less than 0", "value.Width");
+ }
+
+ if (value.Height < 0) {
+ throw new ArgumentException("Height is assigned less than 0", "value.Height");
+ }
+
+ auto_scroll_margin = value;
}
}
public Size AutoScrollMinSize {
get {
- throw new NotImplementedException();
+ return auto_scroll_min_size;
}
set {
- throw new NotImplementedException();
+ auto_scroll_min_size = value;
}
}
public Point AutoScrollPosition {
get {
- throw new NotImplementedException();
+ return auto_scroll_position;
}
set {
- throw new NotImplementedException();
+ auto_scroll_position = value;
}
}
public override Rectangle DisplayRectangle {
get {
- throw new NotImplementedException();
+ Rectangle rect;
+
+ rect = base.DisplayRectangle;
+
+ if (vscroll_visible) {
+ rect.Width -= vscrollbar.Width;
+ if (rect.Width < 0) {
+ rect.Width = 0;
+ }
+ }
+
+ if (hscroll_visible) {
+ rect.Height -= hscrollbar.Height;
+ if (rect.Height < 0) {
+ rect.Height = 0;
+ }
+ }
+ return rect;
}
}
public DockPaddingEdges DockPadding {
get {
- throw new NotImplementedException();
+ return dock_padding;
+ }
+
+ // DockPadding is documented as 'get' only ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsScrollableControlClassAutoScrollTopic.asp )
+ // but Microsoft's on that pageexamples show 'set' usage
+ set {
+ dock_padding = value;
}
}
#endregion // Public Instance Properties
#region Protected Instance Methods
protected override CreateParams CreateParams {
get {
- return base.CreateParams;
+ CreateParams ret;
+
+ ret = base.CreateParams;
+
+ ret.Style |= (int)(WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_VISIBLE);
+
+ return ret;
}
}
protected bool HScroll {
get {
- throw new NotImplementedException();
+ return hscroll_visible;
}
set {
- throw new NotImplementedException();
+ if (hscroll_visible != value) {
+ hscroll_visible = value;
+ if (hscroll_visible && hscrollbar == null)
+ hscrollbar = new ScrollBar ();
+ }
}
}
protected bool VScroll {
get {
- throw new NotImplementedException();
+ return vscroll_visible;
}
set {
- throw new NotImplementedException();
+ if (vscroll_visible != value) {
+ vscroll_visible = value;
+ if (vscroll_visible && vscrollbar == null)
+ vscrollbar = new ScrollBar ();
+ }
}
}
#endregion // Protected Instance Methods
}
protected override void OnLayout(LayoutEventArgs levent) {
- throw new NotImplementedException();
+ base.OnLayout(levent);
}
protected override void OnMouseWheel(MouseEventArgs e) {
- throw new NotImplementedException();
+ base.OnMouseWheel(e);
}
protected override void OnVisibleChanged(EventArgs e) {
- throw new NotImplementedException();
+ base.OnVisibleChanged(e);
}
protected override void ScaleCore(float dx, float dy) {
- throw new NotImplementedException();
+ base.ScaleCore(dx, dy);
}
protected void SetDisplayRectLocation(int x, int y) {