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