| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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_VIEWS_INFO_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ |
| 6 #define CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ | 6 #define CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/views/bubble_border.h" | 8 #include "chrome/browser/views/bubble_border.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 class InfoBubbleDelegate { | 67 class InfoBubbleDelegate { |
| 68 public: | 68 public: |
| 69 // Called when the InfoBubble is closing and is about to be deleted. | 69 // Called when the InfoBubble is closing and is about to be deleted. |
| 70 // |closed_by_escape| is true if the close is the result of the user pressing | 70 // |closed_by_escape| is true if the close is the result of the user pressing |
| 71 // escape. | 71 // escape. |
| 72 virtual void InfoBubbleClosing(InfoBubble* info_bubble, | 72 virtual void InfoBubbleClosing(InfoBubble* info_bubble, |
| 73 bool closed_by_escape) = 0; | 73 bool closed_by_escape) = 0; |
| 74 | 74 |
| 75 // Whether the InfoBubble should be closed when the Esc key is pressed. | 75 // Whether the InfoBubble should be closed when the Esc key is pressed. |
| 76 virtual bool CloseOnEscape() = 0; | 76 virtual bool CloseOnEscape() = 0; |
| 77 |
| 78 // Whether the default placement of the anchor is on the origin side of the |
| 79 // text direction. For example: if true (the default) in LTR text direction, |
| 80 // the ArrowLocation will be TOP_LEFT, if false it will be TOP_RIGHT. |
| 81 // RTL is the reverse. |
| 82 virtual bool PreferOriginSideAnchor() { return true; } |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 // TODO: this code is ifdef-tastic. It might be cleaner to refactor the | 85 // TODO: this code is ifdef-tastic. It might be cleaner to refactor the |
| 80 // WidgetFoo subclass into a separate class that calls into InfoBubble. | 86 // WidgetFoo subclass into a separate class that calls into InfoBubble. |
| 81 // That way InfoBubble has no (or very few) ifdefs. | 87 // That way InfoBubble has no (or very few) ifdefs. |
| 82 class InfoBubble | 88 class InfoBubble |
| 83 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
| 84 : public views::WidgetWin, | 90 : public views::WidgetWin, |
| 85 #elif defined(OS_LINUX) | 91 #elif defined(OS_LINUX) |
| 86 : public views::WidgetGtk, | 92 : public views::WidgetGtk, |
| 87 #endif | 93 #endif |
| 88 public views::AcceleratorTarget { | 94 public views::AcceleratorTarget { |
| 89 public: | 95 public: |
| 90 // Shows the InfoBubble. |parent| is set as the parent window, |contents| are | 96 // Shows the InfoBubble. |parent| is set as the parent window, |contents| are |
| 91 // the contents shown in the bubble, and |position_relative_to| is a rect in | 97 // the contents shown in the bubble, and |position_relative_to| is a rect in |
| 92 // screen coordinates at which the InfoBubble will point. Show() takes | 98 // screen coordinates at which the InfoBubble will point. Show() takes |
| 93 // ownership of |contents| and deletes the created InfoBubble when another | 99 // ownership of |contents| and deletes the created InfoBubble when another |
| 94 // window is activated. You can explicitly close the bubble by invoking | 100 // window is activated. You can explicitly close the bubble by invoking |
| 95 // Close(). You may provide an optional |delegate| to be notified when the | 101 // Close(). You may provide an optional |delegate| to: |
| 96 // InfoBubble is closed and/or to prevent the InfoBubble from being closed | 102 // - Be notified when the InfoBubble is closed. |
| 97 // when the Escape key is pressed (the default behavior). | 103 // - Prevent the InfoBubble from being closed when the Escape key is |
| 104 // pressed (the default behavior). |
| 105 // - Have the InfoBubble prefer to anchor its arrow to the non-origin |
| 106 // side of text direction. (see comment above |
| 107 // InfoBubbleDelegate::PreferOriginSideAnchor); . |
| 98 static InfoBubble* Show(views::Window* parent, | 108 static InfoBubble* Show(views::Window* parent, |
| 99 const gfx::Rect& position_relative_to, | 109 const gfx::Rect& position_relative_to, |
| 100 views::View* contents, | 110 views::View* contents, |
| 101 InfoBubbleDelegate* delegate); | 111 InfoBubbleDelegate* delegate); |
| 102 | 112 |
| 103 // Overridden from WidgetWin: | 113 // Overridden from WidgetWin: |
| 104 virtual void Close(); | 114 virtual void Close(); |
| 105 | 115 |
| 106 static const SkColor kBackgroundColor; | 116 static const SkColor kBackgroundColor; |
| 107 | 117 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 scoped_ptr<BorderWidget> border_; | 152 scoped_ptr<BorderWidget> border_; |
| 143 #endif | 153 #endif |
| 144 | 154 |
| 145 // Have we been closed? | 155 // Have we been closed? |
| 146 bool closed_; | 156 bool closed_; |
| 147 | 157 |
| 148 DISALLOW_COPY_AND_ASSIGN(InfoBubble); | 158 DISALLOW_COPY_AND_ASSIGN(InfoBubble); |
| 149 }; | 159 }; |
| 150 | 160 |
| 151 #endif // CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ | 161 #endif // CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ |
| OLD | NEW |