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.

121 lines
3.7KB

  1. //
  2. // "$Id: pack.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Fl_Pack test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Rather crude test of the Fl_Pack object.
  7. // Changing the type() of an Fl_Pack after it is displayed is not supported
  8. // so I have to do a lot of resizing of things before that.
  9. //
  10. // Copyright 1998-2010 by Bill Spitzak and others.
  11. //
  12. // This library is free software; you can redistribute it and/or
  13. // modify it under the terms of the GNU Library General Public
  14. // License as published by the Free Software Foundation; either
  15. // version 2 of the License, or (at your option) any later version.
  16. //
  17. // This library is distributed in the hope that it will be useful,
  18. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. // Library General Public License for more details.
  21. //
  22. // You should have received a copy of the GNU Library General Public
  23. // License along with this library; if not, write to the Free Software
  24. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  25. // USA.
  26. //
  27. // Please report all bugs and problems on the following page:
  28. //
  29. // http://www.fltk.org/str.php
  30. //
  31. #include <FL/Fl.H>
  32. #include <FL/Fl_Button.H>
  33. #include <FL/Fl_Light_Button.H>
  34. #include <FL/Fl_Double_Window.H>
  35. #include <FL/Fl_Scroll.H>
  36. #include <FL/Fl_Value_Slider.H>
  37. #include <FL/Fl_Pack.H>
  38. Fl_Pack *pack;
  39. Fl_Scroll *scroll;
  40. void type_cb(Fl_Light_Button*, long v) {
  41. for (int i = 0; i < pack->children(); i++) {
  42. Fl_Widget* o = pack->child(i);
  43. o->resize(0,0,25,25);
  44. }
  45. pack->resize(scroll->x(),scroll->y(),scroll->w(),scroll->h());
  46. pack->parent()->redraw();
  47. pack->type(uchar(v));
  48. pack->redraw();
  49. }
  50. void spacing_cb(Fl_Value_Slider*o, long) {
  51. pack->spacing(int(o->value()));
  52. scroll->redraw();
  53. }
  54. int main(int argc, char **argv) {
  55. Fl_Double_Window *w;
  56. {Fl_Double_Window* o = new Fl_Double_Window(360, 370);
  57. w = o;
  58. scroll = new Fl_Scroll(10,10,340,285);
  59. {Fl_Pack* o = new Fl_Pack(10, 10, 340, 285);
  60. pack = o;
  61. o->box(FL_DOWN_FRAME);
  62. //o->box(FL_ENGRAVED_FRAME);
  63. new Fl_Button(35, 35, 25, 25, "b1");
  64. new Fl_Button(45, 45, 25, 25, "b2");
  65. new Fl_Button(55, 55, 25, 25, "b3");
  66. new Fl_Button(65, 65, 25, 25, "b4");
  67. new Fl_Button(75, 75, 25, 25, "b5");
  68. new Fl_Button(85, 85, 25, 25, "b6");
  69. new Fl_Button(95, 95, 25, 25, "b7");
  70. new Fl_Button(105, 105, 25, 25, "b8");
  71. new Fl_Button(115, 115, 25, 25, "b9");
  72. new Fl_Button(125, 125, 25, 25, "b10");
  73. new Fl_Button(135, 135, 25, 25, "b11");
  74. new Fl_Button(145, 145, 25, 25, "b12");
  75. new Fl_Button(155, 155, 25, 25, "b13");
  76. new Fl_Button(165, 165, 25, 25, "b14");
  77. new Fl_Button(175, 175, 25, 25, "b15");
  78. new Fl_Button(185, 185, 25, 25, "b16");
  79. new Fl_Button(195, 195, 25, 25, "b17");
  80. new Fl_Button(205, 205, 25, 25, "b18");
  81. new Fl_Button(215, 215, 25, 25, "b19");
  82. new Fl_Button(225, 225, 25, 25, "b20");
  83. new Fl_Button(235, 235, 25, 25, "b21");
  84. new Fl_Button(245, 245, 25, 25, "b22");
  85. new Fl_Button(255, 255, 25, 25, "b23");
  86. new Fl_Button(265, 265, 25, 25, "b24");
  87. o->end();
  88. w->resizable(o);
  89. }
  90. scroll->end();
  91. {Fl_Light_Button* o = new Fl_Light_Button(10, 305, 165, 25, "HORIZONTAL");
  92. o->type(FL_RADIO_BUTTON);
  93. o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::HORIZONTAL));
  94. }
  95. {Fl_Light_Button* o = new Fl_Light_Button(185, 305, 165, 25, "VERTICAL");
  96. o->type(FL_RADIO_BUTTON);
  97. o->value(1);
  98. o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::VERTICAL));
  99. }
  100. {Fl_Value_Slider* o = new Fl_Value_Slider(100, 335, 250, 25, "Spacing: ");
  101. o->align(FL_ALIGN_LEFT);
  102. o->type(FL_HORIZONTAL);
  103. o->range(0,30);
  104. o->step(1);
  105. o->callback((Fl_Callback*)spacing_cb);
  106. }
  107. w->end();
  108. }
  109. w->show(argc, argv);
  110. return Fl::run();
  111. }
  112. //
  113. // End of "$Id: pack.cxx 7903 2010-11-28 21:06:39Z matt $".
  114. //