2 // System.Windows.Forms.Splitter.cs
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@raytek.com)
8 // (C) 2002/3 Ximian, Inc
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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
32 using System
.ComponentModel
;
33 namespace System
.Windows
.Forms
{
38 public class Splitter
: Control
, IMessageFilter
{
39 BorderStyle borderStyle
;
48 SetStyle ( ControlStyles
.Selectable
, false );
49 borderStyle
= BorderStyle
.None
;
50 Dock
= DockStyle
.Left
;
54 Application
.AddMessageFilter ( this );
59 Application
.RemoveMessageFilter ( this );
62 // --- Public Properties
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; }
86 if ( !Enum
.IsDefined ( typeof(BorderStyle
), value ) )
87 throw new InvalidEnumArgumentException( "BorderStyle",
91 if ( borderStyle
!= value ) {
92 int oldStyle
= getBorderStyle ( borderStyle
);
93 int oldExStyle
= getBorderExStyle ( borderStyle
);
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; }
107 if ( value == DockStyle
.None
|| value == DockStyle
.Fill
)
108 throw new ArgumentException ( "A splitter control must be docked left, right, top or bottom.", "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; }
128 public int MinExtra
{
129 get { return minExtra; }
138 get { return minSize; }
146 public override ISite Site
{
148 throw new NotImplementedException ();
151 throw new NotImplementedException ();
155 public int SplitPosition
{
157 throw new NotImplementedException ();
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
174 public override string ToString()
176 throw new NotImplementedException ();
180 // --- Protected Properties
183 protected override CreateParams CreateParams
{
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
);
197 protected override ImeMode DefaultImeMode
{
199 throw new NotImplementedException ();
203 protected override Size DefaultSize
{
205 return new System
.Drawing
.Size(3, 3);
210 // --- Protected Methods
214 protected override void OnKeyDown(KeyEventArgs e
)
216 throw new NotImplementedException ();
219 protected override void OnMouseDown(MouseEventArgs e
)
221 throw new NotImplementedException ();
224 protected override void OnMouseMove(MouseEventArgs e
)
226 throw new NotImplementedException ();
229 protected override void OnMouseUp(MouseEventArgs e
)
231 throw new NotImplementedException ();
234 protected override void SetBoundsCore( int x
, int y
, int width
, int height
, BoundsSpecified specified
)
236 Control ctrl
= getDockedControl ( );
237 if ( ctrl
!= null ) {
241 height
= ctrl
.Height
;
242 specified
|= ( BoundsSpecified
.X
| BoundsSpecified
.Height
);
244 case DockStyle
.Right
:
248 case DockStyle
.Bottom
:
252 base.SetBoundsCore ( x
, y
, width
, height
, specified
);
254 bool IMessageFilter
.PreFilterMessage(ref Message m
){
258 private int getBorderStyle ( BorderStyle style
)
260 if ( style
== BorderStyle
.FixedSingle
)
261 return (int) WindowStyles
.WS_BORDER
;
266 private int getBorderExStyle ( BorderStyle style
)
268 if ( style
== BorderStyle
.Fixed3D
)
269 return (int) (int)WindowExStyles
.WS_EX_CLIENTEDGE
;
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
)
289 private bool Vertical
{
290 get { return ( Dock == DockStyle.Left || Dock == DockStyle.Right ); }