Author: greg.ercolano
Date: 2012-05-16 16:19:37 -0700 (Wed, 16 May 2012)
New Revision: 9510
Log:
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.



Added:
   branches/branch-1.3/documentation/src/tooltip-options.png
Modified:
   branches/branch-1.3/FL/Fl_Tooltip.H
   branches/branch-1.3/src/Fl_Tooltip.cxx

Modified: branches/branch-1.3/FL/Fl_Tooltip.H
===================================================================
--- branches/branch-1.3/FL/Fl_Tooltip.H 2012-05-16 22:16:56 UTC (rev 9509)
+++ branches/branch-1.3/FL/Fl_Tooltip.H 2012-05-16 23:19:37 UTC (rev 9510)
@@ -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 @@
   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 @@
   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

Added: branches/branch-1.3/documentation/src/tooltip-options.png
===================================================================
(Binary files differ)


Property changes on: branches/branch-1.3/documentation/src/tooltip-options.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/branch-1.3/src/Fl_Tooltip.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Tooltip.cxx      2012-05-16 22:16:56 UTC (rev 
9509)
+++ branches/branch-1.3/src/Fl_Tooltip.cxx      2012-05-16 23:19:37 UTC (rev 
9510)
@@ -31,9 +31,12 @@
 Fl_Color       Fl_Tooltip::textcolor_ = FL_BLACK;
 Fl_Font         Fl_Tooltip::font_ = FL_HELVETICA;
 Fl_Fontsize     Fl_Tooltip::size_ = -1;
+#if FLTK_ABI_VERSION >= 10302
+int            Fl_Tooltip::margin_width_  = 3;
+int            Fl_Tooltip::margin_height_ = 3;
+int            Fl_Tooltip::wrap_width_    = 400;
+#endif
 
-#define MAX_WIDTH 400
-
 static const char* tip;
 /**
     This widget creates a tooltip box window, with no caption.
@@ -70,10 +73,11 @@
 
 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 @@
   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;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to