OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_COCOA_BASE_VIEW_H_ | 5 #ifndef UI_BASE_COCOA_BASE_VIEW_H_ |
6 #define UI_BASE_COCOA_BASE_VIEW_H_ | 6 #define UI_BASE_COCOA_BASE_VIEW_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 | 12 |
13 // A view that provides common functionality that many views will need: | 13 // A view that provides common functionality that many views will need: |
14 // - Automatic registration for mouse-moved events. | 14 // - Automatic registration for mouse-moved events. |
15 // - Funneling of mouse and key events to two methods | 15 // - Funneling of mouse and key events to two methods |
16 // - Coordinate conversion utilities | 16 // - Coordinate conversion utilities |
17 | 17 |
18 @interface BaseView : NSView { | 18 @interface BaseView : NSView { |
19 @private | 19 @private |
20 NSTrackingArea *trackingArea_; | 20 NSTrackingArea *trackingArea_; |
21 BOOL dragging_; | 21 BOOL dragging_; |
22 scoped_nsobject<NSEvent> pendingExitEvent_; | 22 scoped_nsobject<NSEvent> pendingExitEvent_; |
23 } | 23 } |
24 | 24 |
25 - (id)initWithFrame:(NSRect)frame; | |
26 | |
27 // Override these methods in a subclass. | 25 // Override these methods in a subclass. |
28 - (void)mouseEvent:(NSEvent *)theEvent; | 26 - (void)mouseEvent:(NSEvent *)theEvent; |
29 - (void)keyEvent:(NSEvent *)theEvent; | 27 - (void)keyEvent:(NSEvent *)theEvent; |
30 | 28 |
31 // Useful rect conversions (doing coordinate flipping) | 29 // Useful rect conversions (doing coordinate flipping) |
32 - (gfx::Rect)flipNSRectToRect:(NSRect)rect; | 30 - (gfx::Rect)flipNSRectToRect:(NSRect)rect; |
33 - (NSRect)flipRectToNSRect:(gfx::Rect)rect; | 31 - (NSRect)flipRectToNSRect:(gfx::Rect)rect; |
34 | 32 |
35 @end | 33 @end |
36 | 34 |
37 // A notification that a view may issue when it receives first responder status. | 35 // A notification that a view may issue when it receives first responder status. |
38 // The name is |kViewDidBecomeFirstResponder|, the object is the view, and the | 36 // The name is |kViewDidBecomeFirstResponder|, the object is the view, and the |
39 // NSSelectionDirection is wrapped in an NSNumber under the key | 37 // NSSelectionDirection is wrapped in an NSNumber under the key |
40 // |kSelectionDirection|. | 38 // |kSelectionDirection|. |
41 UI_EXPORT extern NSString* kViewDidBecomeFirstResponder; | 39 UI_EXPORT extern NSString* kViewDidBecomeFirstResponder; |
42 UI_EXPORT extern NSString* kSelectionDirection; | 40 UI_EXPORT extern NSString* kSelectionDirection; |
43 | 41 |
44 #endif // UI_BASE_COCOA_BASE_VIEW_H_ | 42 #endif // UI_BASE_COCOA_BASE_VIEW_H_ |
OLD | NEW |