When a line towards the bottom of an Fl_Hold_Browser is selected
through the select() api, the widget gets redrawn with some empty
space at the bottom.  I can't say whether that's a bug or a feature,
but I'd like to stop it from happening.  Anybody have any
ideas?  (demo follows)

TIA,
Stan

/////////////////////////////////////////////
#include "FL/Fl.H"
#include "FL/Fl_Double_Window.H"
#include "FL/Fl_Hold_Browser.H"
#include "FL/Fl_Int_Input.H"
#include "FL/Fl_Button.H"
#include "FL/Fl_Box.H"
#include "FL/fl_ask.H"
#include <sstream>
#include <cstdlib>

Fl_Int_Input* inp;
Fl_Hold_Browser* brs;

void btn_cb(Fl_Widget*, void*)
{
    int i = std::atoi(inp->value());
    if(i < 1 || i > brs->size()) {
        std::ostringstream oss;
        oss << "Please select number between 1 and " << brs->size();
        fl_alert(oss.str().c_str());
    }
    else {
        brs->select(i);
        brs->redraw();
    }
}

void brs_cb(Fl_Widget*, void*)
{
    std::ostringstream oss;
    oss << brs->value();
    inp->value(oss.str().c_str());
}

int main()
{
    Fl_Double_Window win(350, 300);
    Fl_Int_Input input(75, 0, 50, 20, "Selection: ");
    inp = &input;
    Fl_Box bx(125, 0, 150, 20, "(try selecting 100)");
    Fl_Button btn(75, 20, 50, 20, "Go");
    Fl_Hold_Browser browser(50, 50, 150, 200);
    brs = &browser;
    win.end();
    btn.callback(btn_cb);
    input.callback(btn_cb);
    browser.callback(brs_cb);
    input.when(FL_WHEN_ENTER_KEY);
    for(int i = 0; i < 100; ++i) {
        std::ostringstream oss;
        oss << "Line " << i + 1;
        browser.add(oss.str().c_str());
    }
    browser.do_callback();
    win.show();
    return Fl::run();
}

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

Reply via email to