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.

103 lines
3.1KB

  1. //
  2. // "$Id: resizebox.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Resize box test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #define W1 (big ? 60 : 40)
  28. #define B 0
  29. #define W3 (5*W1+6*B)
  30. #include <FL/Fl.H>
  31. #include <FL/Fl_Double_Window.H>
  32. #include <FL/Fl_Box.H>
  33. #include <FL/Fl_Radio_Button.H>
  34. #include <FL/fl_draw.H>
  35. #include <FL/fl_message.H>
  36. Fl_Double_Window *window;
  37. Fl_Box *box;
  38. int big = 0;
  39. void b_cb(Fl_Widget *,long w) {
  40. if (window->w() != W3 || window->h() != W3) {
  41. fl_message("Put window back to minimum size before changing");
  42. return;
  43. }
  44. window->init_sizes();
  45. switch (w) {
  46. case 0: box->hide(); window->box(FL_FLAT_BOX); window->resizable(0); return;
  47. case 8: box->resize(W1+B,W1,2*W1,B); break;
  48. case 2: box->resize(W1+B,W1+B+2*W1,2*W1,B); break;
  49. case 4: box->resize(W1+B,W1,B,2*W1); break;
  50. case 6: box->resize(W1+B+2*W1,W1+B,B,2*W1); break;
  51. }
  52. window->box(FL_NO_BOX);
  53. if (w == 6 || w == 4)
  54. box->label("re\nsiz\nab\nle");
  55. else box->label("resizable");
  56. box->show();
  57. window->resizable(box);
  58. window->redraw();
  59. }
  60. int main(int argc, char **argv) {
  61. window = new Fl_Double_Window(W3,W3);
  62. window->box(FL_NO_BOX);
  63. Fl_Box *n;
  64. for (int x = 0; x<4; x++) for (int y = 0; y<4; y++) {
  65. if ((x==1 || x==2) && (y==1 || y==2)) continue;
  66. n = new Fl_Box(FL_FRAME_BOX,x*(B+W1)+B,y*(B+W1)+B,W1,W1,0);
  67. n->color(x+y+8);
  68. }
  69. n = new Fl_Box(FL_FRAME_BOX,B,4*W1+5*B,4*W1+3*B,W1,0);
  70. n->color(12);
  71. n = new Fl_Box(FL_FRAME_BOX,4*W1+5*B,B,W1,5*W1+4*B,0);
  72. n->color(13);
  73. n = new Fl_Box(FL_FRAME_BOX,W1+B+B,W1+B+B,2*W1+B,2*W1+B,0);
  74. n->color(8);
  75. Fl_Button *b = new Fl_Radio_Button(W1+B+50,W1+B+30,20,20,"@6>");
  76. b->callback(b_cb,6);
  77. (new Fl_Radio_Button(W1+B+30,W1+B+10,20,20,"@8>"))->callback(b_cb,8);
  78. (new Fl_Radio_Button(W1+B+10,W1+B+30,20,20,"@4>"))->callback(b_cb,4);
  79. (new Fl_Radio_Button(W1+B+30,W1+B+50,20,20,"@2>"))->callback(b_cb,2);
  80. (new Fl_Radio_Button(W1+B+30,W1+B+30,20,20,"off"))->callback(b_cb,0);
  81. box = new Fl_Box(FL_FLAT_BOX,0,0,0,0,"resizable");
  82. box->color(FL_DARK2);
  83. b->set();
  84. b->do_callback();
  85. window->end();
  86. window->size_range(W3,W3);
  87. window->show(argc,argv);
  88. return Fl::run();
  89. }
  90. //
  91. // End of "$Id: resizebox.cxx 7903 2010-11-28 21:06:39Z matt $".
  92. //