X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwsettings.c;h=fc0dc12975ab838c1ff9b0a94107012c1d551282;hb=7734c79f4d6e76e3d80f7ff42aea9e891102bc99;hp=a1a6142fa330d4d490f85d1dae37a5e24ae6dc01;hpb=3512e2a362ede1907c75f89e3d6f5945414b46a5;p=xboard.git diff --git a/winboard/wsettings.c b/winboard/wsettings.c index a1a6142..fc0dc12 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -9,12 +9,14 @@ * that generates the actual dialog box from it. */ -//#include "config.h" #include "config.h" +#include #include +#include #include "common.h" #include "backend.h" +#include "backendz.h" int layoutList[2*MAX_OPTIONS]; int checkList[2*MAX_OPTIONS]; @@ -33,10 +35,13 @@ PrintOpt(int i, int right, ChessProgramState *cps) } else { Option opt = cps->option[i]; switch(opt.type) { + case Slider: case Spin: fprintf(debugFP, "%20.20s [ +/-]", opt.name); break; case TextBox: + case FileName: + case PathName: fprintf(debugFP, "%20.20s [______________________________________]", opt.name); break; case CheckBox: @@ -47,7 +52,9 @@ PrintOpt(int i, int right, ChessProgramState *cps) break; case Button: case SaveButton: + case ResetButton: fprintf(debugFP, "[ %26.26s ]", opt.name); + case Message: break; } } @@ -68,7 +75,7 @@ CreateOptionDialogTest(int *list, int nr, ChessProgramState *cps) void LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionList) { - int n, i, b = strlen(groupName), stop, prefix, right, nextOption, firstButton = buttons; + int i, b = strlen(groupName), stop, prefix, right, nextOption, firstButton = buttons; Control lastType, nextType; nextOption = firstOption; @@ -80,10 +87,15 @@ LayoutOptions(int firstOption, int endOption, char *groupName, Option *optionLis switch(nextType = optionList[nextOption].type) { case CheckBox: checkList[checks++] = nextOption; lastType = CheckBox; break; case ComboBox: comboList[combos++] = nextOption; lastType = ComboBox; break; + case ResetButton: case SaveButton: case Button: buttonList[buttons++] = nextOption; lastType = Button; break; case TextBox: + case FileName: + case PathName: + case Slider: case Spin: stop++; + case Message: ; // cannot happen } nextOption++; } @@ -165,7 +177,7 @@ DesignOptionDialog(ChessProgramState *cps) while(k < cps->nrOptions) { // k steps through 'solitary' options // look if we hit a group of options having names that start with the same word int groupSize = 1, groupNameLength = 50; - sscanf(cps->option[k].name, "%s", &buf); // get first word of option name + sscanf(cps->option[k].name, "%s", buf); // get first word of option name while(k + groupSize < cps->nrOptions && strstr(cps->option[k+groupSize].name, buf) == cps->option[k+groupSize].name) { int j; @@ -183,13 +195,6 @@ DesignOptionDialog(ChessProgramState *cps) LayoutOptions(k, k+groupSize, buf, cps->option); // flush the group boxList[groups++] = layout; // group end in odd entries k = n = k + groupSize; -#if 0 - } else { - // try to recognize "two-column groups" based on option suffix - int j = 1; - while((p = EndMatch(cps->option[k].name, EndMatch(cps->option[k+2*j].name)) && - (q = EndMatch(cps->option[k+1].name, EndMatch(cps->option[k+2*j+1].name)) ) j++; -#endif } else k += groupSize; // small groups are grouped with the solitary options } if(n != k) LayoutOptions(n, k, "", cps->option); // flush remaining solitary options @@ -266,6 +271,7 @@ SetOptionValues(HWND hDlg, ChessProgramState *cps) break; case Button: case SaveButton: + default: break; } } @@ -291,14 +297,13 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps) // read out all controls, and if value is altered, remember it and send it to the engine { HANDLE hwndCombo; - int i, k, new, changed; + int i, k, new=0, changed=0; char **choices, newText[MSG_SIZ], buf[MSG_SIZ]; BOOL success; for(i=0; ioption[j].name ); switch(cps->option[j].type) { case Spin: new = GetDlgItemInt( hDlg, 2001+2*i, &success, TRUE ); @@ -334,6 +339,7 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps) if(changed) cps->option[j].value = new; break; case Button: + default: break; // are treated instantly, so they have been sent already } if(changed == 2) sprintf(buf, "option %s=%d\n", cps->option[j].name, new); else @@ -344,8 +350,6 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps) LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static int * lpIndexFRC; - BOOL index_is_ok; char buf[MSG_SIZ]; int i, j; @@ -422,123 +426,6 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa return FALSE; } -#if 0 -// example copied from MS docs -#define ID_HELP 150 -#define ID_TEXT 200 - -LPWORD lpwAlign(LPWORD lpIn) -{ - ULONG ul; - - ul = (ULONG)lpIn; - ul ++; - ul >>=1; - ul <<=1; - return (LPWORD)ul; -} - -LRESULT DisplayMyMessage(HINSTANCE hinst, HWND hwndOwner, LPSTR lpszMessage) -{ - HGLOBAL hgbl; - LPDLGTEMPLATE lpdt; - LPDLGITEMTEMPLATE lpdit; - LPWORD lpw; - LPWSTR lpwsz; - LRESULT ret; - int nchar; - - hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024); - if (!hgbl) - return -1; - - lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl); - - // Define a dialog box. - - lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION; -// WS_POPUP | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | DS_SETFONT - lpdt->cdit = 3; // Number of controls - lpdt->x = 10; lpdt->y = 10; - lpdt->cx = 100; lpdt->cy = 100; - - lpw = (LPWORD)(lpdt + 1); - *lpw++ = 0; // No menu - *lpw++ = 0; // Predefined dialog box class (by default) - - lpwsz = (LPWSTR)lpw; - nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "My Dialog", -1, lpwsz, 50); - lpw += nchar; - - //----------------------- - // Define an OK button. - //----------------------- - lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary - lpdit = (LPDLGITEMTEMPLATE)lpw; - lpdit->x = 10; lpdit->y = 70; - lpdit->cx = 80; lpdit->cy = 20; - lpdit->id = IDOK; // OK button identifier - lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; - - lpw = (LPWORD)(lpdit + 1); - *lpw++ = 0xFFFF; - *lpw++ = 0x0080; // Button class - - lpwsz = (LPWSTR)lpw; - nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "OK", -1, lpwsz, 50); - lpw += nchar; - lpw = lpwAlign(lpw); // Align creation data on DWORD boundary - *lpw++ = 0; // No creation data - - //----------------------- - // Define a Help button. - //----------------------- - lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary - lpdit = (LPDLGITEMTEMPLATE)lpw; - lpdit->x = 55; lpdit->y = 10; - lpdit->cx = 40; lpdit->cy = 20; - lpdit->id = ID_HELP; // Help button identifier - lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; - - lpw = (LPWORD)(lpdit + 1); - *lpw++ = 0xFFFF; - *lpw++ = 0x0080; // Button class atom - - lpwsz = (LPWSTR)lpw; - nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "Help", -1, lpwsz, 50); - lpw += nchar; - lpw = lpwAlign(lpw); // Align creation data on DWORD boundary - *lpw++ = 0; // No creation data - - //----------------------- - // Define a static text control. - //----------------------- - lpw = lpwAlign(lpw); // Align DLGITEMTEMPLATE on DWORD boundary - lpdit = (LPDLGITEMTEMPLATE)lpw; - lpdit->x = 10; lpdit->y = 10; - lpdit->cx = 40; lpdit->cy = 20; - lpdit->id = ID_TEXT; // Text identifier - lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT; - - lpw = (LPWORD)(lpdit + 1); - *lpw++ = 0xFFFF; - *lpw++ = 0x0082; // Static class - - for (lpwsz = (LPWSTR)lpw; *lpwsz++ = (WCHAR)*lpszMessage++;); - lpw = (LPWORD)lpwsz; - lpw = lpwAlign(lpw); // Align creation data on DWORD boundary - *lpw++ = 0; // No creation data - - GlobalUnlock(hgbl); - ret = DialogBoxIndirect(hinst, - (LPDLGTEMPLATE)hgbl, - hwndOwner, - (DLGPROC)DialogProc); - GlobalFree(hgbl); - return ret; -} -#endif - void AddControl(int x, int y, int w, int h, int type, int style, int n) { int i; @@ -562,6 +449,7 @@ void AddOption(int x, int y, Control type, int i) { switch(type) { + case Slider: case Spin: AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i); AddControl(x+95, y, 50, 11, 0x0081, ES_AUTOHSCROLL | ES_NUMBER | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1); @@ -586,8 +474,10 @@ void AddOption(int x, int y, Control type, int i) AddControl(x+95, y-1, 50, 500, 0x0085, CBS_AUTOHSCROLL | CBS_DROPDOWN | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1); break; case Button: + case ResetButton: case SaveButton: AddControl(x-2, y, 65, 13, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, i); + case Message: break; } @@ -600,7 +490,7 @@ CreateDialogTemplate(int *layoutList, int nr, ChessProgramState *cps) template.header.cdit = 0; template.header.cx = 307; - buttonRows = (buttons + 1 + 3)/4; // 4 per row, ronded up + buttonRows = (buttons + 1 + 3)/4; // 4 per row, rounded up if(nr > 50) { breakPoint = (nr+2*buttonRows+1)/2 & ~1; template.header.cx = 625; @@ -634,11 +524,6 @@ CreateDialogTemplate(int *layoutList, int nr, ChessProgramState *cps) template.title[8] = cps == &first ? '1' : '2'; template.header.cy = y += 18*buttonRows+2; template.header.style &= ~WS_VSCROLL; - if(y > 300, 0) { - template.header.cx = 295; - template.header.cy = 300; - template.header.style |= WS_VSCROLL; - } } void