Add licensing info
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / Cursor.cs
1 //
2 // System.Windows.Forms.Cursor.cs
3 //
4 // Author:
5 //   stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 //   Dennis Hayes (dennish@Raytek.com)
7 //   Aleksey Ryabchuk (ryabchuk@yahoo.com)
8 //
9 // (C) Ximian, Inc., 2002
10 //
11
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32 using System;
33 using System.ComponentModel;
34 using System.Runtime.Serialization;
35 using System.IO;
36 using System.Drawing;
37
38 namespace System.Windows.Forms {
39
40         /// <summary>
41         /// Represents the image used to paint the mouse pointer.
42         /// </summary>
43
44         [MonoTODO]
45         [Serializable]
46         public sealed class Cursor : IDisposable, ISerializable {
47
48                 #region Fields
49                 private IntPtr handle;
50                 private bool   fromResource    = false;
51                 private bool   disposed        = false;
52                 private CursorType ctype;
53                 #endregion
54                 
55                 #region Constructors
56                 private Cursor(){
57                 }
58                 internal Cursor ( CursorType type )//For signiture compatablity.
59                 {
60                         handle = Win32.LoadCursor ( IntPtr.Zero, type );
61                         fromResource = true;
62                         ctype  = type;
63                 }
64
65                 [MonoTODO]
66                 public Cursor( IntPtr handle ) 
67                 {
68                         this.handle = handle;   
69                 }
70                 
71                 [MonoTODO]
72                 public Cursor(Stream stream) 
73                 {
74                         
75                 }
76                 
77                 [MonoTODO]
78                 public Cursor(string fileName) 
79                 {
80                         
81                 }
82                 
83                 [MonoTODO]
84                 public Cursor(Type type,string resource) 
85                 {
86                         
87                 }
88                 #endregion
89                 
90                 #region Properties
91                 [MonoTODO]
92                 public static Rectangle Clip {
93                         get {
94                                 throw new NotImplementedException ();
95                         }
96                         set {
97                                 throw new NotImplementedException ();
98                         }
99                 }
100                 
101                 [MonoTODO]
102                 public static Cursor Current {
103                         get { 
104                                 throw new NotImplementedException (); 
105                         }
106                         set { 
107                                 throw new NotImplementedException (); 
108                         }
109                 }
110                 
111                 [MonoTODO]
112                 public IntPtr Handle {
113                         get { return handle; }
114                 }
115                 
116                 [MonoTODO]
117                 public static Point Position {
118                         get { throw new NotImplementedException (); }
119                         set { throw new NotImplementedException (); }
120                 }
121                 
122                 [MonoTODO]
123                 public Size Size {
124                         get { throw new NotImplementedException (); }
125                 }
126                 #endregion
127                 
128                 #region Methods
129
130                 public IntPtr CopyHandle() 
131                 {
132                         return Win32_WineLess.CopyCursor ( Handle );
133                 }
134                 
135                 public void Dispose() 
136                 {
137                         GC.SuppressFinalize( this );
138                         Dispose( true );
139                 }
140                 
141                 private void Dispose( bool disposing )
142                 {
143                         lock ( this ) {
144                                 if ( disposing ) {
145                                         // dispose managed resources
146                                 }
147                                 if ( !this.disposed ) {
148                                         // release all unmanaged resources
149                                         // shared cursor should not be destroyed
150                                         if ( !fromResource )
151                                                 Win32.DestroyCursor ( handle );
152                                         handle = IntPtr.Zero;
153                                 }
154                                 disposed = true;         
155                         }
156                 }
157
158                 [MonoTODO]
159                 public void Draw(Graphics g,Rectangle targetRect) 
160                 {
161                         throw new NotImplementedException ();
162                 }
163                 
164                 [MonoTODO]
165                 public void DrawStretched(Graphics g,Rectangle targetRect) 
166                 {
167                         throw new NotImplementedException ();
168                 }
169                 
170                 [MonoTODO]
171                 public override bool Equals(object obj) 
172                 {
173                         if ( obj == null ) return false;
174                         if ( this.GetType ( ) != obj.GetType ( ) ) return false;
175                         Cursor other = ( Cursor ) obj;
176                         if ( !fromResource.Equals ( other.fromResource ) ) return false;
177                         if ( !ctype.Equals ( other.ctype ) ) return false;
178
179                         return true;
180                 }
181                 
182                 ~Cursor() {
183                         Dispose ( false );
184                 }
185                 
186                 [MonoTODO]
187                 public override int GetHashCode() 
188                 {
189                         //FIXME:
190                         return base.GetHashCode();
191                 }
192                 
193                 public static void Hide() 
194                 {
195                         Win32.ShowCursor ( false );
196                 }
197                 
198                 /// ISerializable.GetObjectData only supports .NET framework:
199                 [MonoTODO]
200                 void ISerializable.GetObjectData(SerializationInfo si,StreamingContext context) 
201                 {
202                         throw new NotImplementedException ();
203                 }
204                 
205                 public static void Show() 
206                 {
207                         Win32.ShowCursor ( true );
208                 }
209                 
210                 [MonoTODO]
211                 public override string ToString() 
212                 {
213                         //FIXME:
214                         return base.ToString();
215                 }
216                 #endregion
217                 
218                 #region Operators
219                 [MonoTODO]
220                 public static bool operator ==(Cursor left, Cursor right) 
221                 {
222                         return Object.Equals ( left, right );
223                 }
224                 
225                 [MonoTODO]
226                 public static bool operator !=(Cursor left, Cursor right) 
227                 {
228                         return ! ( left == right );
229                 }
230                 #endregion
231         }
232 }