Subversion Repositories wimsdev

Rev

Rev 8262 | Rev 8299 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8262 Rev 8297
Line 97... Line 97...
97
    char *draw_type = "points";
97
    char *draw_type = "points";
98
    char *fly_font = "normal";
98
    char *fly_font = "normal";
99
    char *input_style = "";
99
    char *input_style = "";
100
    char *flytext = "";
100
    char *flytext = "";
101
    char *affine_matrix = "[1,0,0,1,0,0]";
101
    char *affine_matrix = "[1,0,0,1,0,0]";
-
 
102
    char *function_label = "f(x)=";
102
    int pixelsize = 1;
103
    int pixelsize = 1;
103
    int reply_format = 0;
104
    int reply_format = 0;
104
    int input_cnt = 0;
105
    int input_cnt = 0;
105
    int ext_img_cnt = 0;
106
    int ext_img_cnt = 0;
106
    int slider_cnt = 0;
107
    int slider_cnt = 0;
Line 1008... Line 1009...
1008
        /*
1009
        /*
1009
         @ userinput function | textarea | inputfield
1010
         @ userinput function | textarea | inputfield
1010
         @ alternative command + argment to keywords "userinput_function","userinput_textarea" and "userinput_xy"
1011
         @ alternative command + argment to keywords "userinput_function","userinput_textarea" and "userinput_xy"
1011
         @ textarea and inputfield are only usable in combination with some 'userdraw draw_ type'
1012
         @ textarea and inputfield are only usable in combination with some 'userdraw draw_ type'
1012
         @ function may be used any time (e.g. without userdraw)
1013
         @ function may be used any time (e.g. without userdraw)
-
 
1014
         @ use command "functionlabel some_string" to define the inputfield text : default value "f(x)="
-
 
1015
         @ use command 'strokecolor some_color' to adjust the plot / functionlabel color
-
 
1016
         @ the userinput for the function will be corrected by a simple 'rawmath' implementation...
1013
        */
1017
        */
1014
            temp = get_string_argument(infile,1);
1018
            temp = get_string_argument(infile,1);
1015
            if(strstr(temp,"function") != 0  || strstr(temp,"curve") != 0  || strstr(temp,"plot") != 0 ){
1019
            if(strstr(temp,"function") != 0  || strstr(temp,"curve") != 0  || strstr(temp,"plot") != 0 ){
1016
             if( js_function[DRAW_JSFUNCTION] != 1 ){
1020
             if( js_function[DRAW_JSFUNCTION] != 1 ){
-
 
1021
              add_rawmath(js_include_file);/* add simple rawmath routine to correct user input of function */
1017
              js_function[DRAW_JSFUNCTION] = 1;
1022
              js_function[DRAW_JSFUNCTION] = 1;
1018
              if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1023
              if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1019
              add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
1024
              add_input_jsfunction(js_include_file,canvas_root_id,input_style,function_label,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
-
 
1025
              input_cnt++;
-
 
1026
             }
-
 
1027
             else
-
 
1028
             {
-
 
1029
              /* no need to add DRAW_JSFUNCTION , just call it with the parameters */
-
 
1030
              fprintf(js_include_file,"add_input_jsfunction(%d,\"%s\",\"%s\",%d,\"%s\",\"%.2f\",%d,%d,%d);\n",input_cnt,input_style,function_label,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1020
              input_cnt++;
1031
              input_cnt++;
1021
             }
1032
             }
1022
             if( use_js_math == FALSE){/* add this stuff only once...*/
1033
             if( use_js_math == FALSE){/* add this stuff only once...*/
1023
              add_to_js_math(js_include_file);
1034
              add_to_js_math(js_include_file);
1024
              use_js_math = TRUE;
1035
              use_js_math = TRUE;
1025
             }
1036
             }
1026
             if( use_js_plot == FALSE){
1037
             if( use_js_plot == FALSE){
1027
              use_js_plot = TRUE;
1038
              use_js_plot = TRUE;
1028
              add_jsplot(js_include_file,canvas_root_id); /* this plots the function on JSPLOT_CANVAS */
1039
              add_jsplot(js_include_file,canvas_root_id); /* this plots the function on JSPLOT_CANVAS */
1029
             }
1040
             }
1030
            }
1041
            }
1031
            else
1042
            else
1032
            {
1043
            {
1033
             if(strstr(temp,"inputfield") != 0 ){
1044
             if(strstr(temp,"inputfield") != 0 ){
1034
              if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1045
              if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1035
              if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1046
              if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
Line 1061... Line 1072...
1061
            if( use_input_xy != 0 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
1072
            if( use_input_xy != 0 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
1062
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1073
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1063
            use_input_xy = 2;
1074
            use_input_xy = 2;
1064
            break;
1075
            break;
1065
        case USERINPUT_XY:
1076
        case USERINPUT_XY:
1066
        /*
1077
        /*
1067
        @ userinput_xy
1078
        @ userinput_xy
1068
        @ keyword
1079
        @ keyword
1069
        @ to be used in combination with command "userdraw object_type,color"
1080
        @ to be used in combination with command "userdraw object_type,color"
1070
        @ if set two (or three) input fields are added to the document<br />(one for x-values , one for y-values and in case of drawing circle one for radius-values)
1081
        @ if set two (or three) input fields are added to the document<br />(one for x-values , one for y-values and in case of drawing circle one for radius-values)
1071
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
1082
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
1072
        @ math input is allowed (e.g something like: 1+3,2*6,1/3,sqrt(3), sin(pi/4),10^-2,log(2)...)<br />eval function is 'protected' against code injection.
1083
        @ math input is allowed (e.g something like: 1+3,2*6,1/3,sqrt(3), sin(pi/4),10^-2,log(2)...)<br />eval function is 'protected' against code injection.
1073
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
1084
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
1074
        @ user drawings will not zoom on zooming (or pan on panning)
1085
        @ user drawings will not zoom on zooming (or pan on panning)
1075
        */
1086
        */
1076
            /* add simple eval check to avoid code injection with unprotected eval(string) */
1087
            /* add simple eval check to avoid code injection with unprotected eval(string) */
1077
            if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1088
            if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1078
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1089
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1079
            use_input_xy = 1;
1090
            use_input_xy = 1;
-
 
1091
            break;
-
 
1092
        case FUNCTION_LABEL:
-
 
1093
            function_label = get_string_argument(infile,1);
1080
            break;
1094
            break;
1081
        case USERINPUT_FUNCTION:
1095
        case USERINPUT_FUNCTION:
1082
        /*
1096
        /*
1083
        @ userinput_function
1097
        @ userinput_function
1084
        @ keyword
1098
        @ keyword
1085
        @ if set , a inputfield will be added to the page
1099
        @ if set , a inputfield will be added to the page
-
 
1100
        @ repeat keyword for more function input fields
1086
        @ the userinput value will be plotted in the canvas
1101
        @ the userinput value will be plotted in the canvas
1087
        @ this value may be read with 'read_canvas()'. <br />for do it yourself js-scripters : If this is the first inputfield in the script, it's id is canvas_input0
1102
        @ this value may be read with 'read_canvas()'. <br />for do it yourself js-scripters : If this is the first inputfield in the script, it's id is canvas_input0
1088
        @ use before this command 'userinput_function',<br />commands like 'inputstyle some_css' , 'xlabel some_description' , 'opacity int,int' , 'linewidth int' , 'dashed' and 'dashtype int,int' to modify
1103
        @ use before this command 'userinput_function',<br />commands like 'inputstyle some_css' , 'xlabel some_description' , 'opacity int,int' , 'linewidth int' , 'dashed' and 'dashtype int,int' to modify
1089
        @ incompatible with command 'intooltip link_text_or_image' : it uses the tooltip div for adding the inputfield
1104
        @ incompatible with command 'intooltip link_text_or_image' : it uses the tooltip div for adding the inputfield
1090
        */
1105
        */
1091
            if( js_function[DRAW_JSFUNCTION] != 1 ){
1106
            if( js_function[DRAW_JSFUNCTION] != 1 ){
1092
             js_function[DRAW_JSFUNCTION] = 1;
1107
             js_function[DRAW_JSFUNCTION] = 1;
-
 
1108
             add_rawmath(js_include_file);
1093
             if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1109
             if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1094
             add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
1110
             add_input_jsfunction(js_include_file,canvas_root_id,input_style,function_label,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
-
 
1111
             input_cnt++;
-
 
1112
            }
-
 
1113
            else
-
 
1114
            {
-
 
1115
              /* no need to add DRAW_JSFUNCTION , just call it with the parameters */
-
 
1116
             fprintf(js_include_file,"add_input_jsfunction(%d,\"%s\",\"%s\",%d,\"%s\",\"%.2f\",%d,%d,%d);\n",input_cnt,input_style,function_label,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1095
             input_cnt++;
1117
             input_cnt++;
1096
            }
1118
            }
1097
            if( use_js_math == FALSE){/* add this stuff only once...*/
1119
            if( use_js_math == FALSE){/* add this stuff only once...*/
1098
             add_to_js_math(js_include_file);
1120
             add_to_js_math(js_include_file);
1099
             use_js_math = TRUE;
1121
             use_js_math = TRUE;
Line 1323... Line 1345...
1323
            if(strncmp(draw_type,"poly",4) == 0){
1345
            if(strncmp(draw_type,"poly",4) == 0){
1324
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1346
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1325
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1347
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1326
                if(reply_format == 0){reply_format = 2;}
1348
                if(reply_format == 0){reply_format = 2;}
1327
                add_js_poly(js_include_file,(int) (draw_type[4]-'0'),draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1349
                add_js_poly(js_include_file,(int) (draw_type[4]-'0'),draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1328
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1350
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1329
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1351
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1330
            }
1352
            }
1331
            else
1353
            else
1332
            if(strcmp(draw_type,"triangle") == 0){
1354
            if(strcmp(draw_type,"triangle") == 0){
1333
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1355
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1334
                if(reply_format == 0){reply_format = 2;}
1356
                if(reply_format == 0){reply_format = 2;}
1335
                add_js_poly(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1357
                add_js_poly(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1336
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1358
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1337
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1359
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1338
            }
1360
            }
1339
            else
1361
            else
1340
            if( strcmp(draw_type,"hline") == 0 ){
1362
            if( strcmp(draw_type,"hline") == 0 ){
1341
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1363
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1342
                if(reply_format == 0){reply_format = 11;}
1364
                if(reply_format == 0){reply_format = 11;}
1343
                add_js_hlines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1365
                add_js_hlines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1344
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1366
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1345
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1367
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1346
            }
1368
            }
1347
            else
1369
            else
1348
            if( strcmp(draw_type,"hlines") == 0 ){
1370
            if( strcmp(draw_type,"hlines") == 0 ){
1349
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1371
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1350
                if(reply_format == 0){reply_format = 11;}
1372
                if(reply_format == 0){reply_format = 11;}
1351
                add_js_hlines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1373
                add_js_hlines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1352
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1374
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1353
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1375
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1354
            }
1376
            }
1355
            else
1377
            else
1356
            if( strcmp(draw_type,"vline") == 0 ){
1378
            if( strcmp(draw_type,"vline") == 0 ){
1357
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1379
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1358
                if(reply_format == 0){reply_format = 11;}
1380
                if(reply_format == 0){reply_format = 11;}
1359
                add_js_hlines(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1381
                add_js_hlines(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1360
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1382
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1361
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1383
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1362
            }
1384
            }
1363
            else
1385
            else
1364
            if( strcmp(draw_type,"vlines") == 0 ){
1386
            if( strcmp(draw_type,"vlines") == 0 ){
1365
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1387
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1366
                if(reply_format == 0){reply_format = 11;}
1388
                if(reply_format == 0){reply_format = 11;}
1367
                add_js_hlines(js_include_file,4,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1389
                add_js_hlines(js_include_file,4,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1368
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1390
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1369
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1391
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1370
            }
1392
            }
1371
            else
1393
            else
Line 1374... Line 1396...
1374
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1396
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1375
                if(reply_format == 0){reply_format = 11;}
1397
                if(reply_format == 0){reply_format = 11;}
1376
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1398
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1377
                if( use_input_xy == 1 ){
1399
                if( use_input_xy == 1 ){
1378
                    add_input_line(js_include_file,1);
1400
                    add_input_line(js_include_file,1);
1379
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1401
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1380
                }
1402
                }
1381
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1403
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1382
            }
1404
            }
1383
            else
1405
            else
1384
            if( strcmp(draw_type,"lines") == 0 ){
1406
            if( strcmp(draw_type,"lines") == 0 ){
1385
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1407
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1386
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1408
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1387
                if(reply_format == 0){reply_format = 11;}
1409
                if(reply_format == 0){reply_format = 11;}
1388
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1410
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1389
                if( use_input_xy == 1 ){
1411
                if( use_input_xy == 1 ){
1390
                    add_input_line(js_include_file,2);
1412
                    add_input_line(js_include_file,2);
1391
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1413
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1392
                }
1414
                }
1393
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1415
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1394
            }
1416
            }
1395
            else
1417
            else
1396
            if( strcmp(draw_type,"demilines") == 0 || strcmp(draw_type,"demilines") == 0 ){
1418
            if( strcmp(draw_type,"demilines") == 0 || strcmp(draw_type,"demilines") == 0 ){
1397
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1419
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1398
                if( js_function[DRAW_DEMILINES] != 1 ){ js_function[DRAW_DEMILINES] = 1;}
1420
                if( js_function[DRAW_DEMILINES] != 1 ){ js_function[DRAW_DEMILINES] = 1;}
1399
                if(reply_format == 0){reply_format = 11;}
1421
                if(reply_format == 0){reply_format = 11;}
1400
                add_js_demilines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1422
                add_js_demilines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1401
                if( use_input_xy == 1 ){
1423
                if( use_input_xy == 1 ){
1402
                    add_input_demiline(js_include_file,2);
1424
                    add_input_demiline(js_include_file,2);
1403
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1425
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1404
                }
1426
                }
1405
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1427
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1406
            }
1428
            }
1407
            else
1429
            else
1408
            if( strcmp(draw_type,"demiline") == 0 || strcmp(draw_type,"demilines") == 0 ){
1430
            if( strcmp(draw_type,"demiline") == 0 || strcmp(draw_type,"demilines") == 0 ){
1409
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1431
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
Line 1412... Line 1434...
1412
                add_js_demilines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1434
                add_js_demilines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1413
                if( use_input_xy == 1 ){
1435
                if( use_input_xy == 1 ){
1414
                    add_input_demiline(js_include_file,1);
1436
                    add_input_demiline(js_include_file,1);
1415
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1437
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1416
                }
1438
                }
1417
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1439
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1418
            }
1440
            }
1419
            else
1441
            else
1420
            if( strcmp(draw_type,"rects") == 0){
1442
            if( strcmp(draw_type,"rects") == 0){
1421
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1443
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1422
                if(reply_format == 0){reply_format = 2;}
1444
                if(reply_format == 0){reply_format = 2;}
1423
                add_js_rect(js_include_file,2,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1445
                add_js_rect(js_include_file,2,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1424
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1446
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1425
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1447
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1426
            }
1448
            }
1427
            else
1449
            else
1428
            if( strcmp(draw_type,"roundrects") == 0){
1450
            if( strcmp(draw_type,"roundrects") == 0){
1429
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1451
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1430
                if(reply_format == 0){reply_format = 2;}
1452
                if(reply_format == 0){reply_format = 2;}
1431
                add_js_rect(js_include_file,2,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1453
                add_js_rect(js_include_file,2,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1432
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1454
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1433
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1455
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1434
            }
1456
            }
Line 1826... Line 1848...
1826
                            decimals = find_number_of_digits(precision);
1848
                            decimals = find_number_of_digits(precision);
1827
                            string_length = snprintf(NULL,0,
1849
                            string_length = snprintf(NULL,0,
1828
                            "draw_centerstring(%d,%.*f,\"%s\",\"%s\",%.2f,\"%s\");\n",canvas_root_id,decimals,double_data[0],font_family,stroke_color,stroke_opacity,temp);
1850
                            "draw_centerstring(%d,%.*f,\"%s\",\"%s\",%.2f,\"%s\");\n",canvas_root_id,decimals,double_data[0],font_family,stroke_color,stroke_opacity,temp);
1829
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1851
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1830
                            snprintf(tmp_buffer,string_length,"draw_centerstring(%d,%.*f,\"%s\",\"%s\",%.2f,\"%s\");\n",canvas_root_id,decimals,double_data[0],font_family,stroke_color,stroke_opacity,temp);
1852
                            snprintf(tmp_buffer,string_length,"draw_centerstring(%d,%.*f,\"%s\",\"%s\",%.2f,\"%s\");\n",canvas_root_id,decimals,double_data[0],font_family,stroke_color,stroke_opacity,temp);
1831
                            add_to_buffer(tmp_buffer);
1853
                            add_to_buffer(tmp_buffer);
1832
                            break;
1854
                            break;
1833
                    default:break;
1855
                    default:break;
1834
                }
1856
                }
1835
            }
1857
            }
1836
            break;
1858
            break;
1837
        case MATHML:
1859
        case MATHML:
1838
        /*
1860
        /*
1839
        @ mathml x1,y1,x2,y2,mathml_string
1861
        @ mathml x1,y1,x2,y2,mathml_string
1840
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1862
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1841
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1863
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
Line 4247... Line 4269...
4247
  reply = reply + (Math.round(prec*(px2x(userdraw_x[p]))))/prec +\",\" + (Math.round(prec*(px2y(userdraw_y[p]))))/prec +\",\" + (Math.round(prec*(px2x(userdraw_x[p+1]))))/prec +\",\" + (Math.round(prec*(px2y(userdraw_y[p+1]))))/prec +\"\\n\" ;\
4269
  reply = reply + (Math.round(prec*(px2x(userdraw_x[p]))))/prec +\",\" + (Math.round(prec*(px2y(userdraw_y[p]))))/prec +\",\" + (Math.round(prec*(px2x(userdraw_x[p+1]))))/prec +\",\" + (Math.round(prec*(px2y(userdraw_y[p+1]))))/prec +\"\\n\" ;\
4248
  p = p+2;\
4270
  p = p+2;\
4249
 };\
4271
 };\
4250
 if(p == 0){alert(\"nothing drawn...\");return;};\
4272
 if(p == 0){alert(\"nothing drawn...\");return;};\
4251
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
4273
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
4252
  var p = 0;var input_reply = new Array();\
4274
  var p = 0;var input_reply = new Array();\
4253
  if( document.getElementById(\"canvas_input0\")){\
4275
  if( document.getElementById(\"canvas_input0\")){\
4254
   var t = 0;\
4276
   var t = 0;\
4255
   while(document.getElementById(\"canvas_input\"+t)){\
4277
   while(document.getElementById(\"canvas_input\"+t)){\
4256
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
4278
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
4257
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
4279
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
4258
     p++;\
4280
     p++;\
4259
    };\
4281
    };\
4260
    t++;\
4282
    t++;\
4261
   };\
4283
   };\
4262
  };\
4284
  };\
4263
  if( typeof userdraw_text != 'undefined' ){\
4285
  if( typeof userdraw_text != 'undefined' ){\
4264
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
4286
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
4265
  }\
4287
  }\
4266
  else\
4288
  else\
4267
  {\
4289
  {\
4268
   return reply +\"\\n\"+input_reply;\
4290
   return reply +\"\\n\"+input_reply;\
4269
  }\
4291
  }\
4270
 }\
4292
 }\
4271
 else\
4293
 else\
4272
 {\
4294
 {\
4273
  if( typeof userdraw_text != 'undefined' ){\
4295
  if( typeof userdraw_text != 'undefined' ){\
4274
   return reply +\"\\n\"+userdraw_text;\
4296
   return reply +\"\\n\"+userdraw_text;\
4275
  }\
4297
  }\
4276
  else\
4298
  else\
4277
  {\
4299
  {\
4278
   return reply;\
4300
   return reply;\
4279
  }\
4301
  }\
4280
 };\
4302
 };\
4281
};\n\
4303
};\n\
4282
<!-- end function 11 read_canvas%d() -->",canvas_root_id,canvas_root_id,reply_precision,canvas_root_id);
4304
<!-- end function 11 read_canvas%d() -->",canvas_root_id,canvas_root_id,reply_precision,canvas_root_id);
Line 6831... Line 6853...
6831
        *yunit="yunit",
6853
        *yunit="yunit",
6832
        *slider="slider",
6854
        *slider="slider",
6833
        *killslider="killslider",
6855
        *killslider="killslider",
6834
        *angle="angle",
6856
        *angle="angle",
6835
        *halfline="halfline",
6857
        *halfline="halfline",
6836
        *demiline="demiline";
6858
        *demiline="demiline",
-
 
6859
        *functionlabel="functionlabel";
6837
 
6860
 
6838
        while(((c = getc(infile)) != EOF)&&(c!='\n')&&(c!=',')&&(c!='=')&&(c!='\r')){
6861
        while(((c = getc(infile)) != EOF)&&(c!='\n')&&(c!=',')&&(c!='=')&&(c!='\r')){
6839
            if( i == 0 && (c == ' ' || c == '\t') ){
6862
            if( i == 0 && (c == ' ' || c == '\t') ){
6840
        continue; /* white spaces or tabs allowed before first command identifier */
6863
        continue; /* white spaces or tabs allowed before first command identifier */
6841
            }
6864
            }
Line 7528... Line 7551...
7528
        return ANGLE;
7551
        return ANGLE;
7529
        }
7552
        }
7530
        if( strcmp(input_type, halfline) == 0 || strcmp(input_type, demiline) == 0  ){
7553
        if( strcmp(input_type, halfline) == 0 || strcmp(input_type, demiline) == 0  ){
7531
        free(input_type);
7554
        free(input_type);
7532
        return HALFLINE;
7555
        return HALFLINE;
-
 
7556
        }
-
 
7557
        if( strcmp(input_type, functionlabel) == 0 ){
-
 
7558
        free(input_type);
-
 
7559
        return FUNCTION_LABEL;
7533
        }
7560
        }
7534
        free(input_type);
7561
        free(input_type);
7535
        ungetc(c,infile);
7562
        ungetc(c,infile);
7536
        return 0;
7563
        return 0;
7537
}
7564
}