OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Overridden from OmniboxPopupMatrixDelegate: | 43 // Overridden from OmniboxPopupMatrixDelegate: |
44 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, | 44 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, |
45 size_t row) OVERRIDE; | 45 size_t row) OVERRIDE; |
46 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, | 46 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, |
47 size_t row) OVERRIDE; | 47 size_t row) OVERRIDE; |
48 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 48 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
49 size_t row) OVERRIDE; | 49 size_t row) OVERRIDE; |
50 | 50 |
51 OmniboxPopupMatrix* matrix() { return matrix_; } | 51 OmniboxPopupMatrix* matrix() { return matrix_; } |
52 | 52 |
53 // Return the text to show for the match, based on the match's | |
54 // contents and description. Result will be in |font|, with the | |
55 // boldfaced version used for matches. | |
56 static NSAttributedString* MatchText(const AutocompleteMatch& match, | |
57 gfx::Font& font, | |
58 float cell_width); | |
59 | |
60 // Applies the given font and colors to the match string based on | 53 // Applies the given font and colors to the match string based on |
61 // classifications. | 54 // classifications. |
62 static NSMutableAttributedString* DecorateMatchedString( | 55 static NSMutableAttributedString* DecorateMatchedString( |
63 const string16& match_string, | 56 const string16& match_string, |
64 const AutocompleteMatch::ACMatchClassifications& classifications, | 57 const AutocompleteMatch::ACMatchClassifications& classifications, |
65 NSColor* text_color, | 58 NSColor* text_color, |
66 NSColor* dim_text_color, | 59 NSColor* dim_text_color, |
67 gfx::Font& font); | 60 gfx::Font& font); |
68 | 61 |
69 // Helper for MatchText() to elide a marked-up string using | |
70 // gfx::ElideText() as a model. Modifies |a_string| in place. | |
71 // TODO(shess): Consider breaking AutocompleteButtonCell out of this | |
72 // code, and modifying it to have something like -setMatch:, so that | |
73 // these convolutions to expose internals for testing can be | |
74 // cleaner. | |
75 static NSMutableAttributedString* ElideString( | |
76 NSMutableAttributedString* a_string, | |
77 const string16& original_string, | |
78 const gfx::Font& font, | |
79 const float cell_width); | |
80 | |
81 protected: | 62 protected: |
82 // Gets the autocomplete results. This is virtual so that it can be overriden | 63 // Gets the autocomplete results. This is virtual so that it can be overriden |
83 // by tests. | 64 // by tests. |
84 virtual const AutocompleteResult& GetResult() const; | 65 virtual const AutocompleteResult& GetResult() const; |
85 | 66 |
86 private: | 67 private: |
87 // Create the popup_ instance if needed. | 68 // Create the popup_ instance if needed. |
88 void CreatePopupIfNeeded(); | 69 void CreatePopupIfNeeded(); |
89 | 70 |
90 // Calculate the appropriate position for the popup based on the | 71 // Calculate the appropriate position for the popup based on the |
(...skipping 20 matching lines...) Expand all Loading... |
111 | 92 |
112 base::scoped_nsobject<OmniboxPopupMatrix> matrix_; | 93 base::scoped_nsobject<OmniboxPopupMatrix> matrix_; |
113 base::scoped_nsobject<NSView> top_separator_view_; | 94 base::scoped_nsobject<NSView> top_separator_view_; |
114 base::scoped_nsobject<NSView> bottom_separator_view_; | 95 base::scoped_nsobject<NSView> bottom_separator_view_; |
115 base::scoped_nsobject<NSBox> background_view_; | 96 base::scoped_nsobject<NSBox> background_view_; |
116 | 97 |
117 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMac); | 98 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMac); |
118 }; | 99 }; |
119 | 100 |
120 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ | 101 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ |
OLD | NEW |