summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/autocomplete_text_field.h
blob: 2d9e76295d7b9328af84d2682fa194d5b219dd53 (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
// Copyright (c) 2009 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_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
#define CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_

#import <Cocoa/Cocoa.h>

@class AutocompleteTextFieldCell;

// AutocompleteTextField intercepts UI actions for forwarding to
// AutocompleteEditViewMac (*), and provides a custom look.  It works
// together with AutocompleteTextFieldEditor (mostly for intercepting
// user actions) and AutocompleteTextFieldCell (mostly for custom
// drawing).
//
// For historical reasons, chrome/browser/autocomplete is the core
// implementation of the Omnibox.  Chrome code seems to vary between
// autocomplete and Omnibox in describing this.
//
// (*) AutocompleteEditViewMac is a view in the MVC sense for the
// Chrome internals, though it's really more of a mish-mash of model,
// view, and controller.

// AutocompleteTextFieldDelegateMethods are meant to be similar to
// NSControl delegate methods, adding additional intercepts relevant
// to the Omnibox implementation.

@protocol AutocompleteTextFieldDelegateMethods

// Delegate -textShouldPaste: implementation to the field being
// edited.  See AutocompleteTextFieldEditor implementation.
- (BOOL)control:(NSControl*)control textShouldPaste:(NSText*)fieldEditor;

// Let the delegate track -flagsChanged: events.
- (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent;

@end

@interface AutocompleteTextField : NSTextField {
}

- (BOOL)textShouldPaste:(NSText*)fieldEditor;

// Convenience method to return the cell, casted appropriately.
- (AutocompleteTextFieldCell*)autocompleteTextFieldCell;

// If the keyword, keyword hint, or search hint changed, then the
// field needs to be relaidout.  This accomplishes that in a manner
// which doesn't disrupt the field delegate.
- (void)resetFieldEditorFrameIfNeeded;

@end

#endif  // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_