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