summaryrefslogtreecommitdiff
path: root/src/Fl_Tabs.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2007-05-01 20:20:21 +0000
committerMatthias Melcher <fltk@matthiasm.com>2007-05-01 20:20:21 +0000
commit488f27d1ebe7a309f38643e6b71236d494201153 (patch)
tree06389e21cec7a43cdf7718c738e39c47caf4860d /src/Fl_Tabs.cxx
parent08d55b7bf293b48fe9324a50dcb4eecc67e027f3 (diff)
STR #1652: allowing shortcuts in tabs
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5791 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tabs.cxx')
-rw-r--r--src/Fl_Tabs.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Fl_Tabs.cxx b/src/Fl_Tabs.cxx
index 235826d2c..7260de4df 100644
--- a/src/Fl_Tabs.cxx
+++ b/src/Fl_Tabs.cxx
@@ -50,6 +50,9 @@ int Fl_Tabs::tab_positions(int* p, int* wp) {
int selected = 0;
Fl_Widget*const* a = array();
int i;
+ char prev_draw_shortcut = fl_draw_shortcut;
+ fl_draw_shortcut = 1;
+
p[0] = Fl::box_dx(box());
for (i=0; i<children(); i++) {
Fl_Widget* o = *a++;
@@ -61,6 +64,8 @@ int Fl_Tabs::tab_positions(int* p, int* wp) {
wp[i] = wt+EXTRASPACE;
p[i+1] = p[i]+wp[i]+BORDER;
}
+ fl_draw_shortcut = prev_draw_shortcut;
+
int r = w();
if (p[i] <= r) return selected;
// uh oh, they are too big:
@@ -214,6 +219,19 @@ int Fl_Tabs::handle(int event) {
default:
break;
}
+ return Fl_Group::handle(event);
+ case FL_SHORTCUT:
+ for (i = 0; i < children(); ++i) {
+ Fl_Widget *c = child(i);
+ if (c->test_shortcut(c->label())) {
+ char sc = !c->visible();
+ value(c);
+ if (sc) set_changed();
+ do_callback();
+ return 1;
+ }
+ }
+ return Fl_Group::handle(event);
case FL_SHOW:
value(); // update visibilities and fall through
default:
@@ -309,6 +327,9 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
int sel = (what == SELECTED);
int dh = Fl::box_dh(box());
int dy = Fl::box_dy(box());
+ char prev_draw_shortcut = fl_draw_shortcut;
+ fl_draw_shortcut = 1;
+
Fl_Boxtype bt = (o==push_ &&!sel) ? fl_down(box()) : box();
// compute offsets to make selected tab look bigger
@@ -367,6 +388,7 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
fl_pop_clip();
}
+ fl_draw_shortcut = prev_draw_shortcut;
}
Fl_Tabs::Fl_Tabs(int X,int Y,int W, int H, const char *l) :