You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.3KB

  1. //
  2. // "$Id: Fl_Tooltip.H 8405 2011-02-08 20:59:46Z manolo $"
  3. //
  4. // Tooltip header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2011 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /* \file
  28. Fl_Tooltip widget . */
  29. #ifndef Fl_Tooltip_H
  30. #define Fl_Tooltip_H
  31. #include <FL/Fl.H>
  32. #include <FL/Fl_Widget.H>
  33. /**
  34. The Fl_Tooltip class provides tooltip support for
  35. all FLTK widgets. It contains only static methods.
  36. */
  37. class FL_EXPORT Fl_Tooltip {
  38. public:
  39. /** Gets the tooltip delay. The default delay is 1.0 seconds. */
  40. static float delay() { return delay_; }
  41. /** Sets the tooltip delay. The default delay is 1.0 seconds. */
  42. static void delay(float f) { delay_ = f; }
  43. /**
  44. Gets the tooltip hover delay, the delay between tooltips.
  45. The default delay is 0.2 seconds.
  46. */
  47. static float hoverdelay() { return hoverdelay_; }
  48. /**
  49. Sets the tooltip hover delay, the delay between tooltips.
  50. The default delay is 0.2 seconds.
  51. */
  52. static void hoverdelay(float f) { hoverdelay_ = f; }
  53. /** Returns non-zero if tooltips are enabled. */
  54. static int enabled() { return Fl::option(Fl::OPTION_SHOW_TOOLTIPS); }
  55. /** Enables tooltips on all widgets (or disables if <i>b</i> is false). */
  56. static void enable(int b = 1) { Fl::option(Fl::OPTION_SHOW_TOOLTIPS, (b!=0));}
  57. /** Same as enable(0), disables tooltips on all widgets. */
  58. static void disable() { enable(0); }
  59. static void (*enter)(Fl_Widget* w);
  60. static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip);
  61. static void (*exit)(Fl_Widget *w);
  62. /** Gets the current widget target */
  63. static Fl_Widget* current() {return widget_;}
  64. static void current(Fl_Widget*);
  65. /** Gets the typeface for the tooltip text. */
  66. static Fl_Font font() { return font_; }
  67. /** Sets the typeface for the tooltip text. */
  68. static void font(Fl_Font i) { font_ = i; }
  69. /** Gets the size of the tooltip text. */
  70. static Fl_Fontsize size() { return (size_ == -1 ? FL_NORMAL_SIZE : size_); }
  71. /** Sets the size of the tooltip text. */
  72. static void size(Fl_Fontsize s) { size_ = s; }
  73. /** Gets the background color for tooltips. The default background color is a pale yellow. */
  74. static Fl_Color color() { return color_; }
  75. /** Sets the background color for tooltips. The default background color is a pale yellow. */
  76. static void color(Fl_Color c) { color_ = c; }
  77. /** Gets the color of the text in the tooltip. The default is black. */
  78. static Fl_Color textcolor() { return textcolor_; }
  79. /** Sets the color of the text in the tooltip. The default is black. */
  80. static void textcolor(Fl_Color c) { textcolor_ = c; }
  81. #ifdef __APPLE__
  82. // the unique tooltip window
  83. static Fl_Window* current_window(void);
  84. #endif
  85. // These should not be public, but Fl_Widget::tooltip() needs them...
  86. // fabien: made it private with only a friend function access
  87. private:
  88. friend void Fl_Widget::tooltip(const char *);
  89. friend void Fl_Widget::copy_tooltip(const char *);
  90. static void enter_(Fl_Widget* w);
  91. static void exit_(Fl_Widget *w);
  92. static void set_enter_exit_once_();
  93. private:
  94. static float delay_; //!< delay before a tooltip is shown
  95. static float hoverdelay_; //!< delay between tooltips
  96. static Fl_Color color_;
  97. static Fl_Color textcolor_;
  98. static Fl_Font font_;
  99. static Fl_Fontsize size_;
  100. static Fl_Widget* widget_; //!< Keeps track of the current target widget
  101. };
  102. extern void (*fl_show_tooltip)( const char *s );
  103. extern void (*fl_hide_tooltip)( void );
  104. #endif
  105. //
  106. // End of "$Id: Fl_Tooltip.H 8405 2011-02-08 20:59:46Z manolo $".
  107. //