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.10 2004/08/11 22:20:59 pbartok
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
38 // Revision 1.8 2004/08/11 18:55:46 pbartok
39 // - Added method to calculate difference between decorated window and raw
42 // Revision 1.7 2004/08/10 17:39:22 pbartok
43 // - Added GetWindowPos method
45 // Revision 1.6 2004/08/09 20:55:59 pbartok
46 // - Removed Run method, was only required for initial development
48 // Revision 1.5 2004/08/09 20:51:25 pbartok
49 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
51 // Revision 1.4 2004/08/09 17:02:29 jackson
52 // Get default window properties from the theme
54 // Revision 1.3 2004/08/09 15:56:44 jackson
55 // Remove defaults, these are handled by the theme now.
57 // Revision 1.2 2004/08/04 20:11:24 pbartok
58 // - Added Invalidate handling
60 // Revision 1.1 2004/07/09 05:21:25 pbartok
69 using System.ComponentModel;
70 using System.Collections;
71 using System.Diagnostics;
72 using System.Runtime.InteropServices;
75 // Random architecture notes
79 // - set location/size
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
99 static public Keys ModifierKeys {
101 return driver.ModifierKeys;
105 static public MouseButtons MouseButtons {
107 return driver.MouseButtons;
111 static public Point MousePosition {
113 return driver.MousePosition;
117 static public bool DropTarget {
119 return driver.DropTarget;
123 driver.DropTarget=value;
127 #endregion // Subclasses
129 #region Constructor & Destructor
131 // Don't forget to throw the mac in here somewhere, too
132 default_class_name="SWFClass";
134 if (Environment.OSVersion.Platform == (PlatformID)128) {
135 driver=XplatUIX11.GetInstance();
137 driver=XplatUIWin32.GetInstance();
140 Console.WriteLine("#region #line XplatUI Constructor called");
144 Console.WriteLine("XplatUI Destructor called");
146 #endregion // Constructor & Destructor
148 #region Public Static Properties
149 internal static string DefaultClassName {
151 return default_class_name;
155 default_class_name=value;
158 #endregion // Public Static Properties
160 #region Public Static Methods
161 internal static void Exit() {
165 internal static void EnableThemes() {
166 driver.EnableThemes();
169 internal static bool Text(IntPtr hWnd, string text) {
170 return driver.Text(hWnd, text);
173 internal static bool SetVisible(IntPtr hWnd, bool visible) {
174 return driver.SetVisible(hWnd, visible);
177 internal static bool IsVisible(IntPtr hWnd) {
178 return driver.IsVisible(hWnd);
181 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
182 return driver.SetParent(hWnd, hParent);
185 internal static IntPtr GetParent(IntPtr hWnd) {
186 return driver.GetParent(hWnd);
189 internal static void Version() {
190 Console.WriteLine("Xplat version $revision: $");
193 internal static IntPtr CreateWindow(CreateParams cp) {
194 return driver.CreateWindow(cp);
197 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
198 return driver.CreateWindow(Parent, X, Y, Width, Height);
201 internal static void DestroyWindow(IntPtr handle) {
202 driver.DestroyWindow(handle);
205 internal static void RefreshWindow(IntPtr handle) {
206 driver.RefreshWindow(handle);
209 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
210 return driver.PaintEventStart(handle);
213 internal static void PaintEventEnd(IntPtr handle) {
214 driver.PaintEventEnd(handle);
217 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
218 driver.SetWindowPos(handle, x, y, width, height);
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);
225 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
226 driver.Invalidate(handle, rc, clear);
229 internal static void Activate(IntPtr handle) {
230 driver.Activate(handle);
233 internal static IntPtr DefWndProc(ref Message msg) {
234 return driver.DefWndProc(ref msg);
237 internal static void HandleException(Exception e) {
238 driver.HandleException(e);
241 internal static void DoEvents() {
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);
249 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
250 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
253 internal static bool TranslateMessage(ref MSG msg) {
254 return driver.TranslateMessage(ref msg);
257 internal static bool DispatchMessage(ref MSG msg) {
258 return driver.DispatchMessage(ref msg);
261 internal static void GrabWindow(IntPtr hWnd) {
262 driver.GrabWindow(hWnd);
265 internal static void ReleaseWindow(IntPtr hWnd) {
266 driver.ReleaseWindow(hWnd);
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);
273 // Santa's little helper
274 internal static void Where() {
275 Console.WriteLine("Here: {0}", new StackTrace().ToString());
277 #endregion // Public Static Methods