home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSEvent.h < prev    next >
Text File  |  1996-10-17  |  8KB  |  244 lines

  1. /*
  2.     NSEvent.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. #import <AppKit/dpsOpenStep.h>
  9. #import <AppKit/NSDPSContext.h>
  10. @class NSWindow;
  11.  
  12. typedef enum _NSEventType {        /* various types of events */
  13.     NSLeftMouseDown        = 1,
  14.     NSLeftMouseUp        = 2,
  15.     NSRightMouseDown    = 3,
  16.     NSRightMouseUp        = 4,
  17.     NSMouseMoved        = 5,
  18.     NSLeftMouseDragged    = 6,
  19.     NSRightMouseDragged    = 7,
  20.     NSMouseEntered        = 8,
  21.     NSMouseExited        = 9,
  22.     NSKeyDown        = 10,
  23.     NSKeyUp            = 11,
  24.     NSFlagsChanged        = 12,
  25. #ifndef STRICT_OPENSTEP
  26.     NSAppKitDefined        = 13,
  27.     NSSystemDefined        = 14,
  28.     NSApplicationDefined    = 15,
  29. #endif
  30.     NSPeriodic        = 16,
  31.     NSCursorUpdate        = 17
  32. } NSEventType;
  33.  
  34. enum {                    /* masks for the types of events */
  35.     NSLeftMouseDownMask        = 1 << NSLeftMouseDown,
  36.     NSLeftMouseUpMask        = 1 << NSLeftMouseUp,
  37.     NSRightMouseDownMask        = 1 << NSRightMouseDown,
  38.     NSRightMouseUpMask        = 1 << NSRightMouseUp,
  39.     NSMouseMovedMask        = 1 << NSMouseMoved,
  40.     NSLeftMouseDraggedMask        = 1 << NSLeftMouseDragged,
  41.     NSRightMouseDraggedMask        = 1 << NSRightMouseDragged,
  42.     NSMouseEnteredMask        = 1 << NSMouseEntered,
  43.     NSMouseExitedMask        = 1 << NSMouseExited,
  44.     NSKeyDownMask            = 1 << NSKeyDown,
  45.     NSKeyUpMask            = 1 << NSKeyUp,
  46.     NSFlagsChangedMask        = 1 << NSFlagsChanged,
  47. #ifndef STRICT_OPENSTEP
  48.     NSAppKitDefinedMask        = 1 << NSAppKitDefined,
  49.     NSSystemDefinedMask        = 1 << NSSystemDefined,
  50.     NSApplicationDefinedMask    = 1 << NSApplicationDefined,
  51. #endif
  52.     NSPeriodicMask            = 1 << NSPeriodic,
  53.     NSCursorUpdateMask        = 1 << NSCursorUpdate,
  54.     NSAnyEventMask            = 0xffffffff
  55. };
  56.  
  57. static inline unsigned int NSEventMaskFromType(NSEventType type) { return (1 << type); }
  58.  
  59. /* Device-independent bits found in event modifier flags */
  60. enum {
  61.     NSAlphaShiftKeyMask =        1 << 16,
  62.     NSShiftKeyMask =        1 << 17,
  63.     NSControlKeyMask =        1 << 18,
  64.     NSAlternateKeyMask =        1 << 19,
  65.     NSCommandKeyMask =        1 << 20,
  66.     NSNumericPadKeyMask =        1 << 21,
  67.     NSHelpKeyMask =            1 << 22,
  68.     NSFunctionKeyMask =        1 << 23
  69. };
  70.  
  71. @interface NSEvent : NSObject <NSCopying, NSCoding> {
  72.     NSEventType _type;
  73.     NSPoint _location;
  74.     unsigned int _modifierFlags;
  75.     int _WSTimestamp;
  76.     NSTimeInterval _timestamp;
  77.     int _windowNumber;
  78.     NSWindow *_window;
  79.     NSDPSContext *_context;
  80.     union {
  81.     struct {
  82.         int eventNumber;
  83.         int    clickCount;
  84.         float pressure;
  85.     } mouse;
  86.     struct {
  87.         NSString *keys;
  88.         NSString *unmodKeys;
  89.         unsigned short keyCode;
  90.         BOOL isARepeat;
  91.     } key;
  92.     struct {
  93.         int eventNumber;
  94.         int    trackingNumber;
  95.         void *userData;
  96.     } tracking;
  97.     struct {
  98.         int subtype;
  99.         int data1;
  100.         int data2;
  101.     } misc;
  102.     } _data;
  103.     int _reservedEvent1;
  104. }
  105.  
  106.  
  107. /* these messages are valid for all events */
  108. - (NSEventType)type;
  109. - (NSPoint)locationInWindow;
  110. - (unsigned int)modifierFlags;
  111. - (NSTimeInterval)timestamp;
  112. - (NSWindow *)window;
  113. - (int)windowNumber;
  114. - (NSDPSContext *)context;
  115.  
  116. /* these messages are valid for all mouse down/up/drag events */
  117. - (int)clickCount;
  118. - (float)pressure;
  119. /* these messages are valid for all mouse down/up/drag and enter/exit events */
  120. - (int)eventNumber;
  121.  
  122. /* these messages are valid for keyup and keydown events */
  123. - (NSString *)characters;
  124. - (NSString *)charactersIgnoringModifiers;
  125.   /* the chars that would have been generated, regardless of modifier keys (except shift) */
  126. - (BOOL)isARepeat;
  127. /* this message is valid for keyup, keydown and flagschanged events */
  128. - (unsigned short)keyCode;        /* device-dependent key number */
  129.  
  130. /* these messages are valid for enter and exit events */
  131. - (int)trackingNumber;
  132. - (void *)userData;
  133.  
  134. /* these messages are valid for kit, system, and app-defined events */
  135. - (short)subtype;
  136. - (int)data1;
  137. - (int)data2;
  138.  
  139. /* used for initial delay and periodic behavior in tracking loops */
  140. + (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delay withPeriod:(NSTimeInterval)period;
  141. + (void)stopPeriodicEvents;
  142.  
  143. /* apps will rarely create these objects */
  144. + (NSEvent *)mouseEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned int)flags timestamp:(NSTimeInterval)time windowNumber:(int)wNum context:(NSDPSContext *)context eventNumber:(int)eNum clickCount:(int)cNum pressure:(float)pressure;
  145. + (NSEvent *)keyEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned int)flags timestamp:(NSTimeInterval)time windowNumber:(int)wNum context:(NSDPSContext *)context characters:(NSString *)keys charactersIgnoringModifiers:(NSString *)ukeys isARepeat:(BOOL)flag keyCode:(unsigned short)code;
  146. + (NSEvent *)enterExitEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned int)flags timestamp:(NSTimeInterval)time windowNumber:(int)wNum context:(NSDPSContext *)context eventNumber:(int)eNum trackingNumber:(int)tNum userData:(void *)data;
  147. + (NSEvent *)otherEventWithType:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned int)flags timestamp:(NSTimeInterval)time windowNumber:(int)wNum context:(NSDPSContext *)context subtype:(short)subtype data1:(int)d1 data2:(int)d2;
  148.  
  149. @end
  150.  
  151.  
  152. /* Unicodes we reserve for function keys on the keyboard,  OpenStep reserves the range 0xF700-0xF8FF for this purpose.  The availability of various keys will be system dependent. */
  153. enum {
  154.     NSUpArrowFunctionKey        = 0xF700,
  155.     NSDownArrowFunctionKey        = 0xF701,
  156.     NSLeftArrowFunctionKey        = 0xF702,
  157.     NSRightArrowFunctionKey        = 0xF703,
  158.     NSF1FunctionKey            = 0xF704,
  159.     NSF2FunctionKey            = 0xF705,
  160.     NSF3FunctionKey            = 0xF706,
  161.     NSF4FunctionKey            = 0xF707,
  162.     NSF5FunctionKey            = 0xF708,
  163.     NSF6FunctionKey            = 0xF709,
  164.     NSF7FunctionKey            = 0xF70A,
  165.     NSF8FunctionKey            = 0xF70B,
  166.     NSF9FunctionKey            = 0xF70C,
  167.     NSF10FunctionKey        = 0xF70D,
  168.     NSF11FunctionKey        = 0xF70E,
  169.     NSF12FunctionKey        = 0xF70F,
  170.     NSF13FunctionKey        = 0xF710,
  171.     NSF14FunctionKey        = 0xF711,
  172.     NSF15FunctionKey        = 0xF712,
  173.     NSF16FunctionKey        = 0xF713,
  174.     NSF17FunctionKey        = 0xF714,
  175.     NSF18FunctionKey        = 0xF715,
  176.     NSF19FunctionKey        = 0xF716,
  177.     NSF20FunctionKey        = 0xF717,
  178.     NSF21FunctionKey        = 0xF718,
  179.     NSF22FunctionKey        = 0xF719,
  180.     NSF23FunctionKey        = 0xF71A,
  181.     NSF24FunctionKey        = 0xF71B,
  182.     NSF25FunctionKey        = 0xF71C,
  183.     NSF26FunctionKey        = 0xF71D,
  184.     NSF27FunctionKey        = 0xF71E,
  185.     NSF28FunctionKey        = 0xF71F,
  186.     NSF29FunctionKey        = 0xF720,
  187.     NSF30FunctionKey        = 0xF721,
  188.     NSF31FunctionKey        = 0xF722,
  189.     NSF32FunctionKey        = 0xF723,
  190.     NSF33FunctionKey        = 0xF724,
  191.     NSF34FunctionKey        = 0xF725,
  192.     NSF35FunctionKey        = 0xF726,
  193.     NSInsertFunctionKey        = 0xF727,
  194.     NSDeleteFunctionKey        = 0xF728,
  195.     NSHomeFunctionKey        = 0xF729,
  196.     NSBeginFunctionKey        = 0xF72A,
  197.     NSEndFunctionKey        = 0xF72B,
  198.     NSPageUpFunctionKey        = 0xF72C,
  199.     NSPageDownFunctionKey        = 0xF72D,
  200.     NSPrintScreenFunctionKey    = 0xF72E,
  201.     NSScrollLockFunctionKey        = 0xF72F,
  202.     NSPauseFunctionKey        = 0xF730,
  203.     NSSysReqFunctionKey        = 0xF731,
  204.     NSBreakFunctionKey        = 0xF732,
  205.     NSResetFunctionKey        = 0xF733,
  206.     NSStopFunctionKey        = 0xF734,
  207.     NSMenuFunctionKey        = 0xF735,
  208.     NSUserFunctionKey        = 0xF736,
  209.     NSSystemFunctionKey        = 0xF737,
  210.     NSPrintFunctionKey        = 0xF738,
  211.     NSClearLineFunctionKey        = 0xF739,
  212.     NSClearDisplayFunctionKey    = 0xF73A,
  213.     NSInsertLineFunctionKey        = 0xF73B,
  214.     NSDeleteLineFunctionKey        = 0xF73C,
  215.     NSInsertCharFunctionKey        = 0xF73D,
  216.     NSDeleteCharFunctionKey        = 0xF73E,
  217.     NSPrevFunctionKey        = 0xF73F,
  218.     NSNextFunctionKey        = 0xF740,
  219.     NSSelectFunctionKey        = 0xF741,
  220.     NSExecuteFunctionKey        = 0xF742,
  221.     NSUndoFunctionKey        = 0xF743,
  222.     NSRedoFunctionKey        = 0xF744,
  223.     NSFindFunctionKey        = 0xF745,
  224.     NSHelpFunctionKey        = 0xF746,
  225.     NSModeSwitchFunctionKey        = 0xF747
  226. };
  227.  
  228.  
  229. #ifndef STRICT_OPENSTEP
  230.  
  231. enum {        /* event subtypes for NSAppKitDefined events */
  232.     NSWindowExposedEventType        = 0,
  233.     NSApplicationActivatedEventType    = 1,
  234.     NSApplicationDeactivatedEventType    = 2,
  235.     NSWindowMovedEventType         = 4,
  236.     NSScreenChangedEventType        = 8
  237. };
  238.  
  239. enum {        /* event subtypes for NSSystemDefined events */
  240.     NSPowerOffEventType            = 1
  241. };
  242.  
  243. #endif
  244.