Fl_Tooltip.H 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // "$Id: Fl_Tooltip.H 11163 2016-02-13 12:57:00Z 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. /** Gets the amount of extra space left/right of the tooltip's text. Default is 3. */
  75. static int margin_width() { return margin_width_; }
  76. /** Sets the amount of extra space left/right of the tooltip's text. Default is 3. */
  77. static void margin_width(int v) { margin_width_ = v; }
  78. /** Gets the amount of extra space above and below the tooltip's text. Default is 3. */
  79. static int margin_height() { return margin_height_; }
  80. /** Sets the amount of extra space above and below the tooltip's text. Default is 3. */
  81. static void margin_height(int v) { margin_height_ = v; }
  82. /** Gets the maximum width for tooltip's text before it word wraps. Default is 400. */
  83. static int wrap_width() { return wrap_width_; }
  84. /** Sets the maximum width for tooltip's text before it word wraps. Default is 400. */
  85. static void wrap_width(int v) { wrap_width_ = v; }
  86. /** Returns the window that is used for tooltips */
  87. static Fl_Window* current_window(void);
  88. // These should not be public, but Fl_Widget::tooltip() needs them...
  89. // fabien: made it private with only a friend function access
  90. private:
  91. friend void Fl_Widget::tooltip(const char *);
  92. friend void Fl_Widget::copy_tooltip(const char *);
  93. static void enter_(Fl_Widget* w);
  94. static void exit_(Fl_Widget *w);
  95. static void set_enter_exit_once_();
  96. private:
  97. static float delay_; //!< delay before a tooltip is shown
  98. static float hoverdelay_; //!< delay between tooltips
  99. static Fl_Color color_;
  100. static Fl_Color textcolor_;
  101. static Fl_Font font_;
  102. static Fl_Fontsize size_;
  103. static Fl_Widget* widget_; //!< Keeps track of the current target widget
  104. static int margin_width_; //!< distance around tooltip text left+right
  105. static int margin_height_; //!< distance around tooltip text top+bottom
  106. static int wrap_width_; //!< maximum width of tooltip text before it word wraps
  107. };
  108. #endif
  109. //
  110. // End of "$Id: Fl_Tooltip.H 11163 2016-02-13 12:57:00Z matt $".
  111. //