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