2992165910b829581cf53a4294df36538eb7b625
[xboard.git] / winboard / wsettings.c
1 /*\r
2  * Engine-settings dialog. The complexity come from an attempt to present the engine-defined options\r
3  * in a nicey formatted layout. To this end we first run a back-end pre-formatter, which will distribute\r
4  * the controls over two columns (the minimum required, as some are double width). It also takes care of \r
5  * grouping options that start with the same word (mainly for "Polyglot ..." options). It assigns relative\r
6  * suitability to break points between lines, and in the end decides if and where to break up the list\r
7  * for display in multiple (2*N) columns.\r
8  * The thus obtained list representing the topology of the layout is then passed to a front-end routine\r
9  * that generates the actual dialog box from it.\r
10  */\r
11 \r
12 //#include "config.h"\r
13 #include "config.h"\r
14 \r
15 #include <stdio.h>\r
16 #include <string.h>\r
17 #include "common.h"\r
18 #include "backend.h"\r
19 #include "backendz.h"\r
20 \r
21 int layoutList[2*MAX_OPTIONS];\r
22 int checkList[2*MAX_OPTIONS];\r
23 int comboList[2*MAX_OPTIONS];\r
24 int buttonList[2*MAX_OPTIONS];\r
25 int boxList[2*MAX_OPTIONS];\r
26 int groupNameList[2*MAX_OPTIONS];\r
27 int breaks[MAX_OPTIONS];\r
28 int checks, combos, buttons, layout, groups;\r
29 \r
30 void\r
31 PrintOpt(int i, int right, ChessProgramState *cps)\r
32 {\r
33     if(i<0) {\r
34         if(!right) fprintf(debugFP, "%30s", "");\r
35     } else {\r
36         Option opt = cps->option[i];\r
37         switch(opt.type) {\r
38             case Slider:\r
39             case Spin:\r
40                 fprintf(debugFP, "%20.20s [    +/-]", opt.name);\r
41                 break;\r
42             case TextBox:\r
43             case FileName:\r
44             case PathName:\r
45                 fprintf(debugFP, "%20.20s [______________________________________]", opt.name);\r
46                 break;\r
47             case CheckBox:\r
48                 fprintf(debugFP, "[x] %-26.25s", opt.name);\r
49                 break;\r
50             case ComboBox:\r
51                 fprintf(debugFP, "%20.20s [ COMBO ]", opt.name);\r
52                 break;\r
53             case Button:\r
54             case SaveButton:\r
55             case ResetButton:\r
56                 fprintf(debugFP, "[ %26.26s ]", opt.name);\r
57             case Message:\r
58                 break;\r
59         }\r
60     }\r
61     fprintf(debugFP, right ? "\n" : " ");\r
62 }\r
63 \r
64 void\r
65 CreateOptionDialogTest(int *list, int nr, ChessProgramState *cps)\r
66 {\r
67     int line;\r
68 \r
69     for(line = 0; line < nr; line+=2) {\r
70         PrintOpt(list[line+1], 0, cps);\r
71         PrintOpt(list[line], 1, cps);\r
72     }\r
73 }\r
74 \r
75 void\r
76 LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionList)\r
77 {\r
78     int i, b = strlen(groupName), stop, prefix, right, nextOption, firstButton = buttons;\r
79     Control lastType, nextType;\r
80 \r
81     nextOption = firstOption;\r
82     while(nextOption < endOption) {\r
83         checks = combos = 0; stop = 0;\r
84         lastType = Button; // kludge to make sure leading Spin will not be prefixed\r
85         // first separate out buttons for later treatment, and collect consecutive checks and combos\r
86         while(nextOption < endOption && !stop) {\r
87             switch(nextType = optionList[nextOption].type) {\r
88                 case CheckBox: checkList[checks++] = nextOption; lastType = CheckBox; break;\r
89                 case ComboBox: comboList[combos++] = nextOption; lastType = ComboBox; break;\r
90                 case ResetButton:\r
91                 case SaveButton:\r
92                 case Button:  buttonList[buttons++] = nextOption; lastType = Button; break;\r
93                 case TextBox:\r
94                 case FileName:\r
95                 case PathName:\r
96                 case Slider:\r
97                 case Spin: stop++;\r
98                 case Message: ; // cannot happen\r
99             }\r
100             nextOption++;\r
101         }\r
102         // We now must be at the end, or looking at a spin or textbox (in nextType)\r
103         if(!stop) \r
104             nextType = Button; // kudge to flush remaining checks and combos undistorted\r
105         // Take a new line if a spin follows combos or checks, or when we encounter a textbox\r
106         if((combos+checks || nextType == TextBox) && layout&1) {\r
107             layoutList[layout++] = -1;\r
108         }\r
109         // The last check or combo before a spin will be put on the same line as that spin (prefix)\r
110         // and will thus not be grouped with other checks and combos\r
111         prefix = -1;\r
112         if(nextType == Spin && lastType != Button) {\r
113             if(lastType == CheckBox) prefix = checkList[--checks]; else\r
114             if(lastType == ComboBox) prefix = comboList[--combos];\r
115         }\r
116         // if a combo is followed by a textbox, it must stay at the end of the combo/checks list to appear\r
117         // immediately above the textbox, so treat it as check. (A check would automatically be and remain there.)\r
118         if(nextType == TextBox && lastType == ComboBox)\r
119             checkList[checks++] = comboList[--combos];\r
120         // Now append the checks behind the (remaining) combos to treat them as one group\r
121         for(i=0; i< checks; i++) \r
122             comboList[combos++] = checkList[i];\r
123         // emit the consecutive checks and combos in two columns\r
124         right = combos/2; // rounded down if odd!\r
125         for(i=0; i<right; i++) {\r
126             breaks[layout/2] = 2;\r
127             layoutList[layout++] = comboList[i];\r
128             layoutList[layout++] = comboList[i + right];\r
129         }\r
130         // An odd check or combo (which could belong to following textBox) will be put in the left column\r
131         // If there was an even number of checks and combos the last one will automatically be in that position\r
132         if(combos&1) {\r
133             layoutList[layout++] = -1;\r
134             layoutList[layout++] = comboList[2*right];\r
135         }\r
136         if(nextType == TextBox) {\r
137             // A textBox is double width, so must be left-adjusted, and the right column remains empty\r
138             breaks[layout/2] = lastType == Button ? 0 : 100;\r
139             layoutList[layout++] = -1;\r
140             layoutList[layout++] = nextOption - 1;\r
141         } else if(nextType == Spin) {\r
142             // A spin will go in the next available position (right to left!). If it had to be prefixed with\r
143             // a check or combo, this next position must be to the right, and the prefix goes left to it.\r
144             layoutList[layout++] = nextOption - 1;\r
145             if(prefix >= 0) layoutList[layout++] = prefix;\r
146         }\r
147     }\r
148     // take a new line if needed\r
149     if(layout&1) layoutList[layout++] = -1;\r
150     // emit the buttons belonging in this group; loose buttons are saved for last, to appear at bottom of dialog\r
151     if(b) {\r
152         while(buttons > firstButton)\r
153             layoutList[layout++] = buttonList[--buttons];\r
154         if(layout&1) layoutList[layout++] = -1;\r
155     }\r
156 }\r
157 \r
158 char *\r
159 EndMatch(char *s1, char *s2)\r
160 {\r
161         char *p, *q;\r
162         p = s1; while(*p) p++;\r
163         q = s2; while(*q) q++;\r
164         while(p > s1 && q > s2 && *p == *q) { p--; q--; }\r
165         if(p[1] == 0) return NULL;\r
166         return p+1;\r
167 }\r
168 \r
169 void\r
170 DesignOptionDialog(ChessProgramState *cps)\r
171 {\r
172     int k=0, n=0;\r
173     char buf[MSG_SIZ];\r
174 \r
175     layout = 0;\r
176     buttons = groups = 0;\r
177     while(k < cps->nrOptions) { // k steps through 'solitary' options\r
178         // look if we hit a group of options having names that start with the same word\r
179         int groupSize = 1, groupNameLength = 50;\r
180         sscanf(cps->option[k].name, "%s", buf); // get first word of option name\r
181         while(k + groupSize < cps->nrOptions &&\r
182               strstr(cps->option[k+groupSize].name, buf) == cps->option[k+groupSize].name) {\r
183                 int j;\r
184                 for(j=0; j<groupNameLength; j++) // determine common initial part of option names\r
185                     if( cps->option[k].name[j] != cps->option[k+groupSize].name[j]) break;\r
186                 groupNameLength = j;\r
187                 groupSize++;\r
188                 \r
189         }\r
190         if(groupSize > 3) {\r
191                 // We found a group to terminates the current section\r
192                 LayoutOptions(n, k, "", cps->option); // flush all solitary options appearing before the group\r
193                 groupNameList[groups] = groupNameLength;\r
194                 boxList[groups++] = layout; // group start in even entries\r
195                 LayoutOptions(k, k+groupSize, buf, cps->option); // flush the group\r
196                 boxList[groups++] = layout; // group end in odd entries\r
197                 k = n = k + groupSize;\r
198         } else k += groupSize; // small groups are grouped with the solitary options\r
199     }\r
200     if(n != k) LayoutOptions(n, k, "", cps->option); // flush remaining solitary options\r
201     // decide if and where we break into two column pairs\r
202     \r
203     // Emit buttons and add OK and cancel\r
204 //    for(k=0; k<buttons; k++) layoutList[layout++] = buttonList[k];\r
205     // Create the dialog window\r
206     if(appData.debugMode) CreateOptionDialogTest(layoutList, layout, cps);\r
207 //    CreateOptionDialog(layoutList, layout, cps);\r
208 }\r
209 \r
210 #include <windows.h>\r
211 \r
212 extern HINSTANCE hInst;\r
213 \r
214 typedef struct {\r
215     DLGITEMTEMPLATE item;\r
216     WORD code;\r
217     WORD controlType;\r
218     wchar_t d1, data;\r
219     WORD creationData;\r
220 } Item;\r
221 \r
222 struct {\r
223     DLGTEMPLATE header;\r
224     WORD menu;\r
225     WORD winClass;\r
226     wchar_t title[20];\r
227     WORD pointSize;\r
228     wchar_t fontName[14];\r
229     Item control[MAX_OPTIONS];\r
230 } template = {\r
231     { DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SETFONT, 0, 0, 0, 0, 295, 300 },\r
232     0x0000, 0x0000, L"Engine #1 Settings ", 8, L"MS Sans Serif"\r
233 };\r
234 \r
235 ChessProgramState *activeCps;\r
236 \r
237 void\r
238 SetOptionValues(HWND hDlg, ChessProgramState *cps)\r
239 // Put all current option values in controls, and write option names next to them\r
240 {\r
241     HANDLE hwndCombo;\r
242     int i, k;\r
243     char **choices, title[MSG_SIZ], *name;\r
244 \r
245     for(i=0; i<layout+buttons; i++) {\r
246         int j=layoutList[i];\r
247         if(j == -2) SetDlgItemText( hDlg, 2000+2*i, ". . ." );\r
248         if(j<0) continue;\r
249         name = cps->option[j].name;\r
250         if(strstr(name, "Polyglot ") == name) name += 9;\r
251         SetDlgItemText( hDlg, 2000+2*i, name );\r
252 //if(appData.debugMode) fprintf(debugFP, "# %s = %d\n",cps->option[j].name, cps->option[j].value );\r
253         switch(cps->option[j].type) {\r
254             case Spin:\r
255                 SetDlgItemInt( hDlg, 2001+2*i, cps->option[j].value, TRUE );\r
256                 break;\r
257             case TextBox:\r
258                 SetDlgItemText( hDlg, 2001+2*i, cps->option[j].textValue );\r
259                 break;\r
260             case CheckBox:\r
261                 CheckDlgButton( hDlg, 2000+2*i, cps->option[j].value != 0);\r
262                 break;\r
263             case ComboBox:\r
264                 choices = (char**) cps->option[j].textValue;\r
265                 hwndCombo = GetDlgItem(hDlg, 2001+2*i);\r
266                 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);\r
267                 for(k=0; k<cps->option[j].max; k++) {\r
268                     SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) choices[k]);\r
269                 }\r
270                 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) choices[cps->option[j].value]);\r
271                 break;\r
272             case Button:\r
273             case SaveButton:\r
274             default:\r
275                 break;\r
276         }\r
277     }\r
278     SetDlgItemText( hDlg, IDOK, "OK" );\r
279     SetDlgItemText( hDlg, IDCANCEL, "Cancel" );\r
280     sprintf(title, "%s Engine Settings (%s)", cps->which, cps->tidy); \r
281     title[0] &= ~32; // capitalize\r
282     SetWindowText( hDlg, title);\r
283     for(i=0; i<groups; i+=2) { \r
284         int id, p; char buf[MSG_SIZ];\r
285         id = k = boxList[i];\r
286         if(layoutList[k] < 0) k++;\r
287         if(layoutList[k] < 0) continue;\r
288         for(p=0; p<groupNameList[i]; p++) buf[p] = cps->option[layoutList[k]].name[p];\r
289         buf[p] = 0;\r
290         SetDlgItemText( hDlg, 2000+2*(id+MAX_OPTIONS), buf );\r
291     }\r
292 }\r
293 \r
294 \r
295 void\r
296 GetOptionValues(HWND hDlg, ChessProgramState *cps)\r
297 // read out all controls, and if value is altered, remember it and send it to the engine\r
298 {\r
299     HANDLE hwndCombo;\r
300     int i, k, new=0, changed=0;\r
301     char **choices, newText[MSG_SIZ], buf[MSG_SIZ];\r
302     BOOL success;\r
303 \r
304     for(i=0; i<layout; i++) {\r
305         int j=layoutList[i];\r
306         if(j<0) continue;\r
307         switch(cps->option[j].type) {\r
308             case Spin:\r
309                 new = GetDlgItemInt( hDlg, 2001+2*i, &success, TRUE );\r
310                 if(!success) break;\r
311                 if(new < cps->option[j].min) new = cps->option[j].min;\r
312                 if(new > cps->option[j].max) new = cps->option[j].max;\r
313                 changed = 2*(cps->option[j].value != new);\r
314                 cps->option[j].value = new;\r
315                 break;\r
316             case TextBox:\r
317             case FileName:\r
318             case PathName:\r
319                 success = GetDlgItemText( hDlg, 2001+2*i, newText, MSG_SIZ - strlen(cps->option[j].name) - 9 );\r
320                 if(!success) break;\r
321                 changed = strcmp(cps->option[j].textValue, newText) != 0;\r
322                 strcpy(cps->option[j].textValue, newText);\r
323                 break;\r
324             case CheckBox:\r
325                 new = IsDlgButtonChecked( hDlg, 2000+2*i );\r
326                 changed = 2*(cps->option[j].value != new);\r
327                 cps->option[j].value = new;\r
328                 break;\r
329             case ComboBox:\r
330                 choices = (char**) cps->option[j].textValue;\r
331                 hwndCombo = GetDlgItem(hDlg, 2001+2*i);\r
332                 success = GetDlgItemText( hDlg, 2001+2*i, newText, MSG_SIZ );\r
333                 if(!success) break;\r
334                 new = -1;\r
335                 for(k=0; k<cps->option[j].max; k++) {\r
336                     if(!strcmp(choices[k], newText)) new = k;\r
337                 }\r
338                 changed = new >= 0 && (cps->option[j].value != new);\r
339                 if(changed) cps->option[j].value = new;\r
340                 break;\r
341             case Button:\r
342             default:\r
343                 break; // are treated instantly, so they have been sent already\r
344         }\r
345         if(changed == 2) sprintf(buf, "option %s=%d\n", cps->option[j].name, new); else\r
346         if(changed == 1) sprintf(buf, "option %s=%s\n", cps->option[j].name, newText);\r
347         if(changed) SendToProgram(buf, cps);\r
348     }\r
349 }\r
350 \r
351 LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
352 {\r
353     char buf[MSG_SIZ];\r
354     int i, j;\r
355 \r
356     switch( message )\r
357     {\r
358     case WM_INITDIALOG:\r
359 \r
360 //        CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));\r
361         SetOptionValues(hDlg, activeCps);\r
362 \r
363 //        SetFocus(GetDlgItem(hDlg, IDC_NFG_Edit));\r
364 \r
365         break;\r
366 \r
367     case WM_COMMAND:\r
368         switch( LOWORD(wParam) ) {\r
369         case IDOK:\r
370             GetOptionValues(hDlg, activeCps);\r
371             EndDialog( hDlg, 0 );\r
372             return TRUE;\r
373 \r
374         case IDCANCEL:\r
375             EndDialog( hDlg, 1 );   \r
376             return TRUE;\r
377 \r
378         default:\r
379             // program-defined push buttons\r
380             i = LOWORD(wParam);\r
381             if( i>=2000 &&  i < 2000+2*(layout+buttons)) {\r
382                 j = layoutList[(i - 2000)/2];\r
383                 if(j == -2) {\r
384                           char filter[] = \r
385                                 "All files\0*.*\0BIN Files\0*.bin\0LOG Files\0*.log\0INI Files\0*.ini\0\0";\r
386 /*\r
387\r
388                               'A','l','l',' ','F','i','l','e','s', 0,\r
389                               '*','.','*', 0,\r
390                               'B','I','N',' ','F','i','l','e','s', 0,\r
391                               '*','.','b','i','n', 0,\r
392                               0 };\r
393 */\r
394                           OPENFILENAME ofn;\r
395 \r
396                           strcpy( buf, "" );\r
397 \r
398                           ZeroMemory( &ofn, sizeof(ofn) );\r
399 \r
400                           ofn.lStructSize = sizeof(ofn);\r
401                           ofn.hwndOwner = hDlg;\r
402                           ofn.hInstance = hInst;\r
403                           ofn.lpstrFilter = filter;\r
404                           ofn.lpstrFile = buf;\r
405                           ofn.nMaxFile = sizeof(buf);\r
406                           ofn.lpstrTitle = "Choose Book";\r
407                           ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;\r
408 \r
409                           if( GetOpenFileName( &ofn ) ) {\r
410                               SetDlgItemText( hDlg, i+3, buf );\r
411                           }\r
412                 }\r
413                 if(j < 0) break;\r
414                 if( activeCps->option[j].type  == SaveButton)\r
415                      GetOptionValues(hDlg, activeCps);\r
416                 else if( activeCps->option[j].type  != Button) break;\r
417                 sprintf(buf, "option %s\n", activeCps->option[j].name);\r
418                 SendToProgram(buf, activeCps);\r
419             }\r
420             break;\r
421         }\r
422 \r
423         break;\r
424     }\r
425 \r
426     return FALSE;\r
427 }\r
428 \r
429 void AddControl(int x, int y, int w, int h, int type, int style, int n)\r
430 {\r
431     int i;\r
432 \r
433     i = template.header.cdit++;\r
434     template.control[i].item.style = style;\r
435     template.control[i].item.dwExtendedStyle = 0;\r
436     template.control[i].item.x = x;\r
437     template.control[i].item.y = y;\r
438     template.control[i].item.cx = w;\r
439     template.control[i].item.cy = h;\r
440     template.control[i].item.id = 2000 + n;\r
441     template.control[i].code = 0xFFFF;\r
442     template.control[i].controlType = type;\r
443     template.control[i].d1 = ' ';\r
444     template.control[i].data = 0;\r
445     template.control[i].creationData = 0;\r
446 }\r
447 \r
448 void AddOption(int x, int y, Control type, int i)\r
449 {\r
450 \r
451     switch(type) {\r
452         case Slider:\r
453         case Spin:\r
454             AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
455             AddControl(x+95, y, 50, 11, 0x0081, ES_AUTOHSCROLL | ES_NUMBER | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
456             break;\r
457 //      case TextBox:\r
458             AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
459             AddControl(x+95, y, 190, 11, 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
460             break;\r
461         case TextBox:  // For now all text edits get a browse button, as long as -file and -path options are not yet implemented\r
462         case FileName:\r
463         case PathName:\r
464             AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
465             AddControl(x+95, y, 180, 11, 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
466             AddControl(x+275, y, 20, 12, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i-2);\r
467             layoutList[i/2-1] = -2;\r
468             break;\r
469         case CheckBox:\r
470             AddControl(x, y, 145, 11, 0x0080, BS_AUTOCHECKBOX | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i);\r
471             break;\r
472         case ComboBox:\r
473             AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
474             AddControl(x+95, y-1, 50, 500, 0x0085, CBS_AUTOHSCROLL | CBS_DROPDOWN | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
475             break;\r
476         case Button:\r
477         case ResetButton:\r
478         case SaveButton:\r
479             AddControl(x-2, y, 65, 13, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, i);\r
480         case Message:\r
481             break;\r
482     }\r
483     \r
484 }\r
485 \r
486 void\r
487 CreateDialogTemplate(int *layoutList, int nr, ChessProgramState *cps)\r
488 {\r
489     int i, j, x=1, y=0, buttonRows, breakPoint = -1, k=0;\r
490 \r
491     template.header.cdit = 0;\r
492     template.header.cx = 307;\r
493     buttonRows = (buttons + 1 + 3)/4; // 4 per row, rounded up\r
494     if(nr > 50) { \r
495         breakPoint = (nr+2*buttonRows+1)/2 & ~1;\r
496         template.header.cx = 625;\r
497     }\r
498 \r
499     for(i=0; i<nr; i++) {\r
500         if(k < groups && i == boxList[k]) {\r
501             y += 10;\r
502             AddControl(x+2, y+13*(i>>1)-2, 301, 13*(boxList[k+1]-boxList[k]>>1)+8, \r
503                                                 0x0082, WS_VISIBLE | WS_CHILD | SS_BLACKFRAME, 2400);\r
504             AddControl(x+60, y+13*(i>>1)-6, 10*groupNameList[k]/3, 10, \r
505                                                 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(i+MAX_OPTIONS));\r
506         }\r
507         j = layoutList[i];\r
508         if(j >= 0)\r
509             AddOption(x+155-150*(i&1), y+13*(i>>1)+5, cps->option[j].type, 2*i);\r
510         if(k < groups && i+1 == boxList[k+1]) {\r
511             k += 2; y += 4;\r
512         }\r
513         if(i+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); }\r
514     }\r
515     // add butons at the bottom of dialog window\r
516     y += 13*(nr>>1)+5;\r
517 \r
518     AddControl(x+275, y+18*(buttonRows-1), 25, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDOK-2000);\r
519     AddControl(x+235, y+18*(buttonRows-1), 35, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDCANCEL-2000);\r
520     for(i=0; i<buttons; i++) {\r
521         AddControl(x+70*(i%4)+5, y+18*(i/4), 65, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 2*(nr+i));\r
522         layoutList[nr+i] = buttonList[i];\r
523     }\r
524     template.title[8] = cps == &first ? '1' :  '2';\r
525     template.header.cy = y += 18*buttonRows+2;\r
526     template.header.style &= ~WS_VSCROLL;\r
527 }\r
528 \r
529 void \r
530 EngineOptionsPopup(HWND hwnd, ChessProgramState *cps)\r
531 {\r
532     FARPROC lpProc = MakeProcInstance( (FARPROC) SettingsProc, hInst );\r
533 \r
534     activeCps = cps;\r
535     DesignOptionDialog(cps);\r
536     CreateDialogTemplate(layoutList, layout, cps);\r
537 \r
538 \r
539     DialogBoxIndirect( hInst, &template.header, hwnd, (DLGPROC)lpProc );\r
540 \r
541     FreeProcInstance(lpProc);\r
542 \r
543     return;\r
544 }\r
545 \r
546 \r