OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
| 6 #define VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/message_loop.h" |
| 10 #include "base/timer.h" |
| 11 #include "views/controls/label.h" |
| 12 #include "views/widget/native_widget.h" |
| 13 #include "views/widget/tooltip_manager.h" |
| 14 #include "views/widget/widget_delegate.h" |
| 15 #include "views/view.h" |
| 16 |
| 17 #if defined(USE_X11) |
| 18 typedef union _XEvent XEvent; |
| 19 #endif |
| 20 |
| 21 namespace views { |
| 22 |
| 23 class MouseEvent; |
| 24 class Widget; |
| 25 |
| 26 // TooltipManager implementation for Views. |
| 27 class TooltipManagerViews : public TooltipManager { |
| 28 public: |
| 29 explicit TooltipManagerViews(views::View* root_view); |
| 30 virtual ~TooltipManagerViews(); |
| 31 |
| 32 // Updates the state of the tooltip based on the mouse event. The mouse event |
| 33 // is the same event that goes to a Widget (i.e. it is in the Widget's |
| 34 // coordinate system). |
| 35 void UpdateForMouseEvent(const MouseEvent& event); |
| 36 |
| 37 // TooltipManager. |
| 38 virtual void UpdateTooltip() OVERRIDE; |
| 39 virtual void TooltipTextChanged(View* view) OVERRIDE; |
| 40 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; |
| 41 virtual void HideKeyboardTooltip() OVERRIDE; |
| 42 |
| 43 private: |
| 44 void TooltipTimerFired(); |
| 45 View* GetViewForTooltip(int x, int y, bool for_keyboard); |
| 46 |
| 47 // Updates the tooltip if required (if there is any change in the tooltip |
| 48 // text or the view. |
| 49 void UpdateIfRequired(int x, int y, bool for_keyboard); |
| 50 |
| 51 // Updates the tooltip. Gets the tooltip text from tooltip_view_ and displays |
| 52 // it at the current mouse position. |
| 53 void Update(); |
| 54 |
| 55 // Adjusts the bounds given by the arguments to fit inside the parent view |
| 56 // and applies the adjusted bounds to the tooltip_label_. |
| 57 void SetTooltipBounds(gfx::Point mouse_pos, int tooltip_width, |
| 58 int tooltip_height); |
| 59 |
| 60 // Creates a widget of type TYPE_TOOLTIP |
| 61 Widget* CreateTooltip(); |
| 62 |
| 63 // Invoked when the mose moves. |
| 64 void OnMouseMoved(int x, int y); |
| 65 |
| 66 scoped_ptr<Widget> tooltip_widget_; |
| 67 views::View* root_view_; |
| 68 View* tooltip_view_; |
| 69 string16 tooltip_text_; |
| 70 Label tooltip_label_; |
| 71 |
| 72 gfx::Point curr_mouse_pos_; |
| 73 base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); |
| 76 }; |
| 77 |
| 78 } // namespace views |
| 79 |
| 80 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
OLD | NEW |