misc_gui.c
changeset 4909 955f318a24cd
parent 4884 94dd5df0d584
child 4912 0f51b47cb983
equal deleted inserted replaced
4908:96e6e645c54e 4909:955f318a24cd
   899 
   899 
   900 	tb->caretpos = tb->length;
   900 	tb->caretpos = tb->length;
   901 	tb->caretxoffs = tb->width;
   901 	tb->caretxoffs = tb->width;
   902 }
   902 }
   903 
   903 
   904 int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e, CharSetFilter afilter)
   904 int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e)
   905 {
   905 {
   906 	e->we.keypress.cont = false;
   906 	e->we.keypress.cont = false;
   907 
   907 
   908 	switch (e->we.keypress.keycode) {
   908 	switch (e->we.keypress.keycode) {
   909 	case WKC_ESC: return 2;
   909 	case WKC_ESC: return 2;
   923 	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
   923 	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
   924 		if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
   924 		if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
   925 			InvalidateWidget(w, wid);
   925 			InvalidateWidget(w, wid);
   926 		break;
   926 		break;
   927 	default:
   927 	default:
   928 		if (IsValidAsciiChar(e->we.keypress.ascii, afilter)) {
   928 		if (IsValidAsciiChar(e->we.keypress.ascii, string->afilter)) {
   929 			if (InsertTextBufferChar(&string->text, e->we.keypress.ascii))
   929 			if (InsertTextBufferChar(&string->text, e->we.keypress.ascii))
   930 				InvalidateWidget(w, wid);
   930 				InvalidateWidget(w, wid);
   931 		} else { // key wasn't caught. Continue only if standard entry specified
   931 		} else { // key wasn't caught. Continue only if standard entry specified
   932 			e->we.keypress.cont = (afilter == CS_ALPHANUMERAL);
   932 			e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
   933 		}
   933 		}
   934 	}
   934 	}
   935 
   935 
   936 	return 0;
   936 	return 0;
   937 }
   937 }
  1017 		}
  1017 		}
  1018 		HandleEditBox(w, &WP(w, querystr_d), 5);
  1018 		HandleEditBox(w, &WP(w, querystr_d), 5);
  1019 	} break;
  1019 	} break;
  1020 
  1020 
  1021 	case WE_KEYPRESS: {
  1021 	case WE_KEYPRESS: {
  1022 		switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e, WP(w, querystr_d).afilter)) {
  1022 		switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e)) {
  1023 		case 1: // Return
  1023 		case 1: // Return
  1024 			goto press_ok;
  1024 			goto press_ok;
  1025 		case 2: // Escape
  1025 		case 2: // Escape
  1026 			DeleteWindow(w);
  1026 			DeleteWindow(w);
  1027 			break;
  1027 			break;
  1453 			DeleteWindow(w);
  1453 			DeleteWindow(w);
  1454 			return;
  1454 			return;
  1455 		}
  1455 		}
  1456 
  1456 
  1457 		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
  1457 		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
  1458 			if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e, CS_ALPHANUMERAL) == 1) /* Press Enter */
  1458 			if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) /* Press Enter */
  1459 					HandleButtonClick(w, 12);
  1459 					HandleButtonClick(w, 12);
  1460 		}
  1460 		}
  1461 		break;
  1461 		break;
  1462 	case WE_TIMEOUT:
  1462 	case WE_TIMEOUT:
  1463 		if (IsWindowWidgetLowered(w, 11)) { /* Delete button clicked */
  1463 		if (IsWindowWidgetLowered(w, 11)) { /* Delete button clicked */
  1578 	LowerWindowWidget(w, 7);
  1578 	LowerWindowWidget(w, 7);
  1579 	WP(w,querystr_d).text.caret = false;
  1579 	WP(w,querystr_d).text.caret = false;
  1580 	WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf);
  1580 	WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf);
  1581 	WP(w,querystr_d).text.maxwidth = 240;
  1581 	WP(w,querystr_d).text.maxwidth = 240;
  1582 	WP(w,querystr_d).text.buf = _edit_str_buf;
  1582 	WP(w,querystr_d).text.buf = _edit_str_buf;
       
  1583 	WP(w,querystr_d).afilter = CS_ALPHANUMERAL;
  1583 	UpdateTextBufferSize(&WP(w, querystr_d).text);
  1584 	UpdateTextBufferSize(&WP(w, querystr_d).text);
  1584 
  1585 
  1585 	// pause is only used in single-player, non-editor mode, non-menu mode. It
  1586 	// pause is only used in single-player, non-editor mode, non-menu mode. It
  1586 	// will be unpaused in the WE_DESTROY event handler.
  1587 	// will be unpaused in the WE_DESTROY event handler.
  1587 	if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
  1588 	if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {