/*\r
* Engine-settings dialog. The complexity come from an attempt to present the engine-defined options\r
* in a nicey formatted layout. To this end we first run a back-end pre-formatter, which will distribute\r
- * the controls over two columns (the minimum required, as some are double width). It also takes care of \r
+ * the controls over two columns (the minimum required, as some are double width). It also takes care of\r
* grouping options that start with the same word (mainly for "Polyglot ..." options). It assigns relative\r
* suitability to break points between lines, and in the end decides if and where to break up the list\r
* for display in multiple (2*N) columns.\r
* that generates the actual dialog box from it.\r
*/\r
\r
-//#include "config.h"\r
#include "config.h"\r
\r
+#include <windows.h>\r
#include <stdio.h>\r
#include <string.h>\r
#include "common.h"\r
+#include "frontend.h"\r
#include "backend.h"\r
+#include "winboard.h"\r
#include "backendz.h"\r
\r
+#define _(s) T_(s)\r
+\r
int layoutList[2*MAX_OPTIONS];\r
int checkList[2*MAX_OPTIONS];\r
int comboList[2*MAX_OPTIONS];\r
nextOption++;\r
}\r
// We now must be at the end, or looking at a spin or textbox (in nextType)\r
- if(!stop) \r
+ if(!stop)\r
nextType = Button; // kudge to flush remaining checks and combos undistorted\r
// Take a new line if a spin follows combos or checks, or when we encounter a textbox\r
if((combos+checks || nextType == TextBox) && layout&1) {\r
if(nextType == TextBox && lastType == ComboBox)\r
checkList[checks++] = comboList[--combos];\r
// Now append the checks behind the (remaining) combos to treat them as one group\r
- for(i=0; i< checks; i++) \r
+ for(i=0; i< checks; i++)\r
comboList[combos++] = checkList[i];\r
// emit the consecutive checks and combos in two columns\r
right = combos/2; // rounded down if odd!\r
if( cps->option[k].name[j] != cps->option[k+groupSize].name[j]) break;\r
groupNameLength = j;\r
groupSize++;\r
- \r
+\r
}\r
if(groupSize > 3) {\r
// We found a group to terminates the current section\r
}\r
if(n != k) LayoutOptions(n, k, "", cps->option); // flush remaining solitary options\r
// decide if and where we break into two column pairs\r
- \r
+\r
// Emit buttons and add OK and cancel\r
// for(k=0; k<buttons; k++) layoutList[layout++] = buttonList[k];\r
// Create the dialog window\r
break;\r
}\r
}\r
- SetDlgItemText( hDlg, IDOK, "OK" );\r
- SetDlgItemText( hDlg, IDCANCEL, "Cancel" );\r
- sprintf(title, "%s Engine Settings (%s)", cps->which, cps->tidy); \r
+ SetDlgItemText( hDlg, IDOK, _("OK") );\r
+ SetDlgItemText( hDlg, IDCANCEL, _("Cancel") );\r
+ snprintf(title, MSG_SIZ, _("%s Engine Settings (%s)"), T_(cps->which), cps->tidy);\r
title[0] &= ~32; // capitalize\r
SetWindowText( hDlg, title);\r
- for(i=0; i<groups; i+=2) { \r
+ for(i=0; i<groups; i+=2) {\r
int id, p; char buf[MSG_SIZ];\r
id = k = boxList[i];\r
if(layoutList[k] < 0) k++;\r
success = GetDlgItemText( hDlg, 2001+2*i, newText, MSG_SIZ - strlen(cps->option[j].name) - 9 );\r
if(!success) break;\r
changed = strcmp(cps->option[j].textValue, newText) != 0;\r
- strcpy(cps->option[j].textValue, newText);\r
+ safeStrCpy(cps->option[j].textValue, newText, MSG_SIZ - (cps->option[j].textValue - cps->option[j].name) );\r
break;\r
case CheckBox:\r
new = IsDlgButtonChecked( hDlg, 2000+2*i );\r
default:\r
break; // are treated instantly, so they have been sent already\r
}\r
- if(changed == 2) sprintf(buf, "option %s=%d\n", cps->option[j].name, new); else\r
- if(changed == 1) sprintf(buf, "option %s=%s\n", cps->option[j].name, newText);\r
+ if(changed == 2)\r
+ snprintf(buf, MSG_SIZ, "option %s=%d\n", cps->option[j].name, new); else\r
+ if(changed == 1)\r
+ snprintf(buf, MSG_SIZ, "option %s=%s\n", cps->option[j].name, newText);\r
if(changed) SendToProgram(buf, cps);\r
}\r
}\r
return TRUE;\r
\r
case IDCANCEL:\r
- EndDialog( hDlg, 1 ); \r
+ EndDialog( hDlg, 1 );\r
return TRUE;\r
\r
default:\r
if( i>=2000 && i < 2000+2*(layout+buttons)) {\r
j = layoutList[(i - 2000)/2];\r
if(j == -2) {\r
- char filter[] = \r
+ char filter[] =\r
"All files\0*.*\0BIN Files\0*.bin\0LOG Files\0*.log\0INI Files\0*.ini\0\0";\r
/*\r
-{ \r
+{\r
'A','l','l',' ','F','i','l','e','s', 0,\r
'*','.','*', 0,\r
'B','I','N',' ','F','i','l','e','s', 0,\r
*/\r
OPENFILENAME ofn;\r
\r
- strcpy( buf, "" );\r
+ safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) );\r
\r
ZeroMemory( &ofn, sizeof(ofn) );\r
\r
ofn.lpstrFilter = filter;\r
ofn.lpstrFile = buf;\r
ofn.nMaxFile = sizeof(buf);\r
- ofn.lpstrTitle = "Choose Book";\r
+ ofn.lpstrTitle = _("Choose Book");\r
ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;\r
\r
if( GetOpenFileName( &ofn ) ) {\r
if( activeCps->option[j].type == SaveButton)\r
GetOptionValues(hDlg, activeCps);\r
else if( activeCps->option[j].type != Button) break;\r
- sprintf(buf, "option %s\n", activeCps->option[j].name);\r
+ snprintf(buf, MSG_SIZ, "option %s\n", activeCps->option[j].name);\r
SendToProgram(buf, activeCps);\r
}\r
break;\r
case Message:\r
break;\r
}\r
- \r
+\r
}\r
\r
void\r
template.header.cdit = 0;\r
template.header.cx = 307;\r
buttonRows = (buttons + 1 + 3)/4; // 4 per row, rounded up\r
- if(nr > 50) { \r
+ if(nr > 50) {\r
breakPoint = (nr+2*buttonRows+1)/2 & ~1;\r
template.header.cx = 625;\r
}\r
for(i=0; i<nr; i++) {\r
if(k < groups && i == boxList[k]) {\r
y += 10;\r
- AddControl(x+2, y+13*(i>>1)-2, 301, 13*(boxList[k+1]-boxList[k]>>1)+8, \r
+ AddControl(x+2, y+13*(i>>1)-2, 301, 13*(boxList[k+1]-boxList[k]>>1)+8,\r
0x0082, WS_VISIBLE | WS_CHILD | SS_BLACKFRAME, 2400);\r
- AddControl(x+60, y+13*(i>>1)-6, 10*groupNameList[k]/3, 10, \r
+ AddControl(x+60, y+13*(i>>1)-6, 10*groupNameList[k]/3, 10,\r
0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(i+MAX_OPTIONS));\r
}\r
j = layoutList[i];\r
// add butons at the bottom of dialog window\r
y += 13*(nr>>1)+5;\r
\r
- AddControl(x+275, y+18*(buttonRows-1), 25, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDOK-2000);\r
- AddControl(x+235, y+18*(buttonRows-1), 35, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDCANCEL-2000);\r
+ AddControl(x+225, y+18*(buttonRows-1), 30, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDOK-2000);\r
+ AddControl(x+260, y+18*(buttonRows-1), 40, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDCANCEL-2000);\r
for(i=0; i<buttons; i++) {\r
AddControl(x+70*(i%4)+5, y+18*(i/4), 65, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 2*(nr+i));\r
layoutList[nr+i] = buttonList[i];\r
template.header.style &= ~WS_VSCROLL;\r
}\r
\r
-void \r
+void\r
EngineOptionsPopup(HWND hwnd, ChessProgramState *cps)\r
{\r
FARPROC lpProc = MakeProcInstance( (FARPROC) SettingsProc, hInst );\r