22 #define INPUTBOX_PASSWD_CHAR '*' // the password protected char
27 return ((c >=
'a') && (c <=
'z')) || ((c >=
'A') && (c <=
'Z'));
77 for (n=strlen(s)-p; n>=0; n-- )
78 *(s+p+n+1) = *(s+p+
n);
86 for (; (*(s+
p) = *(s+p+n)) !=
'\0'; s++ )
90 void UI_INPUTBOX::init_cursor()
93 if ( cursor_first_frame < 0 ) {
97 cursor_elapsed_time=0;
98 cursor_current_frame=0;
106 Assert((
int) strlen(_text) <= _text_len);
118 text = (
char *)
vm_malloc( _text_len + 1);
126 passwd_text = (
char *)
vm_malloc(_text_len + 1);
128 passwd_text[strlen(_text)] = 0;
136 if ( _text_len > 0 ) {
137 strncpy( text, _text, _text_len );
140 position = strlen(_text);
141 oldposition = position;
146 pixel_limit = pixel_lim;
149 invalid_chars = NULL;
155 if(valid_chars != NULL){
166 if(invalid_chars != NULL){
168 invalid_chars = NULL;
174 void UI_INPUTBOX::destroy()
182 if(valid_chars != NULL){
188 if(invalid_chars != NULL){
190 invalid_chars = NULL;
201 void UI_INPUTBOX::draw()
203 int invis,
w1, h1, tw, th;
253 text_x += (w1 - tw)/2;
258 if (
flags & UI_INPUTBOX_FLAG_PASSWD){
267 if (cursor_first_frame == -1) {
275 if ( (time_delta / 1000.0
f) > (1.0
f / cursor_fps) ) {
277 cursor_elapsed_time += time_delta;
278 cursor_current_frame++;
279 if (cursor_current_frame >= cursor_nframes) {
280 cursor_current_frame = 0;
294 int UI_INPUTBOX::validate_input(
int chr)
311 if (isdigit(chr) || isalpha(chr)){
316 if(!valid_chars && !invalid_chars){
321 if((valid_chars) && strchr(valid_chars, chr)){
326 if((invalid_chars) && !strchr(invalid_chars,chr)){
333 void UI_INPUTBOX::process(
int focus)
350 oldposition = position;
366 if (
flags & UI_INPUTBOX_FLAG_PASSWD) {
367 passwd_text[position] = 0;
417 ascii = validate_input(key_check);
418 if ((ascii > 0) && (ascii < 255)) {
421 if ((position == 0) && !
is_letter((
char) ascii))
427 if ( position <
length ) {
428 text[position] = (char) ascii;
429 text[position + 1] = 0;
431 if (
flags & UI_INPUTBOX_FLAG_PASSWD) {
433 passwd_text[position + 1] = 0;
439 if (pixel_limit > -1) {
442 if (
flags & UI_INPUTBOX_FLAG_PASSWD) {
449 if (_w > pixel_limit) {
454 if (
flags & UI_INPUTBOX_FLAG_PASSWD) {
455 passwd_text[position] = 0;
486 strncpy(out, text,
length);
494 in_length = strlen(in);
500 if (
flags & UI_INPUTBOX_FLAG_PASSWD) {
502 passwd_text[strlen(text)] = 0;
505 position = in_length;
void gr_rect(int x, int y, int w, int h, int resize_mode)
void set_text(const char *in)
#define UI_INPUTBOX_FLAG_EAT_USED
#define GR_RESIZE_MENU_NO_OFFSET
#define UI_INPUTBOX_FLAG_LETTER_FIRST
GLfloat GLfloat GLfloat GLfloat h
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
#define UI_INPUTBOX_FLAG_NO_BACK
void base_create(UI_WINDOW *wnd, int _kind, int _x, int _y, int _w, int _h)
void gr_set_color_fast(color *dst)
#define UI_INPUTBOX_FLAG_ESC_FOC
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
int key_to_ascii(int keycode)
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads a bitmap sequance so we can draw with it.
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
#define UI_INPUTBOX_FLAG_PASSWD
void ui_draw_sunken_border(int x1, int y1, int x2, int y2)
#define UI_INPUTBOX_FLAG_NO_NUMERALS
#define UI_INPUTBOX_FLAG_NO_LETTERS
#define UI_INPUTBOX_FLAG_TEXT_CEN
GLint GLint GLint GLint GLint x
void ui_vline(int y1, int y2, int x)
GLubyte GLubyte GLubyte GLubyte w
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
void set_invalid_chars(char *ichars)
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, char *_text, int _flags=0, int pixel_lim=-1, color *clr=NULL)
#define UI_INPUTBOX_FLAG_INVIS
GLenum GLuint GLenum GLsizei length
void gr_bitmap(int _x, int _y, int resize_mode)
void set_valid_chars(char *vchars)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
void gr_set_font(int fontnum)
int timer_get_milliseconds()
#define UI_INPUTBOX_FLAG_KEYTHRU
#define UI_INPUTBOX_FLAG_ESC_CLR
UI_GADGET * selected_gadget