OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
| 10 |
9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
11 #include "ui/gfx/font.h" | 13 #include "ui/gfx/font.h" |
12 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
13 #include "views/view.h" | 15 #include "views/view.h" |
14 | 16 |
15 class AutocompleteResultViewModel; | 17 class AutocompleteResultViewModel; |
16 namespace gfx { | 18 namespace gfx { |
17 class Canvas; | 19 class Canvas; |
18 } | 20 } |
(...skipping 21 matching lines...) Expand all Loading... |
40 const gfx::Font& bold_font); | 42 const gfx::Font& bold_font); |
41 virtual ~AutocompleteResultView(); | 43 virtual ~AutocompleteResultView(); |
42 | 44 |
43 static SkColor GetColor(ResultViewState state, ColorKind kind); | 45 static SkColor GetColor(ResultViewState state, ColorKind kind); |
44 | 46 |
45 // Updates the match used to paint the contents of this result view. We copy | 47 // Updates the match used to paint the contents of this result view. We copy |
46 // the match so that we can continue to paint the last result even after the | 48 // the match so that we can continue to paint the last result even after the |
47 // model has changed. | 49 // model has changed. |
48 void SetMatch(const AutocompleteMatch& match); | 50 void SetMatch(const AutocompleteMatch& match); |
49 | 51 |
| 52 // Returns the size necessary to show just the icon and an ellipsis. |
| 53 gfx::Size GetCollapsedSize(); |
| 54 |
| 55 // views::View: |
| 56 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 57 |
50 protected: | 58 protected: |
51 virtual void PaintMatch(gfx::Canvas* canvas, | 59 virtual void PaintMatch(gfx::Canvas* canvas, |
52 const AutocompleteMatch& match, | 60 const AutocompleteMatch& match, |
53 int x); | 61 int x); |
54 | 62 |
55 // Returns the height of the text portion of the result view. In the base | 63 // Returns the height of the text portion of the result view. In the base |
56 // class, this is the height of one line of text. | 64 // class, this is the height of one line of text. |
57 virtual int GetTextHeight() const; | 65 virtual int GetTextHeight() const; |
58 | 66 |
59 // Draws the specified |text| into the canvas, using highlighting provided by | 67 // Draws the specified |text| into the canvas, using highlighting provided by |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn | 101 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn |
94 // like: | 102 // like: |
95 // LTR_STRING GNIRTS_LTR | 103 // LTR_STRING GNIRTS_LTR |
96 // If we need to elide the RTL run, then it will be drawn like: | 104 // If we need to elide the RTL run, then it will be drawn like: |
97 // LTR_STRING ...RTS_LTR | 105 // LTR_STRING ...RTS_LTR |
98 // Instead of: | 106 // Instead of: |
99 // LTR_STRING RTS_LTR... | 107 // LTR_STRING RTS_LTR... |
100 void Elide(Runs* runs, int remaining_width) const; | 108 void Elide(Runs* runs, int remaining_width) const; |
101 | 109 |
102 // views::View: | 110 // views::View: |
103 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
104 virtual void Layout() OVERRIDE; | 111 virtual void Layout() OVERRIDE; |
105 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 112 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
106 | 113 |
107 static int default_icon_size_; | 114 static int default_icon_size_; |
108 | 115 |
109 // This row's model and model index. | 116 // This row's model and model index. |
110 AutocompleteResultViewModel* model_; | 117 AutocompleteResultViewModel* model_; |
111 size_t model_index_; | 118 size_t model_index_; |
112 | 119 |
113 const gfx::Font normal_font_; | 120 const gfx::Font normal_font_; |
114 const gfx::Font bold_font_; | 121 const gfx::Font bold_font_; |
115 | 122 |
116 // Width of the ellipsis in the normal font. | 123 // Width of the ellipsis in the normal font. |
117 int ellipsis_width_; | 124 int ellipsis_width_; |
118 | 125 |
119 // A context used for mirroring regions. | 126 // A context used for mirroring regions. |
120 class MirroringContext; | 127 class MirroringContext; |
121 scoped_ptr<MirroringContext> mirroring_context_; | 128 scoped_ptr<MirroringContext> mirroring_context_; |
122 | 129 |
123 AutocompleteMatch match_; | 130 AutocompleteMatch match_; |
124 | 131 |
125 gfx::Rect text_bounds_; | 132 gfx::Rect text_bounds_; |
126 gfx::Rect icon_bounds_; | 133 gfx::Rect icon_bounds_; |
127 | 134 |
128 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); | 135 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); |
129 }; | 136 }; |
130 | 137 |
131 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 138 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ |
OLD | NEW |