| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include <fontforge-config.h> |
| 29 |
|
| 30 |
#include "basics.h" |
| 31 |
#include "ggadget.h" |
| 32 |
#include "gwidget.h" |
| 33 |
#include "ustring.h" |
| 34 |
|
| 35 |
void GGadgetProtest8(const char *label) { |
| 36 |
char buf[80]; |
| 37 |
|
| 38 |
snprintf( buf, sizeof(buf),_("Bad Number in %s"), label); |
| 39 |
if ( buf[strlen(buf)-1]==' ' ) |
| 40 |
buf[strlen(buf)-1]='\0'; |
| 41 |
if ( buf[strlen(buf)-1]==':' ) |
| 42 |
buf[strlen(buf)-1]='\0'; |
| 43 |
gwwv_post_notice(buf,buf); |
| 44 |
} |
| 45 |
|
| 46 |
double GetCalmReal8(GWindow gw,int cid,char *name,int *err) { |
| 47 |
char *txt, *end; |
| 48 |
double val; |
| 49 |
|
| 50 |
txt = GGadgetGetTitle8(GWidgetGetControl(gw,cid)); |
| 51 |
val = strtod(txt,&end); |
| 52 |
if ( (*txt=='-' || *txt=='.') && end==txt && txt[1]=='\0' ) |
| 53 |
end = txt+1; |
| 54 |
else if ( *txt=='-' && txt[1]=='.' && txt[2]=='\0' ) |
| 55 |
end = txt+2; |
| 56 |
if ( *end!='\0' ) { |
| 57 |
GDrawBeep(NULL); |
| 58 |
*err = true; |
| 59 |
} |
| 60 |
free(txt); |
| 61 |
return( val ); |
| 62 |
} |
| 63 |
|
| 64 |
double GetReal8(GWindow gw,int cid,char *name,int *err) { |
| 65 |
char *txt, *end; |
| 66 |
double val; |
| 67 |
|
| 68 |
txt = GGadgetGetTitle8(GWidgetGetControl(gw,cid)); |
| 69 |
val = strtod(txt,&end); |
| 70 |
if ( *end!='\0' ) { |
| 71 |
GTextFieldSelect(GWidgetGetControl(gw,cid),0,-1); |
| 72 |
GGadgetProtest8(name); |
| 73 |
*err = true; |
| 74 |
} |
| 75 |
free(txt); |
| 76 |
return( val ); |
| 77 |
} |
| 78 |
|
| 79 |
int GetCalmInt8(GWindow gw,int cid,char *name,int *err) { |
| 80 |
char *txt, *end; |
| 81 |
int val; |
| 82 |
|
| 83 |
txt = GGadgetGetTitle8(GWidgetGetControl(gw,cid)); |
| 84 |
val = strtol(txt,&end,10); |
| 85 |
if ( *txt=='-' && end==txt && txt[1]=='\0' ) |
| 86 |
end = txt+1; |
| 87 |
if ( *end!='\0' ) { |
| 88 |
GDrawBeep(NULL); |
| 89 |
*err = true; |
| 90 |
} |
| 91 |
free(txt); |
| 92 |
return( val ); |
| 93 |
} |
| 94 |
|
| 95 |
int GetInt8(GWindow gw,int cid,char *name,int *err) { |
| 96 |
char *txt, *end; |
| 97 |
int val; |
| 98 |
|
| 99 |
txt = GGadgetGetTitle8(GWidgetGetControl(gw,cid)); |
| 100 |
val = strtol(txt,&end,10); |
| 101 |
if ( *end!='\0' ) { |
| 102 |
GTextFieldSelect(GWidgetGetControl(gw,cid),0,-1); |
| 103 |
GGadgetProtest8(name); |
| 104 |
*err = true; |
| 105 |
} |
| 106 |
free(txt); |
| 107 |
return( val ); |
| 108 |
} |
| 109 |
|
| 110 |
int GetUnicodeChar8(GWindow gw,int cid,char *name,int *err) { |
| 111 |
char *txt, *end, *pt; |
| 112 |
int val; |
| 113 |
const unichar_t *utxt; |
| 114 |
|
| 115 |
utxt = _GGadgetGetTitle(GWidgetGetControl(gw,cid)); |
| 116 |
if ( u_strlen(utxt)==1 ) |
| 117 |
return( utxt[0] ); |
| 118 |
|
| 119 |
txt = GGadgetGetTitle8(GWidgetGetControl(gw,cid)); |
| 120 |
val = strtol(txt,&end,16); |
| 121 |
if ( *end!='\0' ) { |
| 122 |
for ( pt=txt; *pt==' '; ++pt ); |
| 123 |
if ( (*pt=='U' || *pt=='u') && pt[1]=='+' ) { |
| 124 |
pt += 2; |
| 125 |
val = strtol(pt,&end,16); |
| 126 |
if ( *end!='\0' ) { |
| 127 |
GTextFieldSelect(GWidgetGetControl(gw,cid),0,-1); |
| 128 |
GGadgetProtest8(name); |
| 129 |
*err = true; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
free(txt); |
| 134 |
return( val ); |
| 135 |
} |