Add fl_beep() function.

Don't allow non-int/float text to be pasted into an Fl_Int_Input or
Fl_Float_Input widget.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1690 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-11-17 16:37:48 +00:00
parent efbe74758f
commit 45658d7c0f
6 changed files with 85 additions and 33 deletions

View File

@ -3,6 +3,11 @@ CHANGES IN FLTK 1.1.0b6
- Documentation updates...
- The configure script now works within the CygWin
environment.
- Added new fl_beep() function to do audible
notifications of various types.
- Fl_Float_Input and Fl_Int_Input no longer accept
pasted text that is not a floating point or integer
value.
- Implemented the Fl_File_Icon::load_png() method.
- The Fl_File_Icon::load_system_icons() method now
supports KDE 2.x icons.

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_ask.H,v 1.7.2.4 2001/05/11 18:37:08 easysw Exp $"
// "$Id: fl_ask.H,v 1.7.2.4.2.1 2001/11/17 16:37:47 easysw Exp $"
//
// Standard dialog header file for the Fast Light Tool Kit (FLTK).
//
@ -30,6 +30,16 @@
class Fl_Widget;
enum {
FL_BEEP_DEFAULT = 0,
FL_BEEP_MESSAGE,
FL_BEEP_ERROR,
FL_BEEP_QUESTION,
FL_BEEP_PASSWORD,
FL_BEEP_NOTIFICATION
};
FL_EXPORT void fl_beep(int type = FL_BEEP_DEFAULT);
FL_EXPORT void fl_message(const char *,...);
FL_EXPORT void fl_alert(const char *,...);
FL_EXPORT int fl_ask(const char *,...);
@ -52,5 +62,5 @@ extern FL_EXPORT const char* fl_cancel;
#endif
//
// End of "$Id: fl_ask.H,v 1.7.2.4 2001/05/11 18:37:08 easysw Exp $".
// End of "$Id: fl_ask.H,v 1.7.2.4.2.1 2001/11/17 16:37:47 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.2 2001/11/17 15:59:53 easysw Exp $"
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.3 2001/11/17 16:37:48 easysw Exp $"
//
// Fl_File_Icon system icon routines.
//
@ -435,7 +435,7 @@ Fl_File_Icon::load_png(const char *png) // I - File to read from
case 3 :
temp = fl_rgb_color(row[0], row[1], row[2]);
break;
case 4 :
default :
if (row[3] > 127)
temp = fl_rgb_color(row[0], row[1], row[2]);
else
@ -1020,5 +1020,5 @@ get_kde_val(char *str,
//
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.2 2001/11/17 15:59:53 easysw Exp $".
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.3 2001/11/17 16:37:48 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Input.cxx,v 1.10.2.15.2.2 2001/09/29 22:59:45 easysw Exp $"
// "$Id: Fl_Input.cxx,v 1.10.2.15.2.3 2001/11/17 16:37:48 easysw Exp $"
//
// Input widget for the Fast Light Tool Kit (FLTK).
//
@ -251,13 +251,6 @@ int Fl_Input::handle(int event) {
if (Fl::focus() != this) {
Fl::focus(this);
handle(FL_FOCUS);
#if 0 // Misguided attempt to simulate Windoze select-all-on-first-click
// that it does for *some* (but not all) text fields:
if (type() != FL_MULTILINE_INPUT) {
position(size(), 0); // select everything
return 1;
}
#endif
}
break;
@ -283,5 +276,5 @@ Fl_Input::Fl_Input(int x, int y, int w, int h, const char *l)
}
//
// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.2 2001/09/29 22:59:45 easysw Exp $".
// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.3 2001/11/17 16:37:48 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.2 2001/10/29 03:44:32 easysw Exp $"
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.3 2001/11/17 16:37:48 easysw Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@ -31,6 +31,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Input_.H>
#include <FL/fl_draw.H>
#include <FL/fl_ask.H>
#include <math.h>
#include <string.h>
#include <stdlib.h>
@ -713,6 +714,23 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
const char* t = Fl::event_text();
const char* e = t+Fl::event_length();
if (type() != FL_MULTILINE_INPUT) while (e > t && isspace(*(e-1))) e--;
if (type() == FL_INT_INPUT) {
const char *p = t;
while ((isdigit(*p) || *p == '+' || *p == '-') && p < e)
p ++;
if (p < e) {
fl_beep(FL_BEEP_ERROR);
return 1;
}
} else if (type() == FL_FLOAT_INPUT) {
const char *p = t;
while ((isdigit(*p) || *p == '+' || *p == '-' || *p == '.') && p < e)
p ++;
if (p < e) {
fl_beep(FL_BEEP_ERROR);
return 1;
}
}
return replace(position(), mark(), t, e-t);}
default:
@ -821,5 +839,5 @@ Fl_Input_::~Fl_Input_() {
}
//
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.2 2001/10/29 03:44:32 easysw Exp $".
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.3 2001/11/17 16:37:48 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_ask.cxx,v 1.8.2.8 2001/01/22 15:13:40 easysw Exp $"
// "$Id: fl_ask.cxx,v 1.8.2.8.2.1 2001/11/17 16:37:48 easysw Exp $"
//
// Standard dialog functions for the Fast Light Tool Kit (FLTK).
//
@ -134,13 +134,44 @@ const char* fl_ok = "OK";
const char* fl_cancel= "Cancel";
// fltk functions:
void fl_beep(int type) {
#ifdef WIN32
switch (type) {
case FL_BEEP_QUESTION :
case FL_BEEP_PASSWORD :
MessageBeep(MD_ICONQUESTION);
break;
case FL_BEEP_MESSAGE :
MessageBeep(MD_ICONASTERISK);
break;
case FL_BEEP_NOTIFICATION :
MessageBeep(MD_ICONASTERISK);
break;
default :
MessageBeep(MD_ICONERROR);
break;
}
#else
switch (type) {
case FL_BEEP_DEFAULT :
case FL_BEEP_ERROR :
if (!fl_display) fl_open_display();
XBell(fl_display, 100);
break;
default :
if (!fl_display) fl_open_display();
XBell(fl_display, 50);
break;
}
#endif // WIN32
}
void fl_message(const char *fmt, ...) {
va_list ap;
#ifdef WIN32
MessageBeep(MB_ICONASTERISK);
#endif // WIN32
fl_beep(FL_BEEP_MESSAGE);
va_start(ap, fmt);
iconlabel = "i";
@ -152,12 +183,7 @@ void fl_message(const char *fmt, ...) {
void fl_alert(const char *fmt, ...) {
va_list ap;
#ifdef WIN32
MessageBeep(MB_ICONERROR);
#else
if (!fl_display) fl_open_display();
XBell(fl_display, 100);
#endif // WIN32
fl_beep(FL_BEEP_ERROR);
va_start(ap, fmt);
iconlabel = "!";
@ -169,9 +195,7 @@ void fl_alert(const char *fmt, ...) {
int fl_ask(const char *fmt, ...) {
va_list ap;
#ifdef WIN32
MessageBeep(MB_ICONQUESTION);
#endif // WIN32
fl_beep(FL_BEEP_QUESTION);
va_start(ap, fmt);
int r = innards(fmt, ap, fl_no, fl_yes, 0);
@ -183,9 +207,7 @@ int fl_ask(const char *fmt, ...) {
int fl_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...){
va_list ap;
#ifdef WIN32
MessageBeep(MB_ICONQUESTION);
#endif // WIN32
fl_beep(FL_BEEP_QUESTION);
va_start(ap, b2);
int r = innards(fmt, ap, b0, b1, b2);
@ -214,6 +236,8 @@ static const char* input_innards(const char* fmt, va_list ap,
}
const char* fl_input(const char *fmt, const char *defstr, ...) {
fl_beep(FL_BEEP_QUESTION);
va_list ap;
va_start(ap, defstr);
const char* r = input_innards(fmt, ap, defstr, FL_NORMAL_INPUT);
@ -222,6 +246,8 @@ const char* fl_input(const char *fmt, const char *defstr, ...) {
}
const char *fl_password(const char *fmt, const char *defstr, ...) {
fl_beep(FL_BEEP_PASSWORD);
va_list ap;
va_start(ap, defstr);
const char* r = input_innards(fmt, ap, defstr, FL_SECRET_INPUT);
@ -230,5 +256,5 @@ const char *fl_password(const char *fmt, const char *defstr, ...) {
}
//
// End of "$Id: fl_ask.cxx,v 1.8.2.8 2001/01/22 15:13:40 easysw Exp $".
// End of "$Id: fl_ask.cxx,v 1.8.2.8.2.1 2001/11/17 16:37:48 easysw Exp $".
//