Home | History | Annotate | Download | only in cocoa
      1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_COCOA_BASE_VIEW_H_
      6 #define CHROME_BROWSER_UI_COCOA_BASE_VIEW_H_
      7 #pragma once
      8 
      9 #import <Cocoa/Cocoa.h>
     10 
     11 #include "base/memory/scoped_nsobject.h"
     12 #include "ui/gfx/rect.h"
     13 
     14 // A view that provides common functionality that many views will need:
     15 // - Automatic registration for mouse-moved events.
     16 // - Funneling of mouse and key events to two methods
     17 // - Coordinate conversion utilities
     18 
     19 @interface BaseView : NSView {
     20  @private
     21   NSTrackingArea *trackingArea_;
     22   BOOL dragging_;
     23   scoped_nsobject<NSEvent> pendingExitEvent_;
     24 }
     25 
     26 - (id)initWithFrame:(NSRect)frame;
     27 
     28 // Override these methods in a subclass.
     29 - (void)mouseEvent:(NSEvent *)theEvent;
     30 - (void)keyEvent:(NSEvent *)theEvent;
     31 
     32 // Useful rect conversions (doing coordinate flipping)
     33 - (gfx::Rect)flipNSRectToRect:(NSRect)rect;
     34 - (NSRect)flipRectToNSRect:(gfx::Rect)rect;
     35 
     36 @end
     37 
     38 // A notification that a view may issue when it receives first responder status.
     39 // The name is |kViewDidBecomeFirstResponder|, the object is the view, and the
     40 // NSSelectionDirection is wrapped in an NSNumber under the key
     41 // |kSelectionDirection|.
     42 extern NSString* kViewDidBecomeFirstResponder;
     43 extern NSString* kSelectionDirection;
     44 
     45 #endif  // CHROME_BROWSER_UI_COCOA_BASE_VIEW_H_
     46