-static void ctlposinit(struct ctlpos *cp, HWND hwnd,
- int leftborder, int rightborder, int topborder) {
- RECT r, r2;
- cp->hwnd = hwnd;
- cp->font = SendMessage(hwnd, WM_GETFONT, 0, 0);
- cp->ypos = topborder;
- GetClientRect(hwnd, &r);
- r2.left = r2.top = 0;
- r2.right = 4;
- r2.bottom = 8;
- MapDialogRect(hwnd, &r2);
- cp->dlu4inpix = r2.right;
- cp->width = (r.right * 4) / (r2.right) - 2*GAPBETWEEN;
- cp->xoff = leftborder;
- cp->width -= leftborder + rightborder;
-}
-
-static void doctl(struct ctlpos *cp, RECT r,
- char *wclass, int wstyle, int exstyle,
- char *wtext, int wid) {
- HWND ctl;
- /*
- * Note nonstandard use of RECT. This is deliberate: by
- * transforming the width and height directly we arrange to
- * have all supposedly same-sized controls really same-sized.
- */
-
- r.left += cp->xoff;
- MapDialogRect(cp->hwnd, &r);
-
- ctl = CreateWindowEx(exstyle, wclass, wtext, wstyle,
- r.left, r.top, r.right, r.bottom,
- cp->hwnd, (HMENU)wid, hinst, NULL);
- SendMessage(ctl, WM_SETFONT, cp->font, MAKELPARAM(TRUE, 0));
-}
-
-/*
- * A title bar across the top of a sub-dialog.
- */
-static void bartitle(struct ctlpos *cp, char *name, int id) {
- RECT r;
-
- r.left = GAPBETWEEN; r.right = cp->width;
- r.top = cp->ypos; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPBETWEEN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, name, id);
-}
-
-/*
- * Begin a grouping box, with or without a group title.
- */
-static void beginbox(struct ctlpos *cp, char *name, int idbox, int idtext) {
- if (name)
- cp->ypos += STATICHEIGHT/2;
- cp->boxystart = cp->ypos;
- if (name)
- cp->ypos += STATICHEIGHT - (STATICHEIGHT/2);
- cp->ypos += GAPYBOX;
- cp->width -= 2*GAPXBOX;
- cp->xoff += GAPXBOX;
- cp->boxid = idbox;
- cp->boxtextid = idtext;
- cp->boxtext = name;
-}
-
-/*
- * End a grouping box.
- */
-static void endbox(struct ctlpos *cp) {
- RECT r;
- cp->xoff -= GAPXBOX;
- cp->width += 2*GAPXBOX;
- cp->ypos += GAPYBOX - GAPBETWEEN;
- r.left = GAPBETWEEN; r.right = cp->width;
- r.top = cp->boxystart; r.bottom = cp->ypos - cp->boxystart;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE | SS_ETCHEDFRAME, 0,
- "", cp->boxid);
- if (cp->boxtext) {
- SIZE s;
- HDC hdc;
- HFONT oldfont, dlgfont;
- hdc = GetDC(cp->hwnd);
- dlgfont = (HFONT)cp->font;
- oldfont = SelectObject(hdc, dlgfont);
- GetTextExtentPoint32(hdc, cp->boxtext, strlen(cp->boxtext), &s);
- SelectObject(hdc, oldfont);
- DeleteDC(hdc);
- r.left = GAPXBOX + GAPBETWEEN;
- r.right = (s.cx * 4 + cp->dlu4inpix-1) / cp->dlu4inpix;
-
- r.top = cp->boxystart - STATICHEIGHT/2; r.bottom = STATICHEIGHT;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0,
- cp->boxtext, cp->boxtextid);
- }
- cp->ypos += GAPYBOX;
-}
-
-/*
- * Some edit boxes. Each one has a static above it. The percentages
- * of the horizontal space are provided.
- */
-static void multiedit(struct ctlpos *cp, ...) {
- RECT r;
- va_list ap;
- int percent, xpos;
-
- percent = xpos = 0;
- va_start(ap, cp);
- while (1) {
- char *text;
- int staticid, editid, pcwidth;
- text = va_arg(ap, char *);
- if (!text)
- break;
- staticid = va_arg(ap, int);
- editid = va_arg(ap, int);
- pcwidth = va_arg(ap, int);
-
- r.left = xpos + GAPBETWEEN;
- percent += pcwidth;
- xpos = (cp->width + GAPBETWEEN) * percent / 100;
- r.right = xpos - r.left;
-
- r.top = cp->ypos; r.bottom = STATICHEIGHT;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0,
- text, staticid);
- r.top = cp->ypos + 8 + GAPWITHIN; r.bottom = EDITHEIGHT;
- doctl(cp, r, "EDIT",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
- WS_EX_CLIENTEDGE,
- "", editid);
- }
- va_end(ap);
- cp->ypos += 8+GAPWITHIN+12+GAPBETWEEN;
-}
-
-/*
- * A set of radio buttons on the same line, with a static above
- * them. `nacross' dictates how many parts the line is divided into
- * (you might want this not to equal the number of buttons if you
- * needed to line up some 2s and some 3s to look good in the same
- * panel).
- */
-static void radioline(struct ctlpos *cp,
- char *text, int id, int nacross, ...) {
- RECT r;
- va_list ap;
- int group;
- int i;
-
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, text, id);
- va_start(ap, nacross);
- group = WS_GROUP;
- i = 0;
- while (1) {
- char *btext;
- int bid;
- btext = va_arg(ap, char *);
- if (!btext)
- break;
- bid = va_arg(ap, int);
- r.left = GAPBETWEEN + i * (cp->width+GAPBETWEEN)/nacross;
- r.right = (i+1) * (cp->width+GAPBETWEEN)/nacross - r.left;
- r.top = cp->ypos; r.bottom = RADIOHEIGHT;
- doctl(cp, r, "BUTTON",
- BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP | group,
- 0,
- btext, bid);
- group = 0;
- i++;
- }
- va_end(ap);
- cp->ypos += r.bottom + GAPBETWEEN;
-}
-
-/*
- * A set of radio buttons on multiple lines, with a static above
- * them.
- */
-static void radiobig(struct ctlpos *cp, char *text, int id, ...) {
- RECT r;
- va_list ap;
- int group;
-
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, text, id);
- va_start(ap, id);
- group = WS_GROUP;
- while (1) {
- char *btext;
- int bid;
- btext = va_arg(ap, char *);
- if (!btext)
- break;
- bid = va_arg(ap, int);
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "BUTTON",
- BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP | group,
- 0,
- btext, bid);
- group = 0;
- }
- va_end(ap);
- cp->ypos += GAPBETWEEN - GAPWITHIN;
-}
-
-/*
- * A single standalone checkbox.
- */
-static void checkbox(struct ctlpos *cp, char *text, int id) {
- RECT r;
-
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = CHECKBOXHEIGHT;
- cp->ypos += r.bottom + GAPBETWEEN;
- doctl(cp, r, "BUTTON",
- BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0,
- text, id);
-}
-
-/*
- * A button on the right hand side, with a static to its left.
- */
-static void staticbtn(struct ctlpos *cp, char *stext, int sid,
- char *btext, int bid) {
- const int height = (PUSHBTNHEIGHT > STATICHEIGHT ?
- PUSHBTNHEIGHT : STATICHEIGHT);
- RECT r;
- int lwid, rwid, rpos;
-
- rpos = GAPBETWEEN + 3 * (cp->width + GAPBETWEEN) / 4;
- 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-PUSHBTNHEIGHT)/2;
- r.right = rwid; r.bottom = PUSHBTNHEIGHT;
- doctl(cp, r, "BUTTON",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
- 0,
- btext, bid);
-
- cp->ypos += height + GAPBETWEEN;
-}
-
-/*
- * An edit control on the right hand side, with a static to its left.
- */
-static void staticedit(struct ctlpos *cp, char *stext,
- int sid, int eid, int percentedit) {
- const int height = (EDITHEIGHT > STATICHEIGHT ?
- EDITHEIGHT : STATICHEIGHT);
- RECT r;
- int lwid, rwid, rpos;
-
- rpos = GAPBETWEEN + (100-percentedit) * (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 = EDITHEIGHT;
- doctl(cp, r, "EDIT",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
- WS_EX_CLIENTEDGE,
- "", eid);
-
- cp->ypos += height + GAPBETWEEN;
-}
-
-/*
- * A tab-control substitute when a real tab control is unavailable.
- */
-static void ersatztab(struct ctlpos *cp, char *stext, int sid,
- int lid, int s2id) {
- const int height = (COMBOHEIGHT > STATICHEIGHT ?
- COMBOHEIGHT : STATICHEIGHT);
- RECT r;
- int bigwid, lwid, rwid, rpos;
- static const int BIGGAP = 15;
- static const int MEDGAP = 3;
-
- bigwid = cp->width + 2*GAPBETWEEN - 2*BIGGAP;
- cp->ypos += MEDGAP;
- rpos = BIGGAP + (bigwid + BIGGAP) / 2;
- lwid = rpos - 2*BIGGAP;
- rwid = bigwid + BIGGAP - rpos;
-
- r.left = BIGGAP; 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-COMBOHEIGHT)/2;
- r.right = rwid; r.bottom = COMBOHEIGHT*10;
- doctl(cp, r, "COMBOBOX",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP |
- CBS_DROPDOWNLIST | CBS_HASSTRINGS,
- WS_EX_CLIENTEDGE,
- "", lid);
-
- cp->ypos += height + MEDGAP + GAPBETWEEN;
-
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = 2;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ,
- 0, "", s2id);
-}
-
-/*
- * A static line, followed by an edit control on the left hand side
- * and a button on the right.
- */
-static void editbutton(struct ctlpos *cp, char *stext, int sid,
- int eid, char *btext, int bid) {
- const int height = (EDITHEIGHT > PUSHBTNHEIGHT ?
- EDITHEIGHT : PUSHBTNHEIGHT);
- RECT r;
- int lwid, rwid, rpos;
-
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, stext, sid);
-
- rpos = GAPBETWEEN + 3 * (cp->width + GAPBETWEEN) / 4;
- lwid = rpos - 2*GAPBETWEEN;
- rwid = cp->width + GAPBETWEEN - rpos;
-
- r.left = GAPBETWEEN; r.top = cp->ypos + (height-EDITHEIGHT)/2;
- r.right = lwid; r.bottom = EDITHEIGHT;
- doctl(cp, r, "EDIT",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
- WS_EX_CLIENTEDGE,
- "", eid);
-
- r.left = rpos; r.top = cp->ypos + (height-PUSHBTNHEIGHT)/2;
- r.right = rwid; r.bottom = PUSHBTNHEIGHT;
- doctl(cp, r, "BUTTON",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
- 0,
- btext, bid);
-
- cp->ypos += height + GAPBETWEEN;
-}
-
-/*
- * Special control which was hard to describe generically: the
- * session-saver assembly. A static; below that an edit box; below
- * that a list box. To the right of the list box, a column of
- * buttons.
- */
-static void sesssaver(struct ctlpos *cp, char *text,
- int staticid, int editid, int listid, ...) {
- RECT r;
- va_list ap;
- int lwid, rwid, rpos;
- int y;
- const int LISTDEFHEIGHT = 66;
-
- rpos = GAPBETWEEN + 3 * (cp->width + GAPBETWEEN) / 4;
- lwid = rpos - 2*GAPBETWEEN;
- rwid = cp->width + GAPBETWEEN - rpos;
-
- /* The static control. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = lwid; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, text, staticid);
-
- /* The edit control. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = lwid; r.bottom = EDITHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "EDIT",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
- WS_EX_CLIENTEDGE,
- "", editid);
-
- /*
- * The buttons (we should hold off on the list box until we
- * know how big the buttons are).
- */
- va_start(ap, listid);
- y = cp->ypos;
- while (1) {
- char *btext = va_arg(ap, char *);
- int bid;
- if (!btext) break;
- bid = va_arg(ap, int);
- r.left = rpos; r.top = y;
- r.right = rwid; r.bottom = PUSHBTNHEIGHT;
- y += r.bottom + GAPWITHIN;
- doctl(cp, r, "BUTTON",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
- 0,
- btext, bid);
- }
-
- /* Compute list box height. LISTDEFHEIGHT, or height of buttons. */
- y -= cp->ypos;
- y -= GAPWITHIN;
- if (y < LISTDEFHEIGHT) y = LISTDEFHEIGHT;
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = lwid; r.bottom = y;
- cp->ypos += y + GAPBETWEEN;
- doctl(cp, r, "LISTBOX",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL |
- LBS_NOTIFY | LBS_HASSTRINGS,
- WS_EX_CLIENTEDGE,
- "", listid);
-}
-
-/*
- * Another special control: the environment-variable setter. A
- * static line first; then a pair of edit boxes with associated
- * statics, and two buttons; then a list box.
- */
-static void envsetter(struct ctlpos *cp, char *stext, int sid,
- char *e1stext, int e1sid, int e1id,
- char *e2stext, int e2sid, int e2id,
- int listid,
- char *b1text, int b1id, char *b2text, int b2id) {
- RECT r;
- const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
- STATICHEIGHT :
- EDITHEIGHT > PUSHBTNHEIGHT ?
- EDITHEIGHT : PUSHBTNHEIGHT);
- const static int percents[] = { 20, 35, 10, 25 };
- int i, j, xpos, percent;
- const int LISTHEIGHT = 42;
-
- /* The static control. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, stext, sid);
-
- /* The statics+edits+buttons. */
- for (j = 0; j < 2; j++) {
- percent = 10;
- for (i = 0; i < 4; i++) {
- xpos = (cp->width + GAPBETWEEN) * percent / 100;
- r.left = xpos + GAPBETWEEN;
- percent += percents[i];
- xpos = (cp->width + GAPBETWEEN) * percent / 100;
- r.right = xpos - r.left;
- r.top = cp->ypos;
- r.bottom = (i==0 ? STATICHEIGHT :
- i==1 ? EDITHEIGHT :
- PUSHBTNHEIGHT);
- r.top += (height-r.bottom)/2;
- if (i==0) {
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0,
- j==0 ? e1stext : e2stext, j==0 ? e1sid : e2sid);
- } else if (i==1) {
- doctl(cp, r, "EDIT",
- 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,
- j==0 ? b1text : b2text, j==0 ? b1id : b2id);
- }
- }
- cp->ypos += height + GAPWITHIN;
- }
-
- /* The list box. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = LISTHEIGHT;
- cp->ypos += r.bottom + GAPBETWEEN;
- doctl(cp, r, "LISTBOX",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | LBS_HASSTRINGS |
- LBS_USETABSTOPS,
- WS_EX_CLIENTEDGE,
- "", listid);
-}
-
-/*
- * Yet another special control: the character-class setter. A
- * static, then a list, then a line containing a
- * button-and-static-and-edit.
- */
-static void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
- char *btext, int bid, int eid, char *s2text, int s2id) {
- RECT r;
- const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
- STATICHEIGHT :
- EDITHEIGHT > PUSHBTNHEIGHT ?
- EDITHEIGHT : PUSHBTNHEIGHT);
- const static int percents[] = { 30, 40, 30 };
- int i, xpos, percent;
- const int LISTHEIGHT = 66;
-
- /* The static control. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, stext, sid);
-
- /* The list box. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = LISTHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "LISTBOX",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | LBS_HASSTRINGS |
- LBS_USETABSTOPS,
- WS_EX_CLIENTEDGE,
- "", listid);
-
- /* The button+static+edit. */
- percent = xpos = 0;
- for (i = 0; i < 3; i++) {
- r.left = xpos + GAPBETWEEN;
- percent += percents[i];
- xpos = (cp->width + GAPBETWEEN) * percent / 100;
- r.right = xpos - r.left;
- r.top = cp->ypos;
- r.bottom = (i==0 ? PUSHBTNHEIGHT :
- i==1 ? STATICHEIGHT :
- EDITHEIGHT);
- r.top += (height-r.bottom)/2;
- if (i==0) {
- doctl(cp, r, "BUTTON",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
- 0, btext, bid);
- } else if (i==1) {
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE | SS_CENTER,
- 0, s2text, s2id);
- } else if (i==2) {
- doctl(cp, r, "EDIT",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
- WS_EX_CLIENTEDGE, "", eid);
- }
- }
- cp->ypos += height + GAPBETWEEN;
-}
-
-/*
- * A special control (horrors!). The colour editor. A static line;
- * then on the left, a list box, and on the right, a sequence of
- * two-part statics followed by a button.
- */
-static void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
- char *btext, int bid, ...) {
- RECT r;
- int y;
- va_list ap;
- int lwid, rwid, rpos;
- const int LISTHEIGHT = 66;
-
- /* The static control. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = cp->width; r.bottom = STATICHEIGHT;
- cp->ypos += r.bottom + GAPWITHIN;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, stext, sid);
-
- rpos = GAPBETWEEN + 2 * (cp->width + GAPBETWEEN) / 3;
- lwid = rpos - 2*GAPBETWEEN;
- rwid = cp->width + GAPBETWEEN - rpos;
-
- /* The list box. */
- r.left = GAPBETWEEN; r.top = cp->ypos;
- r.right = lwid; r.bottom = LISTHEIGHT;
- doctl(cp, r, "LISTBOX",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | LBS_HASSTRINGS |
- LBS_USETABSTOPS,
- WS_EX_CLIENTEDGE,
- "", listid);
-
- /* The statics. */
- y = cp->ypos;
- va_start(ap, bid);
- while (1) {
- char *ltext;
- int lid, rid;
- ltext = va_arg(ap, char *);
- if (!ltext) break;
- lid = va_arg(ap, int);
- rid = va_arg(ap, int);
- r.top = y; r.bottom = STATICHEIGHT;
- y += r.bottom + GAPWITHIN;
- r.left = rpos; r.right = rwid/2;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, ltext, lid);
- r.left = rpos + r.right; r.right = rwid - r.right;
- doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0, "", rid);
- }
- va_end(ap);
-
- /* The button. */
- r.top = y + 2*GAPWITHIN; r.bottom = PUSHBTNHEIGHT;
- r.left = rpos; r.right = rwid;
- doctl(cp, r, "BUTTON",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
- 0, btext, bid);
-
- cp->ypos += LISTHEIGHT + GAPBETWEEN;
-}
-
-static char savedsession[2048];
-
-enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
-
- sessionpanelstart,
- IDC_TITLE_SESSION,
- IDC_BOX_SESSION1, IDC_BOXT_SESSION1,
- IDC_BOX_SESSION2, IDC_BOXT_SESSION2,
- IDC_BOX_SESSION3,
- IDC_HOSTSTATIC,
- IDC_HOST,
- IDC_PORTSTATIC,
- IDC_PORT,
- IDC_PROTSTATIC,
- IDC_PROTRAW,
- IDC_PROTTELNET,
- IDC_PROTSSH,
- IDC_SESSSTATIC,
- IDC_SESSEDIT,
- IDC_SESSLIST,
- IDC_SESSLOAD,
- IDC_SESSSAVE,
- IDC_SESSDEL,
- IDC_CLOSEEXIT,
- sessionpanelend,
-
- keyboardpanelstart,
- IDC_TITLE_KEYBOARD,
- IDC_BOX_KEYBOARD1, IDC_BOXT_KEYBOARD1,
- IDC_BOX_KEYBOARD2, IDC_BOXT_KEYBOARD2,
- IDC_DELSTATIC,
- IDC_DEL008,
- IDC_DEL127,
- IDC_HOMESTATIC,
- IDC_HOMETILDE,
- IDC_HOMERXVT,
- IDC_FUNCSTATIC,
- IDC_FUNCTILDE,
- IDC_FUNCLINUX,
- IDC_FUNCXTERM,
- IDC_FUNCVT400,
- IDC_KPSTATIC,
- IDC_KPNORMAL,
- IDC_KPAPPLIC,
- IDC_KPNH,
- IDC_CURSTATIC,
- IDC_CURNORMAL,
- IDC_CURAPPLIC,
- keyboardpanelend,
-
- terminalpanelstart,
- IDC_TITLE_TERMINAL,
- IDC_BOX_TERMINAL1, IDC_BOXT_TERMINAL1,
- IDC_BOX_TERMINAL2, IDC_BOXT_TERMINAL2,
- IDC_BOX_TERMINAL3, IDC_BOXT_TERMINAL3,
- IDC_WRAPMODE,
- IDC_DECOM,
- IDC_DIMSTATIC,
- IDC_ROWSSTATIC,
- IDC_ROWSEDIT,
- IDC_COLSSTATIC,
- IDC_COLSEDIT,
- IDC_LOCKSIZE,
- IDC_FONTSTATIC,
- IDC_CHOOSEFONT,
- IDC_LFHASCR,
- IDC_BEEP,
- IDC_BCE,
- IDC_BLINKTEXT,
- IDC_LDISCTERM,
- terminalpanelend,
-
- windowpanelstart,
- IDC_TITLE_WINDOW,
- IDC_BOX_WINDOW1, IDC_BOXT_WINDOW1,
- IDC_BOX_WINDOW2, IDC_BOXT_WINDOW2,
- IDC_BOX_WINDOW3, IDC_BOXT_WINDOW3,
- IDC_BOX_WINDOW4,
- IDC_WINNAME,
- IDC_BLINKCUR,
- IDC_SCROLLBAR,
- IDC_WINTITLE,
- IDC_WINEDIT,
- IDC_CLOSEWARN,
- IDC_SAVESTATIC,
- IDC_SAVEEDIT,
- IDC_ALTF4,
- IDC_ALTSPACE,
- IDC_SCROLLKEY,
- windowpanelend,
-
- connectionpanelstart,
- IDC_TITLE_CONNECTION,
- IDC_BOX_CONNECTION1, IDC_BOXT_CONNECTION1,
- IDC_BOX_CONNECTION2, IDC_BOXT_CONNECTION2,
- IDC_TTSTATIC,
- IDC_TTEDIT,
- IDC_LOGSTATIC,
- IDC_LOGEDIT,
- IDC_PINGSTATIC,
- IDC_PINGEDIT,
- connectionpanelend,
-
- telnetpanelstart,
- IDC_TITLE_TELNET,
- IDC_BOX_TELNET1, IDC_BOXT_TELNET1,
- IDC_BOX_TELNET2, IDC_BOXT_TELNET2,
- IDC_TSSTATIC,
- IDC_TSEDIT,
- IDC_ENVSTATIC,
- IDC_VARSTATIC,
- IDC_VAREDIT,
- IDC_VALSTATIC,
- IDC_VALEDIT,
- IDC_ENVLIST,
- IDC_ENVADD,
- IDC_ENVREMOVE,
- IDC_EMSTATIC,
- IDC_EMBSD,
- IDC_EMRFC,
- telnetpanelend,
-
- sshpanelstart,
- IDC_TITLE_SSH,
- IDC_BOX_SSH1, IDC_BOXT_SSH1,
- IDC_BOX_SSH2, IDC_BOXT_SSH2,
- IDC_BOX_SSH3, IDC_BOXT_SSH3,
- IDC_NOPTY,
- IDC_CIPHERSTATIC,
- IDC_CIPHER3DES,
- IDC_CIPHERBLOWF,
- IDC_CIPHERDES,
- IDC_BUGGYMAC,
- IDC_AUTHTIS,
- IDC_PKSTATIC,
- IDC_PKEDIT,
- IDC_PKBUTTON,
- IDC_SSHPROTSTATIC,
- IDC_SSHPROT1,
- IDC_SSHPROT2,
- IDC_AGENTFWD,
- IDC_CMDSTATIC,
- IDC_CMDEDIT,
- sshpanelend,
-
- selectionpanelstart,
- IDC_TITLE_SELECTION,
- IDC_BOX_SELECTION1, IDC_BOXT_SELECTION1,
- IDC_BOX_SELECTION2, IDC_BOXT_SELECTION2,
- IDC_MBSTATIC,
- IDC_MBWINDOWS,
- IDC_MBXTERM,
- IDC_CCSTATIC,
- IDC_CCLIST,
- IDC_CCSET,
- IDC_CCSTATIC2,
- IDC_CCEDIT,
- selectionpanelend,
-
- colourspanelstart,
- IDC_TITLE_COLOURS,
- IDC_BOX_COLOURS1, IDC_BOXT_COLOURS1,
- IDC_BOX_COLOURS2, IDC_BOXT_COLOURS2,
- IDC_BOLDCOLOUR,
- IDC_PALETTE,
- IDC_STATIC,
- IDC_LIST,
- IDC_RSTATIC,
- IDC_GSTATIC,
- IDC_BSTATIC,
- IDC_RVALUE,
- IDC_GVALUE,
- IDC_BVALUE,
- IDC_CHANGE,
- colourspanelend,
-
- translationpanelstart,
- IDC_TITLE_TRANSLATION,
- IDC_BOX_TRANSLATION1, IDC_BOXT_TRANSLATION1,
- IDC_BOX_TRANSLATION2, IDC_BOXT_TRANSLATION2,
- IDC_BOX_TRANSLATION3, IDC_BOXT_TRANSLATION3,
- IDC_XLATSTATIC,
- IDC_NOXLAT,
- IDC_KOI8WIN1251,
- IDC_88592WIN1250,
- IDC_88592CP852,
- IDC_CAPSLOCKCYR,
- IDC_VTSTATIC,
- IDC_VTXWINDOWS,
- IDC_VTOEMANSI,
- IDC_VTOEMONLY,
- IDC_VTPOORMAN,
- translationpanelend,
-
- controlendvalue
-};
-
-static const char *const colours[] = {
- "Default Foreground", "Default Bold Foreground",
- "Default Background", "Default Bold Background",
- "Cursor Text", "Cursor Colour",
- "ANSI Black", "ANSI Black Bold",
- "ANSI Red", "ANSI Red Bold",
- "ANSI Green", "ANSI Green Bold",
- "ANSI Yellow", "ANSI Yellow Bold",
- "ANSI Blue", "ANSI Blue Bold",
- "ANSI Magenta", "ANSI Magenta Bold",
- "ANSI Cyan", "ANSI Cyan Bold",
- "ANSI White", "ANSI White Bold"
-};
-static const int permcolour[] = {
- TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
- TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
- TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
-};
-
-static void fmtfont (char *buf) {
- sprintf (buf, "Font: %s, ", cfg.font);
- if (cfg.fontisbold)
- strcat(buf, "bold, ");
- if (cfg.fontheight == 0)
- strcat (buf, "default height");
- else
- sprintf (buf+strlen(buf), "%d-%s",
- (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight),
- (cfg.fontheight < 0 ? "pixel" : "point"));
-}
-
-static void init_dlg_ctrls(HWND hwnd) {
- int i;
- char fontstatic[256];
-
- SetDlgItemText (hwnd, IDC_HOST, cfg.host);
- SetDlgItemText (hwnd, IDC_SESSEDIT, savedsession);
- SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
- CheckRadioButton (hwnd, IDC_PROTRAW, IDC_PROTSSH,
- cfg.protocol==PROT_SSH ? IDC_PROTSSH :
- cfg.protocol==PROT_TELNET ? IDC_PROTTELNET : IDC_PROTRAW );
- SetDlgItemInt (hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
-
- CheckRadioButton (hwnd, IDC_DEL008, IDC_DEL127,
- cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
- CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
- cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
- CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCVT400,
- cfg.funky_type == 0 ? IDC_FUNCTILDE :
- cfg.funky_type == 1 ? IDC_FUNCLINUX :
- cfg.funky_type == 2 ? IDC_FUNCXTERM :
- cfg.funky_type == 3 ? IDC_FUNCVT400 :
- IDC_FUNCTILDE );
- CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
- cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
- CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH,
- cfg.nethack_keypad ? IDC_KPNH :
- cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
- CheckDlgButton (hwnd, IDC_ALTF4, cfg.alt_f4);
- CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space);
- CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term);
- CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
-
- CheckDlgButton (hwnd, IDC_WRAPMODE, cfg.wrap_mode);
- CheckDlgButton (hwnd, IDC_DECOM, cfg.dec_om);
- CheckDlgButton (hwnd, IDC_LFHASCR, cfg.lfhascr);
- SetDlgItemInt (hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
- SetDlgItemInt (hwnd, IDC_COLSEDIT, cfg.width, FALSE);
- SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
- fmtfont (fontstatic);
- SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
- CheckDlgButton (hwnd, IDC_BEEP, cfg.beep);
- CheckDlgButton (hwnd, IDC_BCE, cfg.bce);
- CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext);
-
- SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
- CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
- CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
- CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
- CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
- CheckDlgButton (hwnd, IDC_CLOSEEXIT, cfg.close_on_exit);
- CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
-
- SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
- SetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed);
- SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
- {
- char *p = cfg.environmt;
- while (*p) {
- SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
- (LPARAM) p);
- p += strlen(p)+1;
- }
- }
- CheckRadioButton (hwnd, IDC_EMBSD, IDC_EMRFC,
- cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
-
- SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
- SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
- CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty);
- CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
- CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
- CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERDES,
- cfg.cipher == CIPHER_BLOWFISH ? IDC_CIPHERBLOWF :
- cfg.cipher == CIPHER_DES ? IDC_CIPHERDES :
- IDC_CIPHER3DES);
- CheckRadioButton (hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
- cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
- CheckDlgButton (hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
- SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
- SetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd);
-
- CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
- cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
- {
- static int tabs[4] = {25, 61, 96, 128};
- SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
- (LPARAM) tabs);
- }
- for (i=0; i<256; i++) {
- char str[100];
- sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
- (i>=0x21 && i != 0x7F) ? i : ' ',
- cfg.wordness[i]);
- SendDlgItemMessage (hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
- (LPARAM) str);
- }
-
- CheckDlgButton (hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
- CheckDlgButton (hwnd, IDC_PALETTE, cfg.try_palette);
- {
- int i;
- for (i=0; i<22; i++)
- if (cfg.bold_colour || permcolour[i])
- SendDlgItemMessage (hwnd, IDC_LIST, LB_ADDSTRING, 0,
- (LPARAM) colours[i]);
- }
- SendDlgItemMessage (hwnd, IDC_LIST, LB_SETCURSEL, 0, 0);
- SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
- SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
- SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
-
- CheckRadioButton (hwnd, IDC_NOXLAT, IDC_88592CP852,
- cfg.xlat_88592w1250 ? IDC_88592WIN1250 :
- cfg.xlat_88592cp852 ? IDC_88592CP852 :
- cfg.xlat_enablekoiwin ? IDC_KOI8WIN1251 :
- IDC_NOXLAT);
- CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
- CheckRadioButton (hwnd, IDC_VTXWINDOWS, IDC_VTPOORMAN,
- cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
- cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
- cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
- IDC_VTPOORMAN);
-}
-
-static void hide(HWND hwnd, int hide, int minid, int maxid) {
- int i;
- for (i = minid; i < maxid; i++) {
- HWND ctl = GetDlgItem(hwnd, i);
- if (ctl) {
- ShowWindow(ctl, hide ? SW_HIDE : SW_SHOW);
- }
- }
-}
-