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.

87 lines
2.5KB

  1. //
  2. // "$Id: overlay.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Overlay window 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. #include <stdlib.h>
  28. #include <stdio.h>
  29. #include <FL/Fl.H>
  30. #include <FL/Fl_Window.H>
  31. #include <FL/Fl_Overlay_Window.H>
  32. #include <FL/Fl_Button.H>
  33. #include <FL/fl_draw.H>
  34. int width=10,height=10;
  35. class overlay : public Fl_Overlay_Window {
  36. public:
  37. overlay(int w,int h) : Fl_Overlay_Window(w,h) {}
  38. void draw_overlay();
  39. };
  40. void overlay::draw_overlay() {
  41. fl_color(FL_RED); fl_rect((w()-width)/2,(h()-height)/2,width,height);
  42. }
  43. overlay *ovl;
  44. void bcb1(Fl_Widget *,void *) {width+=20; ovl->redraw_overlay();}
  45. void bcb2(Fl_Widget *,void *) {width-=20; ovl->redraw_overlay();}
  46. void bcb3(Fl_Widget *,void *) {height+=20; ovl->redraw_overlay();}
  47. void bcb4(Fl_Widget *,void *) {height-=20; ovl->redraw_overlay();}
  48. int arg(int, char **argv, int& i) {
  49. Fl_Color n = (Fl_Color)atoi(argv[i]);
  50. if (n<=0) return 0;
  51. i++;
  52. uchar r,g,b;
  53. Fl::get_color(n,r,g,b);
  54. Fl::set_color(FL_RED,r,g,b);
  55. return i;
  56. }
  57. int main(int argc, char **argv) {
  58. int i=0; Fl::args(argc,argv,i,arg);
  59. ovl = new overlay(400,400);
  60. Fl_Button *b;
  61. b = new Fl_Button(50,50,100,100,"wider\n(a)");
  62. b->callback(bcb1); b->shortcut('a');
  63. b = new Fl_Button(250,50,100,100,"narrower\n(b)");
  64. b->callback(bcb2); b->shortcut('b');
  65. b = new Fl_Button(50,250,100,100,"taller\n(c)");
  66. b->callback(bcb3); b->shortcut('c');
  67. b = new Fl_Button(250,250,100,100,"shorter\n(d)");
  68. b->callback(bcb4); b->shortcut('d');
  69. ovl->resizable(ovl);
  70. ovl->end();
  71. ovl->show(argc,argv);
  72. ovl->redraw_overlay();
  73. return Fl::run();
  74. }
  75. //
  76. // End of "$Id: overlay.cxx 7903 2010-11-28 21:06:39Z matt $".
  77. //