Subversion Repositories wimsdev

Rev

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