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.3 2004/08/09 15:56:44 jackson
30 // Remove defaults, these are handled by the theme now.
32 // Revision 1.2 2004/08/04 20:11:24 pbartok
33 // - Added Invalidate handling
35 // Revision 1.1 2004/07/09 05:21:25 pbartok
44 using System.ComponentModel;
45 using System.Collections;
46 using System.Diagnostics;
47 using System.Runtime.InteropServices;
50 // Random architecture notes
54 // - set location/size
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
74 static public Keys ModifierKeys {
76 return driver.ModifierKeys;
80 static public MouseButtons MouseButtons {
82 return driver.MouseButtons;
86 static public Point MousePosition {
88 return driver.MousePosition;
92 static public bool DropTarget {
94 return driver.DropTarget;
98 driver.DropTarget=value;
102 #endregion // Subclasses
104 #region Constructor & Destructor
106 // Don't forget to throw the mac in here somewhere, too
107 default_class_name="SWFClass";
109 if (Environment.OSVersion.Platform == (PlatformID)128) {
110 driver=XplatUIX11.GetInstance();
112 driver=XplatUIWin32.GetInstance();
115 Console.WriteLine("#region #line XplatUI Constructor called");
119 Console.WriteLine("XplatUI Destructor called");
121 #endregion // Constructor & Destructor
123 #region Public Static Properties
124 internal static string DefaultClassName {
126 return default_class_name;
130 default_class_name=value;
133 #endregion // Public Static Properties
135 #region Public Static Methods
136 internal static void Exit() {
140 internal static bool Text(IntPtr hWnd, string text) {
141 return driver.Text(hWnd, text);
144 internal static bool SetVisible(IntPtr hWnd, bool visible) {
145 return driver.SetVisible(hWnd, visible);
148 internal static bool IsVisible(IntPtr hWnd) {
149 return driver.IsVisible(hWnd);
152 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
153 return driver.SetParent(hWnd, hParent);
156 internal static IntPtr GetParent(IntPtr hWnd) {
157 return driver.GetParent(hWnd);
160 internal static void Version() {
161 Console.WriteLine("Xplat version $revision: $");
164 internal static IntPtr CreateWindow(CreateParams cp) {
165 return driver.CreateWindow(cp);
168 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
169 return driver.CreateWindow(Parent, X, Y, Width, Height);
172 internal static void DestroyWindow(IntPtr handle) {
173 driver.DestroyWindow(handle);
176 internal static void RefreshWindow(IntPtr handle) {
177 driver.RefreshWindow(handle);
180 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
181 return driver.PaintEventStart(handle);
184 internal static void PaintEventEnd(IntPtr handle) {
185 driver.PaintEventEnd(handle);
188 internal static void SetWindowPos(IntPtr handle, Rectangle rc) {
189 driver.SetWindowPos(handle, rc);
192 internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
193 driver.MoveWindow(hWnd, x, y, width, height);
196 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
197 driver.SetWindowPos(handle, x, y, width, height);
200 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
201 driver.Invalidate(handle, rc, clear);
204 internal static void Activate(IntPtr handle) {
205 driver.Activate(handle);
208 internal static IntPtr DefWndProc(ref Message msg) {
209 return driver.DefWndProc(ref msg);
212 internal static void HandleException(Exception e) {
213 driver.HandleException(e);
216 internal static void DoEvents() {
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);
224 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
225 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
228 internal static bool TranslateMessage(ref MSG msg) {
229 return driver.TranslateMessage(ref msg);
232 internal static bool DispatchMessage(ref MSG msg) {
233 return driver.DispatchMessage(ref msg);
236 // Santa's little helper
237 internal static void Where() {
238 Console.WriteLine("Here: {0}", new StackTrace().ToString());
241 internal static void Run() {
245 #endregion // Public Static Methods