Fl_Tooltip.H 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // "$Id: Fl_Tooltip.H 9706 2012-11-06 20:46:14Z matt $"
  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. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Fl_Tooltip widget . */
  20. #ifndef Fl_Tooltip_H
  21. #define Fl_Tooltip_H
  22. #include <FL/Fl.H>
  23. #include <FL/Fl_Widget.H>
  24. /**
  25. The Fl_Tooltip class provides tooltip support for
  26. all FLTK widgets. It contains only static methods.
  27. \image html tooltip-options.png "Fl_Tooltip Options"
  28. \image latex src/tooltip-options.png "Fl_Tooltip Options" width=6cm
  29. */
  30. class FL_EXPORT Fl_Tooltip {
  31. public:
  32. /** Gets the tooltip delay. The default delay is 1.0 seconds. */
  33. static float delay() { return delay_; }
  34. /** Sets the tooltip delay. The default delay is 1.0 seconds. */
  35. static void delay(float f) { delay_ = f; }
  36. /**
  37. Gets the tooltip hover delay, the delay between tooltips.
  38. The default delay is 0.2 seconds.
  39. */
  40. static float hoverdelay() { return hoverdelay_; }
  41. /**
  42. Sets the tooltip hover delay, the delay between tooltips.
  43. The default delay is 0.2 seconds.
  44. */
  45. static void hoverdelay(float f) { hoverdelay_ = f; }
  46. /** Returns non-zero if tooltips are enabled. */
  47. static int enabled() { return Fl::option(Fl::OPTION_SHOW_TOOLTIPS); }
  48. /** Enables tooltips on all widgets (or disables if <i>b</i> is false). */
  49. static void enable(int b = 1) { Fl::option(Fl::OPTION_SHOW_TOOLTIPS, (b!=0));}
  50. /** Same as enable(0), disables tooltips on all widgets. */
  51. static void disable() { enable(0); }
  52. static void (*enter)(Fl_Widget* w);
  53. static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip);
  54. static void (*exit)(Fl_Widget *w);
  55. /** Gets the current widget target */
  56. static Fl_Widget* current() {return widget_;}
  57. static void current(Fl_Widget*);
  58. /** Gets the typeface for the tooltip text. */
  59. static Fl_Font font() { return font_; }
  60. /** Sets the typeface for the tooltip text. */
  61. static void font(Fl_Font i) { font_ = i; }
  62. /** Gets the size of the tooltip text. */
  63. static Fl_Fontsize size() { return (size_ == -1 ? FL_NORMAL_SIZE : size_); }
  64. /** Sets the size of the tooltip text. */
  65. static void size(Fl_Fontsize s) { size_ = s; }
  66. /** Gets the background color for tooltips. The default background color is a pale yellow. */
  67. static Fl_Color color() { return color_; }
  68. /** Sets the background color for tooltips. The default background color is a pale yellow. */
  69. static void color(Fl_Color c) { color_ = c; }
  70. /** Gets the color of the text in the tooltip. The default is black. */
  71. static Fl_Color textcolor() { return textcolor_; }
  72. /** Sets the color of the text in the tooltip. The default is black. */
  73. static void textcolor(Fl_Color c) { textcolor_ = c; }
  74. #if FLTK_ABI_VERSION >= 10301
  75. /** Gets the amount of extra space left/right of the tooltip's text. Default is 3. */
  76. static int margin_width() { return margin_width_; }
  77. /** Sets the amount of extra space left/right of the tooltip's text. Default is 3. */
  78. static void margin_width(int v) { margin_width_ = v; }
  79. /** Gets the amount of extra space above and below the tooltip's text. Default is 3. */
  80. static int margin_height() { return margin_height_; }
  81. /** Sets the amount of extra space above and below the tooltip's text. Default is 3. */
  82. static void margin_height(int v) { margin_height_ = v; }
  83. /** Gets the maximum width for tooltip's text before it word wraps. Default is 400. */
  84. static int wrap_width() { return wrap_width_; }
  85. /** Sets the maximum width for tooltip's text before it word wraps. Default is 400. */
  86. static void wrap_width(int v) { wrap_width_ = v; }
  87. #else
  88. static int margin_width() { return 3; }
  89. static int margin_height() { return 3; }
  90. static int wrap_width() { return 400; }
  91. #endif
  92. #ifdef __APPLE__
  93. // the unique tooltip window
  94. static Fl_Window* current_window(void);
  95. #endif
  96. // These should not be public, but Fl_Widget::tooltip() needs them...
  97. // fabien: made it private with only a friend function access
  98. private:
  99. friend void Fl_Widget::tooltip(const char *);
  100. friend void Fl_Widget::copy_tooltip(const char *);
  101. static void enter_(Fl_Widget* w);
  102. static void exit_(Fl_Widget *w);
  103. static void set_enter_exit_once_();
  104. private:
  105. static float delay_; //!< delay before a tooltip is shown
  106. static float hoverdelay_; //!< delay between tooltips
  107. static Fl_Color color_;
  108. static Fl_Color textcolor_;
  109. static Fl_Font font_;
  110. static Fl_Fontsize size_;
  111. static Fl_Widget* widget_; //!< Keeps track of the current target widget
  112. #if FLTK_ABI_VERSION >= 10301
  113. static int margin_width_; //!< distance around tooltip text left+right
  114. static int margin_height_; //!< distance around tooltip text top+bottom
  115. static int wrap_width_; //!< maximum width of tooltip text before it word wraps
  116. #endif
  117. };
  118. #endif
  119. //
  120. // End of "$Id: Fl_Tooltip.H 9706 2012-11-06 20:46:14Z matt $".
  121. //