- Signature fixes
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
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.
19 //
20 // Copyright (c) 2004 Novell, Inc.
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25 //
26 // $Revision: 1.10 $
27 // $Modtime: $
28 // $Log: XplatUI.cs,v $
29 // Revision 1.10  2004/08/11 22:20:59  pbartok
30 // - Signature fixes
31 //
32 // Revision 1.9  2004/08/11 19:19:44  pbartok
33 // - We had SetWindowPos and MoveWindow to set window positions and size,
34 //   removed MoveWindow. We have GetWindowPos, so it made sense to keep
35 //   SetWindowPos as matching counterpart
36 // - Added some X11 sanity checking
37 //
38 // Revision 1.8  2004/08/11 18:55:46  pbartok
39 // - Added method to calculate difference between decorated window and raw
40 //   client area
41 //
42 // Revision 1.7  2004/08/10 17:39:22  pbartok
43 // - Added GetWindowPos method
44 //
45 // Revision 1.6  2004/08/09 20:55:59  pbartok
46 // - Removed Run method, was only required for initial development
47 //
48 // Revision 1.5  2004/08/09 20:51:25  pbartok
49 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
50 //
51 // Revision 1.4  2004/08/09 17:02:29  jackson
52 // Get default window properties from the theme
53 //
54 // Revision 1.3  2004/08/09 15:56:44  jackson
55 // Remove defaults, these are handled by the theme now.
56 //
57 // Revision 1.2  2004/08/04 20:11:24  pbartok
58 // - Added Invalidate handling
59 //
60 // Revision 1.1  2004/07/09 05:21:25  pbartok
61 // - Initial check-in
62 //
63 //
64
65 // NOT COMPLETE
66
67 using System;
68 using System.Drawing;
69 using System.ComponentModel;
70 using System.Collections;
71 using System.Diagnostics;
72 using System.Runtime.InteropServices;
73
74 //
75 // Random architecture notes
76 // We need
77 // * windows
78 //   - create
79 //   - set location/size
80 //   - define cursor
81 //   - destroy
82 //   - reparent?
83 //   - show/hide
84 // * Keyboard
85 // * Mouse
86 //
87
88 /// X11 Version
89 namespace System.Windows.Forms {
90         internal class XplatUI {
91                 #region Local Variables
92                 static XplatUIDriver            driver;
93                 static String                   default_class_name;
94                 #endregion      // Local Variables
95
96                 #region Subclasses
97
98                 public class State {
99                         static public Keys ModifierKeys {
100                                 get {
101                                         return driver.ModifierKeys;
102                                 }
103                         }
104
105                         static public MouseButtons MouseButtons {
106                                 get {
107                                         return driver.MouseButtons;
108                                 }
109                         }
110
111                         static public Point MousePosition {
112                                 get {
113                                         return driver.MousePosition;
114                                 }
115                         }
116
117                         static public bool DropTarget {
118                                 get {
119                                         return driver.DropTarget;
120                                 }
121
122                                 set {
123                                         driver.DropTarget=value;
124                                 }
125                         }
126                 }
127                 #endregion      // Subclasses
128
129                 #region Constructor & Destructor
130                 static XplatUI() {
131                         // Don't forget to throw the mac in here somewhere, too
132                         default_class_name="SWFClass";
133
134                         if (Environment.OSVersion.Platform == (PlatformID)128) {
135                                 driver=XplatUIX11.GetInstance();
136                         } else {
137                                 driver=XplatUIWin32.GetInstance();
138                         }
139
140                         Console.WriteLine("#region #line XplatUI Constructor called");
141                 }
142
143                 ~XplatUI() {
144                         Console.WriteLine("XplatUI Destructor called");
145                 }
146                 #endregion      // Constructor & Destructor
147
148                 #region Public Static Properties
149                 internal static string DefaultClassName {
150                         get {
151                                 return default_class_name;
152                         }
153
154                         set {
155                                 default_class_name=value;
156                         }
157                 }
158                 #endregion      // Public Static Properties
159
160                 #region Public Static Methods
161                 internal static void Exit() {
162                         driver.Exit();
163                 }
164
165                 internal static void EnableThemes() {
166                         driver.EnableThemes();
167                 }
168
169                 internal static bool Text(IntPtr hWnd, string text) {
170                         return driver.Text(hWnd, text);
171                 }
172
173                 internal static bool SetVisible(IntPtr hWnd, bool visible) {
174                         return driver.SetVisible(hWnd, visible);
175                 }
176
177                 internal static bool IsVisible(IntPtr hWnd) {
178                         return driver.IsVisible(hWnd);
179                 }
180
181                 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
182                         return driver.SetParent(hWnd, hParent);
183                 }
184
185                 internal static IntPtr GetParent(IntPtr hWnd) {
186                         return driver.GetParent(hWnd);
187                 }
188
189                 internal static void Version() {
190                         Console.WriteLine("Xplat version $revision: $");
191                 }
192
193                 internal static IntPtr CreateWindow(CreateParams cp) {
194                         return driver.CreateWindow(cp);
195                 }
196
197                 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
198                         return driver.CreateWindow(Parent, X, Y, Width, Height);
199                 }
200
201                 internal static void DestroyWindow(IntPtr handle) {
202                         driver.DestroyWindow(handle);
203                 }
204
205                 internal static void RefreshWindow(IntPtr handle) {
206                         driver.RefreshWindow(handle);
207                 }
208
209                 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
210                         return driver.PaintEventStart(handle);
211                 }
212
213                 internal static void PaintEventEnd(IntPtr handle) {
214                         driver.PaintEventEnd(handle);
215                 }
216
217                 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
218                         driver.SetWindowPos(handle, x, y, width, height);
219                 }
220
221                 internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height) {
222                         driver.GetWindowPos(handle, out x, out y, out width, out height);
223                 }
224
225                 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
226                         driver.Invalidate(handle, rc, clear);
227                 }
228
229                 internal static void Activate(IntPtr handle) {
230                         driver.Activate(handle);
231                 }
232
233                 internal static IntPtr DefWndProc(ref Message msg) {
234                         return driver.DefWndProc(ref msg);
235                 }
236
237                 internal static void HandleException(Exception e) {
238                         driver.HandleException(e);
239                 }
240
241                 internal static void DoEvents() {
242                         driver.DoEvents();
243                 }
244
245                 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
246                         return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
247                 }
248
249                 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
250                         return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
251                 }
252
253                 internal static bool TranslateMessage(ref MSG msg) {
254                         return driver.TranslateMessage(ref msg);
255                 }
256
257                 internal static bool DispatchMessage(ref MSG msg) {
258                         return driver.DispatchMessage(ref msg);
259                 }
260
261                 internal static void GrabWindow(IntPtr hWnd) {
262                         driver.GrabWindow(hWnd);
263                 }
264
265                 internal static void ReleaseWindow(IntPtr hWnd) {
266                         driver.ReleaseWindow(hWnd);
267                 }
268
269                 internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
270                         return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
271                 }
272
273                 // Santa's little helper
274                 internal static void Where() {
275                         Console.WriteLine("Here: {0}", new StackTrace().ToString());
276                 }
277                 #endregion      // Public Static Methods
278
279         }
280 }