MDI using Fl_Tabs

47 views
Skip to first unread message

Dimond Stak

unread,
Oct 17, 2017, 11:26:07 AM10/17/17
to fltk.general
Hi all.
I learn FLTK and wanna make Tabs-MDI application. But I can't find how can I close Tab? I mean I can't find "x" button on Tabs. Is this really the lack of functionality?

Albrecht Schlosser

unread,
Oct 17, 2017, 12:11:49 PM10/17/17
to fltkg...@googlegroups.com
For now (as of FLTK 1.3.x) this functionality doesn't exist. In FLTK 1.3
you can subclass Fl_Tabs and do it yourself or you can add a button
elsewhere to close the "active" tab. You can also define a global
shortcut like ctrl/q or ctrl/w to close the active tab.

There are some proposals for closable tabs (with an 'X' button like in
current browsers and some editors) and this new functionality will
likely be available in FLTK 1.4.0. There's no schedule though and no
release planning.

K Dmitrij

unread,
Oct 18, 2017, 11:38:28 AM10/18/17
to fltkg...@googlegroups.com

algorithm:


0) derives from Fl_Tabs;


1) copy draw_tab() mehod from Fl_Tabs.cxx and needs draw cross-image in right corner;


2) to process FL_PUSH event, and close tab if click was inside of the cross-image




From Dimond Stak
 
Hi all.
I learn FLTK and wanna make Tabs-MDI application. But I can't find how can I close Tab? I mean I can't find "x" button on Tabs. Is this really the lack of functionality?

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dimond Stak

unread,
Oct 18, 2017, 2:56:48 PM10/18/17
to fltk.general
Thanks Albrecht, TheKdiman. I'll try to derive my subclass from Fl_Tabs.

вторник, 17 октября 2017 г., 18:26:07 UTC+3 пользователь Dimond Stak написал:

Dimond Stak

unread,
Oct 18, 2017, 2:56:48 PM10/18/17
to fltk.general
draw_tab is private, so I have to dive into Fl_Tabs code.


вторник, 17 октября 2017 г., 18:26:07 UTC+3 пользователь Dimond Stak написал:
Hi all.

Greg Ercolano

unread,
Oct 18, 2017, 3:10:11 PM10/18/17
to fltkg...@googlegroups.com
On 10/18/17 11:52, Dimond Stak wrote:
> draw_tab is private,

Yes, in 1.3.x.

Try 1.4.x -- in 1.4.x it's "protected", so you can access it.

--- snip
class FL_EXPORT Fl_Tabs : public Fl_Group {

Fl_Widget *push_;

protected:
[..]
virtual void clear_tab_positions();
virtual void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0);
[..]
--- snip

Dimond Stak

unread,
Oct 18, 2017, 5:11:13 PM10/18/17
to fltk.general
Thanks Greg, it looks like draw_tab uses "Fl_Widget *push_;" but "push_" is private too.

среда, 18 октября 2017 г., 22:10:11 UTC+3 пользователь Greg Ercolano написал:

Greg Ercolano

unread,
Oct 18, 2017, 5:58:14 PM10/18/17
to fltkg...@googlegroups.com
On 10/18/17 13:50, Dimond Stak wrote:
> Thanks Greg, it looks like draw_tab uses "Fl_Widget *push_;" but "push_" is private too.

Do you need it though?

You just need to re-implement draw_tab() to call Fl_Tabs::draw_tab(),
and then add your drawing code over that to draw the 'x', right? e.g.

class YourTabs : public Fl_Tabs {
..
void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0) {
Fl_Tabs::draw_tab(x1,x2,W,H,o,sel);
// Add your 'x' drawing code here..
}
Reply all
Reply to author
Forward
0 new messages