OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
| 6 #define UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" |
| 11 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 12 |
| 13 namespace views { |
| 14 |
| 15 class InfoBubbleFrame; |
| 16 |
| 17 // Class to create and manage an information bubble for errors or tooltips. |
| 18 class InfoBubble : public BubbleDialogDelegateView { |
| 19 public: |
| 20 InfoBubble(View* anchor, const base::string16& message); |
| 21 ~InfoBubble() override; |
| 22 |
| 23 // Shows the bubble. |widget_| will be NULL until this is called. |
| 24 void Show(); |
| 25 |
| 26 // Hides and closes the bubble. |
| 27 void Hide(); |
| 28 |
| 29 // BubbleDialogDelegateView: |
| 30 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
| 31 gfx::Size GetPreferredSize() const override; |
| 32 void OnWidgetDestroyed(Widget* widget) override; |
| 33 void OnWidgetBoundsChanged(Widget* widget, |
| 34 const gfx::Rect& new_bounds) override; |
| 35 int GetDialogButtons() const override; |
| 36 |
| 37 View* anchor() { return anchor_; } |
| 38 const View* anchor() const { return anchor_; } |
| 39 |
| 40 void set_preferred_width(int preferred_width) { |
| 41 preferred_width_ = preferred_width; |
| 42 } |
| 43 |
| 44 private: |
| 45 // Updates the position of the bubble. |
| 46 void UpdatePosition(); |
| 47 |
| 48 Widget* widget_; // Weak, may be NULL. |
| 49 View* const anchor_; // Weak. |
| 50 InfoBubbleFrame* frame_; // Weak, owned by widget. |
| 51 |
| 52 // The width this bubble prefers to be. Default is 0 (no preference). |
| 53 int preferred_width_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(InfoBubble); |
| 56 }; |
| 57 |
| 58 } // namespace views |
| 59 |
| 60 #endif // UI_VIEWS_BUBBLE_INFO_BUBBLE_H_ |
OLD | NEW |