mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 23:06:54 +08:00
Simplify Fl_Tabs label drawing code (remove code duplication).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12184 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+9
-18
@@ -378,6 +378,10 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
|
|||||||
fl_draw_shortcut = 1;
|
fl_draw_shortcut = 1;
|
||||||
|
|
||||||
Fl_Boxtype bt = (o == push_ && !sel) ? fl_down(box()) : box();
|
Fl_Boxtype bt = (o == push_ && !sel) ? fl_down(box()) : box();
|
||||||
|
Fl_Color bc = sel ? selection_color() : o->selection_color();
|
||||||
|
|
||||||
|
// Save the label color
|
||||||
|
Fl_Color oc = o->labelcolor();
|
||||||
|
|
||||||
// compute offsets to make selected tab look bigger
|
// compute offsets to make selected tab look bigger
|
||||||
int yofs = sel ? 0 : BORDER;
|
int yofs = sel ? 0 : BORDER;
|
||||||
@@ -390,20 +394,12 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
|
|||||||
|
|
||||||
H += dh;
|
H += dh;
|
||||||
|
|
||||||
Fl_Color c = sel ? selection_color() : o->selection_color();
|
draw_box(bt, x1, y() + yofs, W, H + 10 - yofs, bc);
|
||||||
|
|
||||||
draw_box(bt, x1, y() + yofs, W, H + 10 - yofs, c);
|
|
||||||
|
|
||||||
// Save the previous label color
|
|
||||||
Fl_Color oc = o->labelcolor();
|
|
||||||
|
|
||||||
// Draw the label using the current color...
|
// Draw the label using the current color...
|
||||||
o->labelcolor(sel ? labelcolor() : o->labelcolor());
|
o->labelcolor(sel ? labelcolor() : o->labelcolor());
|
||||||
o->draw_label(x1, y() + yofs, W, H - yofs, FL_ALIGN_CENTER);
|
o->draw_label(x1, y() + yofs, W, H - yofs, FL_ALIGN_CENTER);
|
||||||
|
|
||||||
// Restore the original label color...
|
|
||||||
o->labelcolor(oc);
|
|
||||||
|
|
||||||
if (Fl::focus() == this && o->visible())
|
if (Fl::focus() == this && o->visible())
|
||||||
draw_focus(box(), x1, y(), W, H);
|
draw_focus(box(), x1, y(), W, H);
|
||||||
|
|
||||||
@@ -416,26 +412,21 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
|
|||||||
|
|
||||||
H += dh;
|
H += dh;
|
||||||
|
|
||||||
Fl_Color c = sel ? selection_color() : o->selection_color();
|
draw_box(bt, x1, y() + h() - H - 10, W, H + 10 - yofs, bc);
|
||||||
|
|
||||||
draw_box(bt, x1, y() + h() - H - 10, W, H + 10 - yofs, c);
|
|
||||||
|
|
||||||
// Save the previous label color
|
|
||||||
Fl_Color oc = o->labelcolor();
|
|
||||||
|
|
||||||
// Draw the label using the current color...
|
// Draw the label using the current color...
|
||||||
o->labelcolor(sel ? labelcolor() : o->labelcolor());
|
o->labelcolor(sel ? labelcolor() : o->labelcolor());
|
||||||
o->draw_label(x1, y() + h() - H, W, H - yofs, FL_ALIGN_CENTER);
|
o->draw_label(x1, y() + h() - H, W, H - yofs, FL_ALIGN_CENTER);
|
||||||
|
|
||||||
// Restore the original label color...
|
|
||||||
o->labelcolor(oc);
|
|
||||||
|
|
||||||
if (Fl::focus() == this && o->visible())
|
if (Fl::focus() == this && o->visible())
|
||||||
draw_focus(box(), x1, y() + h() - H, W, H);
|
draw_focus(box(), x1, y() + h() - H, W, H);
|
||||||
|
|
||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
}
|
}
|
||||||
fl_draw_shortcut = prev_draw_shortcut;
|
fl_draw_shortcut = prev_draw_shortcut;
|
||||||
|
|
||||||
|
// Restore the original label color
|
||||||
|
o->labelcolor(oc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user