Search code examples
c++ooptooltipdeclarationfltk

FLTK - FL_Tooltip - Modify tooltip size


I am using FLTK 1.3.5 (on Mac, Catalina 10.15.5, clang version 11.0.3) and I would like to have widgets with tooltips for whom I want to decide margins and other options. In particular, I want to work on margin_width and on wrap_width, so I tried the following

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tooltip.H>
#include <FL/Fl_Box.H>


int main(int argc, char **argv) {

    Fl_Window *G_win = 0;
    G_win = new Fl_Window(300,300,"Test");

    Fl_Box* B;
    B = new Fl_Box(10,10,280,280,"Test Tooltip");
    Fl_Tooltip::margin_width(12);
    B->tooltip("I want a huge tooltip!");


    G_win->end();
    G_win->show(argc, argv);
    
    return Fl::run();
}

But I get this error:

error: too many arguments to function call, expected 0, have 1
    Fl_Tooltip::margin_width(12);
    ~~~~~~~~~~~~~~~~~~~~~~~~ ^~
/usr/local/include/FL/Fl_Tooltip.H:95:3: note: 'margin_width' declared here
  static int margin_width() { return 3; }

After carefully looking to Fl_Tooltip.H, it seems that the function I want to use is enabled if the FLTK_ABI_VERSION variable is greater or equal to 10301 (line 81 of the header file). I inspected the file Enumerations.H and I checked that even if I have FLTK 1.3.5 FLTK_ABI_VERSION is 10300. Indeed, FLTK_ABI_VERSION is defined as FL_MAJOR_VERSION*10000 + FL_MINOR_VERSION*100 thus it will be always lower than 10301, being FL_MAJOR_VERSION equal to 1 FL_MINOR_VERSION equal to 3 in my case.

Moreover, the same header file says that actually FLTK_ABI_VERSION is deprecated and it will be substituted by FL_API_VERSION, which is exactly 10305 and corresponds to FLTK 1.3.5.

Is this a bug in the original code or am I missing something?


Solution

  • I don't know about the Mac but to get this to work on MS compilers

    #if FLTK_ABI_VERSION >= 10301
    

    should be changed to

    #if (FLTK_ABI_VERSION >= 10301)
    

    Try that on the Mac. If it works, please report the bug and fix to https://www.fltk.org/applications/str.php and remember to specify Mac and Windows.

    I've looked through the regression tests - I can't find a test for it. I suspect the feature was only tested on Linux

    Edit

    You will also need to modify FL_Tooltip.cxx and rebuild the FLTK library

    Edit

    For reference, have a look at README.abi-version.txt. After adding the brackets, reconfigure with

    ./configure --with-abiversion=10305
    

    Then make install