1998-10-20 00:46:58 +04:00
|
|
|
//
|
1999-02-16 16:48:04 +03:00
|
|
|
// "$Id: Fl_Choice.cxx,v 1.8 1999/02/16 13:48:04 mike Exp $"
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// Choice widget for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
1999-01-07 22:18:01 +03:00
|
|
|
// Copyright 1998-1999 by Bill Spitzak and others.
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Choice.H>
|
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
1998-10-20 00:46:58 +04:00
|
|
|
// Emulates the Forms choice widget. This is almost exactly the same
|
|
|
|
// as an Fl_Menu_Button. The only difference is the appearance of the
|
|
|
|
// button: it draws the text of the current pick and a down-arrow.
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
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());
|
1998-12-02 18:39:39 +03:00
|
|
|
fl_font(textfont(),textsize());
|
1998-10-06 22:21:25 +04:00
|
|
|
fl_color(active_r() ? textcolor() : inactive(textcolor()));
|
|
|
|
fl_draw_shortcut = 2; // hack value to make '&' disappear
|
1998-11-10 17:40:18 +03:00
|
|
|
int BW = Fl::box_dx(box());
|
1999-02-16 16:48:04 +03:00
|
|
|
mvalue()->draw( x()+BW+3, y(), w()-2*BW-2-3*H, h(), this);
|
1998-10-06 22:21:25 +04:00
|
|
|
fl_draw_shortcut = 0;
|
|
|
|
draw_label();
|
|
|
|
}
|
|
|
|
|
|
|
|
Fl_Choice::Fl_Choice(int x,int y,int w,int h, const char *l)
|
|
|
|
: Fl_Menu_(x,y,w,h,l) {
|
|
|
|
align(FL_ALIGN_LEFT);
|
|
|
|
when(FL_WHEN_RELEASE);
|
|
|
|
textfont(FL_HELVETICA);
|
|
|
|
down_box(FL_NO_BOX);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Fl_Choice::value(int v) {
|
|
|
|
if (!Fl_Menu_::value(v)) return 0;
|
|
|
|
redraw();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Fl_Choice::handle(int e) {
|
|
|
|
if (!menu() || !menu()->text) return 0;
|
|
|
|
const Fl_Menu_Item* v;
|
|
|
|
switch (e) {
|
|
|
|
case FL_PUSH:
|
1999-01-19 22:12:51 +03:00
|
|
|
Fl::event_is_click(0);
|
1998-10-06 22:21:25 +04:00
|
|
|
J1:
|
|
|
|
v = menu()->pulldown(x(), y(), w(), h(), mvalue(), this);
|
|
|
|
if (!v || v->submenu()) return 1;
|
|
|
|
if (v != mvalue()) redraw();
|
|
|
|
picked(v);
|
|
|
|
return 1;
|
|
|
|
case FL_SHORTCUT:
|
|
|
|
if (Fl_Widget::test_shortcut()) goto J1;
|
|
|
|
v = menu()->test_shortcut();
|
|
|
|
if (!v) return 0;
|
|
|
|
if (v != mvalue()) redraw();
|
|
|
|
picked(v);
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
1999-02-16 16:48:04 +03:00
|
|
|
// End of "$Id: Fl_Choice.cxx,v 1.8 1999/02/16 13:48:04 mike Exp $".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|