misc_gui.c
changeset 4955 e3496ee0e37d
parent 4949 fa564e9c2aea
child 4958 aaa8a92059bf
equal deleted inserted replaced
4954:d773d01b35f5 4955:e3496ee0e37d
   970 	if (HandleCaret(&string->text)) InvalidateWidget(w, wid);
   970 	if (HandleCaret(&string->text)) InvalidateWidget(w, wid);
   971 }
   971 }
   972 
   972 
   973 void DrawEditBox(Window *w, querystr_d *string, int wid)
   973 void DrawEditBox(Window *w, querystr_d *string, int wid)
   974 {
   974 {
   975 	const Widget *wi = w->widget + wid;
   975 	DrawPixelInfo dpi, *old_dpi;
       
   976 	int delta;
       
   977 	const Widget *wi = &w->widget[wid];
   976 	const Textbuf *tb = &string->text;
   978 	const Textbuf *tb = &string->text;
   977 
   979 
   978 	GfxFillRect(wi->left+1, wi->top+1, wi->right-1, wi->bottom-1, 215);
   980 	/* Limit the drawing of the string inside the widget boundaries */
   979 	DoDrawString(tb->buf, wi->left+2, wi->top+1, 8);
   981 	if (!FillDrawPixelInfo(&dpi,
   980 	if (tb->caret) DoDrawString("_", wi->left + 2 + tb->caretxoffs, wi->top + 1, 12);
   982 	     	wi->left + 4,
       
   983 	     	wi->top + 1,
       
   984 	     	wi->right - wi->left - 4,
       
   985 	     	wi->bottom - wi->top - 1)
       
   986 	) return;
       
   987 
       
   988 	GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
       
   989 
       
   990 	old_dpi = _cur_dpi;
       
   991 	_cur_dpi = &dpi;
       
   992 
       
   993 	/* We will take the current widget length as maximum width, with a small
       
   994 	 * space reserved at the end for the caret to show */
       
   995 	delta = (wi->right - wi->left) - tb->width - 10;
       
   996 	if (delta > 0) delta = 0;
       
   997 
       
   998 	if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
       
   999 
       
  1000 	DoDrawString(tb->buf, delta, 0, 8);
       
  1001 	if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, 12);
       
  1002 
       
  1003 	_cur_dpi = old_dpi;
   981 }
  1004 }
   982 
  1005 
   983 static void QueryStringWndProc(Window *w, WindowEvent *e)
  1006 static void QueryStringWndProc(Window *w, WindowEvent *e)
   984 {
  1007 {
   985 	static bool closed = false;
  1008 	static bool closed = false;