home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks3 / AppKit.framework / Headers / NSEvent.h < prev    next >
Text File  |  1995-08-18  |  7KB  |  214 lines

  1. /*
  2. NSEvent.h
  3. An event generated by the user, such as a mouse movement or key press.
  4. Copyright (c) 1994, NeXT, Inc.  All rights reserved.
  5. */
  6.  
  7. #import <Foundation/NSObject.h>
  8. #import "dpsOpenStep.h"
  9. #import "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 {
  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.             int    userData;
  96.         } tracking;
  97.         struct {
  98.             int subtype;
  99.             int data1;
  100.             int data2;
  101.         } misc;
  102.     } _data;
  103. }
  104.  
  105.  
  106. /* these messages are valid for all events */
  107. - (NSEventType)type;
  108. - (NSPoint)locationInWindow;
  109. - (unsigned int)modifierFlags;
  110. - (NSTimeInterval)timestamp;
  111. - (NSWindow *)window;
  112. - (int)windowNumber;
  113. - (NSDPSContext *)context;
  114.  
  115.     /* these messages are valid for all mouse down/up/drag events */
  116. - (int)clickCount;
  117. - (float)pressure;
  118.     /* these messages are valid for all mouse down/up/drag and enter/exit events */
  119. - (int)eventNumber;
  120.  
  121.     /* these messages are valid for keyup and keydown events */
  122. - (NSString *)characters;
  123. - (NSString *)charactersIgnoringModifiers;
  124.     /* the chars that would have been generated, regardless of modifier keys (except shift) */
  125. - (BOOL)isARepeat;
  126.     /* this message is valid for keyup, keydown and flagschanged events */
  127. - (unsigned short)keyCode;        /* device-dependent key number */
  128.  
  129.     /* these messages are valid for enter and exit events */
  130. - (int)trackingNumber;
  131. - (int)userData;
  132.  
  133.     /* these messages are valid for kit, system, and app-defined events */
  134. - (short)subtype;
  135. - (int)data1;
  136. - (int)data2;
  137.  
  138.     /* used for initial delay and periodic behavior in tracking loops */
  139. + (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delay withPeriod:(NSTimeInterval)period;
  140. + (void)stopPeriodicEvents;
  141.  
  142.     /* apps will rarely create these objects */
  143. + (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;
  144. + (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;
  145. + (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:(int)data;
  146. + (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;
  147.  
  148. @end
  149.  
  150.  
  151. /* 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. */
  152. enum {
  153.     NSUpArrowFunctionKey    = 0xF700,
  154.     NSDownArrowFunctionKey    = 0xF701,
  155.     NSLeftArrowFunctionKey    = 0xF702,
  156.     NSRightArrowFunctionKey    = 0xF703,
  157.     NSF1FunctionKey        = 0xF704,
  158.     NSF2FunctionKey        = 0xF705,
  159.     NSF3FunctionKey        = 0xF706,
  160.     NSF4FunctionKey        = 0xF707,
  161.     NSF5FunctionKey        = 0xF708,
  162.     NSF6FunctionKey        = 0xF709,
  163.     NSF7FunctionKey        = 0xF70A,
  164.     NSF8FunctionKey        = 0xF70B,
  165.     NSF9FunctionKey        = 0xF70C,
  166.     NSF10FunctionKey        = 0xF70D,
  167.     NSF11FunctionKey        = 0xF70E,
  168.     NSF12FunctionKey        = 0xF70F,
  169.     NSInsertFunctionKey        = 0xF710,
  170.     NSDeleteFunctionKey        = 0xF711,
  171.     NSHomeFunctionKey        = 0xF712,
  172.     NSEndFunctionKey        = 0xF713,
  173.     NSPageUpFunctionKey        = 0xF714,
  174.     NSPageDownFunctionKey    = 0xF715,
  175.     NSPrintScreenFunctionKey    = 0xF716,
  176.     NSScrollLockFunctionKey    = 0xF717,
  177.     NSPauseFunctionKey        = 0xF718,
  178.     NSSysReqFunctionKey        = 0xF719,
  179.     NSBreakFunctionKey        = 0xF71A,
  180.     NSResetFunctionKey        = 0xF71B,
  181.     NSStopFunctionKey        = 0xF71C,
  182.     NSMenuFunctionKey        = 0xF71D,
  183.     NSUserFunctionKey        = 0xF71E,
  184.     NSSystemFunctionKey        = 0xF71F,
  185.     NSPrintFunctionKey        = 0xF720,
  186.     NSClearLineFunctionKey    = 0xF721,
  187.     NSClearDisplayFunctionKey    = 0xF722,
  188.     NSInsertLineFunctionKey    = 0xF723,
  189.     NSDeleteLineFunctionKey    = 0xF724,
  190.     NSInsertCharFunctionKey    = 0xF725,
  191.     NSDeleteCharFunctionKey    = 0xF726,
  192.     NSPrevFunctionKey        = 0xF727,
  193.     NSNextFunctionKey        = 0xF728,
  194.     NSSelectFuctionKey        = 0xF729,
  195.     NSLastFunctionKey        = 0xF72A
  196. };
  197.  
  198.  
  199. #ifndef STRICT_OPENSTEP
  200.  
  201. enum {        /* event subtypes for NSAppKitDefined events */
  202.     NSWindowExposedEventType        = 0,
  203.     NSApplicationActivatedEventType    = 1,
  204.     NSApplicationDeactivatedEventType    = 2,
  205.     NSWindowMovedEventType         = 4,
  206.     NSScreenChangedEventType        = 8
  207. };
  208.  
  209. enum {        /* event subtypes for NSSystemDefined events */
  210.     NSPowerOffEventType            = 1
  211. };
  212.  
  213. #endif
  214.