| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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_COCOA_LOCATION_BAR_LOCATION_BAR_DECORATION_H_ |
| 6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_LOCATION_BAR_DECORATION_H_ |
| 7 |
| 8 #import <Cocoa/Cocoa.h> |
| 9 |
| 10 #import "base/basictypes.h" |
| 11 |
| 12 // Base class for decorations at the left and right of the location |
| 13 // bar. For instance, the location icon. |
| 14 |
| 15 // |LocationBarDecoration| and subclasses should approximately |
| 16 // parallel the classes provided under views/location_bar/. The term |
| 17 // "decoration" is used because "view" has strong connotations in |
| 18 // Cocoa, and while these are view-like, they aren't views at all. |
| 19 // Decorations are more like Cocoa cells, except implemented in C++ to |
| 20 // allow more similarity to the other platform implementations. |
| 21 |
| 22 class LocationBarDecoration { |
| 23 public: |
| 24 LocationBarDecoration() |
| 25 : visible_(false) { |
| 26 } |
| 27 virtual ~LocationBarDecoration() {} |
| 28 |
| 29 // Determines whether the decoration is visible. |
| 30 virtual bool IsVisible() const { |
| 31 return visible_; |
| 32 } |
| 33 virtual void SetVisible(bool visible) { |
| 34 visible_ = visible; |
| 35 } |
| 36 |
| 37 // Decorations can change their size to fit the available space. |
| 38 // Returns the width the decoration will use in the space allotted, |
| 39 // or |kOmittedWidth| if it should be omitted. |
| 40 virtual CGFloat GetWidthForSpace(CGFloat width); |
| 41 |
| 42 // Draw the decoration in the frame provided. The frame will be |
| 43 // generated from an earlier call to |GetWidthForSpace()|. |
| 44 virtual void DrawInFrame(NSRect frame, NSView* control_view); |
| 45 |
| 46 // Returns the tooltip for this decoration, return |nil| for no tooltip. |
| 47 virtual NSString* GetToolTip() { return nil; } |
| 48 |
| 49 // Determine if the item can act as a drag source. |
| 50 virtual bool IsDraggable() { return false; } |
| 51 |
| 52 // The image to drag. |
| 53 virtual NSImage* GetDragImage() { return nil; } |
| 54 |
| 55 // The pasteboard to drag. |
| 56 virtual NSPasteboard* GetDragPasteboard() { return nil; } |
| 57 |
| 58 // Called on mouse down. Return |false| to indicate that the press |
| 59 // was not processed and should be handled by the cell. |
| 60 virtual bool OnMousePressed(NSRect frame) { return false; } |
| 61 |
| 62 // Called to get the right-click menu, return |nil| for no menu. |
| 63 virtual NSMenu* GetMenu() { return nil; } |
| 64 |
| 65 // Width returned by |GetWidthForSpace()| when the item should be |
| 66 // omitted for this width; |
| 67 static const CGFloat kOmittedWidth; |
| 68 |
| 69 private: |
| 70 bool visible_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(LocationBarDecoration); |
| 73 }; |
| 74 |
| 75 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_LOCATION_BAR_DECORATION_H_ |
| OLD | NEW |