| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #import "ui/base/cocoa/tracking_area.h" | 10 #import "ui/base/cocoa/tracking_area.h" |
| 11 #include "ui/base/window_open_disposition.h" | 11 #include "ui/base/window_open_disposition.h" |
| 12 | 12 |
| 13 @class OmniboxPopupCell; |
| 14 |
| 15 @interface OmniboxPopupTableController |
| 16 : NSViewController<NSTableViewDelegate, NSTableViewDataSource> { |
| 17 @private |
| 18 base::scoped_nsobject<NSArray> array_; |
| 19 NSInteger hovered_index_; |
| 20 }; |
| 21 |
| 22 // Set the hovered highlight. |
| 23 - (void)highlightRowAt:(NSInteger)rowIndex withView:(NSView*)view; |
| 24 |
| 25 // Which row has the hovered highlight. |
| 26 - (NSInteger)highlightedRow; |
| 27 |
| 28 @end |
| 29 |
| 13 @class OmniboxPopupMatrix; | 30 @class OmniboxPopupMatrix; |
| 14 | 31 |
| 15 class OmniboxPopupMatrixObserver { | 32 class OmniboxPopupMatrixObserver { |
| 16 public: | 33 public: |
| 17 // Called when the selection in the matrix changes. | 34 // Called when the selection in the matrix changes. |
| 18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 35 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; |
| 19 | 36 |
| 20 // Called when the user clicks on a row. | 37 // Called when the user clicks on a row. |
| 21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 38 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; |
| 22 | 39 |
| 23 // Called when the user middle clicks on a row. | 40 // Called when the user middle clicks on a row. |
| 24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 41 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
| 25 size_t row) = 0; | 42 size_t row) = 0; |
| 26 }; | 43 }; |
| 27 | 44 |
| 28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 45 // Sets up a tracking area to implement hover by highlighting the cell the mouse |
| 29 // is over. | 46 // is over. |
| 30 @interface OmniboxPopupMatrix : NSMatrix { | 47 @interface OmniboxPopupMatrix : NSTableView { |
| 31 OmniboxPopupMatrixObserver* observer_; // weak | 48 OmniboxPopupMatrixObserver* observer_; // weak |
| 32 ui::ScopedCrTrackingArea trackingArea_; | 49 ui::ScopedCrTrackingArea trackingArea_; |
| 50 base::scoped_nsobject<OmniboxPopupTableController> controller_; |
| 33 } | 51 } |
| 34 | 52 |
| 35 // Create a zero-size matrix. | 53 // Create a zero-size matrix. |
| 36 - (id)initWithObserver:(OmniboxPopupMatrixObserver*)observer; | 54 - (id)initWithObserver:(OmniboxPopupMatrixObserver*)observer; |
| 37 | 55 |
| 38 // Sets the delegate. | 56 // Sets the delegate. |
| 39 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; | 57 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; |
| 40 | 58 |
| 41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 59 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
| 42 - (NSInteger)highlightedRow; | 60 - (NSInteger)highlightedRow; |
| 43 | 61 |
| 62 // Move the selection to |rowIndex|. |
| 63 - (void)selectRowAt:(NSInteger)rowIndex; |
| 64 |
| 65 // Setup the information used by the NSTableView data source. |
| 66 - (void)setDataArray:(NSArray*)array; |
| 67 |
| 44 @end | 68 @end |
| 45 | 69 |
| 46 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 70 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
| OLD | NEW |