Remove defaults, these are handled by the theme now.
[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.3 $
27 // $Modtime: $
28 // $Log: XplatUI.cs,v $
29 // Revision 1.3  2004/08/09 15:56:44  jackson
30 // Remove defaults, these are handled by the theme now.
31 //
32 // Revision 1.2  2004/08/04 20:11:24  pbartok
33 // - Added Invalidate handling
34 //
35 // Revision 1.1  2004/07/09 05:21:25  pbartok
36 // - Initial check-in
37 //
38 //
39
40 // NOT COMPLETE
41
42 using System;
43 using System.Drawing;
44 using System.ComponentModel;
45 using System.Collections;
46 using System.Diagnostics;
47 using System.Runtime.InteropServices;
48
49 //
50 // Random architecture notes
51 // We need
52 // * windows
53 //   - create
54 //   - set location/size
55 //   - define cursor
56 //   - destroy
57 //   - reparent?
58 //   - show/hide
59 // * Keyboard
60 // * Mouse
61 //
62
63 /// X11 Version
64 namespace System.Windows.Forms {
65         public class XplatUI {
66                 #region Local Variables
67                 static XplatUIDriver            driver;
68                 static String                   default_class_name;
69                 #endregion      // Local Variables
70
71                 #region Subclasses
72
73                 public class State {
74                         static public Keys ModifierKeys {
75                                 get {
76                                         return driver.ModifierKeys;
77                                 }
78                         }
79
80                         static public MouseButtons MouseButtons {
81                                 get {
82                                         return driver.MouseButtons;
83                                 }
84                         }
85
86                         static public Point MousePosition {
87                                 get {
88                                         return driver.MousePosition;
89                                 }
90                         }
91
92                         static public bool DropTarget {
93                                 get {
94                                         return driver.DropTarget;
95                                 }
96
97                                 set {
98                                         driver.DropTarget=value;
99                                 }
100                         }
101                 }
102                 #endregion      // Subclasses
103
104                 #region Constructor & Destructor
105                 static XplatUI() {
106                         // Don't forget to throw the mac in here somewhere, too
107                         default_class_name="SWFClass";
108
109                         if (Environment.OSVersion.Platform == (PlatformID)128) {
110                                 driver=XplatUIX11.GetInstance();
111                         } else {
112                                 driver=XplatUIWin32.GetInstance();
113                         }
114
115                         Console.WriteLine("#region #line XplatUI Constructor called");
116                 }
117
118                 ~XplatUI() {
119                         Console.WriteLine("XplatUI Destructor called");
120                 }
121                 #endregion      // Constructor & Destructor
122
123                 #region Public Static Properties
124                 internal static string DefaultClassName {
125                         get {
126                                 return default_class_name;
127                         }
128
129                         set {
130                                 default_class_name=value;
131                         }
132                 }
133                 #endregion      // Public Static Properties
134
135                 #region Public Static Methods
136                 internal static void Exit() {
137                         driver.Exit();
138                 }
139
140                 internal static bool Text(IntPtr hWnd, string text) {
141                         return driver.Text(hWnd, text);
142                 }
143
144                 internal static bool SetVisible(IntPtr hWnd, bool visible) {
145                         return driver.SetVisible(hWnd, visible);
146                 }
147
148                 internal static bool IsVisible(IntPtr hWnd) {
149                         return driver.IsVisible(hWnd);
150                 }
151
152                 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
153                         return driver.SetParent(hWnd, hParent);
154                 }
155
156                 internal static IntPtr GetParent(IntPtr hWnd) {
157                         return driver.GetParent(hWnd);
158                 }
159
160                 internal static void Version() {
161                         Console.WriteLine("Xplat version $revision: $");
162                 }
163
164                 internal static IntPtr CreateWindow(CreateParams cp) {
165                         return driver.CreateWindow(cp);
166                 }
167
168                 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
169                         return driver.CreateWindow(Parent, X, Y, Width, Height);
170                 }
171
172                 internal static void DestroyWindow(IntPtr handle) {
173                         driver.DestroyWindow(handle);
174                 }
175
176                 internal static void RefreshWindow(IntPtr handle) {
177                         driver.RefreshWindow(handle);
178                 }
179
180                 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
181                         return driver.PaintEventStart(handle);
182                 }
183
184                 internal static void PaintEventEnd(IntPtr handle) {
185                         driver.PaintEventEnd(handle);
186                 }
187
188                 internal static void SetWindowPos(IntPtr handle, Rectangle rc) {
189                         driver.SetWindowPos(handle, rc);
190                 }
191
192                 internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
193                         driver.MoveWindow(hWnd, x, y, width, height);
194                 }
195
196                 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
197                         driver.SetWindowPos(handle, x, y, width, height);
198                 }
199
200                 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
201                         driver.Invalidate(handle, rc, clear);
202                 }
203
204                 internal static void Activate(IntPtr handle) {
205                         driver.Activate(handle);
206                 }
207
208                 internal static IntPtr DefWndProc(ref Message msg) {
209                         return driver.DefWndProc(ref msg);
210                 }
211
212                 internal static void HandleException(Exception e) {
213                         driver.HandleException(e);
214                 }
215
216                 internal static void DoEvents() {
217                         driver.DoEvents();
218                 }
219
220                 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
221                         return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
222                 }
223
224                 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
225                         return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
226                 }
227
228                 internal static bool TranslateMessage(ref MSG msg) {
229                         return driver.TranslateMessage(ref msg);
230                 }
231
232                 internal static bool DispatchMessage(ref MSG msg) {
233                         return driver.DispatchMessage(ref msg);
234                 }
235
236                 // Santa's little helper
237                 internal static void Where() {
238                         Console.WriteLine("Here: {0}", new StackTrace().ToString());
239                 }
240
241                 internal static void Run() {
242                         driver.Run();
243                 }
244
245                 #endregion      // Public Static Methods
246
247         }
248 }