1 //
2 // "$Id$"
3 //
4 // 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. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file.  If this
10 // file is missing or damaged, see the license at:
11 //
12 //     http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 //     http://www.fltk.org/str.php
17 //
18 
19 #include <FL/Fl.H>
20 #include <FL/Fl_Double_Window.H>
21 #include <FL/Fl_Box.H>
22 #include <FL/Fl_Hor_Value_Slider.H>
23 #include <FL/Fl_Toggle_Button.H>
24 #include <FL/Fl_Input.H>
25 #include <FL/Fl_Choice.H>
26 #include <FL/Fl_Pixmap.H>
27 #include <FL/fl_draw.H>
28 
29 #include "pixmaps/blast.xpm"
30 
31 Fl_Toggle_Button *imageb, *imageovertextb, *imagenexttotextb, *imagebackdropb;
32 Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
33 Fl_Box *text;
34 Fl_Input *input;
35 Fl_Hor_Value_Slider *fonts;
36 Fl_Hor_Value_Slider *sizes;
37 Fl_Double_Window *window;
38 Fl_Pixmap *img;
39 
button_cb(Fl_Widget *,void *)40 void button_cb(Fl_Widget *,void *) {
41   int i = 0;
42   if (leftb->value()) i |= FL_ALIGN_LEFT;
43   if (rightb->value()) i |= FL_ALIGN_RIGHT;
44   if (topb->value()) i |= FL_ALIGN_TOP;
45   if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
46   if (insideb->value()) i |= FL_ALIGN_INSIDE;
47   if (clipb->value()) i |= FL_ALIGN_CLIP;
48   if (wrapb->value()) i |= FL_ALIGN_WRAP;
49   if (imageovertextb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE;
50   if (imagenexttotextb->value()) i |= FL_ALIGN_IMAGE_NEXT_TO_TEXT;
51   if (imagebackdropb->value()) i |= FL_ALIGN_IMAGE_BACKDROP;
52   text->align(i);
53   window->redraw();
54 }
55 
image_cb(Fl_Widget *,void *)56 void image_cb(Fl_Widget *,void *) {
57   if (imageb->value())
58     text->image(img);
59   else
60     text->image(0);
61   window->redraw();
62 }
63 
font_cb(Fl_Widget *,void *)64 void font_cb(Fl_Widget *,void *) {
65   text->labelfont(int(fonts->value()));
66   window->redraw();
67 }
68 
size_cb(Fl_Widget *,void *)69 void size_cb(Fl_Widget *,void *) {
70   text->labelsize(int(sizes->value()));
71   window->redraw();
72 }
73 
input_cb(Fl_Widget *,void *)74 void input_cb(Fl_Widget *,void *) {
75   text->label(input->value());
76   window->redraw();
77 }
78 
normal_cb(Fl_Widget *,void *)79 void normal_cb(Fl_Widget *,void *) {
80   text->labeltype(FL_NORMAL_LABEL);
81   window->redraw();
82 }
83 
symbol_cb(Fl_Widget *,void *)84 void symbol_cb(Fl_Widget *,void *) {
85   text->labeltype(FL_SYMBOL_LABEL);
86   if (input->value()[0] != '@') {
87     input->static_value("@->");
88     text->label("@->");
89   }
90   window->redraw();
91 }
92 
shadow_cb(Fl_Widget *,void *)93 void shadow_cb(Fl_Widget *,void *) {
94   text->labeltype(FL_SHADOW_LABEL);
95   window->redraw();
96 }
97 
embossed_cb(Fl_Widget *,void *)98 void embossed_cb(Fl_Widget *,void *) {
99   text->labeltype(FL_EMBOSSED_LABEL);
100   window->redraw();
101 }
102 
engraved_cb(Fl_Widget *,void *)103 void engraved_cb(Fl_Widget *,void *) {
104   text->labeltype(FL_ENGRAVED_LABEL);
105   window->redraw();
106 }
107 
108 Fl_Menu_Item choices[] = {
109   {"FL_NORMAL_LABEL",0,normal_cb},
110   {"FL_SYMBOL_LABEL",0,symbol_cb},
111   {"FL_SHADOW_LABEL",0,shadow_cb},
112   {"FL_ENGRAVED_LABEL",0,engraved_cb},
113   {"FL_EMBOSSED_LABEL",0,embossed_cb},
114   {0}};
115 
main(int argc,char ** argv)116 int main(int argc, char **argv) {
117   img = new Fl_Pixmap(blast_xpm);
118 
119   window = new Fl_Double_Window(440,420);
120 
121   input = new Fl_Input(70,375,350,25,"Label:");
122   input->static_value("The quick brown fox jumped over the lazy dog.");
123   input->when(FL_WHEN_CHANGED);
124   input->callback(input_cb);
125   input->tooltip("label text");
126 
127   sizes= new Fl_Hor_Value_Slider(70,350,350,25,"Size:");
128   sizes->align(FL_ALIGN_LEFT);
129   sizes->bounds(1,64);
130   sizes->step(1);
131   sizes->value(14);
132   sizes->callback(size_cb);
133 
134   fonts=new Fl_Hor_Value_Slider(70,325,350,25,"Font:");
135   fonts->align(FL_ALIGN_LEFT);
136   fonts->bounds(0,15);
137   fonts->step(1);
138   fonts->value(0);
139   fonts->callback(font_cb);
140 
141   Fl_Group *g = new Fl_Group(70,275,350,50);
142   imageb = new Fl_Toggle_Button(70,275,50,25,"image");
143   imageb->callback(image_cb);
144   imageb->tooltip("show image");
145 
146   imageovertextb = new Fl_Toggle_Button(120,275,50,25,"T o I");
147   imageovertextb->callback(button_cb);
148   imageovertextb->tooltip("FL_ALIGN_TEXT_OVER_IMAGE");
149 
150   imagenexttotextb = new Fl_Toggle_Button(170,275,50,25,"I | T");
151   imagenexttotextb->callback(button_cb);
152   imagenexttotextb->tooltip("FL_ALIGN_IMAGE_NEXT_TO_TEXT");
153 
154   imagebackdropb = new Fl_Toggle_Button(220,275,50,25,"back");
155   imagebackdropb->callback(button_cb);
156   imagebackdropb->tooltip("FL_ALIGN_IMAGE_BACKDROP");
157 
158   leftb = new Fl_Toggle_Button(70,300,50,25,"left");
159   leftb->callback(button_cb);
160   leftb->tooltip("FL_ALIGN_LEFT");
161 
162   rightb = new Fl_Toggle_Button(120,300,50,25,"right");
163   rightb->callback(button_cb);
164   rightb->tooltip("FL_ALIGN_RIGHT");
165 
166   topb = new Fl_Toggle_Button(170,300,50,25,"top");
167   topb->callback(button_cb);
168   topb->tooltip("FL_ALIGN_TOP");
169 
170   bottomb = new Fl_Toggle_Button(220,300,50,25,"bottom");
171   bottomb->callback(button_cb);
172   bottomb->tooltip("FL_ALIGN_BOTTOM");
173 
174   insideb = new Fl_Toggle_Button(270,300,50,25,"inside");
175   insideb->callback(button_cb);
176   insideb->tooltip("FL_ALIGN_INSIDE");
177 
178   wrapb = new Fl_Toggle_Button(320,300,50,25,"wrap");
179   wrapb->callback(button_cb);
180   wrapb->tooltip("FL_ALIGN_WRAP");
181 
182   clipb = new Fl_Toggle_Button(370,300,50,25,"clip");
183   clipb->callback(button_cb);
184   clipb->tooltip("FL_ALIGN_CLIP");
185 
186   g->resizable(insideb);
187   g->end();
188 
189   Fl_Choice *c = new Fl_Choice(70,250,200,25);
190   c->menu(choices);
191 
192   text = new Fl_Box(FL_FRAME_BOX,120,75,200,100,input->value());
193   text->align(FL_ALIGN_CENTER);
194 
195   window->resizable(text);
196   window->end();
197   window->show(argc,argv);
198   return Fl::run();
199 }
200 
201 //
202 // End of "$Id$".
203 //
204