blob: 7f306ca8cf6cb919dccd200cc6327b279f2f370e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
#define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsobject.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
class OmniboxPopupViewMac;
// OmniboxPopupCell overrides how backgrounds are displayed to
// handle hover versus selected. So long as we're in there, it also
// provides some default initialization.
@interface OmniboxPopupCell : NSButtonCell {
@private
// The popup view parent of this cell.
OmniboxPopupViewMac* parent_;
// The match which will be rendered for this row in omnibox dropdown.
AutocompleteMatch match_;
// NSAttributedString instances for various match components.
base::scoped_nsobject<NSAttributedString> separator_;
base::scoped_nsobject<NSAttributedString> description_;
// NOTE: While |prefix_| is used only for postfix suggestions, it still needs
// to be a member of the class. This allows the |NSAttributedString| instance
// to stay alive between the call to |drawTitle| and the actual paint event
// which accesses the |NSAttributedString| instance.
base::scoped_nsobject<NSAttributedString> prefix_;
// The width of widest match contents in a set of infinite suggestions.
CGFloat maxMatchContentsWidth_;
// The offset at which the infinite suggesiton contents should be displayed.
CGFloat contentsOffset_;
}
- (void)setMatch:(const AutocompleteMatch&)match;
- (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth;
- (void)setContentsOffset:(CGFloat)contentsOffset;
// Returns the width of the match contents.
- (CGFloat)getMatchContentsWidth;
// Returns the offset of the start of the contents in the input text for the
// given match. It is costly to compute this offset, so it is computed once and
// shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent.
+ (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match;
@end
#endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
|