1// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_COCOA_STYLED_TEXT_FIELD_CELL_H_
6#define CHROME_BROWSER_UI_COCOA_STYLED_TEXT_FIELD_CELL_H_
7#pragma once
8
9#import <Cocoa/Cocoa.h>
10
11typedef enum {
12  StyledTextFieldCellRoundedAll = 0,
13  StyledTextFieldCellRoundedLeft = 1
14} StyledTextFieldCellRoundedFlags;
15
16// StyledTextFieldCell customizes the look of the standard Cocoa text field.
17// The border and focus ring are modified, as is the font baseline.  Subclasses
18// can override |drawInteriorWithFrame:inView:| to provide custom drawing for
19// decorations, but they must make sure to call the superclass' implementation
20// with a modified frame after performing any custom drawing.
21
22@interface StyledTextFieldCell : NSTextFieldCell {
23}
24
25@end
26
27// Methods intended to be overridden by subclasses, not part of the public API
28// and should not be called outside of subclasses.
29@interface StyledTextFieldCell (ProtectedMethods)
30
31// Return the portion of the cell to show the text cursor over.  The default
32// implementation returns the full |cellFrame|.  Subclasses should override this
33// method if they add any decorations.
34- (NSRect)textCursorFrameForFrame:(NSRect)cellFrame;
35
36// Return the portion of the cell to use for text display.  This corresponds to
37// the frame with our added decorations sliced off.  The default implementation
38// returns the full |cellFrame|, as by default there are no decorations.
39// Subclasses should override this method if they add any decorations.
40- (NSRect)textFrameForFrame:(NSRect)cellFrame;
41
42// Baseline adjust for the text in this cell.  Defaults to 0.  Subclasses should
43// override as needed.
44- (CGFloat)baselineAdjust;
45
46// Radius of the corners of the field.  Defaults to square corners (0.0).
47- (CGFloat)cornerRadius;
48
49// Which corners of the field to round.  Defaults to RoundedAll.
50- (StyledTextFieldCellRoundedFlags)roundedFlags;
51
52// Returns YES if a light themed bezel should be drawn under the text field.
53// Default implementation returns NO.
54- (BOOL)shouldDrawBezel;
55
56@end
57
58#endif  // CHROME_BROWSER_UI_COCOA_STYLED_TEXT_FIELD_CELL_H_
59