Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ebf042f1e7
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 107 lines (88 sloc) 4.03 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
//
// MATrackingArea.h
// MATrackingArea
//
// Created by Matt Gemmell on 25/09/2007.
//

#import <Cocoa/Cocoa.h>

/*
Type of tracking area. You must specify one or more types from this list in the
MATrackingAreaOptions argument of -initWithRect:options:owner:userInfo:
*/
enum {
    // Owner receives mouseEntered when mouse enters area, and mouseExited when mouse leaves area.
    MATrackingMouseEnteredAndExited = 0x01,

    // Owner receives mouseMoved while mouse is within area. Note that mouseMoved events do not
    // contain userInfo.
    MATrackingMouseMoved = 0x02,
};

/*
When the tracking area is active. You must specify exactly one of the following in the
MATrackingAreaOptions argument of -initWithRect:options:owner:userInfo:
*/
enum {
    // Owner receives mouseEntered/Exited or mouseMoved when view is first responder.
    MATrackingActiveWhenFirstResponder = 0x10,

    // Owner receives mouseEntered/Exited or mouseMoved when view is in key window.
    MATrackingActiveInKeyWindow = 0x20,

    // Owner receives mouseEntered/Exited or mouseMoved when app is active.
    MATrackingActiveInActiveApp = 0x40,

    // Owner receives mouseEntered/Exited or mouseMoved regardless of activation.
    MATrackingActiveAlways = 0x80,
};

/*
Behavior of tracking area. You may specify any number of the following in the
MATrackingAreaOptions argument of -initWithRect:options:owner:userInfo:
*/
enum {
    // If set, generate mouseExited event when mouse leaves area (same as assumeInside argument
    // in NSView's addtrackingArea:owner:userData:assumeInside: method).
    MATrackingAssumeInside = 0x100,

    // If set, tracking occurs in visibleRect of view and rect is ignored.
    MATrackingInVisibleRect = 0x200,

    // If set, mouseEntered events will be generated as mouse is dragged. If not set, mouseEntered
    // events will be generated as mouse is moved, and on mouseUp after a drag. mouseExited
    // events are paired with mouseEntered events so their delivery is affected indirectly.
    // That is, if a mouseEntered event is generated and the mouse subsequently moves out of the
    // trackingArea, a mouseExited event will be generated whether the mouse is being moved or
    // dragged, independent of this flag.
    MATrackingEnabledDuringMouseDrag = 0x400
};

typedef unsigned int MATrackingAreaOptions;

@interface MATrackingArea : NSObject <NSCopying, NSCoding>
{
    @private
    NSRect _rect;
    MATrackingAreaOptions _options;
    /*
Work-around: __weak breaks under ClickToFlash's specific environment:
* 10.5-or-later Base SDK (GC-aware)
* -fobjc-gc (GC supported but not required)
* 10.4 deployment target (MACOSX_DEPLOYMENT_TARGET=10.4)
The problem is 10.5 SDK + -fobjc-gc settings means function calls
such as _objc_assign_weak are emitted, but don't actually exist on
10.4. We die with an "Symbol not found" dyld error.

We work-around this by commenting-out __weak. In the general case
this is a too-broad work-around, but is fine for ClickToFlash's
specific case: we only use MATrackingArea when NSTrackingArea isn't
available. That means we only use MATrackingArea on 10.4, and 10.4
doesn't support GC anyways.
*/
    /*__weak*/ id _owner;
    NSDictionary * _userInfo;
    NSPoint _lastMovedPoint;
    BOOL _inside;
}

+ (void)addTrackingArea:(MATrackingArea *)trackingArea toView:(NSView *)view;
+ (void)removeTrackingArea:(MATrackingArea *)trackingArea fromView:(NSView *)view;
+ (NSArray *)trackingAreasForView:(NSView *)view;

- (MATrackingArea *)initWithRect:(NSRect)rect
                         options:(MATrackingAreaOptions)options
                           owner:(id)owner
                        userInfo:(NSDictionary *)userInfo;
- (NSRect)rect;
- (void)setRect:(NSRect)newRect;
- (MATrackingAreaOptions)options;
- (id)owner;
- (NSDictionary *)userInfo;

@end
Something went wrong with that request. Please try again.