Guys,
I have inherited Fl_Tabs for my own tabs widget. When I display it I occasionally get one of the tabs not displayed. I tried to understand the algorithm in tabs_position() that adjusts the tab widths if they are larger than the Fl_Tabs width but failed. I overrode tabs_position() to implement a different algorithm.
Keep the selected tab width as calculated and then shrink the other tab widths by the same ratio.
I replaced the correction code with the following.
// Change the algorithm if they are too big
// Reduce all deselected widths by the apportioned oversize
// Use fixed point arithmetic (x2^10) to reduce rounding error
int delta = 1024 * (r - tab_width[selected]) / (tab_pos[i] - tab_width[selected]);
for (i = 0; i < nc; i++) {
if (i != selected) {
tab_width[i] = tab_width[i] * delta / 1024;
}
tab_pos[i + 1] = tab_pos[i] + tab_width[i] + BORDER;
}
// If we haven't used the full width, increase the size of the last tab to compensate
if (tab_pos[i] < r) {
tab_width[i - 1] = r - tab_pos[i];
tab_pos[i] = r;
}
return selected;
I am using a fairly old version of fLTK 1.4. It doesn't yet have the change that introduced the when(FL_WHEN_CLOSED) feature for Fl_Tabs.
Regards Phil.