2 // "$Id: label.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Label test program for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
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
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
29 #include <FL/Fl_Double_Window.H>
30 #include <FL/Fl_Box.H>
31 #include <FL/Fl_Hor_Value_Slider.H>
32 #include <FL/Fl_Toggle_Button.H>
33 #include <FL/Fl_Input.H>
34 #include <FL/Fl_Choice.H>
35 #include <FL/Fl_Pixmap.H>
36 #include <FL/fl_draw.H>
38 #include "pixmaps/blast.xpm"
40 Fl_Toggle_Button
*imageb
, *imageovertextb
, *imagenexttotextb
, *imagebackdropb
;
41 Fl_Toggle_Button
*leftb
,*rightb
,*topb
,*bottomb
,*insideb
,*clipb
,*wrapb
;
44 Fl_Hor_Value_Slider
*fonts
;
45 Fl_Hor_Value_Slider
*sizes
;
46 Fl_Double_Window
*window
;
49 void button_cb(Fl_Widget
*,void *) {
51 if (leftb
->value()) i
|= FL_ALIGN_LEFT
;
52 if (rightb
->value()) i
|= FL_ALIGN_RIGHT
;
53 if (topb
->value()) i
|= FL_ALIGN_TOP
;
54 if (bottomb
->value()) i
|= FL_ALIGN_BOTTOM
;
55 if (insideb
->value()) i
|= FL_ALIGN_INSIDE
;
56 if (clipb
->value()) i
|= FL_ALIGN_CLIP
;
57 if (wrapb
->value()) i
|= FL_ALIGN_WRAP
;
58 if (imageovertextb
->value()) i
|= FL_ALIGN_TEXT_OVER_IMAGE
;
59 if (imagenexttotextb
->value()) i
|= FL_ALIGN_IMAGE_NEXT_TO_TEXT
;
60 if (imagebackdropb
->value()) i
|= FL_ALIGN_IMAGE_BACKDROP
;
65 void image_cb(Fl_Widget
*,void *) {
73 void font_cb(Fl_Widget
*,void *) {
74 text
->labelfont(int(fonts
->value()));
78 void size_cb(Fl_Widget
*,void *) {
79 text
->labelsize(int(sizes
->value()));
83 void input_cb(Fl_Widget
*,void *) {
84 text
->label(input
->value());
88 void normal_cb(Fl_Widget
*,void *) {
89 text
->labeltype(FL_NORMAL_LABEL
);
93 void symbol_cb(Fl_Widget
*,void *) {
94 text
->labeltype(FL_SYMBOL_LABEL
);
95 if (input
->value()[0] != '@') {
96 input
->static_value("@->");
102 void shadow_cb(Fl_Widget
*,void *) {
103 text
->labeltype(FL_SHADOW_LABEL
);
107 void embossed_cb(Fl_Widget
*,void *) {
108 text
->labeltype(FL_EMBOSSED_LABEL
);
112 void engraved_cb(Fl_Widget
*,void *) {
113 text
->labeltype(FL_ENGRAVED_LABEL
);
117 Fl_Menu_Item choices
[] = {
118 {"FL_NORMAL_LABEL",0,normal_cb
},
119 {"FL_SYMBOL_LABEL",0,symbol_cb
},
120 {"FL_SHADOW_LABEL",0,shadow_cb
},
121 {"FL_ENGRAVED_LABEL",0,engraved_cb
},
122 {"FL_EMBOSSED_LABEL",0,embossed_cb
},
125 int main(int argc
, char **argv
) {
126 img
= new Fl_Pixmap(blast_xpm
);
128 window
= new Fl_Double_Window(400,400);
130 input
= new Fl_Input(50,375,350,25);
131 input
->static_value("The quick brown fox jumped over the lazy dog.");
132 input
->when(FL_WHEN_CHANGED
);
133 input
->callback(input_cb
);
135 sizes
= new Fl_Hor_Value_Slider(50,350,350,25,"Size:");
136 sizes
->align(FL_ALIGN_LEFT
);
140 sizes
->callback(size_cb
);
142 fonts
=new Fl_Hor_Value_Slider(50,325,350,25,"Font:");
143 fonts
->align(FL_ALIGN_LEFT
);
147 fonts
->callback(font_cb
);
149 Fl_Group
*g
= new Fl_Group(50,275,350,50);
150 imageb
= new Fl_Toggle_Button(50,275,50,25,"image");
151 imageb
->callback(image_cb
);
152 imageovertextb
= new Fl_Toggle_Button(100,275,50,25,"I - T");
153 imageovertextb
->callback(button_cb
);
154 imagenexttotextb
= new Fl_Toggle_Button(150,275,50,25,"I | T");
155 imagenexttotextb
->callback(button_cb
);
156 imagebackdropb
= new Fl_Toggle_Button(200,275,50,25,"back");
157 imagebackdropb
->callback(button_cb
);
158 leftb
= new Fl_Toggle_Button(50,300,50,25,"left");
159 leftb
->callback(button_cb
);
160 rightb
= new Fl_Toggle_Button(100,300,50,25,"right");
161 rightb
->callback(button_cb
);
162 topb
= new Fl_Toggle_Button(150,300,50,25,"top");
163 topb
->callback(button_cb
);
164 bottomb
= new Fl_Toggle_Button(200,300,50,25,"bottom");
165 bottomb
->callback(button_cb
);
166 insideb
= new Fl_Toggle_Button(250,300,50,25,"inside");
167 insideb
->callback(button_cb
);
168 wrapb
= new Fl_Toggle_Button(300,300,50,25,"wrap");
169 wrapb
->callback(button_cb
);
170 clipb
= new Fl_Toggle_Button(350,300,50,25,"clip");
171 clipb
->callback(button_cb
);
172 g
->resizable(insideb
);
175 Fl_Choice
*c
= new Fl_Choice(50,250,200,25);
178 text
= new Fl_Box(FL_FRAME_BOX
,100,75,200,100,input
->value());
179 text
->align(FL_ALIGN_CENTER
);
180 window
->resizable(text
);
182 window
->show(argc
,argv
);
187 // End of "$Id: label.cxx 7903 2010-11-28 21:06:39Z matt $".