1 | // |
---|
2 | // "$Id$" |
---|
3 | // |
---|
4 | // Standard dialog test program for the Fast Light Tool Kit (FLTK). |
---|
5 | // |
---|
6 | // Demonstrates how to use readqueue to see if a button has been |
---|
7 | // pushed, and to see if a window has been closed, thus avoiding |
---|
8 | // the need to define callbacks. |
---|
9 | // |
---|
10 | // This also demonstrates how to trap attempts by the user to |
---|
11 | // close the last window by overriding Fl::exit |
---|
12 | // |
---|
13 | // Copyright 1998-2005 by Bill Spitzak and others. |
---|
14 | // |
---|
15 | // This library is free software; you can redistribute it and/or |
---|
16 | // modify it under the terms of the GNU Library General Public |
---|
17 | // License as published by the Free Software Foundation; either |
---|
18 | // version 2 of the License, or (at your option) any later version. |
---|
19 | // |
---|
20 | // This library is distributed in the hope that it will be useful, |
---|
21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
23 | // Library General Public License for more details. |
---|
24 | // |
---|
25 | // You should have received a copy of the GNU Library General Public |
---|
26 | // License along with this library; if not, write to the Free Software |
---|
27 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
28 | // USA. |
---|
29 | // |
---|
30 | // Please report all bugs and problems on the following page: |
---|
31 | // |
---|
32 | // http://www.fltk.org/str.php |
---|
33 | // |
---|
34 | |
---|
35 | #include <stdio.h> |
---|
36 | #include <string.h> |
---|
37 | #include <FL/Fl.H> |
---|
38 | #include <FL/Fl_Window.H> |
---|
39 | #include <FL/Fl_Input.H> |
---|
40 | #include <FL/Fl_Button.H> |
---|
41 | #include <FL/Fl_Return_Button.H> |
---|
42 | |
---|
43 | #include <FL/fl_ask.H> |
---|
44 | #include <stdlib.h> |
---|
45 | |
---|
46 | void rename_me(Fl_Widget*o) { |
---|
47 | const char *input = fl_input("Input:", o->label()); |
---|
48 | |
---|
49 | if (input) { |
---|
50 | o->copy_label(input); |
---|
51 | o->redraw(); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | void window_callback(Fl_Widget*, void*) { |
---|
56 | if (!fl_choice("Are you sure you want to quit?", "Cancel", "Quit", 0L)) return; |
---|
57 | exit(0); |
---|
58 | } |
---|
59 | |
---|
60 | int main(int argc, char **argv) { |
---|
61 | char buffer[128] = "test text"; |
---|
62 | |
---|
63 | // this is a test to make sure automatic destructors work. Pop up |
---|
64 | // the question dialog several times and make sure it don't crash. |
---|
65 | |
---|
66 | Fl_Window window(200, 55); |
---|
67 | Fl_Return_Button b(20, 10, 160, 35, buffer); b.callback(rename_me); |
---|
68 | window.end(); |
---|
69 | window.resizable(&b); |
---|
70 | window.show(argc, argv); |
---|
71 | |
---|
72 | // Also we test to see if the exit callback works: |
---|
73 | window.callback(window_callback); |
---|
74 | |
---|
75 | return Fl::run(); |
---|
76 | } |
---|
77 | |
---|
78 | // |
---|
79 | // End of "$Id$". |
---|
80 | // |
---|