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 OmniboxPopupMatrix; |
| 16 class OmniboxPopupViewMac; |
| 17 |
| 18 @interface OmniboxPopupTableController |
| 19 : NSViewController<NSTableViewDelegate, NSTableViewDataSource> { |
| 20 @private |
| 21 base::scoped_nsobject<NSArray> array_; |
| 22 NSInteger hoveredIndex_; |
| 23 }; |
| 24 |
| 25 // Setup the information used by the NSTableView data source. |
| 26 - (instancetype)initWithMatchResults:(const AutocompleteResult&)result |
| 27 tableView:(OmniboxPopupMatrix*)tableView |
| 28 popupView:(const OmniboxPopupViewMac&)popupView |
| 29 answerImage:(NSImage*)answerImage; |
| 30 |
| 31 // Set the hovered highlight. |
| 32 - (void)setHighlightedRow:(NSInteger)rowIndex; |
| 33 |
| 34 // Which row has the hovered highlight. |
| 35 - (NSInteger)highlightedRow; |
| 36 |
| 37 @end |
| 38 |
| 39 @interface OmniboxPopupTableController (TestingAPI) |
| 40 - (instancetype)initWithArray:(NSArray*)array; |
| 41 @end |
| 42 |
13 @class OmniboxPopupMatrix; | 43 @class OmniboxPopupMatrix; |
14 | 44 |
15 class OmniboxPopupMatrixObserver { | 45 class OmniboxPopupMatrixObserver { |
16 public: | 46 public: |
17 // Called when the selection in the matrix changes. | 47 // Called when the selection in the matrix changes. |
18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 48 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; |
19 | 49 |
20 // Called when the user clicks on a row. | 50 // Called when the user clicks on a row. |
21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 51 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; |
22 | 52 |
23 // Called when the user middle clicks on a row. | 53 // Called when the user middle clicks on a row. |
24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 54 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
25 size_t row) = 0; | 55 size_t row) = 0; |
26 }; | 56 }; |
27 | 57 |
28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 58 // Sets up a tracking area to implement hover by highlighting the cell the mouse |
29 // is over. | 59 // is over. |
30 @interface OmniboxPopupMatrix : NSMatrix { | 60 @interface OmniboxPopupMatrix : NSTableView { |
| 61 base::scoped_nsobject<OmniboxPopupTableController> matrixController_; |
31 OmniboxPopupMatrixObserver* observer_; // weak | 62 OmniboxPopupMatrixObserver* observer_; // weak |
32 ui::ScopedCrTrackingArea trackingArea_; | 63 ui::ScopedCrTrackingArea trackingArea_; |
| 64 NSAttributedString* separator_; |
| 65 |
| 66 // The width of widest match contents in a set of infinite suggestions. |
| 67 CGFloat maxMatchContentsWidth_; |
33 } | 68 } |
34 | 69 |
| 70 @property(retain, nonatomic) NSAttributedString* separator; |
| 71 @property(nonatomic) CGFloat maxMatchContentsWidth; |
| 72 |
35 // Create a zero-size matrix. | 73 // Create a zero-size matrix. |
36 - (instancetype)initWithObserver:(OmniboxPopupMatrixObserver*)observer; | 74 - (instancetype)initWithObserver:(OmniboxPopupMatrixObserver*)observer; |
37 | 75 |
38 // Sets the observer. | 76 // Sets the observer. |
39 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; | 77 - (void)setObserver:(OmniboxPopupMatrixObserver*)observer; |
40 | 78 |
41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 79 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
42 - (NSInteger)highlightedRow; | 80 - (NSInteger)highlightedRow; |
43 | 81 |
| 82 // Move the selection to |rowIndex|. |
| 83 - (void)selectRowIndex:(NSInteger)rowIndex; |
| 84 |
| 85 // Setup the NSTableView data source. |
| 86 - (void)setController:(OmniboxPopupTableController*)controller; |
| 87 |
44 @end | 88 @end |
45 | 89 |
46 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 90 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
OLD | NEW |