New draw_focus() methods.
Keyboard nav for choice, menu button. Updated Fl_Choice to draw like a combo box. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1553 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
2636d6fcd2
commit
03f49329ff
4
CHANGES
4
CHANGES
@ -9,7 +9,7 @@ TODO - Added new alignment bit FL_ALIGN_TEXT_OVER_IMAGE.
|
||||
- Added tooltip support using Jacques Tremblay's tooltip
|
||||
patch.
|
||||
|
||||
TODO - Added keyboard navigation to all widgets.
|
||||
PARTIAL - Added keyboard navigation to all widgets.
|
||||
|
||||
- Added support for mouse wheels using the new
|
||||
FL_MOUSEWHEEL event type. Get the mouse wheel
|
||||
@ -26,7 +26,7 @@ TODO - Added the Fl_Check_Browser, and Fl_Tree_Browser
|
||||
- Added 2.0 Fl_Text_Display and Fl_Text_Editor widgets
|
||||
based on NEdit.
|
||||
|
||||
TODO - The Fl_Choice widget now looks more line a combo box
|
||||
- The Fl_Choice widget now looks more line a combo box
|
||||
than a Motif option menu.
|
||||
|
||||
- Moved the OpenGL widgets into a separate library
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Widget.H,v 1.6.2.4.2.3 2001/08/03 02:28:32 easysw Exp $"
|
||||
// "$Id: Fl_Widget.H,v 1.6.2.4.2.4 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Widget header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -86,6 +86,8 @@ protected:
|
||||
void draw_box() const;
|
||||
void draw_box(Fl_Boxtype, Fl_Color) const;
|
||||
void draw_box(Fl_Boxtype, int,int,int,int, Fl_Color) const;
|
||||
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
|
||||
void draw_focus(Fl_Boxtype, int,int,int,int) const;
|
||||
void draw_label() const;
|
||||
void draw_label(int, int, int, int) const;
|
||||
|
||||
@ -195,5 +197,5 @@ public:
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.3 2001/08/03 02:28:32 easysw Exp $".
|
||||
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.4 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.4 2001/08/04 12:21:33 easysw Exp $"
|
||||
// "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.5 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Base Browser widget class for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -316,9 +316,8 @@ J1:
|
||||
fl_rectf(X, yy+Y, W, hh);
|
||||
}
|
||||
item_draw(l, X-hposition_, yy+Y, W+hposition_, hh);
|
||||
if (l == selection_) {
|
||||
fl_color(active_r() ? textcolor() : inactive(textcolor()));
|
||||
fl_rect(X+1, yy+Y, W-2, hh);
|
||||
if (l == selection_ && Fl::focus() == this) {
|
||||
draw_focus(FL_NO_BOX, X, yy+Y+1, W, hh);
|
||||
}
|
||||
int w = item_width(l);
|
||||
if (w > max_width) {max_width = w; max_width_item = l;}
|
||||
@ -499,8 +498,7 @@ int Fl_Browser_::select_only(void* l, int docallbacks) {
|
||||
|
||||
int Fl_Browser_::handle(int event) {
|
||||
// must do shortcuts first or the scrollbar will get them...
|
||||
if ((event == FL_SHORTCUT || event == FL_KEYBOARD)
|
||||
&& type() >= FL_HOLD_BROWSER) {
|
||||
if (event == FL_KEYBOARD && type() >= FL_HOLD_BROWSER) {
|
||||
void* l1 = selection_;
|
||||
void* l = l1; if (!l) l = top_; if (!l) l = item_first();
|
||||
if (l) {
|
||||
@ -553,6 +551,7 @@ int Fl_Browser_::handle(int event) {
|
||||
switch (event) {
|
||||
case FL_PUSH:
|
||||
if (!Fl::event_inside(X, Y, W, H)) return 0;
|
||||
take_focus();
|
||||
my = py = Fl::event_y();
|
||||
change = 0;
|
||||
if (type() == FL_NORMAL_BROWSER || !top_)
|
||||
@ -647,6 +646,12 @@ int Fl_Browser_::handle(int event) {
|
||||
if (when() & FL_WHEN_NOT_CHANGED) do_callback();
|
||||
}
|
||||
return 1;
|
||||
case FL_FOCUS:
|
||||
case FL_UNFOCUS:
|
||||
if (type() >= FL_HOLD_BROWSER) {
|
||||
redraw();
|
||||
return 1;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -707,5 +712,5 @@ void Fl_Browser_::item_select(void*, int) {}
|
||||
int Fl_Browser_::item_selected(void* l) const {return l==selection_;}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.4 2001/08/04 12:21:33 easysw Exp $".
|
||||
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.5 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.3 2001/08/04 16:43:31 easysw Exp $"
|
||||
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.4 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Button widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -26,7 +26,6 @@
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
// There are a lot of subclasses, named Fl_*_Button. Some of
|
||||
// them are implemented by setting the type() value and testing it
|
||||
@ -56,12 +55,7 @@ void Fl_Button::draw() {
|
||||
//if (col == FL_GRAY && Fl::belowmouse()==this) col = FL_LIGHT1;
|
||||
draw_box(value() ? (down_box()?down_box():down(box())) : box(), col);
|
||||
draw_label();
|
||||
if (Fl::focus() == this) {
|
||||
fl_line_style(FL_DASH);
|
||||
fl_rect(x() + Fl::box_dx(box()), y() + Fl::box_dy(box()),
|
||||
w() - Fl::box_dw(box()) - 1, h() - Fl::box_dh(box()) - 1);
|
||||
fl_line_style(FL_SOLID);
|
||||
}
|
||||
if (Fl::focus() == this) draw_focus();
|
||||
}
|
||||
int Fl_Button::handle(int event) {
|
||||
int newval;
|
||||
@ -72,6 +66,7 @@ int Fl_Button::handle(int event) {
|
||||
return 1;
|
||||
case FL_PUSH:
|
||||
case FL_DRAG:
|
||||
take_focus();
|
||||
if (Fl::event_inside(this)) {
|
||||
if (type() == FL_RADIO_BUTTON) newval = 1;
|
||||
else newval = !oldval;
|
||||
@ -141,5 +136,5 @@ Fl_Button::Fl_Button(int x,int y,int w,int h, const char *l)
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.3 2001/08/04 16:43:31 easysw Exp $".
|
||||
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.4 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Choice.cxx,v 1.10.2.5 2001/01/22 15:13:39 easysw Exp $"
|
||||
// "$Id: Fl_Choice.cxx,v 1.10.2.5.2.1 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Choice widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -34,17 +34,28 @@
|
||||
extern char fl_draw_shortcut;
|
||||
|
||||
void Fl_Choice::draw() {
|
||||
draw_box();
|
||||
if (box() == FL_FLAT_BOX) return; // for XForms compatability
|
||||
int H = labelsize()/2+1;
|
||||
draw_box(FL_THIN_UP_BOX,x()+w()-3*H,y()+(h()-H)/2,2*H,H,color());
|
||||
draw_box(FL_DOWN_BOX, color());
|
||||
int dx = Fl::box_dx(FL_DOWN_BOX);
|
||||
int dy = Fl::box_dy(FL_DOWN_BOX);
|
||||
int H = h() - 2 * dy;
|
||||
int X = x() + w() - h() + dx;
|
||||
int Y = y() + dy;
|
||||
int w1 = (H - 4) / 3; if (w1 < 1) w1 = 1;
|
||||
int x1 = X + (H - 2 * w1 - 1) / 2;
|
||||
int y1 = Y + (H - w1 - 1) / 2;
|
||||
|
||||
draw_box(FL_UP_BOX,X,Y,H,H,FL_GRAY);
|
||||
|
||||
fl_color(active_r() ? labelcolor() : fl_inactive(labelcolor()));
|
||||
fl_polygon(x1, y1, x1 + w1, y1 + w1, x1 + 2 * w1, y1);
|
||||
|
||||
if (mvalue()) {
|
||||
Fl_Menu_Item m = *mvalue();
|
||||
if (active_r()) m.activate(); else m.deactivate();
|
||||
int BW = Fl::box_dx(box());
|
||||
fl_clip(x(), y(), w()-3*H, h());
|
||||
fl_clip(x() + dx, y() + dy + 1, w() - h() - 2 * dx, H - 2);
|
||||
fl_draw_shortcut = 2; // hack value to make '&' disappear
|
||||
m.draw(x()+BW, y(), w()-2*BW-3*H, h(), this);
|
||||
m.draw(x() + dx, y() + dy + 1, w() - h() - 2 * dx, H - 2, this,
|
||||
Fl::focus() == this);
|
||||
fl_draw_shortcut = 0;
|
||||
fl_pop_clip();
|
||||
}
|
||||
@ -56,7 +67,9 @@ Fl_Choice::Fl_Choice(int x,int y,int w,int h, const char *l)
|
||||
align(FL_ALIGN_LEFT);
|
||||
when(FL_WHEN_RELEASE);
|
||||
textfont(FL_HELVETICA);
|
||||
down_box(FL_NO_BOX);
|
||||
box(FL_FLAT_BOX);
|
||||
down_box(FL_BORDER_BOX);
|
||||
color(FL_WHITE);
|
||||
}
|
||||
|
||||
int Fl_Choice::value(int v) {
|
||||
@ -69,7 +82,10 @@ int Fl_Choice::handle(int e) {
|
||||
if (!menu() || !menu()->text) return 0;
|
||||
const Fl_Menu_Item* v;
|
||||
switch (e) {
|
||||
case FL_KEYBOARD:
|
||||
if (Fl::event_key() != ' ') return 0;
|
||||
case FL_PUSH:
|
||||
take_focus();
|
||||
Fl::event_is_click(0);
|
||||
J1:
|
||||
v = menu()->pulldown(x(), y(), w(), h(), mvalue(), this);
|
||||
@ -84,11 +100,15 @@ int Fl_Choice::handle(int e) {
|
||||
if (v != mvalue()) redraw();
|
||||
picked(v);
|
||||
return 1;
|
||||
case FL_FOCUS:
|
||||
case FL_UNFOCUS:
|
||||
redraw();
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Choice.cxx,v 1.10.2.5 2001/01/22 15:13:39 easysw Exp $".
|
||||
// End of "$Id: Fl_Choice.cxx,v 1.10.2.5.2.1 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Light_Button.cxx,v 1.4.2.3.2.1 2001/08/04 16:43:31 easysw Exp $"
|
||||
// "$Id: Fl_Light_Button.cxx,v 1.4.2.3.2.2 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Lighted button widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -85,12 +85,7 @@ void Fl_Light_Button::draw() {
|
||||
draw_box(FL_THIN_DOWN_BOX, x()+xx, y()+d+1, ww, hh, col);
|
||||
}
|
||||
draw_label(x()+W-d, y(), w()-W+d, h());
|
||||
if (Fl::focus() == this) {
|
||||
fl_line_style(FL_DASH);
|
||||
fl_rect(x() + Fl::box_dx(box()), y() + Fl::box_dy(box()),
|
||||
w() - Fl::box_dw(box()) - 1, h() - Fl::box_dh(box()) - 1);
|
||||
fl_line_style(FL_SOLID);
|
||||
}
|
||||
if (Fl::focus() == this) draw_focus();
|
||||
}
|
||||
|
||||
int Fl_Light_Button::handle(int event) {
|
||||
@ -110,5 +105,5 @@ Fl_Light_Button::Fl_Light_Button(int x, int y, int w, int h, const char* l)
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Light_Button.cxx,v 1.4.2.3.2.1 2001/08/04 16:43:31 easysw Exp $".
|
||||
// End of "$Id: Fl_Light_Button.cxx,v 1.4.2.3.2.2 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Menu.cxx,v 1.18.2.12 2001/01/22 15:13:40 easysw Exp $"
|
||||
// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.1 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Menu code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -460,9 +460,6 @@ int menuwindow::handle(int e) {
|
||||
switch (Fl::event_key()) {
|
||||
case FL_Tab:
|
||||
if (Fl::event_shift()&FL_SHIFT) goto BACKTAB;
|
||||
case ' ':
|
||||
if (!forward(p.menu_number)) {p.item_number = -1; forward(p.menu_number);}
|
||||
return 1;
|
||||
case FL_BackSpace:
|
||||
case 0xFE20: // backtab
|
||||
BACKTAB:
|
||||
@ -488,6 +485,7 @@ int menuwindow::handle(int e) {
|
||||
setitem(p.menu_number-1, p.p[p.menu_number-1]->selected);
|
||||
return 1;
|
||||
case FL_Enter:
|
||||
case ' ':
|
||||
p.state = DONE_STATE;
|
||||
return 1;
|
||||
case FL_Escape:
|
||||
@ -743,5 +741,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu.cxx,v 1.18.2.12 2001/01/22 15:13:40 easysw Exp $".
|
||||
// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.1 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Menu_Button.cxx,v 1.4.2.3 2001/01/22 15:13:40 easysw Exp $"
|
||||
// "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.1 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Menu button widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -31,12 +31,15 @@ void Fl_Menu_Button::draw() {
|
||||
if (!box() || type()) return;
|
||||
draw_box(box(), color());
|
||||
draw_label();
|
||||
if (Fl::focus() == this) draw_focus();
|
||||
if (box() == FL_FLAT_BOX) return; // for XForms compatability
|
||||
int H = (labelsize()-3)&-2;
|
||||
int X = x()+w()-H*2;
|
||||
int Y = y()+(h()-H)/2;
|
||||
fl_color(FL_DARK3); fl_line(X+H/2, Y+H, X, Y, X+H, Y);
|
||||
fl_color(FL_LIGHT3); fl_line(X+H, Y, X+H/2, Y+H);
|
||||
fl_color(active_r() ? FL_DARK3 : fl_inactive(FL_DARK3));
|
||||
fl_line(X+H/2, Y+H, X, Y, X+H, Y);
|
||||
fl_color(active_r() ? FL_LIGHT3 : fl_inactive(FL_LIGHT3));
|
||||
fl_line(X+H, Y, X+H/2, Y+H);
|
||||
}
|
||||
|
||||
const Fl_Menu_Item* Fl_Menu_Button::popup() {
|
||||
@ -62,11 +65,23 @@ int Fl_Menu_Button::handle(int e) {
|
||||
} else if (type()) {
|
||||
if (!(type() & (1 << (Fl::event_button()-1)))) return 0;
|
||||
}
|
||||
take_focus();
|
||||
popup();
|
||||
return 1;
|
||||
case FL_KEYBOARD:
|
||||
if (Fl::event_key() == ' ') {
|
||||
popup();
|
||||
return 1;
|
||||
} else return 0;
|
||||
case FL_SHORTCUT:
|
||||
if (Fl_Widget::test_shortcut()) {popup(); return 1;}
|
||||
return test_shortcut() != 0;
|
||||
case FL_FOCUS:
|
||||
case FL_UNFOCUS:
|
||||
if (box()) {
|
||||
redraw();
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -78,5 +93,5 @@ Fl_Menu_Button::Fl_Menu_Button(int X,int Y,int W,int H,const char *l)
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_Button.cxx,v 1.4.2.3 2001/01/22 15:13:40 easysw Exp $".
|
||||
// End of "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.1 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.2 2001/08/03 15:48:20 easysw Exp $"
|
||||
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.3 2001/08/04 20:17:10 easysw Exp $"
|
||||
//
|
||||
// Base widget class for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -27,6 +27,7 @@
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Tooltip.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@ -132,6 +133,17 @@ Fl_Widget::~Fl_Widget() {
|
||||
fl_throw_focus(this);
|
||||
}
|
||||
|
||||
// draw a focus box for the widget...
|
||||
void
|
||||
Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
|
||||
fl_color(FL_BLACK);
|
||||
fl_line_style(FL_DASH);
|
||||
fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B),
|
||||
W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1);
|
||||
fl_line_style(FL_SOLID);
|
||||
}
|
||||
|
||||
|
||||
// redraw this, plus redraw opaque object if there is an outside label
|
||||
static void redraw_label(Fl_Widget* w) {
|
||||
w->redraw();
|
||||
@ -206,5 +218,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.2 2001/08/03 15:48:20 easysw Exp $".
|
||||
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.3 2001/08/04 20:17:10 easysw Exp $".
|
||||
//
|
||||
|
@ -26,6 +26,7 @@ Fl_Box.o: ../FL/Fl_Widget.H ../FL/Fl_Box.H ../FL/Fl_Widget.H
|
||||
Fl_Box.o: ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Button.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Button.o: ../FL/Fl_Button.H ../FL/Fl_Widget.H ../FL/Fl_Group.H
|
||||
Fl_Button.o: ../FL/fl_draw.H
|
||||
Fl_Chart.o: ../FL/math.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Chart.o: ../FL/Fl_Chart.H ../FL/Fl_Widget.H ../FL/fl_draw.H
|
||||
Fl_Check_Button.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
|
Loading…
Reference in New Issue
Block a user