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: XplatUIDriver.cs,v $
29 // Revision 1.26 2004/11/08 20:53:17 pbartok
30 // - Added argument to SetTopmost
32 // Revision 1.25 2004/10/18 04:50:54 pbartok
33 // - Added method for enabling/disabling windows
34 // - Added method for setting window modality
35 // - Added method for setting topmost window
37 // Revision 1.24 2004/10/02 19:07:36 pbartok
38 // - Added ClientToScreen coordinate translation method
40 // Revision 1.23 2004/09/21 00:54:15 jackson
41 // New message loop that uses poll so we don't get a busy loop
43 // Revision 1.22 2004/09/13 21:18:32 pbartok
44 // - Added Z-Ordering methods
46 // Revision 1.21 2004/09/11 00:57:35 pbartok
47 // - Added method to retrieve text from window
49 // Revision 1.20 2004/08/24 11:29:44 jackson
50 // Move timers to the driver level. On X they are queued by the driver and checked on idle.
52 // Revision 1.19 2004/08/23 19:39:30 pbartok
53 // - Added method to move mouse cursor
55 // Revision 1.18 2004/08/21 20:51:27 pbartok
56 // - Added method to get default display size
58 // Revision 1.17 2004/08/21 20:23:56 pbartok
59 // - Added method to query current grab state
60 // - Added argument to allow confining a grab to a window
62 // Revision 1.16 2004/08/20 20:03:20 pbartok
63 // - Added method for setting the window background
65 // Revision 1.15 2004/08/20 19:19:28 jackson
66 // Expose functionality to send async messages through the driver
68 // Revision 1.14 2004/08/13 21:42:15 pbartok
69 // - Changed signature for GetCursorPos
71 // Revision 1.13 2004/08/13 19:00:15 jordi
72 // implements PointToClient (ScreenToClient)
74 // Revision 1.12 2004/08/13 18:53:14 pbartok
75 // - Changed GetWindowPos to also provide client area size
77 // Revision 1.11 2004/08/12 22:59:03 pbartok
78 // - Implemented method to get current mouse position
80 // Revision 1.10 2004/08/11 22:20:59 pbartok
83 // Revision 1.9 2004/08/11 19:19:44 pbartok
84 // - We had SetWindowPos and MoveWindow to set window positions and size,
85 // removed MoveWindow. We have GetWindowPos, so it made sense to keep
86 // SetWindowPos as matching counterpart
87 // - Added some X11 sanity checking
89 // Revision 1.8 2004/08/11 18:55:46 pbartok
90 // - Added method to calculate difference between decorated window and raw
93 // Revision 1.7 2004/08/10 17:39:22 pbartok
94 // - Added GetWindowPos method
96 // Revision 1.6 2004/08/10 14:34:15 jackson
97 // Use default colors from the theme
99 // Revision 1.5 2004/08/09 20:55:59 pbartok
100 // - Removed Run method, was only required for initial development
102 // Revision 1.4 2004/08/09 20:51:25 pbartok
103 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
105 // Revision 1.3 2004/08/04 20:11:24 pbartok
106 // - Added Invalidate handling
108 // Revision 1.2 2004/08/03 23:09:02 jordi
109 // fixes spelling mistake
111 // Revision 1.1 2004/07/09 05:21:25 pbartok
112 // - Initial check-in
118 using System.Drawing;
120 namespace System.Windows.Forms {
121 internal abstract class XplatUIDriver {
122 internal abstract IntPtr InitializeDriver();
123 internal abstract void ShutdownDriver(IntPtr token);
124 internal delegate IntPtr WndProc(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
127 #region XplatUI Driver Properties
128 internal virtual Color ForeColor {
130 return ThemeEngine.Current.DefaultWindowForeColor;
134 internal virtual Color BackColor {
136 return ThemeEngine.Current.DefaultWindowBackColor;
140 internal virtual Font Font {
142 return ThemeEngine.Current.DefaultFont;
146 internal virtual Keys ModifierKeys {
152 internal virtual MouseButtons MouseButtons {
154 return MouseButtons.None;
158 internal virtual Point MousePosition {
164 internal virtual bool DropTarget {
172 #endregion // XplatUI Driver Properties
174 internal abstract event EventHandler Idle;
176 #region XplatUI Driver Methods
177 internal abstract void Exit();
179 internal abstract void EnableThemes();
181 internal abstract void GetDisplaySize(out Size size);
183 internal abstract IntPtr CreateWindow(CreateParams cp);
184 internal abstract IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height);
185 internal abstract void DestroyWindow(IntPtr handle);
187 internal abstract bool GetText(IntPtr handle, out string text);
188 internal abstract bool Text(IntPtr handle, string text);
189 internal abstract bool SetVisible(IntPtr handle, bool visible);
190 internal abstract bool IsVisible(IntPtr handle);
191 internal abstract IntPtr SetParent(IntPtr handle, IntPtr parent);
192 internal abstract IntPtr GetParent(IntPtr handle);
194 internal abstract void RefreshWindow(IntPtr handle);
195 internal abstract void SetWindowBackground(IntPtr handle, Color color);
196 internal abstract PaintEventArgs PaintEventStart(IntPtr handle);
197 internal abstract void PaintEventEnd(IntPtr handle);
199 internal abstract void SetWindowPos(IntPtr handle, int x, int y, int width, int height);
200 internal abstract void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height);
201 internal abstract void Activate(IntPtr handle);
202 internal abstract void EnableWindow(IntPtr handle, bool Enable);
203 internal abstract void SetModal(IntPtr handle, bool Modal);
204 internal abstract void Invalidate(IntPtr handle, Rectangle rc, bool clear);
205 internal abstract IntPtr DefWndProc(ref Message msg);
206 internal abstract void HandleException(Exception e);
207 internal abstract void DoEvents();
208 internal abstract bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
209 internal abstract bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
210 internal abstract bool TranslateMessage(ref MSG msg);
211 internal abstract bool DispatchMessage(ref MSG msg);
213 internal abstract bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom);
214 internal abstract bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled);
216 internal abstract bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect);
218 internal abstract void GetCursorPos(IntPtr handle, out int x, out int y);
219 internal abstract void SetCursorPos(IntPtr handle, int x, int y);
220 internal abstract void ScreenToClient(IntPtr handle, ref int x, ref int y);
221 internal abstract void ClientToScreen(IntPtr handle, ref int x, ref int y);
223 internal abstract void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd);
224 internal abstract void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea);
225 internal abstract void ReleaseWindow(IntPtr hWnd);
227 internal abstract void SendAsyncMethod (AsyncMethodData method);
228 internal abstract void SetTimer (Timer timer);
229 internal abstract void KillTimer (Timer timer);
232 #endregion // XplatUI Driver Methods