home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / resizebox.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  3.1 KB  |  102 lines

  1. //
  2. // "$Id: resizebox.cxx,v 1.4 1999/01/07 19:18:00 mike Exp $"
  3. //
  4. // Resize box test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 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 to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #define W1 (big ? 60 : 40)
  27. #define B 0
  28. #define W3 (5*W1+6*B)
  29.  
  30. #include <FL/Fl.H>
  31. #include <FL/Fl_Single_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.  
  37. Fl_Single_Window *window;
  38. Fl_Box *box;
  39.  
  40. int big = 0;
  41.  
  42. void b_cb(Fl_Widget *,long w) {
  43.   if (window->w() != W3 || window->h() != W3) {
  44.     fl_message("Put window back to minimum size before changing");
  45.     return;
  46.   }
  47.   window->init_sizes();
  48.   switch (w) {
  49.   case 0: box->hide(); window->box(FL_FLAT_BOX); window->resizable(0); return;
  50.   case 8: box->resize(W1+B,W1,2*W1,B); break;
  51.   case 2: box->resize(W1+B,W1+B+2*W1,2*W1,B); break;
  52.   case 4: box->resize(W1+B,W1,B,2*W1); break;
  53.   case 6: box->resize(W1+B+2*W1,W1+B,B,2*W1); break;
  54.   }
  55.   window->box(FL_NO_BOX);
  56.   if (w == 6 || w == 4)
  57.     box->label("re\nsiz\nab\nle");
  58.   else box->label("resizable");
  59.   box->show();
  60.   window->resizable(box);
  61.   window->redraw();
  62. }
  63.  
  64. int main(int argc, char **argv) {
  65.   window = new Fl_Single_Window(W3,W3);
  66.   window->box(FL_NO_BOX);
  67.   Fl_Box *n;
  68.   for (int x = 0; x<4; x++) for (int y = 0; y<4; y++) {
  69.     if ((x==1 || x==2) && (y==1 || y==2)) continue;
  70.     n = new Fl_Box(FL_FRAME_BOX,x*(B+W1)+B,y*(B+W1)+B,W1,W1,0);
  71.     n->color(x+y+8);
  72.   }
  73.   n = new Fl_Box(FL_FRAME_BOX,B,4*W1+5*B,4*W1+3*B,W1,0);
  74.   n->color(12);
  75.   n = new Fl_Box(FL_FRAME_BOX,4*W1+5*B,B,W1,5*W1+4*B,0);
  76.   n->color(13);
  77.   n = new Fl_Box(FL_FRAME_BOX,W1+B+B,W1+B+B,2*W1+B,2*W1+B,0);
  78.   n->color(8);
  79.  
  80.   Fl::enable_symbols();
  81.   Fl_Button *b = new Fl_Radio_Button(W1+B+50,W1+B+30,20,20,"@6>");
  82.   b->callback(b_cb,6);
  83.   (new Fl_Radio_Button(W1+B+30,W1+B+10,20,20,"@8>"))->callback(b_cb,8);
  84.   (new Fl_Radio_Button(W1+B+10,W1+B+30,20,20,"@4>"))->callback(b_cb,4);
  85.   (new Fl_Radio_Button(W1+B+30,W1+B+50,20,20,"@2>"))->callback(b_cb,2);
  86.   (new Fl_Radio_Button(W1+B+30,W1+B+30,20,20,"off"))->callback(b_cb,0);
  87.  
  88.   box = new Fl_Box(FL_FLAT_BOX,0,0,0,0,"resizable");
  89.   box->color(FL_DARK2);
  90.   b->set();
  91.   b->do_callback();
  92.   window->end();
  93.  
  94.   window->size_range(W3,W3);
  95.   window->show(argc,argv);
  96.   return Fl::run();
  97. }
  98.  
  99. //
  100. // End of "$Id: resizebox.cxx,v 1.4 1999/01/07 19:18:00 mike Exp $".
  101. //
  102.