base_view.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 3// found in the LICENSE file. 4 5#ifndef UI_BASE_COCOA_BASE_VIEW_H_ 6#define UI_BASE_COCOA_BASE_VIEW_H_ 7 8#import <Cocoa/Cocoa.h> 9 10#include "base/memory/scoped_nsobject.h" 11#include "ui/gfx/rect.h" 12 13// A view that provides common functionality that many views will need: 14// - Automatic registration for mouse-moved events. 15// - Funneling of mouse and key events to two methods 16// - Coordinate conversion utilities 17 18@interface BaseView : NSView { 19 @private 20 NSTrackingArea *trackingArea_; 21 BOOL dragging_; 22 scoped_nsobject<NSEvent> pendingExitEvent_; 23} 24 25- (id)initWithFrame:(NSRect)frame; 26 27// Override these methods in a subclass. 28- (void)mouseEvent:(NSEvent *)theEvent; 29- (void)keyEvent:(NSEvent *)theEvent; 30 31// Useful rect conversions (doing coordinate flipping) 32- (gfx::Rect)flipNSRectToRect:(NSRect)rect; 33- (NSRect)flipRectToNSRect:(gfx::Rect)rect; 34 35@end 36 37// 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 39// NSSelectionDirection is wrapped in an NSNumber under the key 40// |kSelectionDirection|. 41UI_EXPORT extern NSString* kViewDidBecomeFirstResponder; 42UI_EXPORT extern NSString* kSelectionDirection; 43 44#endif // UI_BASE_COCOA_BASE_VIEW_H_ 45