Implement Tournament Manager
[xboard.git] / winboard / wsettings.c
index 643de2a..caacb0c 100644 (file)
@@ -59,6 +59,7 @@ PrintOpt(int i, int right, ChessProgramState *cps)
            case ResetButton:\r
                fprintf(debugFP, "[ %26.26s ]", opt.name);\r
            case Message:\r
+           default:\r
                break;\r
        }\r
     }\r
@@ -99,6 +100,7 @@ LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionLis
                case PathName:\r
                case Slider:\r
                case Spin: stop++;\r
+               default:\r
                case Message: ; // cannot happen\r
            }\r
            nextOption++;\r
@@ -107,7 +109,7 @@ LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionLis
        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((combos+checks || nextType == TextBox || nextType == FileName || nextType == PathName) && layout&1) {\r
            layoutList[layout++] = -1;\r
        }\r
        // The last check or combo before a spin will be put on the same line as that spin (prefix)\r
@@ -119,7 +121,7 @@ LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionLis
        }\r
        // if a combo is followed by a textbox, it must stay at the end of the combo/checks list to appear\r
        // immediately above the textbox, so treat it as check. (A check would automatically be and remain there.)\r
-       if(nextType == TextBox && lastType == ComboBox)\r
+       if((nextType == TextBox || nextType == FileName || nextType == PathName) && 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
@@ -137,7 +139,7 @@ LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionLis
            layoutList[layout++] = -1;\r
            layoutList[layout++] = comboList[2*right];\r
        }\r
-       if(nextType == TextBox) {\r
+       if(nextType == TextBox || nextType == FileName || nextType == PathName) {\r
            // A textBox is double width, so must be left-adjusted, and the right column remains empty\r
            breaks[layout/2] = lastType == Button ? 0 : 100;\r
            layoutList[layout++] = -1;\r
@@ -259,6 +261,8 @@ SetOptionValues(HWND hDlg, ChessProgramState *cps)
                SetDlgItemInt( hDlg, 2001+2*i, cps->option[j].value, TRUE );\r
                break;\r
            case TextBox:\r
+           case FileName:\r
+           case PathName:\r
                SetDlgItemText( hDlg, 2001+2*i, cps->option[j].textValue );\r
                break;\r
            case CheckBox:\r
@@ -409,12 +413,17 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
                          ofn.lpstrFilter = filter;\r
                          ofn.lpstrFile = buf;\r
                          ofn.nMaxFile = sizeof(buf);\r
-                         ofn.lpstrTitle = _("Choose Book");\r
+                         ofn.lpstrTitle = _("Choose File");\r
                          ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;\r
 \r
                          if( GetOpenFileName( &ofn ) ) {\r
                              SetDlgItemText( hDlg, i+3, buf );\r
                          }\r
+               } else\r
+               if(j == -3) {\r
+                   if( BrowseForFolder( _("Choose Folder:"), buf ) ) {\r
+                       SetDlgItemText( hDlg, i+3, buf );\r
+                   }\r
                }\r
                if(j < 0) break;\r
                if( activeCps->option[j].type  == SaveButton)\r
@@ -460,17 +469,16 @@ void AddOption(int x, int y, Control type, int i)
            AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
            AddControl(x+95, y, 50, 11, 0x0081, ES_AUTOHSCROLL | ES_NUMBER | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
            break;\r
-//     case TextBox:\r
+       case TextBox:\r
            AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
            AddControl(x+95, y, 190, 11, 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
            break;\r
-       case TextBox:  // For now all text edits get a browse button, as long as -file and -path options are not yet implemented\r
        case FileName:\r
        case PathName:\r
            AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
            AddControl(x+95, y, 180, 11, 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
            AddControl(x+275, y, 20, 12, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i-2);\r
-           layoutList[i/2-1] = -2;\r
+           layoutList[i/2-1] = -2 - (type == PathName);\r
            break;\r
        case CheckBox:\r
            AddControl(x, y, 145, 11, 0x0080, BS_AUTOCHECKBOX | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i);\r
@@ -484,6 +492,7 @@ void AddOption(int x, int y, Control type, int i)
        case SaveButton:\r
            AddControl(x-2, y, 65, 13, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, i);\r
        case Message:\r
+       default:\r
            break;\r
     }\r
 \r
@@ -521,8 +530,8 @@ CreateDialogTemplate(int *layoutList, int nr, ChessProgramState *cps)
     // 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