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 AutocompleteResult; |
| 14 @class OmniboxPopupCell; |
| 15 class OmniboxPopupViewMac; |
| 16 |
| 17 @interface OmniboxPopupTableController |
| 18 : NSViewController<NSTableViewDelegate, NSTableViewDataSource> { |
| 19 @private |
| 20 base::scoped_nsobject<NSArray> array_; |
| 21 NSInteger hoveredIndex_; |
| 22 }; |
| 23 |
| 24 // Setup the information used by the NSTableView data source. |
| 25 - (id)initWithMatchResults:(const AutocompleteResult&)result |
| 26 popupView:(const OmniboxPopupViewMac&)popupView; |
| 27 |
| 28 // Set the hovered highlight. |
| 29 - (void)highlightRowAt:(NSInteger)rowIndex; |
| 30 |
| 31 // Which row has the hovered highlight. |
| 32 - (NSInteger)highlightedRow; |
| 33 |
| 34 @end |
| 35 |
13 @class OmniboxPopupMatrix; | 36 @class OmniboxPopupMatrix; |
14 | 37 |
15 class OmniboxPopupMatrixObserver { | 38 class OmniboxPopupMatrixObserver { |
16 public: | 39 public: |
17 // Called when the selection in the matrix changes. | 40 // Called when the selection in the matrix changes. |
18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 41 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; |
19 | 42 |
20 // Called when the user clicks on a row. | 43 // Called when the user clicks on a row. |
21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 44 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; |
22 | 45 |
23 // Called when the user middle clicks on a row. | 46 // Called when the user middle clicks on a row. |
24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 47 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
25 size_t row) = 0; | 48 size_t row) = 0; |
26 }; | 49 }; |
27 | 50 |
28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 51 // Sets up a tracking area to implement hover by highlighting the cell the mouse |
29 // is over. | 52 // is over. |
30 @interface OmniboxPopupMatrix : NSMatrix { | 53 @interface OmniboxPopupMatrix : NSTableView { |
31 OmniboxPopupMatrixObserver* observer_; // weak | 54 OmniboxPopupMatrixObserver* observer_; // weak |
32 ui::ScopedCrTrackingArea trackingArea_; | 55 ui::ScopedCrTrackingArea trackingArea_; |
33 } | 56 } |
34 | 57 |
35 // Create a zero-size matrix. | 58 // Create a zero-size matrix. |
36 - (id)initWithObserver:(OmniboxPopupMatrixObserver*)observer; | 59 - (id)initWithObserver:(OmniboxPopupMatrixObserver*)observer; |
37 | 60 |
38 // Sets the delegate. | 61 // Sets the delegate. |
39 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; | 62 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; |
40 | 63 |
41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 64 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
42 - (NSInteger)highlightedRow; | 65 - (NSInteger)highlightedRow; |
43 | 66 |
| 67 // Move the selection to |rowIndex|. |
| 68 - (void)selectRowIndex:(NSInteger)rowIndex; |
| 69 |
| 70 // Setup the NSTableView data source. |
| 71 - (void)setController:(OmniboxPopupTableController*)controller; |
| 72 |
44 @end | 73 @end |
45 | 74 |
46 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 75 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
OLD | NEW |