2 * winctrls.c: routines to self-manage the controls in a dialog
16 #define STATICHEIGHT 8
17 #define CHECKBOXHEIGHT 8
20 #define COMBOHEIGHT 12
21 #define PUSHBTNHEIGHT 14
22 #define PROGBARHEIGHT 14
24 void ctlposinit(struct ctlpos
*cp
, HWND hwnd
,
25 int leftborder
, int rightborder
, int topborder
)
29 cp
->font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
31 GetClientRect(hwnd
, &r
);
35 MapDialogRect(hwnd
, &r2
);
36 cp
->dlu4inpix
= r2
.right
;
37 cp
->width
= (r
.right
* 4) / (r2
.right
) - 2 * GAPBETWEEN
;
38 cp
->xoff
= leftborder
;
39 cp
->width
-= leftborder
+ rightborder
;
42 void doctl(struct ctlpos
*cp
, RECT r
,
43 char *wclass
, int wstyle
, int exstyle
, char *wtext
, int wid
)
47 * Note nonstandard use of RECT. This is deliberate: by
48 * transforming the width and height directly we arrange to
49 * have all supposedly same-sized controls really same-sized.
53 MapDialogRect(cp
->hwnd
, &r
);
55 ctl
= CreateWindowEx(exstyle
, wclass
, wtext
, wstyle
,
56 r
.left
, r
.top
, r
.right
, r
.bottom
,
57 cp
->hwnd
, (HMENU
) wid
, hinst
, NULL
);
58 SendMessage(ctl
, WM_SETFONT
, cp
->font
, MAKELPARAM(TRUE
, 0));
62 * A title bar across the top of a sub-dialog.
64 void bartitle(struct ctlpos
*cp
, char *name
, int id
)
71 r
.bottom
= STATICHEIGHT
;
72 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
73 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, name
, id
);
77 * Begin a grouping box, with or without a group title.
79 void beginbox(struct ctlpos
*cp
, char *name
, int idbox
)
81 cp
->boxystart
= cp
->ypos
;
83 cp
->boxystart
-= STATICHEIGHT
/ 2;
85 cp
->ypos
+= STATICHEIGHT
;
87 cp
->width
-= 2 * GAPXBOX
;
96 void endbox(struct ctlpos
*cp
)
100 cp
->width
+= 2 * GAPXBOX
;
101 cp
->ypos
+= GAPYBOX
- GAPBETWEEN
;
104 r
.top
= cp
->boxystart
;
105 r
.bottom
= cp
->ypos
- cp
->boxystart
;
106 doctl(cp
, r
, "BUTTON", BS_GROUPBOX
| WS_CHILD
| WS_VISIBLE
, 0,
107 cp
->boxtext ? cp
->boxtext
: "", cp
->boxid
);
112 * Some edit boxes. Each one has a static above it. The percentages
113 * of the horizontal space are provided.
115 void multiedit(struct ctlpos
*cp
, ...)
125 int staticid
, editid
, pcwidth
;
126 text
= va_arg(ap
, char *);
129 staticid
= va_arg(ap
, int);
130 editid
= va_arg(ap
, int);
131 pcwidth
= va_arg(ap
, int);
133 r
.left
= xpos
+ GAPBETWEEN
;
135 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
136 r
.right
= xpos
- r
.left
;
139 r
.bottom
= STATICHEIGHT
;
140 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, staticid
);
141 r
.top
= cp
->ypos
+ 8 + GAPWITHIN
;
142 r
.bottom
= EDITHEIGHT
;
144 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
145 WS_EX_CLIENTEDGE
, "", editid
);
148 cp
->ypos
+= STATICHEIGHT
+ GAPWITHIN
+ EDITHEIGHT
+ GAPBETWEEN
;
152 * A static line, followed by a full-width drop-down list (ie a
153 * non-editing combo box).
155 void dropdownlist(struct ctlpos
*cp
, char *text
, int staticid
, int listid
)
164 r
.bottom
= STATICHEIGHT
;
165 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, staticid
);
166 r
.top
= cp
->ypos
+ 8 + GAPWITHIN
;
167 r
.bottom
= COMBOHEIGHT
* 10;
168 doctl(cp
, r
, "COMBOBOX",
169 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
|
170 CBS_DROPDOWNLIST
| CBS_HASSTRINGS
, WS_EX_CLIENTEDGE
, "", listid
);
172 cp
->ypos
+= STATICHEIGHT
+ GAPWITHIN
+ COMBOHEIGHT
+ GAPBETWEEN
;
175 static void radioline_common(struct ctlpos
*cp
, int nacross
, va_list ap
)
184 btext
= va_arg(ap
, char *);
191 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
194 bid
= va_arg(ap
, int);
195 nextbtext
= va_arg(ap
, char *);
196 r
.left
= GAPBETWEEN
+ i
* (cp
->width
+ GAPBETWEEN
) / nacross
;
199 (i
+ 1) * (cp
->width
+ GAPBETWEEN
) / nacross
- r
.left
;
201 r
.right
= cp
->width
- r
.left
;
203 r
.bottom
= RADIOHEIGHT
;
204 doctl(cp
, r
, "BUTTON",
205 BS_AUTORADIOBUTTON
| WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
|
206 group
, 0, btext
, bid
);
211 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
215 * A set of radio buttons on the same line, with a static above
216 * them. `nacross' dictates how many parts the line is divided into
217 * (you might want this not to equal the number of buttons if you
218 * needed to line up some 2s and some 3s to look good in the same
221 * There's a bit of a hack in here to ensure that if nacross
222 * exceeds the actual number of buttons, the rightmost button
223 * really does get all the space right to the edge of the line, so
224 * you can do things like
226 * (*) Button1 (*) Button2 (*) ButtonWithReallyLongTitle
228 void radioline(struct ctlpos
*cp
, char *text
, int id
, int nacross
, ...)
236 r
.bottom
= STATICHEIGHT
;
237 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
238 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, id
);
239 va_start(ap
, nacross
);
240 radioline_common(cp
, nacross
, ap
);
245 * A set of radio buttons on the same line, without a static above
246 * them. Otherwise just like radioline.
248 void bareradioline(struct ctlpos
*cp
, int nacross
, ...)
252 va_start(ap
, nacross
);
253 radioline_common(cp
, nacross
, ap
);
258 * A set of radio buttons on multiple lines, with a static above
261 void radiobig(struct ctlpos
*cp
, char *text
, int id
, ...)
270 r
.bottom
= STATICHEIGHT
;
271 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
272 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, id
);
278 btext
= va_arg(ap
, char *);
281 bid
= va_arg(ap
, int);
285 r
.bottom
= STATICHEIGHT
;
286 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
287 doctl(cp
, r
, "BUTTON",
288 BS_AUTORADIOBUTTON
| WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
|
289 group
, 0, btext
, bid
);
293 cp
->ypos
+= GAPBETWEEN
- GAPWITHIN
;
297 * A single standalone checkbox.
299 void checkbox(struct ctlpos
*cp
, char *text
, int id
)
306 r
.bottom
= CHECKBOXHEIGHT
;
307 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
308 doctl(cp
, r
, "BUTTON",
309 BS_AUTOCHECKBOX
| WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
, 0,
314 * A single standalone static text control.
316 void statictext(struct ctlpos
*cp
, char *text
, int id
)
323 r
.bottom
= STATICHEIGHT
;
324 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
325 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, id
);
329 * A button on the right hand side, with a static to its left.
331 void staticbtn(struct ctlpos
*cp
, char *stext
, int sid
,
332 char *btext
, int bid
)
334 const int height
= (PUSHBTNHEIGHT
> STATICHEIGHT ?
335 PUSHBTNHEIGHT
: STATICHEIGHT
);
337 int lwid
, rwid
, rpos
;
339 rpos
= GAPBETWEEN
+ 3 * (cp
->width
+ GAPBETWEEN
) / 4;
340 lwid
= rpos
- 2 * GAPBETWEEN
;
341 rwid
= cp
->width
+ GAPBETWEEN
- rpos
;
344 r
.top
= cp
->ypos
+ (height
- STATICHEIGHT
) / 2;
346 r
.bottom
= STATICHEIGHT
;
347 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
350 r
.top
= cp
->ypos
+ (height
- PUSHBTNHEIGHT
) / 2;
352 r
.bottom
= PUSHBTNHEIGHT
;
353 doctl(cp
, r
, "BUTTON",
354 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
357 cp
->ypos
+= height
+ GAPBETWEEN
;
361 * An edit control on the right hand side, with a static to its left.
363 static void staticedit_internal(struct ctlpos
*cp
, char *stext
,
364 int sid
, int eid
, int percentedit
,
367 const int height
= (EDITHEIGHT
> STATICHEIGHT ?
368 EDITHEIGHT
: STATICHEIGHT
);
370 int lwid
, rwid
, rpos
;
373 GAPBETWEEN
+ (100 - percentedit
) * (cp
->width
+ GAPBETWEEN
) / 100;
374 lwid
= rpos
- 2 * GAPBETWEEN
;
375 rwid
= cp
->width
+ GAPBETWEEN
- rpos
;
378 r
.top
= cp
->ypos
+ (height
- STATICHEIGHT
) / 2;
380 r
.bottom
= STATICHEIGHT
;
381 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
384 r
.top
= cp
->ypos
+ (height
- EDITHEIGHT
) / 2;
386 r
.bottom
= EDITHEIGHT
;
388 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
| style
,
389 WS_EX_CLIENTEDGE
, "", eid
);
391 cp
->ypos
+= height
+ GAPBETWEEN
;
394 void staticedit(struct ctlpos
*cp
, char *stext
,
395 int sid
, int eid
, int percentedit
)
397 staticedit_internal(cp
, stext
, sid
, eid
, percentedit
, 0);
400 void staticpassedit(struct ctlpos
*cp
, char *stext
,
401 int sid
, int eid
, int percentedit
)
403 staticedit_internal(cp
, stext
, sid
, eid
, percentedit
, ES_PASSWORD
);
407 * A big multiline edit control with a static labelling it.
409 void bigeditctrl(struct ctlpos
*cp
, char *stext
,
410 int sid
, int eid
, int lines
)
417 r
.bottom
= STATICHEIGHT
;
418 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
419 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
424 r
.bottom
= EDITHEIGHT
+ (lines
- 1) * STATICHEIGHT
;
425 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
427 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
| ES_MULTILINE
,
428 WS_EX_CLIENTEDGE
, "", eid
);
432 * A tab-control substitute when a real tab control is unavailable.
434 void ersatztab(struct ctlpos
*cp
, char *stext
, int sid
, int lid
, int s2id
)
436 const int height
= (COMBOHEIGHT
> STATICHEIGHT ?
437 COMBOHEIGHT
: STATICHEIGHT
);
439 int bigwid
, lwid
, rwid
, rpos
;
440 static const int BIGGAP
= 15;
441 static const int MEDGAP
= 3;
443 bigwid
= cp
->width
+ 2 * GAPBETWEEN
- 2 * BIGGAP
;
445 rpos
= BIGGAP
+ (bigwid
+ BIGGAP
) / 2;
446 lwid
= rpos
- 2 * BIGGAP
;
447 rwid
= bigwid
+ BIGGAP
- rpos
;
450 r
.top
= cp
->ypos
+ (height
- STATICHEIGHT
) / 2;
452 r
.bottom
= STATICHEIGHT
;
453 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
456 r
.top
= cp
->ypos
+ (height
- COMBOHEIGHT
) / 2;
458 r
.bottom
= COMBOHEIGHT
* 10;
459 doctl(cp
, r
, "COMBOBOX",
460 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
|
461 CBS_DROPDOWNLIST
| CBS_HASSTRINGS
, WS_EX_CLIENTEDGE
, "", lid
);
463 cp
->ypos
+= height
+ MEDGAP
+ GAPBETWEEN
;
469 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
| SS_ETCHEDHORZ
,
474 * A static line, followed by an edit control on the left hand side
475 * and a button on the right.
477 void editbutton(struct ctlpos
*cp
, char *stext
, int sid
,
478 int eid
, char *btext
, int bid
)
480 const int height
= (EDITHEIGHT
> PUSHBTNHEIGHT ?
481 EDITHEIGHT
: PUSHBTNHEIGHT
);
483 int lwid
, rwid
, rpos
;
488 r
.bottom
= STATICHEIGHT
;
489 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
490 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
492 rpos
= GAPBETWEEN
+ 3 * (cp
->width
+ GAPBETWEEN
) / 4;
493 lwid
= rpos
- 2 * GAPBETWEEN
;
494 rwid
= cp
->width
+ GAPBETWEEN
- rpos
;
497 r
.top
= cp
->ypos
+ (height
- EDITHEIGHT
) / 2;
499 r
.bottom
= EDITHEIGHT
;
501 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
502 WS_EX_CLIENTEDGE
, "", eid
);
505 r
.top
= cp
->ypos
+ (height
- PUSHBTNHEIGHT
) / 2;
507 r
.bottom
= PUSHBTNHEIGHT
;
508 doctl(cp
, r
, "BUTTON",
509 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
512 cp
->ypos
+= height
+ GAPBETWEEN
;
516 * Special control which was hard to describe generically: the
517 * session-saver assembly. A static; below that an edit box; below
518 * that a list box. To the right of the list box, a column of
521 void sesssaver(struct ctlpos
*cp
, char *text
,
522 int staticid
, int editid
, int listid
, ...)
526 int lwid
, rwid
, rpos
;
528 const int LISTDEFHEIGHT
= 66;
530 rpos
= GAPBETWEEN
+ 3 * (cp
->width
+ GAPBETWEEN
) / 4;
531 lwid
= rpos
- 2 * GAPBETWEEN
;
532 rwid
= cp
->width
+ GAPBETWEEN
- rpos
;
534 /* The static control. */
538 r
.bottom
= STATICHEIGHT
;
539 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
540 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, text
, staticid
);
542 /* The edit control. */
546 r
.bottom
= EDITHEIGHT
;
547 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
549 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
550 WS_EX_CLIENTEDGE
, "", editid
);
553 * The buttons (we should hold off on the list box until we
554 * know how big the buttons are).
556 va_start(ap
, listid
);
559 char *btext
= va_arg(ap
, char *);
563 bid
= va_arg(ap
, int);
567 r
.bottom
= PUSHBTNHEIGHT
;
568 y
+= r
.bottom
+ GAPWITHIN
;
569 doctl(cp
, r
, "BUTTON",
570 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
574 /* Compute list box height. LISTDEFHEIGHT, or height of buttons. */
577 if (y
< LISTDEFHEIGHT
)
583 cp
->ypos
+= y
+ GAPBETWEEN
;
584 doctl(cp
, r
, "LISTBOX",
585 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
|
586 LBS_NOTIFY
| LBS_HASSTRINGS
, WS_EX_CLIENTEDGE
, "", listid
);
590 * Another special control: the environment-variable setter. A
591 * static line first; then a pair of edit boxes with associated
592 * statics, and two buttons; then a list box.
594 void envsetter(struct ctlpos
*cp
, char *stext
, int sid
,
595 char *e1stext
, int e1sid
, int e1id
,
596 char *e2stext
, int e2sid
, int e2id
,
597 int listid
, char *b1text
, int b1id
, char *b2text
, int b2id
)
600 const int height
= (STATICHEIGHT
> EDITHEIGHT
602 PUSHBTNHEIGHT ? STATICHEIGHT
: EDITHEIGHT
>
603 PUSHBTNHEIGHT ? EDITHEIGHT
: PUSHBTNHEIGHT
);
604 const static int percents
[] = { 20, 35, 10, 25 };
605 int i
, j
, xpos
, percent
;
606 const int LISTHEIGHT
= 42;
608 /* The static control. */
612 r
.bottom
= STATICHEIGHT
;
613 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
614 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
616 /* The statics+edits+buttons. */
617 for (j
= 0; j
< 2; j
++) {
619 for (i
= 0; i
< 4; i
++) {
620 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
621 r
.left
= xpos
+ GAPBETWEEN
;
622 percent
+= percents
[i
];
623 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
624 r
.right
= xpos
- r
.left
;
626 r
.bottom
= (i
== 0 ? STATICHEIGHT
:
627 i
== 1 ? EDITHEIGHT
: PUSHBTNHEIGHT
);
628 r
.top
+= (height
- r
.bottom
) / 2;
630 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0,
631 j
== 0 ? e1stext
: e2stext
, j
== 0 ? e1sid
: e2sid
);
634 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
635 WS_EX_CLIENTEDGE
, "", j
== 0 ? e1id
: e2id
);
637 doctl(cp
, r
, "BUTTON",
638 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
639 0, j
== 0 ? b1text
: b2text
, j
== 0 ? b1id
: b2id
);
642 cp
->ypos
+= height
+ GAPWITHIN
;
649 r
.bottom
= LISTHEIGHT
;
650 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
651 doctl(cp
, r
, "LISTBOX",
652 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
| LBS_HASSTRINGS
653 | LBS_USETABSTOPS
, WS_EX_CLIENTEDGE
, "", listid
);
657 * Yet another special control: the character-class setter. A
658 * static, then a list, then a line containing a
659 * button-and-static-and-edit.
661 void charclass(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
662 char *btext
, int bid
, int eid
, char *s2text
, int s2id
)
665 const int height
= (STATICHEIGHT
> EDITHEIGHT
667 PUSHBTNHEIGHT ? STATICHEIGHT
: EDITHEIGHT
>
668 PUSHBTNHEIGHT ? EDITHEIGHT
: PUSHBTNHEIGHT
);
669 const static int percents
[] = { 30, 40, 30 };
670 int i
, xpos
, percent
;
671 const int LISTHEIGHT
= 66;
673 /* The static control. */
677 r
.bottom
= STATICHEIGHT
;
678 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
679 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
685 r
.bottom
= LISTHEIGHT
;
686 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
687 doctl(cp
, r
, "LISTBOX",
688 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
| LBS_HASSTRINGS
689 | LBS_USETABSTOPS
, WS_EX_CLIENTEDGE
, "", listid
);
691 /* The button+static+edit. */
693 for (i
= 0; i
< 3; i
++) {
694 r
.left
= xpos
+ GAPBETWEEN
;
695 percent
+= percents
[i
];
696 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
697 r
.right
= xpos
- r
.left
;
699 r
.bottom
= (i
== 0 ? PUSHBTNHEIGHT
:
700 i
== 1 ? STATICHEIGHT
: EDITHEIGHT
);
701 r
.top
+= (height
- r
.bottom
) / 2;
703 doctl(cp
, r
, "BUTTON",
704 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
707 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
| SS_CENTER
,
711 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
712 WS_EX_CLIENTEDGE
, "", eid
);
715 cp
->ypos
+= height
+ GAPBETWEEN
;
719 * A special control (horrors!). The colour editor. A static line;
720 * then on the left, a list box, and on the right, a sequence of
721 * two-part statics followed by a button.
723 void colouredit(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
724 char *btext
, int bid
, ...)
729 int lwid
, rwid
, rpos
;
730 const int LISTHEIGHT
= 66;
732 /* The static control. */
736 r
.bottom
= STATICHEIGHT
;
737 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
738 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
740 rpos
= GAPBETWEEN
+ 2 * (cp
->width
+ GAPBETWEEN
) / 3;
741 lwid
= rpos
- 2 * GAPBETWEEN
;
742 rwid
= cp
->width
+ GAPBETWEEN
- rpos
;
748 r
.bottom
= LISTHEIGHT
;
749 doctl(cp
, r
, "LISTBOX",
750 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
| LBS_HASSTRINGS
751 | LBS_USETABSTOPS
| LBS_NOTIFY
, WS_EX_CLIENTEDGE
, "", listid
);
759 ltext
= va_arg(ap
, char *);
762 lid
= va_arg(ap
, int);
763 rid
= va_arg(ap
, int);
765 r
.bottom
= STATICHEIGHT
;
766 y
+= r
.bottom
+ GAPWITHIN
;
769 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, ltext
, lid
);
770 r
.left
= rpos
+ r
.right
;
771 r
.right
= rwid
- r
.right
;
772 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
| SS_RIGHT
, 0, "",
778 r
.top
= y
+ 2 * GAPWITHIN
;
779 r
.bottom
= PUSHBTNHEIGHT
;
782 doctl(cp
, r
, "BUTTON",
783 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
786 cp
->ypos
+= LISTHEIGHT
+ GAPBETWEEN
;
790 * A progress bar (from Common Controls). We like our progress bars
791 * to be smooth and unbroken, without those ugly divisions; some
792 * older compilers may not support that, but that's life.
794 void progressbar(struct ctlpos
*cp
, int id
)
801 r
.bottom
= PROGBARHEIGHT
;
802 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
804 doctl(cp
, r
, PROGRESS_CLASS
, WS_CHILD
| WS_VISIBLE
808 , WS_EX_CLIENTEDGE
, "", id
);
812 * Another special control: the forwarding options setter. First a
813 * list box; next a static header line, introducing a pair of edit
814 * boxes with associated statics, another button, and a radio
817 void fwdsetter(struct ctlpos
*cp
, int listid
, char *stext
, int sid
,
818 char *e1stext
, int e1sid
, int e1id
,
819 char *e2stext
, int e2sid
, int e2id
,
820 char *btext
, int bid
)
823 const int height
= (STATICHEIGHT
> EDITHEIGHT
825 PUSHBTNHEIGHT ? STATICHEIGHT
: EDITHEIGHT
>
826 PUSHBTNHEIGHT ? EDITHEIGHT
: PUSHBTNHEIGHT
);
827 const static int percents
[] = { 25, 35, 15, 25 };
828 int i
, j
, xpos
, percent
;
829 const int LISTHEIGHT
= 42;
835 r
.bottom
= LISTHEIGHT
;
836 cp
->ypos
+= r
.bottom
+ GAPBETWEEN
;
837 doctl(cp
, r
, "LISTBOX",
838 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_VSCROLL
| LBS_HASSTRINGS
839 | LBS_USETABSTOPS
, WS_EX_CLIENTEDGE
, "", listid
);
841 /* The static control. */
845 r
.bottom
= STATICHEIGHT
;
846 cp
->ypos
+= r
.bottom
+ GAPWITHIN
;
847 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0, stext
, sid
);
849 /* The statics+edits+buttons. */
850 for (j
= 0; j
< 2; j
++) {
852 for (i
= 0; i
< (j ?
2 : 4); i
++) {
853 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
854 r
.left
= xpos
+ GAPBETWEEN
;
855 percent
+= percents
[i
];
856 if (j
==1 && i
==1) percent
= 100;
857 xpos
= (cp
->width
+ GAPBETWEEN
) * percent
/ 100;
858 r
.right
= xpos
- r
.left
;
860 r
.bottom
= (i
== 0 ? STATICHEIGHT
:
861 i
== 1 ? EDITHEIGHT
: PUSHBTNHEIGHT
);
862 r
.top
+= (height
- r
.bottom
) / 2;
864 doctl(cp
, r
, "STATIC", WS_CHILD
| WS_VISIBLE
, 0,
865 j
== 0 ? e1stext
: e2stext
, j
== 0 ? e1sid
: e2sid
);
868 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
,
869 WS_EX_CLIENTEDGE
, "", j
== 0 ? e1id
: e2id
);
871 doctl(cp
, r
, "BUTTON",
872 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| BS_PUSHBUTTON
,
876 cp
->ypos
+= height
+ GAPWITHIN
;