Allow entry of negative numbers in spin control (WB)
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 26 Aug 2013 11:35:47 +0000 (13:35 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 26 Aug 2013 11:35:47 +0000 (13:35 +0200)
Windows numeric controls do not accept negative numbers, so in case the
range of a spin option can go negative, the style ES_NUMBER should not be
set on the control.

winboard/wsettings.c

index 545071c..2cce2e0 100644 (file)
@@ -551,13 +551,15 @@ void AddControl(int x, int y, int w, int h, int type, int style, int n)
 \r
 void AddOption(int x, int y, Control type, int i)\r
 {\r
-    int extra;\r
+    int extra, num = ES_NUMBER;\r
 \r
     switch(type) {\r
+       case Slider+100:\r
+           num = 0; // needs text control for accepting negative numbers\r
        case Slider:\r
        case Spin:\r
            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
+           AddControl(x+95, y, 50, 11, 0x0081, ES_AUTOHSCROLL | num | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
            break;\r
        case TextBox:\r
            extra = 13*activeList[layoutList[i/2]].min; // when extra high, left-align and put description text above it\r
@@ -625,7 +627,8 @@ CreateDialogTemplate(int *layoutList, int nr, Option *optionList)
        }\r
        j = layoutList[i];\r
        if(j >= 0) {\r
-           AddOption(x+155-150*(i&1), y+13*(i>>1)+5, optionList[j].type, 2*i);\r
+           int neg = (optionList[j].type == Spin && optionList[j].min < 0 ? 100 : 0); // flags spin with negative range\r
+           AddOption(x+155-150*(i&1), y+13*(i>>1)+5, optionList[j].type + neg, 2*i);\r
            // listboxes have the special power to adjust the width of the column they are in\r
            if(optionList[j].type == ListBox) x -= optionList[j].value, template.header.cx -= optionList[j].value;\r
        }\r