_panel.c
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 4k
Development Platform:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  _panel.c
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #include <LEDA/window.h>
  12. //------------------------------------------------------------------------------
  13. //   PANELS
  14. //------------------------------------------------------------------------------
  15. void  panel::set_bg_color(color c) { LEDA_PANEL::set_bg_color(c); }
  16. void  panel::display(window& W) { display(W,-1,-1); }
  17. void  panel::display(window& W, int x, int y)
  18. { LEDA_PANEL::display(x,y, W.xpos(), W.ypos(), W.width(), W.height()); }
  19. void panel::display() { display(-1,-1); }
  20. void panel::display(int x, int y)
  21. { LEDA_PANEL::display(x,y,0,0,0,0); }
  22. int  panel::open(window& W) { return open(W,-1,-1); }
  23. int  panel::open(window& W, int x, int y)
  24. { return LEDA_PANEL::open(x,y, W.xpos(), W.ypos(), W.width(), W.height()); }
  25. int  panel::open() { return open(-1,-1); }
  26. int  panel::open(int x, int y)
  27. { return LEDA_PANEL::open(x,y,0,0,0,0); }
  28. void panel::text_item(string s)   
  29. { LEDA_PANEL::text_item(s); }
  30. void panel::int_item(string s,int& x) 
  31. { LEDA_PANEL::int_item(s,&x);}
  32. void panel::int_item(string s,int& x, int l, int h) 
  33. { LEDA_PANEL::slider_item(s,&x,l,h,0);}
  34. void panel::int_item(string s,int& x, int l, int h, void (*F)(int)) 
  35. { LEDA_PANEL::slider_item(s,&x,l,h,F);}
  36. void panel::double_item(string s, double& x) 
  37. { LEDA_PANEL::float_item(s,&x);}
  38. void panel::real_item(string s, double& x)
  39. { LEDA_PANEL::float_item(s,&x); }
  40. void panel::string_item(string label, string& x)
  41. { x = ~x; //disconnect
  42.   LEDA_PANEL::string_item(label,x.access_ptr());
  43.  }
  44. void  panel::string_item(string label,string& x,list<string>& L)
  45. { x = x.cstring(); //disconnect
  46.   const char** p = new const char*[L.length()];
  47.   int    i = 0;
  48.   string s;
  49.   forall(s,L) 
  50.      if (s.length() > 0) p[i++] = s;
  51.   LEDA_PANEL::string_menu_item(label,x.access_ptr(),"",i,p); 
  52.   delete p;
  53. }
  54. void  panel::choice_item(string label,int& x,list<string>& L)
  55. { const char** p = new const char*[L.length()];
  56.   int    i = 0;
  57.   string s;
  58.   forall(s,L) p[i++] = s;
  59.   LEDA_PANEL::choice_item(label,&x,i,p,1,0); 
  60.   delete p;
  61. }
  62. void  panel::choice_item(string head,int& x,string s1, string s2)
  63. { const char* p[2];
  64.   p[0] = s1;
  65.   p[1] = s2;
  66.   LEDA_PANEL::choice_item(head,&x,2,p,1,0);
  67.  }
  68. void  panel::choice_item(string head,int& x,string s1, string s2, string s3)
  69. { const char* p[3];
  70.   p[0] = s1;
  71.   p[1] = s2;
  72.   p[2] = s3;
  73.   LEDA_PANEL::choice_item(head,&x,3,p,1,0);
  74.  }
  75. void  panel::choice_item(string head,int& x,string s1, string s2, string s3, string s4)
  76. { const char* p[4];
  77.   p[0] = s1;
  78.   p[1] = s2;
  79.   p[2] = s3;
  80.   p[3] = s4;
  81.   LEDA_PANEL::choice_item(head,&x,4,p,1,0);
  82.  }
  83. void  panel::choice_item(string head,int& x,string s1, string s2, string s3, string s4, string s5)
  84. { const char* p[5];
  85.   p[0] = s1;
  86.   p[1] = s2;
  87.   p[2] = s3;
  88.   p[3] = s4;
  89.   p[4] = s5;
  90.   LEDA_PANEL::choice_item(head,&x,5,p,1,0);
  91.  }
  92. void panel::int_item(string s,int& x,int low, int high, int step)   
  93. { int n = (high-low)/step +1;
  94.   char** p = new char*[n];
  95.   int i;
  96.   for(i = 0; i < n; i++) p[i] = ~string("%d",low+i*step);
  97.   LEDA_PANEL::choice_item(s,&x,n,(const char**)p,step,low);
  98.   for(i = 0; i < n; i++) delete p[i];
  99.   delete p;
  100.  }
  101. void panel::bool_item(string s, bool& x)
  102. { LEDA_PANEL::bool_item(s,(char*)&x); }
  103. void panel::color_item(string s, color& x)
  104. { LEDA_PANEL::color_item(s,(int*)&x); }
  105. /*
  106. void panel::color_item(string s, color& x)
  107. {
  108.   const char* p[8];
  109.   int n = 8;
  110.   p[0] = "white";
  111.   p[1] = "black";
  112.   p[2] = "red";
  113.   p[3] = "green";
  114.   p[4] = "blue";
  115.   p[5] = "yellow";
  116.   p[6] = "violet";
  117.   p[7] = "orange";
  118.   if (window::screen_depth()==1) 
  119.   { n = 2;
  120.     if (x!=white) x = black;
  121.    }
  122.   LEDA_PANEL::choice_item(s,(int*)&x,n,p,1,0);
  123.  }
  124. */
  125. void panel::lstyle_item(string s, line_style& x)
  126. { const char* p[3];
  127.   p[0] = "solid";
  128.   p[1] = "dashed";
  129.   p[2] = "dotted";
  130.   LEDA_PANEL::choice_item(s,(int*)&x,3,p,1,0);
  131.  }
  132. // buttons:
  133. int panel::button(string s)             
  134. { return LEDA_PANEL::button(s); }
  135. void panel::new_button_line()            
  136. { LEDA_PANEL::button_line(0,0);  }
  137. void panel::new_button_line(list<string>& L)
  138. { const char** p = new const char*[L.length()];
  139.   int i=0;
  140.   string s;
  141.   forall(s,L) p[i++] = s;
  142.   LEDA_PANEL::button_line(i,p);
  143.   delete p;
  144.  }