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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2004 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
28 // $Log: XplatUI.cs,v $
29 // Revision 1.12 2004/08/13 18:53:14 pbartok
30 // - Changed GetWindowPos to also provide client area size
32 // Revision 1.11 2004/08/12 22:59:03 pbartok
33 // - Implemented method to get current mouse position
35 // Revision 1.10 2004/08/11 22:20:59 pbartok
38 // Revision 1.9 2004/08/11 19:19:44 pbartok
39 // - We had SetWindowPos and MoveWindow to set window positions and size,
40 // removed MoveWindow. We have GetWindowPos, so it made sense to keep
41 // SetWindowPos as matching counterpart
42 // - Added some X11 sanity checking
44 // Revision 1.8 2004/08/11 18:55:46 pbartok
45 // - Added method to calculate difference between decorated window and raw
48 // Revision 1.7 2004/08/10 17:39:22 pbartok
49 // - Added GetWindowPos method
51 // Revision 1.6 2004/08/09 20:55:59 pbartok
52 // - Removed Run method, was only required for initial development
54 // Revision 1.5 2004/08/09 20:51:25 pbartok
55 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
57 // Revision 1.4 2004/08/09 17:02:29 jackson
58 // Get default window properties from the theme
60 // Revision 1.3 2004/08/09 15:56:44 jackson
61 // Remove defaults, these are handled by the theme now.
63 // Revision 1.2 2004/08/04 20:11:24 pbartok
64 // - Added Invalidate handling
66 // Revision 1.1 2004/07/09 05:21:25 pbartok
75 using System.ComponentModel;
76 using System.Collections;
77 using System.Diagnostics;
78 using System.Runtime.InteropServices;
81 // Random architecture notes
85 // - set location/size
95 namespace System.Windows.Forms {
96 internal class XplatUI {
97 #region Local Variables
98 static XplatUIDriver driver;
99 static String default_class_name;
100 #endregion // Local Variables
105 static public Keys ModifierKeys {
107 return driver.ModifierKeys;
111 static public MouseButtons MouseButtons {
113 return driver.MouseButtons;
117 static public Point MousePosition {
119 return driver.MousePosition;
123 static public bool DropTarget {
125 return driver.DropTarget;
129 driver.DropTarget=value;
133 #endregion // Subclasses
135 #region Constructor & Destructor
137 // Don't forget to throw the mac in here somewhere, too
138 default_class_name="SWFClass";
140 if (Environment.OSVersion.Platform == (PlatformID)128) {
141 driver=XplatUIX11.GetInstance();
143 driver=XplatUIWin32.GetInstance();
146 Console.WriteLine("#region #line XplatUI Constructor called");
150 Console.WriteLine("XplatUI Destructor called");
152 #endregion // Constructor & Destructor
154 #region Public Static Properties
155 internal static string DefaultClassName {
157 return default_class_name;
161 default_class_name=value;
164 #endregion // Public Static Properties
166 #region Public Static Methods
167 internal static void Exit() {
171 internal static void EnableThemes() {
172 driver.EnableThemes();
175 internal static bool Text(IntPtr hWnd, string text) {
176 return driver.Text(hWnd, text);
179 internal static bool SetVisible(IntPtr hWnd, bool visible) {
180 return driver.SetVisible(hWnd, visible);
183 internal static bool IsVisible(IntPtr hWnd) {
184 return driver.IsVisible(hWnd);
187 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
188 return driver.SetParent(hWnd, hParent);
191 internal static IntPtr GetParent(IntPtr hWnd) {
192 return driver.GetParent(hWnd);
195 internal static void Version() {
196 Console.WriteLine("Xplat version $revision: $");
199 internal static IntPtr CreateWindow(CreateParams cp) {
200 return driver.CreateWindow(cp);
203 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
204 return driver.CreateWindow(Parent, X, Y, Width, Height);
207 internal static void DestroyWindow(IntPtr handle) {
208 driver.DestroyWindow(handle);
211 internal static void RefreshWindow(IntPtr handle) {
212 driver.RefreshWindow(handle);
215 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
216 return driver.PaintEventStart(handle);
219 internal static void PaintEventEnd(IntPtr handle) {
220 driver.PaintEventEnd(handle);
223 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
224 driver.SetWindowPos(handle, x, y, width, height);
227 internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
228 driver.GetWindowPos(handle, out x, out y, out width, out height, out client_width, out client_height);
231 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
232 driver.Invalidate(handle, rc, clear);
235 internal static void Activate(IntPtr handle) {
236 driver.Activate(handle);
239 internal static IntPtr DefWndProc(ref Message msg) {
240 return driver.DefWndProc(ref msg);
243 internal static void HandleException(Exception e) {
244 driver.HandleException(e);
247 internal static void DoEvents() {
251 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
252 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
255 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
256 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
259 internal static bool TranslateMessage(ref MSG msg) {
260 return driver.TranslateMessage(ref msg);
263 internal static bool DispatchMessage(ref MSG msg) {
264 return driver.DispatchMessage(ref msg);
267 internal static void GrabWindow(IntPtr hWnd) {
268 driver.GrabWindow(hWnd);
271 internal static void ReleaseWindow(IntPtr hWnd) {
272 driver.ReleaseWindow(hWnd);
275 internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
276 return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
279 internal static void GetCursorPos(IntPtr handle, ref int x, ref int y) {
280 driver.GetCursorPos(handle, ref x, ref y);
284 // Santa's little helper
285 internal static void Where() {
286 Console.WriteLine("Here: {0}", new StackTrace().ToString());
288 #endregion // Public Static Methods