2005-06-02 Peter Bartok <pbartok@novell.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / OSXStructs.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) 2005 Novell, Inc.
21 //
22 // Authors:
23 //      Geoff Norton  <gnorton@customerdna.com>
24 //
25
26
27 // NOT COMPLETE
28
29 using System;
30 using System.ComponentModel;
31 using System.Collections;
32 using System.Diagnostics;
33 using System.Runtime.InteropServices;
34
35 /// Mac OSX Version
36 namespace System.Windows.Forms {
37
38         internal class OSXConstants {
39
40                 #region EventClass constants
41                 internal const uint kEventClassMouse = 1836021107;
42                 internal const uint kEventClassKeyboard = 1801812322;
43                 internal const uint kEventClassTextInput = 1952807028;
44                 internal const uint kEventClassApplication = 1634758764;
45                 internal const uint kEventClassAppleEvent = 1701867619;
46                 internal const uint kEventClassMenu = 1835363957;
47                 internal const uint kEventClassWindow = 2003398244;
48                 internal const uint kEventClassControl = 1668183148;
49                 internal const uint kEventClassCommand = 1668113523;
50                 internal const uint kEventClassTablet = 1952607348;
51                 internal const uint kEventClassVolume = 1987013664;
52                 internal const uint kEventClassAppearance = 1634758765;
53                 internal const uint kEventClassService = 1936028278;
54                 internal const uint kEventClassToolbar = 1952604530;
55                 internal const uint kEventClassToolbarItem = 1952606580;
56                 internal const uint kEventClassAccessibility = 1633903461;
57                 #endregion
58
59                 #region kEventClassMouse constants
60                 internal const uint kEventMouseDown = 1;
61                 internal const uint kEventMouseUp = 2;
62                 internal const uint kEventMouseMoved = 5;
63                 internal const uint kEventMouseDragged = 6;
64                 internal const uint kEventMouseEntered = 8;
65                 internal const uint kEventMouseExited = 9;
66                 internal const uint kEventMouseWheelMoved = 10;
67                 #endregion
68
69                 #region kEventClassKeyboard constants
70                 internal const uint kEventRawKeyDown = 1;
71                 internal const uint kEventRawKeyRepeat = 2;
72                 internal const uint kEventRawKeyUp = 3;
73                 internal const uint kEventRawKeyModifiersChanged = 4;
74                 internal const uint kEventHotKeyPressed = 5;
75                 internal const uint kEventHotKeyReleased = 6;
76                 #endregion
77
78                 #region kEventClassTextInput constants
79                 // TODO: We dont use these yet; fill if needed
80                 #endregion
81                 
82                 #region kEventClassApplication constants
83                 // TODO: We dont use these yet; fill if needed
84                 #endregion
85
86                 #region kEventClassAppleEvent constants
87                 // TODO: We dont use these yet; fill if needed
88                 #endregion
89
90                 #region kEventClassMenu constants
91                 // TODO: We dont use these yet; fill if needed
92                 #endregion
93
94                 #region kEventClassWindow constants
95                 internal const uint kEventWindowUpdate = 1;
96                 internal const uint kEventWindowDrawContent = 2;
97                 internal const uint kEventWindowActivated = 5;
98                 internal const uint kEventWindowDeactivated = 6;
99                 internal const uint kEventWindowGetClickActivation = 7;
100                 internal const uint kEventWindowShowing = 22;
101                 internal const uint kEventWindowHiding = 23;
102                 internal const uint kEventWindowShown = 24;
103                 internal const uint kEventWindowHidden = 25;
104                 internal const uint kEventWindowCollapsing = 86;
105                 internal const uint kEventWindowExpanding = 87;
106                 internal const uint kEventWindowZoomed = 76;
107                 internal const uint kEventWindowBoundsChanging = 26;
108                 internal const uint kEventWindowBoundsChanged = 27;
109                 internal const uint kEventWindowResizeStarted = 28;
110                 internal const uint kEventWindowResizeCompleted = 29;
111                 internal const uint kEventWindowDragStarted = 30;
112                 internal const uint kEventWindowDragCompleted = 31;
113                 internal const uint kEventWindowTransitionStarted = 88;
114                 internal const uint kEventWindowTransitionCompleted = 89;
115                 internal const uint kEventWindowClickDragRgn = 32;
116                 internal const uint kEventWindowClickResizeRgn = 33;
117                 internal const uint kEventWindowClickCollapseRgn = 34;
118                 internal const uint kEventWindowClickCloseRgn = 35;
119                 internal const uint kEventWindowClickZoomRgn = 36;
120                 internal const uint kEventWindowClickContentRgn = 37;
121                 internal const uint kEventWindowClickProxyIconRgn = 38;
122                 internal const uint kEventWindowClickToolbarButtonRgn = 41;
123                 internal const uint kEventWindowClickStructureRgn = 42;
124                 internal const uint kEventWindowCursorChange = 40;
125                 internal const uint kEventWindowCollapse = 66;
126                 internal const uint kEventWindowCollapsed = 67;
127                 internal const uint kEventWindowCollapseAll = 68;
128                 internal const uint kEventWindowExpand = 69;
129                 internal const uint kEventWindowExpanded = 70;
130                 internal const uint kEventWindowExpandAll = 71;
131                 internal const uint kEventWindowClose = 72;
132                 internal const uint kEventWindowClosed = 73;
133                 internal const uint kEventWindowCloseAll = 74;
134                 internal const uint kEventWindowZoom = 75;
135                 internal const uint kEventWindowZoomAll = 77;
136                 internal const uint kEventWindowContextualMenuSelect = 78;
137                 internal const uint kEventWindowPathSelect = 79;
138                 internal const uint kEventWindowGetIdealSize = 80;
139                 internal const uint kEventWindowGetMinimumSize = 81;
140                 internal const uint kEventWindowGetMaximumSize = 82;
141                 internal const uint kEventWindowConstrain = 83;
142                 internal const uint kEventWindowHandleContentClick = 85;
143                 internal const uint kEventWindowGetDockTileMenu = 90;
144                 internal const uint kEventWindowHandleActivate = 91;
145                 internal const uint kEventWindowHandleDeactivate = 92;
146                 internal const uint kEventWindowProxyBeginDrag = 128;
147                 internal const uint kEventWindowProxyEndDrag = 129;
148                 internal const uint kEventWindowToolbarSwitchMode = 150;
149                 internal const uint kEventWindowFocusAcquired = 200;
150                 internal const uint kEventWindowFocusRelinquish = 201;
151                 internal const uint kEventWindowFocusContent = 202;
152                 internal const uint kEventWindowFocusToolbar = 203;
153                 internal const uint kEventWindowDrawerOpening = 220;
154                 internal const uint kEventWindowDrawerOpened = 221;
155                 internal const uint kEventWindowDrawerClosing = 222;
156                 internal const uint kEventWindowDrawerClosed = 223;
157                 internal const uint kEventWindowDrawFrame = 1000;
158                 internal const uint kEventWindowDrawPart = 1001;
159                 internal const uint kEventWindowGetRegion = 1002;
160                 internal const uint kEventWindowHitTest = 1003;
161                 internal const uint kEventWindowInit = 1004;
162                 internal const uint kEventWindowDispose = 1005;
163                 internal const uint kEventWindowDragHilite = 1006;
164                 internal const uint kEventWindowModified = 1007;
165                 internal const uint kEventWindowSetupProxyDragImage = 1008;
166                 internal const uint kEventWindowStateChanged = 1009;
167                 internal const uint kEventWindowMeasureTitle = 1010;
168                 internal const uint kEventWindowDrawGrowBox = 1011;
169                 internal const uint kEventWindowGetGrowImageRegion = 1012;
170                 internal const uint kEventWindowPaint = 1013;
171                 #endregion
172
173                 #region kEventClassControl constants
174                 internal const uint kEventControlInitialize = 1000;
175                 internal const uint kEventControlDispose = 1001;
176                 internal const uint kEventControlGetOptimalBounds = 1003;
177                 internal const uint kEventControlDefInitialize = kEventControlInitialize;
178                 internal const uint kEventControlDefDispose = kEventControlDispose;
179                 internal const uint kEventControlHit = 1;
180                 internal const uint kEventControlSimulateHit = 2;
181                 internal const uint kEventControlHitTest = 3;
182                 internal const uint kEventControlDraw = 4;
183                 internal const uint kEventControlApplyBackground = 5;
184                 internal const uint kEventControlApplyTextColor = 6;
185                 internal const uint kEventControlSetFocusPart = 7;
186                 internal const uint kEventControlGetFocusPart = 8;
187                 internal const uint kEventControlActivate = 9;
188                 internal const uint kEventControlDeactivate = 10;
189                 internal const uint kEventControlSetCursor = 11;
190                 internal const uint kEventControlContextualMenuClick = 12;
191                 internal const uint kEventControlClick = 13;
192                 internal const uint kEventControlGetNextFocusCandidate = 14;
193                 internal const uint kEventControlGetAutoToggleValue = 15;
194                 internal const uint kEventControlInterceptSubviewClick = 16;
195                 internal const uint kEventControlGetClickActivation = 17;
196                 internal const uint kEventControlDragEnter = 18;
197                 internal const uint kEventControlDragWithin = 19;
198                 internal const uint kEventControlDragLeave = 20;
199                 internal const uint kEventControlDragReceive = 21;
200                 internal const uint kEventControlInvalidateForSizeChange = 22;
201                 internal const uint kEventControlTrackingAreaEntered = 23;
202                 internal const uint kEventControlTrackingAreaExited = 24;
203                 internal const uint kEventControlTrack = 51;
204                 internal const uint kEventControlGetScrollToHereStartPoint = 52;
205                 internal const uint kEventControlGetIndicatorDragConstraint = 53;
206                 internal const uint kEventControlIndicatorMoved = 54;
207                 internal const uint kEventControlGhostingFinished = 55;
208                 internal const uint kEventControlGetActionProcPart = 56;
209                 internal const uint kEventControlGetPartRegion = 101;
210                 internal const uint kEventControlGetPartBounds = 102;
211                 internal const uint kEventControlSetData = 103;
212                 internal const uint kEventControlGetData = 104;
213                 internal const uint kEventControlGetSizeConstraints= 105;
214                 internal const uint kEventControlGetFrameMetrics = 106;
215                 internal const uint kEventControlValueFieldChanged = 151;
216                 internal const uint kEventControlAddedSubControl = 152;
217                 internal const uint kEventControlRemovingSubControl = 153;
218                 internal const uint kEventControlBoundsChanged = 154;
219                 internal const uint kEventControlVisibilityChanged = 157;
220                 internal const uint kEventControlTitleChanged = 158;
221                 internal const uint kEventControlOwningWindowChanged = 159;
222                 internal const uint kEventControlHiliteChanged = 160;
223                 internal const uint kEventControlEnabledStateChanged = 161;
224                 internal const uint kEventControlLayoutInfoChanged = 162;
225                 internal const uint kEventControlArbitraryMessage = 201;
226                 #endregion
227                 
228                 #region kEventClassCommand constants
229                 // TODO: We dont use these yet; fill if needed
230                 #endregion
231
232                 #region kEventClassTablet constants
233                 // TODO: We dont use these yet; fill if needed
234                 #endregion
235
236                 #region kEventClassVolume constants
237                 // TODO: We dont use these yet; fill if needed
238                 #endregion
239
240                 #region kEventClassAppearance constants
241                 // TODO: We dont use these yet; fill if needed
242                 #endregion
243
244                 #region kEventClassService constants
245                 // TODO: We dont use these yet; fill if needed
246                 #endregion
247
248                 #region kEventClassToolbar constants
249                 // TODO: We dont use these yet; fill if needed
250                 #endregion
251
252                 #region kEventClassToolbarItem constants
253                 // TODO: We dont use these yet; fill if needed
254                 #endregion
255
256                 #region kEventClassAccessibility constants
257                 // TODO: We dont use these yet; fill if needed
258                 #endregion
259
260                 #region kEventParam constants
261
262                 internal enum EventParamName : uint {
263                         //      source: /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/CarbonEvents.h
264
265                         /* Keyboard event parameter and types*/
266                         kEventParamKeyMacCharCodes = 1801676914,        //      'kchr'
267         
268                         /* Mouse event parameters and types*/
269                         kEventParamMouseLocation = 1835822947,          //      'mloc', /* typeHIPoint*/
270                         kEventParamMouseButton = 1835168878,            //      'mbtn'  /* type MouseButton*/
271
272                         /* Generic toolbox parameters and types */
273                         kEventParamCGContextRef = 1668183160,           //      'cntx'  /* typeCGContextRef*/
274                         kEventParamRgnHandle = 1919381096,                      //      'rgnh'
275
276                         /* Control event parameters and types */
277                         kEventParamControlPart = 1668313716,            //      'cprt'  /* typeControlPartCode*/
278
279                         //      source: /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/CarbonEventsCore.h
280                         /* Core Event Types */
281                         kEventParamDirectObject = 757935405,            //      '----' /* type varies depending on event*/
282                 }
283
284                 internal enum EventParamType : uint {
285
286                         typeControlPartCode = 1668313716,                       //      'cprt'  /* ControlPartCode*/
287
288                         typeQDPoint = 1363439732,                                       //      'QDpt'
289
290                         typeControlRef = 1668575852,                            //      'ctrl'
291
292                         typeCGContextRef = 1668183160,                          //      'cntx'  /* CGContextRef*/
293
294                         typeMouseButton = 1835168878,                           //      'mbtn'  /* EventMouseButton*/
295
296                         typeQDRgnHandle = 1919381096,                           //      'rgnh'
297
298                         typeChar = 1413830740,                                          //      'TEXT'
299                 }
300
301                 #endregion
302         }
303
304         internal enum WindowClass : uint {
305                 kAlertWindowClass = 1,
306                 kMovableAlertWindowClass = 2,
307                 kModalWindowClass = 3,
308                 kMovableModalWindowClass = 4,
309                 kFloatingWindowClass = 5,
310                 kDocumentWindowClass = 6,
311                 kUtilityWindowClass = 8,
312                 kHelpWindowClass = 10,
313                 kSheetWindowClass = 11,
314                 kToolbarWindowClass = 12,
315                 kPlainWindowClass = 13,
316                 kOverlayWindowClass = 14,
317                 kSheetAlertWindowClass = 15,
318                 kAltPlainWindowClass = 16,
319                 kDrawerWindowClass = 20,
320                 kAllWindowClasses = 0xFFFFFFFF
321         }
322
323         internal enum WindowAttributes : uint {
324                 kWindowNoAttributes = 0,
325                 kWindowCloseBoxAttribute = (1u << 0),
326                 kWindowHorizontalZoomAttribute = (1u << 1),
327                 kWindowVerticalZoomAttribute = (1u << 2),
328                 kWindowFullZoomAttribute = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute),
329                 kWindowCollapseBoxAttribute = (1u << 3),
330                 kWindowResizableAttribute = (1u << 4),
331                 kWindowSideTitlebarAttribute = (1u << 5),
332                 kWindowToolbarButtonAttribute = (1u << 6),
333                 kWindowMetalAttribute = (1u << 8),
334                 kWindowNoUpdatesAttribute = (1u << 16),
335                 kWindowNoActivatesAttribute = (1u << 17),
336                 kWindowOpaqueForEventsAttribute = (1u << 18),
337                 kWindowCompositingAttribute = (1u << 19),
338                 kWindowNoShadowAttribute = (1u << 21),
339                 kWindowHideOnSuspendAttribute = (1u << 24),
340                 kWindowStandardHandlerAttribute = (1u << 25),
341                 kWindowHideOnFullScreenAttribute = (1u << 26),
342                 kWindowInWindowMenuAttribute = (1u << 27),
343                 kWindowuiveResizeAttribute = (1u << 28),
344                 kWindowIgnoreClicksAttribute = (1u << 29),
345                 kWindowNoConstrainAttribute = (1u << 31),
346                 kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute),
347                 kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
348         }
349         internal enum ThemeCursor : uint {
350                 kThemeArrowCursor = 0,
351                 kThemeCopyArrowCursor = 1,
352                 kThemeAliasArrowCursor = 2,
353                 kThemeContextualMenuArrowCursor = 3,
354                 kThemeIBeamCursor = 4,
355                 kThemeCrossCursor = 5,
356                 kThemePlusCursor = 6,
357                 kThemeWatchCursor = 7,
358                 kThemeClosedHandCursor = 8,
359                 kThemeOpenHandCursor = 9,
360                 kThemePointingHandCursor = 10,
361                 kThemeCountingUpHandCursor = 11,
362                 kThemeCountingDownHandCursor = 12,
363                 kThemeCountingUpAndDownHandCursor = 13,
364                 kThemeSpinningCursor = 14,
365                 kThemeResizeLeftCursor = 15,
366                 kThemeResizeRightCursor = 16,
367                 kThemeResizeLeftRightCursor = 17,
368                 kThemeNotAllowedCursor = 18
369         }
370         
371         internal struct CGSize {
372                 public float width;
373                 public float height;
374
375                 public CGSize (int w, int h) {
376                         this.width = (float)w;
377                         this.height = (float)h;
378                 }
379         }
380
381         internal struct QDPoint {
382                 public short y;
383                 public short x;
384
385                 public QDPoint (short x, short y) {
386                         this.x = x;
387                         this.y = y;
388                 }
389         }
390         internal struct CGPoint {
391                 public float x;
392                 public float y;
393
394                 public CGPoint (int x, int y) {
395                         this.x = (float)x;
396                         this.y = (float)y;
397                 }
398         }
399
400         internal struct HIRect {
401                 public CGPoint origin;
402                 public CGSize size;
403
404                 public HIRect (int x, int y, int w, int h) {
405                         this.origin = new CGPoint (x, y);
406                         this.size = new CGSize (w, h);
407                 }
408         }
409
410         internal struct HIViewID {
411                 public uint type;
412                 public uint id;
413
414                 public HIViewID (uint type, uint id) {
415                         this.type = type;
416                         this.id = id;
417                 }
418         }
419         
420         internal struct EventTypeSpec
421         {
422                 public UInt32 eventClass;
423                 public UInt32 eventKind;
424
425                 public EventTypeSpec (UInt32 eventClass, UInt32 eventKind)
426                 {
427                         this.eventClass = eventClass;
428                         this.eventKind = eventKind;
429                 }
430         }
431         
432         internal struct CarbonEvent
433         {
434                 public IntPtr hWnd;
435                 public IntPtr evt;
436
437                 public CarbonEvent (IntPtr hWnd, IntPtr evt)
438                 {
439                         this.hWnd = hWnd;
440                         this.evt = evt;
441                 }
442         }
443         
444         internal struct RGBColor
445         {
446                 public short red;
447                 public short green;
448                 public short blue;
449         }
450
451         internal struct Rect
452         {
453                 public short top;
454                 public short left;
455                 public short bottom;
456                 public short right;
457         }
458
459         internal struct OSXCaret
460         {
461                 internal Timer Timer;
462                 internal IntPtr Hwnd;
463                 internal int X;
464                 internal int Y;
465                 internal int Width;
466                 internal int Height;
467                 internal int Visible;
468                 internal bool On;
469                 internal bool Paused;
470         }
471
472         internal struct OSXHover {
473                 internal Timer Timer;
474                 internal IntPtr Hwnd;
475                 internal int X;
476                 internal int Y;
477                 internal int Interval;
478         }
479
480         internal struct CGAffineTransform
481         {
482                 internal float a;
483                 internal float b;
484                 internal float c;
485                 internal float d;
486                 internal float tx;
487                 internal float ty;
488         }
489         
490         internal enum MouseTrackingResult : ushort
491         {
492                 kMouseTrackingMouseDown = 1,
493                 kMouseTrackingMouseUp = 2,
494                 kMouseTrackingMouseExited = 3,
495                 kMouseTrackingMouseEntered = 4,
496                 kMouseTrackingMouseDragged = 5,
497                 kMouseTrackingKeyModifiersChanged = 6,
498                 kMouseTrackingUserCancelled = 7,
499                 kMouseTrackingTimedOut = 8,
500                 kMouseTrackingMouseMoved = 9
501         }
502         
503         internal struct MouseTrackingRegionID
504         {
505                 uint signature;
506                 uint id;
507                 
508                 public MouseTrackingRegionID (uint signature, uint id) {
509                         this.signature = signature;
510                         this.id = id;
511                 }
512         }
513         
514 }