src/misc_gui.cpp
changeset 8028 e578ea22f371
parent 8019 fc0e94dee165
child 8032 f35fba9bacb0
equal deleted inserted replaced
8027:d26059c1971f 8028:e578ea22f371
  1014 	switch (e->we.keypress.keycode) {
  1014 	switch (e->we.keypress.keycode) {
  1015 	case WKC_ESC: return 2;
  1015 	case WKC_ESC: return 2;
  1016 	case WKC_RETURN: case WKC_NUM_ENTER: return 1;
  1016 	case WKC_RETURN: case WKC_NUM_ENTER: return 1;
  1017 	case (WKC_CTRL | 'V'):
  1017 	case (WKC_CTRL | 'V'):
  1018 		if (InsertTextBufferClipboard(&string->text))
  1018 		if (InsertTextBufferClipboard(&string->text))
  1019 			InvalidateWidget(w, wid);
  1019 			w->InvalidateWidget(wid);
  1020 		break;
  1020 		break;
  1021 	case (WKC_CTRL | 'U'):
  1021 	case (WKC_CTRL | 'U'):
  1022 		DeleteTextBufferAll(&string->text);
  1022 		DeleteTextBufferAll(&string->text);
  1023 		InvalidateWidget(w, wid);
  1023 		w->InvalidateWidget(wid);
  1024 		break;
  1024 		break;
  1025 	case WKC_BACKSPACE: case WKC_DELETE:
  1025 	case WKC_BACKSPACE: case WKC_DELETE:
  1026 		if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode))
  1026 		if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode))
  1027 			InvalidateWidget(w, wid);
  1027 			w->InvalidateWidget(wid);
  1028 		break;
  1028 		break;
  1029 	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
  1029 	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
  1030 		if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
  1030 		if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
  1031 			InvalidateWidget(w, wid);
  1031 			w->InvalidateWidget(wid);
  1032 		break;
  1032 		break;
  1033 	default:
  1033 	default:
  1034 		if (IsValidChar(e->we.keypress.key, string->afilter)) {
  1034 		if (IsValidChar(e->we.keypress.key, string->afilter)) {
  1035 			if (InsertTextBufferChar(&string->text, e->we.keypress.key)) {
  1035 			if (InsertTextBufferChar(&string->text, e->we.keypress.key)) {
  1036 				InvalidateWidget(w, wid);
  1036 				w->InvalidateWidget(wid);
  1037 			}
  1037 			}
  1038 		} else { // key wasn't caught. Continue only if standard entry specified
  1038 		} else { // key wasn't caught. Continue only if standard entry specified
  1039 			e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
  1039 			e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
  1040 		}
  1040 		}
  1041 	}
  1041 	}
  1055 	return false;
  1055 	return false;
  1056 }
  1056 }
  1057 
  1057 
  1058 void HandleEditBox(Window *w, querystr_d *string, int wid)
  1058 void HandleEditBox(Window *w, querystr_d *string, int wid)
  1059 {
  1059 {
  1060 	if (HandleCaret(&string->text)) InvalidateWidget(w, wid);
  1060 	if (HandleCaret(&string->text)) w->InvalidateWidget(wid);
  1061 }
  1061 }
  1062 
  1062 
  1063 void DrawEditBox(Window *w, querystr_d *string, int wid)
  1063 void DrawEditBox(Window *w, querystr_d *string, int wid)
  1064 {
  1064 {
  1065 	DrawPixelInfo dpi, *old_dpi;
  1065 	DrawPixelInfo dpi, *old_dpi;
  1562 					ShowHeightmapLoad();
  1562 					ShowHeightmapLoad();
  1563 				} else {
  1563 				} else {
  1564 					/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
  1564 					/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
  1565 					ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
  1565 					ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
  1566 					UpdateTextBufferSize(&WP(w, querystr_d).text);
  1566 					UpdateTextBufferSize(&WP(w, querystr_d).text);
  1567 					InvalidateWidget(w, 10);
  1567 					w->InvalidateWidget(10);
  1568 				}
  1568 				}
  1569 			} else {
  1569 			} else {
  1570 				/* Changed directory, need repaint. */
  1570 				/* Changed directory, need repaint. */
  1571 				SetWindowDirty(w);
  1571 				SetWindowDirty(w);
  1572 				BuildFileList();
  1572 				BuildFileList();