summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2012-05-16 23:19:37 +0000
committerGreg Ercolano <erco@seriss.com>2012-05-16 23:19:37 +0000
commit34716f86a02b71aa210f998dd7be48bc07550199 (patch)
treea4237ce6558254b1a22189575d63bde5b89c7ba9
parentf9d8abbf7bcfaa74bf52db3f8f97481d35792d29 (diff)
Added three methods and dox to Fl_Tooltip:
margin_width() -- controls margins around tooltip's text margin_height() -- controls margins above and below tooltip's text wrap_width() -- controls maximum width of text before wordwrapping is enforced These are read-only for the current release, and read/write as an ABI feature. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9510 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Tooltip.H28
-rw-r--r--documentation/src/tooltip-options.pngbin0 -> 6625 bytes
-rw-r--r--src/Fl_Tooltip.cxx20
3 files changed, 42 insertions, 6 deletions
diff --git a/FL/Fl_Tooltip.H b/FL/Fl_Tooltip.H
index ca631b327..0378aa80b 100644
--- a/FL/Fl_Tooltip.H
+++ b/FL/Fl_Tooltip.H
@@ -28,6 +28,10 @@
/**
The Fl_Tooltip class provides tooltip support for
all FLTK widgets. It contains only static methods.
+
+ \image html tooltip-options.png "Fl_Tooltip Options"
+ \image latex src/tooltip-options.png "Fl_Tooltip Options" width=6cm
+
*/
class FL_EXPORT Fl_Tooltip {
public:
@@ -74,6 +78,25 @@ public:
static Fl_Color textcolor() { return textcolor_; }
/** Sets the color of the text in the tooltip. The default is black. */
static void textcolor(Fl_Color c) { textcolor_ = c; }
+#if FLTK_ABI_VERSION >= 10302
+ /** Gets the amount of extra space left/right of the tooltip's text. Default is 3. */
+ static int margin_width() { return margin_width_; }
+ /** Sets the amount of extra space left/right of the tooltip's text. Default is 3. */
+ static void margin_width(int v) { margin_width_ = v; }
+ /** Gets the amount of extra space above and below the tooltip's text. Default is 3. */
+ static int margin_height() { return margin_height_; }
+ /** Sets the amount of extra space above and below the tooltip's text. Default is 3. */
+ static void margin_height(int v) { margin_height_ = v; }
+ /** Gets the maximum width for tooltip's text before it word wraps. Default is 400. */
+ static int wrap_width() { return wrap_width_; }
+ /** Sets the maximum width for tooltip's text before it word wraps. Default is 400. */
+ static void wrap_width(int v) { wrap_width_ = v; }
+#else
+ static int margin_width() { return 3; }
+ static int margin_height() { return 3; }
+ static int wrap_width() { return 400; }
+#endif
+
#ifdef __APPLE__
// the unique tooltip window
static Fl_Window* current_window(void);
@@ -96,6 +119,11 @@ private:
static Fl_Font font_;
static Fl_Fontsize size_;
static Fl_Widget* widget_; //!< Keeps track of the current target widget
+#if FLTK_ABI_VERSION >= 10302
+ static int margin_width_; //!< distance around tooltip text left+right
+ static int margin_height_; //!< distance around tooltip text top+bottom
+ static int wrap_width_; //!< maximum width of tooltip text before it word wraps
+#endif
};
#endif
diff --git a/documentation/src/tooltip-options.png b/documentation/src/tooltip-options.png
new file mode 100644
index 000000000..f742b72ce
--- /dev/null
+++ b/documentation/src/tooltip-options.png
Binary files differ
diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx
index b59cec09c..670c7b8e7 100644
--- a/src/Fl_Tooltip.cxx
+++ b/src/Fl_Tooltip.cxx
@@ -31,8 +31,11 @@ Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
Fl_Color Fl_Tooltip::textcolor_ = FL_BLACK;
Fl_Font Fl_Tooltip::font_ = FL_HELVETICA;
Fl_Fontsize Fl_Tooltip::size_ = -1;
-
-#define MAX_WIDTH 400
+#if FLTK_ABI_VERSION >= 10302
+int Fl_Tooltip::margin_width_ = 3;
+int Fl_Tooltip::margin_height_ = 3;
+int Fl_Tooltip::wrap_width_ = 400;
+#endif
static const char* tip;
/**
@@ -70,10 +73,11 @@ Fl_Window *Fl_Tooltip::current_window(void)
void Fl_TooltipBox::layout() {
fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());
- int ww, hh;
- ww = MAX_WIDTH;
+ int ww = Fl_Tooltip::wrap_width();
+ int hh;
fl_measure(tip, ww, hh, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE);
- ww += 6; hh += 6;
+ ww += (Fl_Tooltip::margin_width() * 2);
+ hh += (Fl_Tooltip::margin_height() * 2);
// find position on the screen of the widget:
int ox = Fl::event_x_root();
@@ -100,7 +104,11 @@ void Fl_TooltipBox::draw() {
draw_box(FL_BORDER_BOX, 0, 0, w(), h(), Fl_Tooltip::color());
fl_color(Fl_Tooltip::textcolor());
fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());
- fl_draw(tip, 3, 3, w()-6, h()-6, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_WRAP));
+ int X = Fl_Tooltip::margin_width();
+ int Y = Fl_Tooltip::margin_height();
+ int W = w() - (Fl_Tooltip::margin_width()*2);
+ int H = h() - (Fl_Tooltip::margin_height()*2);
+ fl_draw(tip, X, Y, W, H, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_WRAP));
}
static char recent_tooltip;