Bump version.
[ntk.git] / test / tiled_image.cxx
blob0b1d6f28f7e3507b3e47d6e60523fe0186c65ec1
1 //
2 // "$Id: tiled_image.cxx 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Fl_Tiled_Image 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.
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.
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.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 #include <FL/Fl.H>
29 #include <FL/Fl_Double_Window.H>
30 #include <FL/Fl_Button.H>
31 #include <FL/Fl_Pixmap.H>
32 #include <FL/Fl_Tiled_Image.H>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <math.h>
37 #include "pixmaps/tile.xpm"
39 Fl_Button *b;
40 Fl_Double_Window *w;
42 void button_cb(Fl_Widget *,void *) {
43 w->hide();
46 #include <FL/x.H>
47 #if !defined(WIN32) && !defined(__APPLE__)
48 #include "list_visuals.cxx"
49 #endif
51 int visid = -1;
52 int arg(int argc, char **argv, int &i) {
53 if (argv[i][1] == 'v') {
54 if (i+1 >= argc) return 0;
55 visid = atoi(argv[i+1]);
56 i += 2;
57 return 2;
59 return 0;
62 int main(int argc, char **argv) {
63 #if !defined(WIN32) && !defined(__APPLE__)
64 int i = 1;
66 Fl::args(argc,argv,i,arg);
68 if (visid >= 0) {
69 fl_open_display();
70 XVisualInfo templt; int num;
71 templt.visualid = visid;
72 fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
73 if (!fl_visual) {
74 fprintf(stderr, "No visual with id %d, use one of:\n",visid);
75 list_visuals();
76 exit(1);
78 fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
79 fl_visual->visual, AllocNone);
80 fl_xpixel(FL_BLACK); // make sure black is allocated in overlay visuals
81 } else {
82 Fl::visual(FL_RGB);
84 #endif
86 Fl_Double_Window window(400,400); ::w = &window;
87 Fl_Group group(0,0,400,400);
88 group.image(new Fl_Tiled_Image(new Fl_Pixmap((const char * const *)tile_xpm)));
89 group.align(FL_ALIGN_INSIDE);
91 Fl_Button b(340,365,50,25,"Close"); ::b = &b;
92 b.callback(button_cb);
94 group.end();
96 window.resizable(group);
97 window.end();
98 window.show(argc, argv);
100 return Fl::run();
104 // End of "$Id: tiled_image.cxx 7903 2010-11-28 21:06:39Z matt $".