Home | History | Annotate | Download | only in widget
      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 UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
      6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/strings/string16.h"
     12 #include "ui/gfx/native_widget_types.h"
     13 #include "ui/views/views_export.h"
     14 
     15 namespace gfx {
     16 class Display;
     17 class FontList;
     18 }  // namespace gfx
     19 
     20 namespace views {
     21 
     22 class View;
     23 
     24 // TooltipManager takes care of the wiring to support tooltips for Views. You
     25 // almost never need to interact directly with TooltipManager, rather look to
     26 // the various tooltip methods on View.
     27 class VIEWS_EXPORT TooltipManager {
     28  public:
     29   // When a NativeView has capture all events are delivered to it. In some
     30   // situations, such as menus, we want the tooltip to be shown for the
     31   // NativeView the mouse is over, even if it differs from the NativeView that
     32   // has capture (with menus the first menu shown has capture). To enable this
     33   // if the NativeView that has capture has the same value for the property
     34   // |kGroupingPropertyKey| as the NativeView the mouse is over the tooltip is
     35   // shown.
     36   static const char kGroupingPropertyKey[];
     37 
     38   TooltipManager() {}
     39   virtual ~TooltipManager() {}
     40 
     41   // Returns the height of tooltips. This should only be invoked from within
     42   // GetTooltipTextOrigin.
     43   static int GetTooltipHeight();
     44 
     45   // Returns the maximum width of the tooltip. |x| and |y| give the location
     46   // the tooltip is to be displayed on in screen coordinates. |context| is
     47   // used to determine which gfx::Screen should be used.
     48   static int GetMaxWidth(int x, int y, gfx::NativeView context);
     49 
     50   // Same as GetMaxWidth(), but takes a Display.
     51   static int GetMaxWidth(const gfx::Display& display);
     52 
     53   // If necessary trims the text of a tooltip to ensure we don't try to display
     54   // a mega-tooltip.
     55   static void TrimTooltipText(base::string16* text);
     56 
     57   // Returns the font list used for tooltips.
     58   virtual const gfx::FontList& GetFontList() const = 0;
     59 
     60   // Notification that the view hierarchy has changed in some way.
     61   virtual void UpdateTooltip() = 0;
     62 
     63   // Invoked when the tooltip text changes for the specified views.
     64   virtual void TooltipTextChanged(View* view) = 0;
     65 };
     66 
     67 }  // namespace views
     68 
     69 #endif  // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
     70