You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
3.4KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0010
  3. header_name {.H}
  4. code_name {.cxx}
  5. gridx 2
  6. gridy 2
  7. snap 1
  8. decl {\#include <FL/fl_draw.H>} {public
  9. }
  10. decl {\#include <FL/Fl_Widget.H>} {public
  11. }
  12. decl {\#include <FL/Fl_Window.H>} {public
  13. }
  14. class Fl_DragBar {open : {public Fl_Widget}
  15. } {
  16. decl {int old_rx,old_ry;} {}
  17. decl {int _type;} {}
  18. decl {enum DragType {WINDRAG=0,NICEWINDRAG,FLDRAG,NICEFLDRAG};} {public
  19. }
  20. Function {Fl_DragBar(int x,int y,int w,int h,const char *l=0): Fl_Widget(x,y,w,h,l)} {open
  21. } {
  22. code {_type = Fl_DragBar::NICEFLDRAG;} {}
  23. }
  24. Function {~Fl_DragBar()} {} {}
  25. Function {draw()} {private
  26. } {
  27. code {int ww,hh;
  28. uchar r,g,b;
  29. uchar rb,gb,bb;
  30. uchar rd,gd,bd;
  31. int val;
  32. draw_box();
  33. int x1 = x()+5;
  34. int x2 = x()+w()-5;
  35. int y1 = y()+5;
  36. int y2 = y()+h()-5;
  37. Fl::get_color(color(),r,g,b);
  38. val = (int)r + 64; rb = val > 255 ? 255:val;
  39. val = (int)g + 64; gb = val > 255 ? 255:val;
  40. val = (int)b + 64; bb = val > 255 ? 255:val;
  41. val = (int)r - 64; rd = val < 0 ? 0:val;
  42. val = (int)g - 64; gd = val < 0 ? 0:val;
  43. val = (int)b - 64; bd = val < 0 ? 0:val;
  44. if (h()<w())
  45. {
  46. if ((_type==Fl_DragBar::NICEWINDRAG) || (_type==Fl_DragBar::NICEFLDRAG))
  47. {
  48. fl_line_style(FL_DASH);
  49. for (int i = y() + 4; i < y()+h()-5;i+=3)
  50. {
  51. fl_line_style(FL_DASH);
  52. fl_color(rb,gb,bb);
  53. fl_line(x1,i,x2,i);
  54. fl_color(rd,gd,bd);
  55. fl_line(x1,i+1,x2,i+1);
  56. }
  57. fl_line_style(FL_SOLID);
  58. }
  59. fl_color(color());
  60. const char *l = label();
  61. ww = labelsize()*strlen(l)/2;
  62. //ww = (int)fl_width(l);
  63. hh = h() - 4;
  64. if (align() & FL_ALIGN_RIGHT)
  65. {
  66. x1 = x() + w() - 5 - ww;
  67. }
  68. else
  69. if (align() & FL_ALIGN_CENTER)
  70. {
  71. x1 = x() + 5;
  72. }
  73. else
  74. {
  75. x1 = x() + (w() - ww) / 2;
  76. }
  77. fl_rectf(x1,y()+(h() - hh) / 2, ww, hh);
  78. draw_label();
  79. }
  80. else
  81. if ((_type==Fl_DragBar::NICEWINDRAG) || (_type==Fl_DragBar::NICEFLDRAG))
  82. {
  83. fl_line_style(FL_DASH);
  84. for (int i = x() + 4; i < x()+w()-5;i+=3)
  85. {
  86. fl_color(rb,gb,bb);
  87. fl_line(i,y1,i,y2);
  88. fl_color(rd,gd,bd);
  89. fl_line(i+1,y1,i+1,y2);
  90. }
  91. fl_line_style(FL_SOLID);
  92. }} {selected
  93. }
  94. }
  95. Function {handle(int event)} {private return_type int
  96. } {
  97. code {int rx,ry,xx,yy;
  98. int mx,my;
  99. if (_type < (int)Fl_DragBar::FLDRAG)
  100. {
  101. rx = Fl::event_x_root();
  102. ry = Fl::event_y_root();
  103. }
  104. else
  105. {
  106. rx = Fl::event_x();
  107. ry = Fl::event_y();
  108. }
  109. switch(event)
  110. {
  111. case FL_PUSH:
  112. {
  113. window()->show();
  114. fl_cursor(FL_CURSOR_MOVE);
  115. if (_type < (int)Fl_DragBar::FLDRAG)
  116. {
  117. old_rx = rx - window()->x();
  118. old_ry = ry - window()->y();
  119. }
  120. else
  121. {
  122. old_rx = rx - parent()->x();
  123. old_ry = ry - parent()->y();
  124. }
  125. return 1;
  126. }
  127. case FL_RELEASE:
  128. {
  129. fl_cursor(FL_CURSOR_DEFAULT);
  130. do_callback();
  131. return 1;
  132. }
  133. case FL_DRAG:
  134. {
  135. if ((rx != old_rx) || (ry != old_ry))
  136. {
  137. xx = rx - old_rx;
  138. yy = ry - old_ry;
  139. if (_type < (int)Fl_DragBar::FLDRAG)
  140. {
  141. window()->position(xx,yy);
  142. }
  143. else
  144. {
  145. parent()->position(xx,yy);
  146. if (parent()->parent())
  147. parent()->parent()->redraw();
  148. else
  149. window()->redraw();
  150. }
  151. }
  152. return 1;
  153. }
  154. case FL_MOVE:
  155. {
  156. return 0;
  157. }
  158. case FL_ENTER :
  159. {
  160. return 0;
  161. }
  162. case FL_LEAVE :
  163. {
  164. fl_cursor(FL_CURSOR_DEFAULT);
  165. return 1;
  166. }
  167. default :
  168. return 0;
  169. }} {}
  170. }
  171. Function {type(int t)} {} {
  172. code {_type = t;} {}
  173. }
  174. }