Subversion Repositories wimsdev

Rev

Rev 8244 | Rev 8299 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <assert.h>
  2. #include "../../Lib/libwims.h"
  3.  
  4. #define canvas_iscalculation(x) ( ((x&~32)>='A' && (x&~32)<='Z') || ( x == '/' ) || (x == '*') || (x == '+') || x == '-' || x == '^' || x == '(' || x == ')' )
  5. #define MAX_INT         128
  6. #define MAX_BUFFER 16384
  7. #define MAX_COLOR_STRING        32
  8. #define MAX_JS_FUNCTIONS 64
  9.  
  10. #define END             -1
  11. #define COMMENT         -2
  12. #define SIZE            1
  13. #define XRANGE          2
  14. #define YRANGE          3
  15. #define FONTFAMILY      4
  16. #define MATHML          5
  17. #define INPUT           6
  18. #define TEXTAREA        7
  19. #define LINEWIDTH       8
  20. #define POLYLINE        9
  21. #define POLY            10
  22. #define SEGMENT         15
  23. #define LINE            16
  24. #define DLINE           17
  25. #define RECT            18
  26. #define ARC             19
  27. #define NEW             20
  28. #define STRING          21
  29. #define STRINGUP        22
  30. #define COPY            23
  31. #define COPYRESIZED     24
  32. #define TRANSPARENT     25
  33. #define POINT           26
  34. #define CIRCLE          27
  35. #define GETPIXEL        28
  36. #define SQUARE          29
  37. #define EMPTY           30
  38. #define ELLIPSE         31
  39. #define ROTATE          32
  40. #define TYPE            33
  41. #define QUALITY         34
  42. #define INPUTSTYLE      35
  43. #define POINTS          36
  44. #define TRIANGLE        37
  45. #define HLINE           38
  46. #define VLINE           39
  47. #define GRID            40
  48. #define ZOOM            41
  49. #define ARROW           42
  50. #define DARROW          43
  51. #define AXIS            44
  52. #define FONTSIZE        46
  53. #define CURVE           50
  54. #define PLOTSTEPS       51
  55. #define TRANGE          53
  56. #define MOUSE_PRECISION 54
  57. #define FLY_TEXT        55
  58. #define FLY_TEXTUP      56
  59. #define BGIMAGE         57
  60. #define DASHED          58
  61. #define PARALLEL        59
  62. #define LATTICE         60
  63. #define OPACITY         61
  64. #define AXIS_NUMBERING  62
  65. #define RAYS            63
  66. #define OUTPUT          64
  67. #define CLOCK           65
  68. #define STYLE           66
  69. #define USERDRAW        67
  70. #define MOUSE           68
  71. #define AUDIO           69
  72. #define AUDIOOBJECT     70
  73. #define STOP            71
  74. #define RESTART         72
  75. #define FILLCOLOR       73
  76. #define CUBE            74
  77. #define CLEARBUTTON     75
  78. #define ONCLICK         76
  79. #define CROSSHAIR       77
  80. #define CROSSHAIRS      78
  81. #define BLINK           79
  82. #define DASHTYPE        80
  83. #define HTML            81
  84. #define CROSSHAIRSIZE   82
  85. #define ARROWHEAD       83
  86. #define DRAG            84
  87. #define HTTP            85
  88. #define SLIDER          86
  89. #define CLICKTILE       88
  90. #define CLICKTILE_COLORS        89
  91. #define TRANSLATION     90
  92. #define KILLTRANSLATION 91
  93. #define ARROW2          92
  94. #define DARROW2         93
  95. #define SVGCODE         95
  96. #define ROUNDRECT       96
  97. #define HATCHFILL       97
  98. #define PATTERNFILL     98
  99. #define DIAMONDFILL     99
  100. #define DOTFILL         100
  101. #define GRIDFILL        101
  102. #define IMAGEFILL       102
  103. #define FILL            103
  104. #define FILLED          104
  105. #define XYLOGSCALE      105
  106. #define XLOGSCALE       106
  107. #define YLOGSCALE       107
  108. #define XLOGBASE        108
  109. #define INTOOLTIP       109
  110. #define REPLYFORMAT     110
  111. #define VIDEO           111
  112. #define BGCOLOR         112
  113. #define FLOODFILL       113
  114. #define FILLTOBORDER    114
  115. #define CLICKFILL       115
  116. #define SETPIXEL        117
  117. #define PIXELS          118
  118. #define PIXELSIZE       119
  119. #define CLICKFILLMARGE  120
  120. #define X_AXIS_STRINGS  121
  121. #define Y_AXIS_STRINGS  122
  122. #define FONTCOLOR       123
  123. #define PIECHART        124
  124. #define LEGEND          125
  125. #define BARCHART        126
  126. #define LINEGRAPH       127
  127. #define STROKECOLOR     128
  128. #define XLABEL          129
  129. #define YLABEL          130
  130. #define LEGENDCOLORS    131
  131. #define ANIMATE         132
  132. #define STATUS          133
  133. #define SNAPTOGRID      134
  134. #define XSNAPTOGRID     135
  135. #define YSNAPTOGRID     136
  136. #define USERINPUT_XY    137
  137. #define USERTEXTAREA_XY 138
  138. #define SGRAPH          139
  139. #define YLOGBASE        140
  140. #define AFFINE          141
  141. #define KILLAFFINE      142
  142. #define LEVELCURVE      143
  143. #define JSMATH          144
  144. #define TRACE_JSCURVE   145
  145. #define SETLIMITS       146
  146. #define JSCURVE         147
  147. #define CENTERSTRING    148
  148. #define MOUSEX          149
  149. #define MOUSEY          150
  150. #define MOUSE_DEGREE    151
  151. #define MOUSE_DISPLAY   152
  152. #define XUNIT           153
  153. #define YUNIT           154
  154. #define KILLSLIDER      155
  155. #define ANGLE           156
  156. #define USERINPUT_FUNCTION 157
  157. #define USERINPUT       158
  158. #define HALFLINE        159
  159. #define FUNCTION_LABEL  160
  160.  
  161. #define DRAW_GRID       0
  162. #define DRAW_SEGMENTS   1
  163. #define DRAW_CROSSHAIRS 2
  164. #define DRAW_RECTS      3
  165. #define DRAW_ROUNDRECTS 4
  166. #define DRAW_ARROWS     6
  167. #define DRAW_GRIDFILL   7
  168. #define DRAW_XML        8
  169. #define DRAW_CIRCLES    9
  170. #define DRAW_ARCS       10
  171. #define DRAW_ELLIPSES   11
  172. #define DRAW_TEXTS      12
  173. #define DRAW_CURVE      13
  174. #define DRAW_PATHS      14
  175. #define DRAW_LATTICE    15
  176. #define DRAW_INPUTS     16
  177. #define DRAW_TEXTAREAS  17
  178. #define DRAW_HTTP       18
  179. #define DRAW_AUDIO      19
  180. #define DRAW_VIDEO      20
  181. #define DRAW_DOTFILL    21
  182. #define DRAW_HATCHFILL  22
  183. #define DRAW_IMAGEFILL  23
  184. #define DRAW_FLOODFILL  24
  185. #define DRAW_FILLTOBORDER       25
  186. #define DRAW_PIXELS     26
  187. #define DRAW_POLY       27
  188. #define DRAW_LINES      28
  189. #define DRAW_PIECHART   29
  190. #define DRAW_CLOCK      30
  191. #define DRAW_EXTERNAL_IMAGE     31
  192. #define DRAG_EXTERNAL_IMAGE     32
  193. #define DRAW_DIAMONDFILL        33
  194. #define DRAW_SGRAPH     34
  195. #define DRAW_POLYLINE   35
  196. #define DRAW_YLOGSCALE  36
  197. #define DRAW_XLOGSCALE  37
  198. #define DRAW_XYLOGSCALE 38
  199. #define DRAW_CENTERSTRING 39
  200. #define DRAW_JSFUNCTION 40
  201. #define DRAW_DEMILINES  41
  202.  
  203. #define BG_CANVAS       0
  204. #define STATIC_CANVAS   1
  205. #define MOUSE_CANVAS    2
  206. #define GRID_CANVAS     3
  207. #define DRAG_CANVAS     4
  208. #define DRAW_CANVAS     5
  209. #define TEXT_CANVAS     6
  210. #define EXTERNAL_DRAG_CANVAS 7
  211. #define EXTERNAL_IMAGE_CANVAS 8
  212. #define CLOCK_CANVAS    9
  213. #define ANIMATE_CANVAS  10
  214. #define TRACE_CANVAS    11
  215. #define JSPLOT_CANVAS   12
  216. #define USERDRAW_JSPLOT 13 /* USERDRAW_JSPLOT will be increased with every added inputfield... 13,14,14... SHOULD ALWAYS HAVE HIGHEST NUMBER*/
  217.  
  218. #ifndef STD_H
  219. #define STD_H
  220.  
  221. #ifndef bool
  222. #define bool            char
  223. #endif
  224. #ifndef TRUE
  225. #define TRUE            1
  226. #endif
  227. #ifndef FALSE
  228. #define FALSE           0
  229. #endif
  230.  
  231. #endif
  232.  
  233. void add_drag_code(FILE *js_include_file,int canvas_cnt,int canvas_root_id);
  234. void add_trace_js_mouse(FILE *js_include_file,int canvas_cnt,int canvas_root_id,char *stroke_color,char *jsmath,int font_size,double stroke_opacity,int line_width,int crosshair_size);
  235. void add_setlimits(FILE *js_include_file, int canvas_root_id);
  236. void add_safe_eval(FILE *js_include_file);
  237. void add_to_js_math(FILE *js_include_file);
  238. void add_calc_y(FILE *js_include_file,int canvas_root_id,char *jsmath);
  239. void add_jsplot(FILE *js_include_file,int canvas_root_id);
  240. void add_slider(FILE *js_include_file, int canvas_root_id,double v1,double v2,int width,int height,int type,char *label,int slider_cnt,char *stroke_color,char *fill_color,int line_width,double opacity,char *font_family,char *font_color,int use_slider_display);
  241. void add_slider_display(FILE *js_include_file, int canvas_root_id,int precision,int font_size,char *font_color,double stroke_opacity);
  242. void add_xyslider(FILE *js_include_file, int canvas_root_id,double v1,double v2,int width,int height,int type,char *label,int slider_cnt,char *stroke_color,char *fill_color,int line_width,double opacity,char *font_family,char *font_color,int use_slider_display);
  243. void *my_newmem(size_t size);
  244. void canvas_error(char *msg);
  245. char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision);
  246. char *eval_parametric(int xsize,int ysize,char *fun1,char* fun2,double xmin,double xmax,double ymin,double ymax, double tmin,double tmax,int plotsteps,int precision);
  247. char *eval_levelcurve(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int plotsteps,int precision,double level);
  248.  
  249. char *double_xy2js_array(double xy[],int len,int decimals);
  250. int find_number_of_digits(int i);
  251. int x2px(double x);
  252. int y2px(double y);
  253.  
  254. void add_clear_button(FILE *js_include_file,int canvas_root_id,char *input_style,char *button_text);
  255. void add_js_inputs(FILE *js_include_file,int canvas_root_id,int num,int input_cnt,char *input_style,int line_width);
  256. void add_js_mouse(FILE *js_include_file,int canvas_cnt,int canvas_root_id,int precision,char *stroke_color,int font_size,double stroke_opacity,int type);
  257. void add_js_points(FILE *js_include_file,int num,char *draw_type,int line_width, int radius ,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  258. void add_js_circles(FILE *js_include_file,int num,char *draw_type, int line_width, int radius , char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  259. void add_js_segments(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1);
  260. void add_js_demilines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1);
  261. void add_js_polyline(FILE *js_include_file,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1);
  262. void add_js_lines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1);
  263. void add_js_hlines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1);
  264. void add_js_arrows(FILE *js_include_file,int num,char *draw_type,int line_width,int type, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int arrow_head);
  265. void add_js_crosshairs(FILE *js_include_file,int num,char *draw_type,int line_width, int crosshair_size ,char *stroke_color,double stroke_opacity);
  266. void add_js_paths(FILE *js_include_file,int num,char *draw_type,int line_width, int closed_path,char *stroke_color,double stroke_opacity,int use_filled, char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  267. void add_js_poly(FILE *js_include_file,int num,char *draw_type,int line_width,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  268. void add_js_rect(FILE *js_include_file,int num,int roundrect,char *draw_type,int line_width,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  269. void add_js_floodfill(FILE *js_include_file,int canvas_root_id);
  270. void add_js_filltoborder(FILE *js_include_file,int canvas_root_id);
  271. void add_js_arc(FILE *js_include_file,int canvas_root_id,int num,int line_width,char *stroke_color,double stroke_opacity,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1);
  272. void add_js_text(FILE *js_include_file,int canvas_root_id,int font_size,char *font_family,char *font_color,double stroke_opacity);
  273. /* these should  be harmonized via switch key !!*/
  274. void add_input_circle(FILE *js_include_file,int type,int num);
  275. void add_input_segment(FILE *js_include_file,int num);
  276. void add_input_demiline(FILE *js_include_file,int num);
  277. void add_input_line(FILE *js_include_file,int num);
  278. void add_input_polyline(FILE *js_include_file);
  279. void add_textarea_polygon(FILE *js_include_file);
  280. void add_input_crosshair(FILE *js_include_file,int num);
  281. void add_input_arrow(FILE *js_include_file,int num);
  282. void add_input_xy(FILE *js_include_file, int canvas_root_id);
  283. void add_input_xyr(FILE *js_include_file, int canvas_root_id);
  284. void add_input_x1y1x2y2(FILE *js_include_file, int canvas_root_id);
  285. void add_textarea_xy(FILE *js_include_file, int canvas_root_id);
  286. void add_zoom_buttons(FILE *js_include_file,int canvas_root_id,char *stroke_color,double stroke_opacity);
  287. void add_js_tooltip(int canvas_root_id,char *tooltip_text,char *bgcolor,int xsize,int ysize);
  288. void add_input_jsfunction(FILE *js_include_file, int canvas_root_id,char *input_style,char *input_label,int input_cnt,char *stroke_color,float stroke_opacity,int line_width,int use_dashed,int dashtype0,int dashtype1);
  289. void add_rawmath(FILE *js_include_file);
  290. extern int NUMBER_OF_COLORNAMES;
  291. extern struct colors { char *hex; char *name; char *rgb; } colors[];
  292.