X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/af282e3b62c5113c046a9ef88ff1f36f24e0b04f..5dc6132d3a8e6e4048698bf1914b486f9cf41e2c:/winctrls.c diff --git a/winctrls.c b/winctrls.c index 61821c31..53228236 100644 --- a/winctrls.c +++ b/winctrls.c @@ -153,13 +153,11 @@ void multiedit(struct ctlpos *cp, ...) } /* - * A static line, followed by a full-width drop-down list (ie a - * non-editing combo box). + * A static line, followed by a full-width combo box. */ -void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid) +void combobox(struct ctlpos *cp, char *text, int staticid, int listid) { RECT r; - va_list ap; r.left = GAPBETWEEN; r.right = cp->width; @@ -171,7 +169,7 @@ void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid) r.bottom = COMBOHEIGHT * 10; doctl(cp, r, "COMBOBOX", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | - CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid); + CBS_DROPDOWN | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid); cp->ypos += STATICHEIGHT + GAPWITHIN + COMBOHEIGHT + GAPBETWEEN; } @@ -317,14 +315,14 @@ void checkbox(struct ctlpos *cp, char *text, int id) /* * A single standalone static text control. */ -void statictext(struct ctlpos *cp, char *text, int id) +void statictext(struct ctlpos *cp, char *text, int lines, int id) { RECT r; r.left = GAPBETWEEN; r.top = cp->ypos; r.right = cp->width; - r.bottom = STATICHEIGHT; + r.bottom = STATICHEIGHT * lines; cp->ypos += r.bottom + GAPBETWEEN; doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, text, id); } @@ -450,6 +448,40 @@ void staticpassedit(struct ctlpos *cp, char *stext, } /* + * A drop-down list box on the right hand side, with a static to + * its left. + */ +void staticddl(struct ctlpos *cp, char *stext, + int sid, int lid, int percentlist) +{ + const int height = (COMBOHEIGHT > STATICHEIGHT ? + COMBOHEIGHT : STATICHEIGHT); + RECT r; + int lwid, rwid, rpos; + + rpos = + GAPBETWEEN + (100 - percentlist) * (cp->width + GAPBETWEEN) / 100; + lwid = rpos - 2 * GAPBETWEEN; + rwid = cp->width + GAPBETWEEN - rpos; + + r.left = GAPBETWEEN; + r.top = cp->ypos + (height - STATICHEIGHT) / 2; + r.right = lwid; + r.bottom = STATICHEIGHT; + doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, stext, sid); + + r.left = rpos; + r.top = cp->ypos + (height - EDITHEIGHT) / 2; + r.right = rwid; + r.bottom = COMBOHEIGHT*4; + doctl(cp, r, "COMBOBOX", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | + CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", lid); + + cp->ypos += height + GAPBETWEEN; +} + +/* * A big multiline edit control with a static labelling it. */ void bigeditctrl(struct ctlpos *cp, char *stext, @@ -714,7 +746,7 @@ void charclass(struct ctlpos *cp, char *stext, int sid, int listid, PUSHBTNHEIGHT ? EDITHEIGHT : PUSHBTNHEIGHT); const static int percents[] = { 30, 40, 30 }; int i, xpos, percent; - const int LISTHEIGHT = 66; + const int LISTHEIGHT = 52; /* The static control. */ r.left = GAPBETWEEN; @@ -995,7 +1027,7 @@ int handle_prefslist(struct prefslist *hdl, if (is_dlmsg) { - if (wParam == hdl->listid) { + if ((int)wParam == hdl->listid) { DRAGLISTINFO *dlm = (DRAGLISTINFO *)lParam; int dest; switch (dlm->uNotification) { @@ -1026,20 +1058,20 @@ int handle_prefslist(struct prefslist *hdl, SetWindowLong(hwnd, DWL_MSGRESULT, DL_STOPCURSOR); ret = 1; break; case DL_DROPPED: - ret = 1; - if (!hdl->dragging) break; - dest = pl_itemfrompt(dlm->hWnd, dlm->ptCursor, TRUE); - if (dest > hdl->dummyitem) dest = hdl->dummyitem; - DrawInsert (hwnd, dlm->hWnd, -1); + if (hdl->dragging) { + dest = pl_itemfrompt(dlm->hWnd, dlm->ptCursor, TRUE); + if (dest > hdl->dummyitem) dest = hdl->dummyitem; + DrawInsert (hwnd, dlm->hWnd, -1); + } SendDlgItemMessage(hwnd, hdl->listid, LB_DELETESTRING, hdl->dummyitem, 0); - hdl->dragging = 0; - if (dest >= 0) { - /* Correct for "missing" item. This means you can't drag - * an item to the end, but that seems to be the way this - * control is used. */ - if (dest > hdl->srcitem) dest--; - pl_moveitem(hwnd, hdl->listid, hdl->srcitem, dest); + if (hdl->dragging) { + hdl->dragging = 0; + if (dest >= 0) { + /* Correct for "missing" item. */ + if (dest > hdl->srcitem) dest--; + pl_moveitem(hwnd, hdl->listid, hdl->srcitem, dest); + } } ret = 1; break; } @@ -1107,14 +1139,17 @@ void progressbar(struct ctlpos *cp, int id) * Another special control: the forwarding options setter. First a * list box; next a static header line, introducing a pair of edit * boxes with associated statics, another button, and a radio - * button pair. + * button pair. Then we have a bareradioline, which is included in + * this control group because it belongs before the `Add' button in + * the tab order. */ void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid, char *e1stext, int e1sid, int e1id, char *e2stext, int e2sid, int e2id, - char *btext, int bid) + char *btext, int bid, + char *r1text, int r1id, char *r2text, int r2id) { - RECT r; + RECT r, button_r; const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ? STATICHEIGHT : EDITHEIGHT > @@ -1163,11 +1198,19 @@ void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, WS_EX_CLIENTEDGE, "", j == 0 ? e1id : e2id); } else if (i == 3) { - doctl(cp, r, "BUTTON", - WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, - 0, btext, bid); + /* + * We postpone creation of the button until we've + * done everything else, since it belongs last in + * the tab order. + */ + button_r = r; /* structure copy */ } } cp->ypos += height + GAPWITHIN; } + bareradioline(cp, 2, r1text, r1id, r2text, r2id, NULL); + /* Create the postponed button. */ + doctl(cp, button_r, "BUTTON", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, + 0, btext, bid); }