1 //
2 // "$Id: pixmap.cxx 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Pixmap label 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 <FL/Fl.H>
29 #include <FL/Fl_Double_Window.H>
30 #include <FL/Fl_Button.H>
31 #include <FL/Fl_Pixmap.H>
32 #include <stdio.h>
33 
34 #include "pixmaps/porsche.xpm"
35 
36 #include <FL/Fl_Toggle_Button.H>
37 
38 Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*overb,*inactb;
39 Fl_Button *b;
40 Fl_Double_Window *w;
41 
button_cb(Fl_Widget *,void *)42 void button_cb(Fl_Widget *,void *) {
43   int i = 0;
44   if (leftb->value()) i |= FL_ALIGN_LEFT;
45   if (rightb->value()) i |= FL_ALIGN_RIGHT;
46   if (topb->value()) i |= FL_ALIGN_TOP;
47   if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
48   if (insideb->value()) i |= FL_ALIGN_INSIDE;
49   if (overb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE;
50   b->align(i);
51   if (inactb->value()) b->deactivate();
52   else b->activate();
53   w->redraw();
54 }
55 
56 int dvisual = 0;
arg(int,char ** argv,int & i)57 int arg(int, char **argv, int &i) {
58   if (argv[i][1] == '8') {dvisual = 1; i++; return 1;}
59   return 0;
60 }
61 
62 #include <FL/Fl_Multi_Label.H>
63 
main(int argc,char ** argv)64 int main(int argc, char **argv) {
65   int i = 1;
66   if (Fl::args(argc,argv,i,arg) < argc)
67     Fl::fatal(" -8 # : use default visual\n%s\n",Fl::help);
68 
69   Fl_Double_Window window(400,400); ::w = &window;
70   Fl_Button b(140,160,120,120,"Pixmap"); ::b = &b;
71   Fl_Pixmap *pixmap = new Fl_Pixmap(porsche_xpm);
72   Fl_Pixmap *depixmap;
73   depixmap = (Fl_Pixmap *)pixmap->copy();
74   depixmap->inactive();
75 
76   b.image(pixmap);
77   b.deimage(depixmap);
78 
79   leftb = new Fl_Toggle_Button(25,50,50,25,"left");
80   leftb->callback(button_cb);
81   rightb = new Fl_Toggle_Button(75,50,50,25,"right");
82   rightb->callback(button_cb);
83   topb = new Fl_Toggle_Button(125,50,50,25,"top");
84   topb->callback(button_cb);
85   bottomb = new Fl_Toggle_Button(175,50,50,25,"bottom");
86   bottomb->callback(button_cb);
87   insideb = new Fl_Toggle_Button(225,50,50,25,"inside");
88   insideb->callback(button_cb);
89   overb = new Fl_Toggle_Button(25,75,100,25,"text over");
90   overb->callback(button_cb);
91   inactb = new Fl_Toggle_Button(125,75,100,25,"inactive");
92   inactb->callback(button_cb);
93   if (!dvisual) Fl::visual(FL_RGB);
94   window.resizable(window);
95   window.end();
96   window.show(argc,argv);
97   return Fl::run();
98 }
99 
100 //
101 // End of "$Id: pixmap.cxx 7903 2010-11-28 21:06:39Z matt $".
102 //
103