window.h
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:27k
开发平台:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  window.h
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #ifndef LEDA_WINDOW_H
  12. #define LEDA_WINDOW_H
  13. #include <LEDA/basic.h>
  14. #include <LEDA/plane.h>
  15. #include <LEDA/leda_window.h>
  16. #include <LEDA/leda_panel.h>
  17. /*{Manpage {window} {} {Graphic Windows}}*/
  18. class window : public LEDA_WINDOW {
  19. /*{Mdefinition
  20. The data type $window$ provides an interface for the input and
  21. output of basic two-dimensional geometric objects (cf.~section 5.1) using the
  22. X11 window system.  Application programs using data type $window$ have to
  23. be linked with {em libWx.a} and the X11 library (cf.~section~1.6):
  24. CC $prog.c$ -lP -lG -lL -lWx -lX11 -lm
  25. An instance $W$ of the data type $window$ is an iso-oriented
  26. rectangular window in the two-dimensional plane.
  27. The default representation of $W$ on the screen is a square of maximal possible
  28. edge length positioned in the upper right corner (cf.~creation, variant c)).
  29. The coordinates and scaling of $W$ used for drawing operations are defined
  30. by three double parameters:
  31. $x_0$, the x-coordinate of the left side, $x_1$, the x-coordinate of the right
  32. side, and $y_0$, the y-coordinate of the bottom side.
  33. The y-coordinate of the top side of $W$ is determined by the current size and
  34. shape of the window on the screen, which can be changed interactively.
  35. A graphic window supports operations for drawing points, lines, segments,
  36. arrows, circles, polygons, graphs, dots and for graphical input of all these
  37. objects using the mouse input device. Most of the drawing operations have an
  38. optional color argument. Possible colors are $black$ (default), $white$,
  39. $blue$, $green$, $red$, $violet$, and $orange$. On monochrome displays all
  40. colors different from $white$ are turned to $black$. There are 6 parameters
  41. used by the drawing operations:
  42. begin{enumerate}
  43. item
  44. The {sl line width} parameter (default value 1 pixel) defines the width of all
  45. kinds of lines (segments, arrows, edges, circles, polygons).
  46. item
  47. The {sl line style} parameter defines the style of lines. Possible line
  48. styles are $solid$ (default), $dashed$, and $dotted$.
  49. item
  50. The {sl node width} parameter (default value 10 pixels) defines the diameter
  51. of nodes created by the draw_node and draw_filled_node operations.
  52. item
  53. The {sl text mode} parameter defines how text is inserted into the window.
  54. Possible values are $transparent$ (default)  and $opaque$.
  55. item
  56. The {sl drawing mode} parameter defines the logical operation that is used
  57. for setting pixels in all drawing operations. Possible values are
  58. $src_mode$ (default) and $xor_mode$. In $src_mode$ pixels are set to
  59. the respective color value, in $xor_mode$ the value is bitwise added to the
  60. current pixel value.
  61. item
  62. The {sl redraw function} parameter is used to redraw the entire window
  63. whenever a redrawing is necessary, e.g., if the window shape on the screen
  64. has  been changed. Its type is pointer to a void-function taking no arguments,
  65. i.e., void (*F)();
  66. end{enumerate} }*/
  67. public:
  68. /*{Mcreation W }*/ 
  69. enum placement {min = -1, center =-2, max = -3 };
  70. window(float width, float height, float xpos, float ypos, const char* = LEDA::version_string);
  71. /*
  72. window(float xpix, float ypix, float xpos, float ypos);
  73. */
  74. /*{Mcreate creates a window $W$ of physical size $xpix times ypix$ pixels
  75.     with its upper left corner at position ($xpos,ypos$) on the screen.}*/
  76. window(float width, float height, const char* = LEDA::version_string);
  77. /*
  78. window(float xpix, float ypix);
  79. */
  80. /*{Mcreate creates a window $W$ of physical size $xpix times ypix$ pixels
  81.     positioned into the upper right corner of the screen.}*/
  82. window(const char* = LEDA::version_string);
  83. /*
  84. window();
  85. */
  86. /*{Mcreate creates a maximal squared window $W$ positioned into the 
  87.     upper right corner of the screen.}*/
  88. /*{Mtext
  89. medskip
  90. All three variants initialize the coordinates of $W$ to $x_0 = 0$,
  91. $x_1 = 100$ and $y_0 = 0$. The $init$ operation (see  below) can later
  92. be used to change the window coordinates and scaling.}*/
  93.  window(int);  // just create, do not open
  94.  window(const window& w) : LEDA_WINDOW(w) {}
  95. ~window() {}   // ~LEDA_WINDOW does this job
  96.  window& operator=(const window& w) 
  97.  { LEDA_WINDOW::operator=(w); return *this; }
  98.  
  99. /*{Moperations 3.1 4.4}*/
  100. /*{Mtext
  101. medskip
  102. {bf 3.1 Initialization} }*/
  103. void init(double x0,double x1,double y0) { LEDA_WINDOW::init(x0,x1,y0); }
  104. /*{Mopl     sets the coordinates of $W$ to $x_0$, $x_1$, and $y_0$.}*/
  105. void set_grid_mode(int d) {LEDA_WINDOW::set_grid_mode(d);}
  106. /*{Mopl     adds a rectangular grid with integer coordinates and  
  107.              grid distance $d$ to $W$, if $d > 0$. Removes grid from
  108.              $W$, if $dle 0$.}*/
  109. void init(double x0, double x1, double y0, int d) { LEDA_WINDOW::init(x0,x1,y0,d);}
  110. /*{Mopl     like init($x_0,x_1,y_0$) followed by set_grid_mode($d$).}*/
  111. void clear(color c=BG_color) { LEDA_WINDOW::clear(c); };
  112. /*{Mopl      clears $W$.}*/
  113. /*{Mtext
  114. medskip
  115. {bf 3.2 Setting parameters} }*/
  116. int set_line_width(int pix){return LEDA_WINDOW::set_line_width(pix);}
  117. /*{Mopl     sets the line width parameter to $pix$ pixels and
  118.      returns its previous value.}*/
  119. line_style set_line_style(line_style s)
  120. {return LEDA_WINDOW::set_line_style(s);}
  121. /*{Mopl     sets the line style parameter to $s$ and returns its
  122.      previous value.}*/
  123. int set_node_width(int pix) {return LEDA_WINDOW::set_node_width(pix);}
  124. /*{Mopl     sets the node width parameter to $pix$ pixels and
  125.      returns its previous value.}*/
  126. text_mode set_text_mode(text_mode m)
  127. {return LEDA_WINDOW::set_text_mode(m);}
  128. /*{Mopl     sets the text mode parameter to $m$ and returns
  129.      its previous value.}*/
  130. drawing_mode set_mode(drawing_mode m)
  131. {return LEDA_WINDOW::set_mode(m);}
  132. /*{Mopl     sets the drawing mode parameter to $m$ and returns 
  133.      its previous value.}*/
  134. void set_frame_label(string s){ LEDA_WINDOW::set_frame_label(s); }
  135. /*{Mopl     makes $s$ the window frame label. }*/
  136. void reset_frame_label() { LEDA_WINDOW::reset_frame_label(); }
  137. /*{Mop      restores the standard LEDA frame label. }*/
  138. void set_redraw(void (*F)()) { LEDA_WINDOW::set_redraw(*F);}
  139. /*{Mopl     sets the redraw function parameter to $F$.}*/
  140. void set_flush(bool b)     { LEDA_WINDOW::set_flush(b); }
  141. /*{Mopl      flushes $X11$ output stream after each draw action 
  142.              iff $b = true$.}*/
  143. bool load_text_font(string fn)    { return LEDA_WINDOW::load_text_font(fn); }
  144. /*{Mopl      loads $X11$ font $fn$ and uses it as text font. Returns true
  145.              on success and false if the font is not available.}*/
  146. bool load_bold_font(string fn)    { return LEDA_WINDOW::load_bold_font(fn); }
  147. /*{Mopl      loads $X11$ font $fn$ and uses it as bold font. Returns true
  148.              on success and false if the font is not available.}*/
  149. bool load_message_font(string fn) { return LEDA_WINDOW::load_message_font(fn); }
  150. /*{Mopl      load $X11$ font $fn$ and use it as message font. Returns true
  151.              on success and false if the font is not available.}*/
  152. /*{Mtext
  153. medskip
  154. {bf 3.3 Reading parameters and window coordinates} }*/
  155. int get_line_width() {return LEDA_WINDOW::get_line_width();}
  156. /*{Mop      returns the current line width.}*/ 
  157. line_style get_line_style() {return LEDA_WINDOW::get_line_style();}
  158. /*{Mop      returns the current line style.}*/ 
  159. int get_node_width() {return LEDA_WINDOW::get_node_width();}
  160. /*{Mop      returns the current node width.}*/ 
  161. text_mode get_text_mode() {return LEDA_WINDOW::get_text_mode();}
  162. /*{Mop      returns the current text mode.}*/ 
  163. drawing_mode get_mode() {return LEDA_WINDOW::get_mode();}
  164. /*{Mop      returns the current drawing mode.}*/ 
  165. double xmin() {return LEDA_WINDOW::xmin();}
  166. /*{Mop      returns $x_0$, the minimal x-coordinate of $W$.}*/ 
  167. double ymin() {return LEDA_WINDOW::ymin();}
  168. /*{Mop      returns $y_0$, the minimal y-coordinate of $W$.}*/ 
  169. double xmax() {return LEDA_WINDOW::xmax();}
  170. /*{Mop      returns $x_1$, the maximal x-coordinate of $W$.}*/ 
  171. double ymax() {return LEDA_WINDOW::ymax();}
  172. /*{Mop      returns $y_1$, the maximal y-coordinate of $W$.}*/ 
  173. double scale() {return LEDA_WINDOW::scale();}
  174. /*{Mop      returns the number of pixels of a unit length 
  175.      line segment.}*/
  176. operator void*() { return (state==0) ? 0 : this; }
  177. // points
  178. /*{Mtext
  179. medskip
  180. {bf 3.4 Drawing points} 
  181. setopdims 1.2 4.4
  182. }*/
  183. void draw_point(double x, double y, color c=FG_color);
  184. /*{Mopl     draws the point $(x,y)$ as a cross of a vertical 
  185.      and a horizontal segment intersecting at $(x,y)$.}*/
  186. void draw_point(const point& p, color c=FG_color);
  187. /*{Mopl     draws point ($p$.xcoord(),$p$.ycoord()).}*/
  188. void draw_pix(double x, double y, color c=FG_color);
  189. void draw_pixel(double x, double y, color c=FG_color) { draw_pix(x,y,c); }
  190. /*{Mopl     sets the color of the pixel at position $(x,y)$ to $c$. }*/
  191. void draw_pix(const point& p, color c=FG_color);
  192. void draw_pixel(const point& p, color c=FG_color) { draw_pix(p,c); }
  193. /*{Mopl     sets the color of the pixel at position $p$ to $c$. }*/
  194. // drawing segments
  195. /*{Mtext
  196. medskip
  197. {bf 3.5 Drawing line segments}
  198. }*/
  199. void draw_segment(double x1, double y1, double x2, double y2, color c=FG_color);
  200. /*{Mopl     draws a line segment from $(x_1,y_1)$ to $(x_2,y_2)$.}*/
  201. void draw_segment(const point& p, const point& q, color c=FG_color );
  202. /*{Mopl     draws a line segment from point $p$ to point $q$.}*/
  203. void draw_segment(const segment& s, color c=FG_color );
  204. /*{Mopl     draws line segment $s$.}*/
  205. // lines
  206. /*{Mtext
  207. medskip
  208. {bf 3.6 Drawing lines}
  209. }*/
  210. void draw_line(double x1, double y1, double x2, double y2, color c=FG_color );
  211. /*{Mopl     draws a straight line passing through points $(x_1,y_1)$ and 
  212.      $(x_2,y_2)$.}*/
  213. void draw_line(const point& p, const point& q, color c=FG_color);
  214. /*{Mopl     draws a straight line passing through points $p$ and $q$.}*/
  215. void draw_line(const segment& s, color c=FG_color);
  216. /*{Mopl     draws the line supporting $s$.}*/
  217. void draw_line(const line& l, color c=FG_color);
  218. /*{Mopl     draws line $l$.}*/
  219. void draw_hline(double y, color c=FG_color );
  220. /*{Mopl     draws a horizontal line with y-coordinate $y$. }*/
  221. void draw_vline(double x, color c=FG_color );
  222. /*{Mopl     draws a vertical line with x-coordinate $x$. }*/
  223. // drawing arcs
  224. void draw_arc(double x1, double y1, double x2, double y2, double r, color c=FG_color);
  225. void draw_arc(const segment&, double, color c=FG_color);
  226. void draw_arc(const point& p, const point& q, double r , color c=FG_color);
  227. /*{Mopl     draws a circular arc with radius r from p to q 
  228.              with the center lying  to the right of the
  229.              directed segment $plongrightarrow q$.  }*/
  230. // arrows
  231. /*{Mtext
  232. medskip
  233. {bf 3.7 Drawing arrows}
  234. }*/
  235. point draw_arrow_head(const point& q, double dir, color c=FG_color);
  236. void draw_arrow(double x1, double y1, double x2, double y2, color c =FG_color );
  237. /*{Mopl     draws an arrow pointing from $(x_1,y_1)$ to $(x_2,y_2)$.}*/
  238. void draw_arrow(const point& p, const point& q, color c=FG_color );
  239. /*{Mopl     draws an arrow pointing from point $p$ to point $q$.}*/
  240. void draw_arrow(const segment& s, color=FG_color );
  241. /*{Mopl     draws an arrow pointing from $s$.start() to $s$.end().}*/
  242. void draw_arc_arrow(double x1, double y1, double x2, double y2, double r,color c=FG_color);
  243. void draw_arc_arrow(const segment& s, double r, color c=FG_color);
  244. void draw_arc_arrow(const point& p , const point& q, double r, color c=FG_color);
  245. /*{Mopl      draws a circular arc arrow with radius r pointing from 
  246.              p to q with the center lying  to the right of the
  247.              directed segment $plongrightarrow q$.  }*/
  248. //circles
  249. /*{Mtext
  250. medskip
  251. {bf 3.8 Drawing circles}
  252. }*/
  253. void draw_circle(double x, double y, double r, color c=FG_color);
  254. /*{Mopl     draws the circle with center $(x,y)$ and radius $r$.}*/
  255. void draw_circle(const point& p, double r, color c=FG_color);
  256. /*{Mopl     draws the circle with center $p$ and radius $r$.}*/
  257. void draw_circle(const circle& C, color c=FG_color);
  258. /*{Mopl     draws circle $C$.}*/
  259. void draw_ellipse(double x, double y, double r1, double r2, color c=FG_color);
  260. /*{Mopl     draws the ellipse with center $(x,y)$ and radii $r1$ and $r2$.}*/
  261. void draw_ellipse(const point& p, double r1, double r2, color c=FG_color);
  262. /*{Mopl     draws the ellipse with center $p$ and radii $r1$ and $r2$.}*/
  263. /*{Mtext
  264. medskip
  265. {bf 3.9 Drawing discs}
  266. }*/
  267. void draw_disc(double x, double y, double r, color c=FG_color);
  268. /*{Mopl     draws a filled circle with center $(x,y)$ and radius $r$.}*/
  269. void draw_disc(const point& p, double r, color c=FG_color);
  270. /*{Mopl     draws a filled circle with center $p$ and radius $r$.}*/
  271. void draw_disc(const circle& C, color c=FG_color);
  272. /*{Mopl     draws filled circle $C$.}*/
  273. void draw_filled_ellipse(double x, double y, double r1, double r2, color c=FG_color);
  274. /*{Mopl  draws a filled ellipse with center $(x,y)$ and radii $r1$ and $r2$.}*/
  275. void draw_filled_ellipse(const point& p, double r1, double r2, color c=FG_color);
  276. /*{Mopl  draws a filled ellipse with center $p$ and radii $r1$ and $r2$.}*/
  277. //polygons 
  278. /*{Mtext
  279. medskip
  280. {bf 3.10 Drawing polygons }
  281. }*/
  282. void draw_polygon(const list<point>& lp, color c=FG_color );
  283. /*{Mopl     draws the polygon with vertex sequence $lp$.}*/
  284. void draw_polygon(const polygon& P, color c=FG_color );
  285. /*{Mopl     draws polygon $P$.}*/
  286. void draw_filled_polygon(const list<point>& lp, color c=FG_color );
  287. /*{Mopl     draws the filled polygon with vertex sequence $lp$.}*/
  288. void draw_filled_polygon(const polygon& P, color c=FG_color );
  289. /*{Mopl     draws filled polygon $P$.}*/
  290. void draw_rectangle(double a, double  b, double c, double d, color=FG_color);
  291. void draw_filled_rectangle(double a, double  b, double c, double d, color=FG_color);
  292. // functions
  293. /*{Mtext
  294. medskip
  295. {bf 3.11 Drawing functions}
  296. }*/
  297. void plot_xy(double x0, double x1, draw_func_ptr F, color c=FG_color);
  298. /*{Mopl     draws function $F$ in range $[x_0,x_1]$, i.e., all points 
  299.      $(x,y)$ with $y = F(x)$ and $x_0le xle x_1$.}*/
  300. void plot_yx(double y0, double y1, draw_func_ptr F, color c=FG_color);
  301. /*{Mopl     draws function $F$ in range $[y_0,y_1]$, i.e., all points 
  302.      $(x,y)$ with $x = F(y)$ and $y_0le yle y_1$.}*/
  303. // text
  304. /*{Mtext
  305. medskip
  306. {bf 3.12 Drawing text}
  307. }*/
  308. void draw_text(double x, double y, string s, color c=FG_color);
  309. /*{Mopl     writes string $s$ starting at position $(x,y)$.}*/
  310. void draw_text(const point& p, string s, color c=FG_color);
  311. /*{Mopl     writes string $s$ starting at position $p$.}*/
  312. void draw_ctext(double x, double y, string s, color c=FG_color);
  313. /*{Mopl     writes string $s$ centered at position $(x,y)$.}*/
  314. void draw_ctext(const point& p, string s, color c=FG_color);
  315. /*{Mopl     writes string $s$ centered at position $p$.}*/
  316. // nodes
  317. /*{Mtext
  318. medskip
  319. {bf 3.13 Drawing nodes}
  320. %Nodes are circles of diameter $node_width$.
  321. }*/
  322. void draw_node(double x0, double y0, color c=FG_color);
  323. /*{Mopl     draws a node at position $(x_0,y_0)$.}*/
  324. void draw_node(const point& p, color c=FG_color);
  325. /*{Mopl     draws a node at position $p$.}*/
  326. void draw_filled_node(double x0, double y0, color c=FG_color);
  327. /*{Mopl     draws a filled node at position $(x_0,y_0)$.}*/
  328. void draw_filled_node(const point& p, color c=FG_color);
  329. /*{Mopl     draws a filled node at position $p$.}*/
  330. void draw_text_node(double x, double y, string s, color c=BG_color);
  331. /*{Mopl     draws a node with label $s$ at position $(x,y)$. }*/
  332. void draw_text_node(const point& p, string s, color c=BG_color);
  333. /*{Mopl     draws a node with label $s$ at position $p$. }*/
  334. void draw_int_node(double x, double y, int i, color c=BG_color);
  335. /*{Mopl     draws a node with integer label $i$ at position 
  336.      $(x,y)$. }*/
  337. void draw_int_node(const point& p, int i, color c=BG_color);
  338. /*{Mopl     draws a node with integer label $i$ at position  $p$. }*/
  339. // edges
  340. /*{Mtext
  341. medskip
  342. {bf 3.14 Drawing edges}
  343. %Edges are straigth line segments or arrows with a clearance of 
  344. %$node_width/2$ at each end.
  345. }*/
  346. void draw_edge(double x1, double y1, double x2, double y2, color c=FG_color);
  347. /*{Mopl     draws an edge from $(x_1,y_1)$ to $(x_2,y_2)$.}*/
  348. void draw_edge(const point& p, const point& q, color c=FG_color);
  349. /*{Mopl     draws an edge from $p$ to $q$.}*/
  350. void draw_edge(const segment& s, color c=FG_color);
  351. /*{Mopl     draws an edge from $s$.start() to $s$.end().}*/
  352. void draw_edge_arrow(double x1, double y1, double x2, double y2, color c=FG_color);
  353. /*{Mopl     draws a directed edge from $(x_1,y_1)$ to $(x_2,y_2)$.}*/
  354. void draw_edge_arrow(const point& p, const point& q, color c=FG_color);
  355. /*{Mopl     draws a directed edge from $p$ to $q$.}*/
  356. void draw_edge_arrow(const segment& s, color c=FG_color);
  357. /*{Mopl     draws a directed edge from $s$.start() to $s$.end().}*/ 
  358. void draw_arc_edge(double x1, double y1, double x2, double y2, color c=FG_color);
  359. void draw_arc_edge(const segment& s, double r, color c=FG_color);
  360. void draw_arc_edge(const point& p, const point& q, double r, color c=FG_color);
  361. /*{Mopl     draws a circular edge arc with radius r from p to q 
  362.              with the center lying  to the right of the
  363.              directed segment $plongrightarrow q$.  }*/
  364. void draw_arc_edge_arrow(double x1, double y1, double x2, double y2, color c=FG_color);
  365. void draw_arc_edge_arrow(const segment& s, double r, color c=FG_color );
  366. void draw_arc_edge_arrow(const point& p, const point& q, double r, color c=FG_color);
  367. /*{Mopl     draws a circular directed edge arc with radius r from p 
  368.              to q with the center lying  to the right of the
  369.              directed segment $plongrightarrow q$.  }*/
  370. // mouse input
  371. /*{Mtext
  372. medskip
  373. {bf 3.15 Mouse Input}
  374. }*/
  375. int read_mouse();
  376. /*{Mop      displays the mouse cursor until a button is pressed.
  377.      Returns integer 1 for the left, 2 for the middle, and
  378.      3 for the right button (-1,-2,-3, if the shift key is
  379.      pressed simultaneously).}*/
  380. int read_mouse(double& x, double& y);
  381. /*{Mopl     displays the mouse cursor on the screen until a
  382.      button is pressed. When a button is pressed the
  383.              current position of the cursor is assigned
  384.              to $(x,y)$ and the pressed button is returned.}*/
  385. int read_mouse(point& p);
  386. /*{Mopl     displays the mouse cursor on the screen until a
  387.      button is pressed. When a button is pressed the
  388.              current position of the cursor is assigned
  389.              to $p$ and the pressed button is returned.}*/
  390. int read_mouse_seg(double x0, double y0, double& x, double& y);
  391. /*{Mopl     displays a line segment from $(x_0,y_0)$ to the
  392.      current cursor position until a mouse button is
  393.      pressed. When a button is pressed the current
  394.      position is assigned to $(x,y)$ and the pressed
  395.      button is returned.}*/
  396. int read_mouse_seg(const point& p, point& q);
  397. /*{Mopl     displays a line segment from $p$ to the current 
  398.              cursor position until a mouse button is
  399.      pressed. When a button is pressed the current
  400.      position is assigned to $q$ and the pressed
  401.      button is returned.}*/
  402. int read_mouse_rect(double x0, double y0, double& x, double& y);
  403. /*{Mopl     displays a rectangle with diagonal from $(x_0,y_0)$ 
  404.            to the current cursor position until a mouse button 
  405.      is pressed. When a button is pressed the current 
  406.      position is assigned to $(x,y)$ and the pressed 
  407.      button is returned.}*/
  408. int read_mouse_rect(const point& p, point& q);
  409. /*{Mopl     displays a rectangle with diagonal from $p$ 
  410.            to the current cursor position until a mouse button 
  411.      is pressed. When a button is pressed the current 
  412.      position is assigned to $q$ and the pressed 
  413.      button is returned.}*/
  414. int read_mouse_circle(double x0, double y0, double& x, double& y);
  415. /*{Mopl     displays a circle with center $(x_0,y_0)$ passing 
  416.      through the current cursor position until a mouse 
  417.      button is pressed. When a button is pressed the 
  418.      current position is assigned to $(x,y)$ and the 
  419.      pressed button is returned.}*/
  420. int read_mouse_circle(const point& p, point& q);
  421. /*{Mopl     displays a circle with center $p$ passing 
  422.      through the current cursor position until a mouse 
  423.      button is pressed. When a button is pressed the 
  424.      current position is assigned to $q$ and the 
  425.      pressed button is returned.}*/
  426. int read_mouse_action(mouse_action_func_ptr, double&, double&);
  427. int read_mouse_action(mouse_action_func_ptr, point&);
  428. int get_button();
  429. /*{Mop     non-blocking read operation, i.e., if a button was pressed 
  430.             its number is returned, otherwise $0$ is returned. }*/
  431. int get_button(double& x, double& y);
  432. /*{Mopl     if a button was pressed the corresponding position is
  433.             assigned to $(x,y)$ and the button number is returned, 
  434.             otherwise $0$ is returned. }*/
  435. int get_button(point& p);
  436. /*{Mop     if a button was pressed the corresponding position is
  437.             assigned to $p$ and the button number is returned, 
  438.             otherwise $0$ is returned. }*/
  439. /*{Mtext
  440. bigskip
  441. {bf 3.16 Events}
  442. }*/
  443. /* inherited:
  444. int  read_event(int& val, double& x, double& y);
  445. */
  446. /*{Mop    waits for next event in window W and returns it. 
  447.             Assigns the button or key to $val$ and the position
  448.             in $W$ to  $(x,y)$. Possible events are 
  449.             (cf. <LEDA/impl/x_window.h>): 
  450.             key_press_event, key_release_event,
  451.             button_press_event, button_release_event, 
  452.             configure_event,motion_event, destroy_event. }*/
  453. /* inherited:
  454. unsigned button_press_time();
  455. */
  456. /*{Mop     returns $X11$ time-stamp of last button press event. }*/
  457. /* inherited:
  458. unsigned button_release_time();
  459. */
  460. /*{Mop     returns $X11$ time-stamp of last button release event. }*/
  461.         
  462.  
  463. /*{Mtext
  464. bigskip
  465. {bf 3.17 Panel Input}
  466. }*/
  467. int     confirm(string s);
  468. /*{Mop      displays string $s$ and asks for confirmation. 
  469.      Returns true iff the answer was ``yes''.}*/
  470. void    notice(string s);
  471. void    acknowledge(string s);
  472. /*{Mopl     displays string $s$ and asks for acknowledgement.}*/
  473. int     read_panel(string h, int n, string*);
  474. /*{Mopl     displays a panel with header $h$ and an array $S[1..n]$  
  475.      of $n$ string buttons, returns the index of the selected 
  476.      button.}*/
  477. int     read_vpanel(string h, int n, string*);
  478. /*{Mopl     like read_panel with vertical button layout.}*/
  479. string  read_string(string p);
  480. /*{Mop      displays a panel with prompt $p$ for string input, 
  481.           returns the input.}*/
  482. double  read_real(string p);
  483. /*{Mop      displays a panel with prompt $p$ for real input 
  484.        returns the input.}*/
  485. int     read_int(string p);
  486. /*{Mop      displays a panel with prompt $p$ for integer input, 
  487.      returns the input.}*/
  488. // miscellaneous
  489. void message(string s) {LEDA_WINDOW::message(s);};
  490. /*{Mop      displays message $s$ (each call adds a new line).}*/
  491. void del_message()  { LEDA_WINDOW::del_messages(); };
  492. void del_messages() { LEDA_WINDOW::del_messages(); };
  493. /*{Mop      deletes the text written by all previous message 
  494.      operations.}*/
  495. void fill(double x, double y, color c=FG_color);
  496. void copy_rect(double x1, double y1, double x2, double y2, double x, double y);
  497. void move_rect(double x1, double y1, double x2, double y2, double x, double y);
  498. void copy(double x1, double y1, double x2, double y2, int i=0);
  499. void cut(double x1, double y1, double x2, double y2, int i=0);
  500. void paste(int i, double x, double y);
  501. void paste(double x, double y);
  502. void clear_buf(int i=0);
  503. // I/O operators
  504. /*{Mtext
  505. bigskip
  506. {bf 3.18 Input and output operators}
  507. For input and output of basic geometric objects in the plane such as points, 
  508. lines, line segments, circles, and polygons the $<<$ and $>>$ operators can 
  509. be used. Similar to CC input streams windows have an internal state indicating
  510. whether there is more input to read or not. Its initial value is true and it 
  511. is turned to false if an input sequence is terminated  by clicking the right 
  512. mouse button (similar to ending stream input by the eof character). In 
  513. conditional statements objects of type $window$ are automatically converted 
  514. to boolean by returning this internal state. Thus, they can be used in 
  515. conditional statements in the same way as CC input streams. For example,
  516. to read a sequence of points terminated by a right button click,  use 
  517. `` {bf while} ($W >> p$) ${  dots }$ ''. 
  518. }*/
  519. /*{Mtext
  520. medskip
  521. {bf 3.18.1 Output}
  522. setopdims 2.5 4.4
  523. }*/
  524. window& draw(const point& p,color c=FG_color)   
  525. { draw_point(p,c); return *this; }
  526. window& draw(const segment& s,color c=FG_color) 
  527. { draw_segment(s,c); return *this;}
  528. window& draw(const line& l,color c=FG_color)    
  529. { draw_line(l,c); return *this; }
  530. window& draw(const circle& C,color c=FG_color)  
  531. { draw_circle(C,c); return *this;}
  532. window& draw(const polygon& P,color c=FG_color )
  533. { draw_polygon(P,c); return *this;}
  534. window& operator<<(const point& p)   { return draw(p); }
  535. /*{Mbinop   like $W$.draw_point($p$).}*/
  536. window& operator<<(const segment& s) { return draw(s); }
  537. /*{Mbinop   like $W$.draw_segment($s$).}*/
  538. window& operator<<(const line& l)    { return draw(l); }
  539. /*{Mbinop   like $W$.draw_line($l$).}*/
  540. window& operator<<(const circle& C)  { return draw(C); }
  541. /*{Mbinop   like $W$.draw_circle($C$).}*/
  542. window& operator<<(const polygon& P) { return draw(P); }
  543. /*{Mbinop   like $W$.draw_polygon($P$).}*/
  544. /*{Mtext
  545. bigskip
  546. {bf 3.18.2 Input}
  547. }*/
  548. window& read(point&);
  549. window& read(segment&);
  550. window& read(line&);
  551. window& read(circle&);
  552. window& read(polygon&);
  553. window& operator>>(point& p);
  554. /*{Mbinop   reads a point $p$: clicking the left button 
  555.      assigns the current cursor position to $p$.}*/
  556. window& operator>>(segment& s);
  557. /*{Mbinop   reads a segment $s$: use the left button to input 
  558.      the start and end point of $s$.}*/
  559. window& operator>>(line& l);
  560. /*{Mbinop   reads a line $l$: use the left button to input 
  561.      two different points on $l$.}*/
  562. window& operator>>(circle& C);
  563. /*{Mbinop   reads a circle $C$: use the left button to input 
  564.      the center of $C$ and a point on $C$.}*/
  565. window& operator>>(polygon& P);
  566. /*{Mbinop   reads a polygon $P$: use the left button to input 
  567.      the sequence of vertices of $P$, end the sequence 
  568.      by clicking the middle button.}*/
  569. /*{Mtext
  570. As long as an input operation has not been completed the last read point can 
  571. be erased by simultaneously pressing the shift key and the left mouse button.
  572. }*/
  573. /*{Mtext
  574. bigskip
  575. {bf 3.19 Non-Member Functions} 
  576. }*/
  577. friend int read_mouse(window*& w, double& x, double& y)
  578. { return LEDA_WINDOW::read_mouse((LEDA_WINDOW*&)w,x,y); }
  579. /*{Mfunc   waits for mouse input, assigns a pointer to the 
  580.             corresonding window to $w$ and the position in 
  581.             $*w$ to $(x,y)$ and returns the pressed button. }*/
  582.  
  583.         
  584. /*
  585. friend void put_back_event();
  586. */
  587. /*{Mfunc   puts last read event back to the input stream of events. }*/
  588.  
  589. }; // end of class window
  590.  
  591. #include <LEDA/panel.h>
  592. #endif