home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / src / graphics / _win_pan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  4.6 KB  |  197 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  _win_panel.c
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #include <LEDA/window.h>
  16. #include "global.c"
  17.  
  18.  
  19. //------------------------------------------------------------------------------
  20. //   PANELS
  21. //------------------------------------------------------------------------------
  22.  
  23.  
  24. panel::panel()  
  25. { panel_ptr = x_draw_panel_create(); 
  26.   x_draw_panel_label(panel_ptr,""); 
  27.   }
  28.  
  29. panel::panel(string s) 
  30. { panel_ptr = x_draw_panel_create(); 
  31.   x_draw_panel_label(panel_ptr,~s); 
  32.  }
  33.  
  34. panel::~panel() 
  35. { x_draw_panel_destroy(panel_ptr); }
  36.  
  37.  
  38. void panel::label(string s)       
  39. { x_draw_panel_label(panel_ptr,~s); }
  40.  
  41. void panel::text_item(string s)   
  42. { x_draw_panel_text_item(panel_ptr,~s); }
  43.  
  44. void panel::int_item(string s,int& x) 
  45. { x_draw_panel_int_item(panel_ptr,~s,&x);}
  46.  
  47. void panel::int_item(string s,int& x, int l, int h) 
  48. { x_draw_panel_slider_item(panel_ptr,~s,&x,l,h);}
  49.  
  50. void panel::double_item(string s, double& x) 
  51. { x_draw_panel_float_item(panel_ptr,~s,&x);}
  52.  
  53.  
  54.  
  55. void panel::real_item(string s, real& x)
  56. { x = ~x;
  57.   x_draw_panel_float_item(panel_ptr,~s,x.dp());
  58.  }
  59.  
  60. void panel::string_item(string s, string& x)
  61. { x = ~x;
  62.   x_draw_panel_string_item(panel_ptr,~s,x.cstring());
  63.  }
  64.  
  65. void  panel::string_item(string label,string& x,list(string)& L)
  66. { x = ~x;  // isolate
  67.  char** p = new char*[L.length()];
  68.  int    i = 0;
  69.  string s;
  70.  forall(s,L) 
  71.     if (s.length() > 0) p[i++] = ~s;
  72.  x_draw_panel_string_menu_item(panel_ptr,~label,x.cstring(),"",i,p); 
  73. }
  74.  
  75. void panel::new_button_line(int n, string* buttons)
  76. { char** p = new char*[n];
  77.   for(int i = 0; i < n; i++) p[i] = ~buttons[i];
  78.   x_draw_panel_button_line(panel_ptr,n,p);
  79.  }
  80.  
  81. void panel::new_button_line(list(string)& L)
  82. { char** p = new char*[L.length()];
  83.   int i=0;
  84.   string s;
  85.   forall(s,L) p[i++] = ~s;
  86.   x_draw_panel_button_line(panel_ptr,i,p);
  87.  }
  88.  
  89. int  panel::open()
  90. { if (x_draw_grid_mode) x_draw_cursor();
  91.   int button = x_draw_panel_open(panel_ptr);
  92.   if (x_draw_grid_mode) x_draw_cursor();
  93.   return button;
  94.  }
  95.  
  96. void  panel::choice_item(string header,int& x,int n,string* L)
  97. { char** p = new char*[n];
  98.   for(int i = 0; i < n; i++) p[i] = ~L[i];
  99.   x_draw_panel_choice_item(panel_ptr,~header,&x,n,p,1,0);
  100.  delete p;
  101.  }
  102.  
  103. void  panel::choice_item(string label,int& x,list(string)& L)
  104. { char** p = new char*[L.length()];
  105.   int    i = 0;
  106.   string s;
  107.   forall(s,L) p[i++] = ~s;
  108.   x_draw_panel_choice_item(panel_ptr,~label,&x,i,p,1,0); 
  109.   delete p;
  110. }
  111.  
  112. void  panel::choice_item(string header,int& x,string s1, string s2)
  113. { char** p = new char*[2];
  114.   p[0] = ~s1;
  115.   p[1] = ~s2;
  116.   x_draw_panel_choice_item(panel_ptr,~header,&x,2,p,1,0);
  117.   delete p;
  118.  }
  119.  
  120. void  panel::choice_item(string header,int& x,string s1, string s2, string s3)
  121. { char** p = new char*[3];
  122.   p[0] = ~s1;
  123.   p[1] = ~s2;
  124.   p[2] = ~s3;
  125.   x_draw_panel_choice_item(panel_ptr,~header,&x,3,p,1,0);
  126.   delete p;
  127.  }
  128.  
  129. void  panel::choice_item(string header,int& x,string s1, string s2, string s3, string s4)
  130. { char** p = new char*[4];
  131.   p[0] = ~s1;
  132.   p[1] = ~s2;
  133.   p[2] = ~s3;
  134.   p[3] = ~s4;
  135.   x_draw_panel_choice_item(panel_ptr,~header,&x,4,p,1,0);
  136.   delete p;
  137.  }
  138.  
  139. void  panel::choice_item(string header,int& x,string s1, string s2, string s3, string s4, string s5)
  140. { char** p = new char*[5];
  141.   p[0] = ~s1;
  142.   p[1] = ~s2;
  143.   p[2] = ~s3;
  144.   p[3] = ~s4;
  145.   p[4] = ~s5;
  146.   x_draw_panel_choice_item(panel_ptr,~header,&x,5,p,1,0);
  147.   delete p;
  148.  }
  149.  
  150.  
  151. void panel::int_item(string s,int& x,int low, int high, int step)   
  152. { int n = high -low;
  153.   n = n/step +1;
  154.   char** p = new char*[n];
  155.   for(int i = 0; i < n; i++) p[i] = ~string("%d",low+i*step);
  156.   x_draw_panel_choice_item(panel_ptr,~s,&x,n,p,step,low);
  157.   delete p;
  158.  }
  159.  
  160. void panel::bool_item(string s, int& x)
  161. { char** p = new char*[2];
  162.   p[0] = "off";
  163.   p[1] = "on";
  164.   x_draw_panel_choice_item(panel_ptr,~s,&x,2,p,1,0);
  165.   delete p;
  166.  }
  167.  
  168. void panel::color_item(string s, color& x)
  169. { char** p = new char*[6];
  170.  
  171.   p[0] = "white";
  172.   p[1] = "black";
  173.   p[2] = "red";
  174.   p[3] = "green";
  175.   p[4] = "blue";
  176.   p[5] = "yellow";
  177.  
  178.   x_draw_panel_choice_item(panel_ptr,~s,(int*)&x,6,p,1,0);
  179.   delete p;
  180.  }
  181.  
  182.  
  183. // buttons:
  184.  
  185. void panel::button(string s)             
  186. { x_draw_panel_button(panel_ptr,~s); }
  187.  
  188. void panel::button(int i,int l)        
  189. { char* f = ~string("%%%dd",l);
  190.   x_draw_panel_button(panel_ptr,~string(f,i));
  191. }
  192.  
  193. void panel::new_button_line()            
  194. { x_draw_panel_button_line(panel_ptr,0,0);  }
  195.  
  196.