(svn r4312) Calculate the maximum pixel width of the entered text in the chat box from the "text box"-widget instead of hardcoding an arbitrary - and wrong - number
authortron
Fri, 07 Apr 2006 08:57:03 +0000
changeset 3467 4ddbab0eb586
parent 3466 b17ee472b2af
child 3468 ec6463161999
(svn r4312) Calculate the maximum pixel width of the entered text in the chat box from the "text box"-widget instead of hardcoding an arbitrary - and wrong - number
gui.h
main_gui.c
network_gui.c
--- a/gui.h	Fri Apr 07 08:42:30 2006 +0000
+++ b/gui.h	Fri Apr 07 08:57:03 2006 +0000
@@ -124,7 +124,7 @@
 
 /* network gui */
 void ShowNetworkGameWindow(void);
-void ShowChatWindow(int maxlen, int maxwidth, WindowClass window_class, WindowNumber window_number);
+void ShowChatWindow(int maxlen, WindowClass window_class, WindowNumber window_number);
 
 /* bridge_gui.c */
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
--- a/main_gui.c	Fri Apr 07 08:42:30 2006 +0000
+++ b/main_gui.c	Fri Apr 07 08:57:03 2006 +0000
@@ -332,7 +332,7 @@
 {
 	_rename_id = desttype + (dest << 8);
 	_rename_what = 2;
-	ShowChatWindow(150, 338, 1, 0);
+	ShowChatWindow(150, 1, 0);
 }
 
 void ShowNetworkGiveMoneyWindow(byte player)
--- a/network_gui.c	Fri Apr 07 08:42:30 2006 +0000
+++ b/network_gui.c	Fri Apr 07 08:57:03 2006 +0000
@@ -1545,7 +1545,7 @@
 	ChatWindowWndProc
 };
 
-void ShowChatWindow(int maxlen, int maxwidth, WindowClass window_class, WindowNumber window_number)
+void ShowChatWindow(int maxlen, WindowClass window_class, WindowNumber window_number)
 {
 	Window *w;
 
@@ -1561,7 +1561,7 @@
 	WP(w,querystr_d).wnd_num = window_number;
 	WP(w,querystr_d).text.caret = false;
 	WP(w,querystr_d).text.maxlength = maxlen;
-	WP(w,querystr_d).text.maxwidth = maxwidth;
+	WP(w,querystr_d).text.maxwidth = w->widget[1].right - w->widget[1].left - 2; // widget[1] is the "text box"
 	WP(w,querystr_d).text.buf = _edit_str_buf;
 	UpdateTextBufferSize(&WP(w, querystr_d).text);
 }