**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / Splitter.cs
blob80dffbe5ca3c5232d3b1928c0bc220bbf7c8a35f
1 //
2 // System.Windows.Forms.Splitter.cs
3 //
4 // Author:
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@raytek.com)
7 //
8 // (C) 2002/3 Ximian, Inc
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Drawing;
32 using System.ComponentModel;
33 namespace System.Windows.Forms {
35 // <summary>
36 // </summary>
38 public class Splitter : Control, IMessageFilter {
39 BorderStyle borderStyle;
40 int minSize;
41 int minExtra;
43 // --- Constructor
45 [MonoTODO]
46 public Splitter()
48 SetStyle ( ControlStyles.Selectable, false );
49 borderStyle = BorderStyle.None;
50 Dock = DockStyle.Left;
51 minSize = 25;
52 minExtra = 25;
54 Application.AddMessageFilter ( this );
57 ~Splitter ( )
59 Application.RemoveMessageFilter ( this );
62 // --- Public Properties
64 [MonoTODO]
65 [EditorBrowsable (EditorBrowsableState.Never)]
66 public override bool AllowDrop {
67 get { return base.AllowDrop; }
68 set { base.AllowDrop = value; }
71 [EditorBrowsable (EditorBrowsableState.Never)]
72 public override AnchorStyles Anchor {
73 get { return base.Anchor; }
74 set { base.Anchor = value; }
77 [EditorBrowsable (EditorBrowsableState.Never)]
78 public override Image BackgroundImage {
79 get { return base.BackgroundImage; }
80 set { base.BackgroundImage = value; }
83 public BorderStyle BorderStyle {
84 get { return borderStyle; }
85 set {
86 if ( !Enum.IsDefined ( typeof(BorderStyle), value ) )
87 throw new InvalidEnumArgumentException( "BorderStyle",
88 (int)value,
89 typeof(BorderStyle));
91 if ( borderStyle != value ) {
92 int oldStyle = getBorderStyle ( borderStyle );
93 int oldExStyle = getBorderExStyle ( borderStyle );
94 borderStyle = value;
96 if ( IsHandleCreated ) {
97 Win32.UpdateWindowStyle ( Handle, oldStyle, getBorderStyle ( borderStyle ) );
98 Win32.UpdateWindowExStyle ( Handle, oldExStyle, getBorderExStyle ( borderStyle ) );
104 public override DockStyle Dock {
105 get { return base.Dock; }
106 set {
107 if ( value == DockStyle.None || value == DockStyle.Fill )
108 throw new ArgumentException ( "A splitter control must be docked left, right, top or bottom.", "value" );
110 base.Dock = value;
112 Cursor = Vertical ? Cursors.VSplit : Cursors.HSplit;
116 [EditorBrowsable (EditorBrowsableState.Never)]
117 public override Font Font {
118 get { return base.Font; }
119 set { base.Font = value; }
122 [EditorBrowsable (EditorBrowsableState.Never)]
123 public override Color ForeColor {
124 get { return base.ForeColor; }
125 set { base.ForeColor = value; }
127 [MonoTODO]
128 public int MinExtra {
129 get { return minExtra; }
130 set {
131 minExtra = value;
132 if ( minExtra < 0 )
133 minExtra = 0;
136 [MonoTODO]
137 public int MinSize {
138 get { return minSize; }
139 set {
140 minSize = value;
141 if ( minSize < 0 )
142 minSize = 0;
145 [MonoTODO]
146 public override ISite Site {
147 get {
148 throw new NotImplementedException ();
150 set {
151 throw new NotImplementedException ();
154 [MonoTODO]
155 public int SplitPosition {
156 get {
157 throw new NotImplementedException ();
159 set {
160 throw new NotImplementedException ();
164 [EditorBrowsable (EditorBrowsableState.Never)]
165 public override string Text {
166 get { return base.Text; }
167 set { base.Text = value; }
171 // --- Public Methods
173 [MonoTODO]
174 public override string ToString()
176 throw new NotImplementedException ();
180 // --- Protected Properties
182 [MonoTODO]
183 protected override CreateParams CreateParams {
184 get {
185 CreateParams createParams = base.CreateParams;
187 createParams.ClassName = Win32.DEFAULT_WINDOW_CLASS;
188 createParams.Style |= (int) WindowStyles.WS_CHILD;
190 createParams.Style |= getBorderStyle ( BorderStyle );
191 createParams.ExStyle |= getBorderExStyle ( BorderStyle );
193 return createParams;
196 [MonoTODO]
197 protected override ImeMode DefaultImeMode {
198 get {
199 throw new NotImplementedException ();
202 [MonoTODO]
203 protected override Size DefaultSize {
204 get {
205 return new System.Drawing.Size(3, 3);
210 // --- Protected Methods
213 [MonoTODO]
214 protected override void OnKeyDown(KeyEventArgs e)
216 throw new NotImplementedException ();
218 [MonoTODO]
219 protected override void OnMouseDown(MouseEventArgs e)
221 throw new NotImplementedException ();
223 [MonoTODO]
224 protected override void OnMouseMove(MouseEventArgs e)
226 throw new NotImplementedException ();
228 [MonoTODO]
229 protected override void OnMouseUp(MouseEventArgs e)
231 throw new NotImplementedException ();
233 [MonoTODO]
234 protected override void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified)
236 Control ctrl = getDockedControl ( );
237 if ( ctrl != null ) {
238 switch ( Dock ) {
239 case DockStyle.Left:
240 x = ctrl.Right;
241 height = ctrl.Height;
242 specified |= ( BoundsSpecified.X | BoundsSpecified.Height );
243 break;
244 case DockStyle.Right:
245 break;
246 case DockStyle.Top:
247 break;
248 case DockStyle.Bottom:
249 break;
252 base.SetBoundsCore ( x, y, width, height, specified );
254 bool IMessageFilter.PreFilterMessage(ref Message m){
255 return false;
258 private int getBorderStyle ( BorderStyle style )
260 if ( style == BorderStyle.FixedSingle )
261 return (int) WindowStyles.WS_BORDER;
263 return 0;
266 private int getBorderExStyle ( BorderStyle style )
268 if ( style == BorderStyle.Fixed3D )
269 return (int) (int)WindowExStyles.WS_EX_CLIENTEDGE;
271 return 0;
274 Control getDockedControl ( ) {
275 if ( Parent != null ) {
276 int index = Parent.Controls.GetChildIndex ( this, false );
277 if ( index != - 1 ) {
278 for ( int i = index + 1; i < Parent.Controls.Count; i++ ) {
279 Control ctrl = Parent.Controls [ i ];
280 if ( ctrl.Dock == this.Dock )
281 return ctrl;
284 return Parent;
286 return null;
289 private bool Vertical {
290 get { return ( Dock == DockStyle.Left || Dock == DockStyle.Right ); }