1998-10-20 17:25:25 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
|
|
|
// Label test program for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright 1998-2010 by Bill Spitzak and others.
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Double_Window.H>
|
|
|
|
#include <FL/Fl_Box.H>
|
|
|
|
#include <FL/Fl_Hor_Value_Slider.H>
|
|
|
|
#include <FL/Fl_Toggle_Button.H>
|
|
|
|
#include <FL/Fl_Input.H>
|
|
|
|
#include <FL/Fl_Choice.H>
|
2010-04-08 03:17:33 +04:00
|
|
|
#include <FL/Fl_Pixmap.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
2010-04-08 03:17:33 +04:00
|
|
|
#include "pixmaps/blast.xpm"
|
|
|
|
|
|
|
|
Fl_Toggle_Button *imageb, *imageovertextb, *imagenexttotextb, *imagebackdropb;
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
|
|
|
|
Fl_Box *text;
|
|
|
|
Fl_Input *input;
|
|
|
|
Fl_Hor_Value_Slider *fonts;
|
|
|
|
Fl_Hor_Value_Slider *sizes;
|
|
|
|
Fl_Double_Window *window;
|
2010-04-08 03:17:33 +04:00
|
|
|
Fl_Pixmap *img;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void button_cb(Fl_Widget *,void *) {
|
|
|
|
int i = 0;
|
|
|
|
if (leftb->value()) i |= FL_ALIGN_LEFT;
|
|
|
|
if (rightb->value()) i |= FL_ALIGN_RIGHT;
|
|
|
|
if (topb->value()) i |= FL_ALIGN_TOP;
|
|
|
|
if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
|
|
|
|
if (insideb->value()) i |= FL_ALIGN_INSIDE;
|
|
|
|
if (clipb->value()) i |= FL_ALIGN_CLIP;
|
|
|
|
if (wrapb->value()) i |= FL_ALIGN_WRAP;
|
2010-04-08 03:17:33 +04:00
|
|
|
if (imageovertextb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE;
|
2010-10-31 01:32:15 +04:00
|
|
|
if (imagenexttotextb->value()) i |= FL_ALIGN_IMAGE_NEXT_TO_TEXT;
|
2010-04-08 03:17:33 +04:00
|
|
|
if (imagebackdropb->value()) i |= FL_ALIGN_IMAGE_BACKDROP;
|
1998-10-06 22:21:25 +04:00
|
|
|
text->align(i);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
2010-04-08 03:17:33 +04:00
|
|
|
void image_cb(Fl_Widget *,void *) {
|
|
|
|
if (imageb->value())
|
|
|
|
text->image(img);
|
2015-03-05 15:40:32 +03:00
|
|
|
else
|
2010-04-08 03:17:33 +04:00
|
|
|
text->image(0);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void font_cb(Fl_Widget *,void *) {
|
|
|
|
text->labelfont(int(fonts->value()));
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void size_cb(Fl_Widget *,void *) {
|
|
|
|
text->labelsize(int(sizes->value()));
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void input_cb(Fl_Widget *,void *) {
|
|
|
|
text->label(input->value());
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void normal_cb(Fl_Widget *,void *) {
|
|
|
|
text->labeltype(FL_NORMAL_LABEL);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void symbol_cb(Fl_Widget *,void *) {
|
|
|
|
text->labeltype(FL_SYMBOL_LABEL);
|
|
|
|
if (input->value()[0] != '@') {
|
|
|
|
input->static_value("@->");
|
|
|
|
text->label("@->");
|
|
|
|
}
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void shadow_cb(Fl_Widget *,void *) {
|
|
|
|
text->labeltype(FL_SHADOW_LABEL);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void embossed_cb(Fl_Widget *,void *) {
|
|
|
|
text->labeltype(FL_EMBOSSED_LABEL);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void engraved_cb(Fl_Widget *,void *) {
|
|
|
|
text->labeltype(FL_ENGRAVED_LABEL);
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
Fl_Menu_Item choices[] = {
|
|
|
|
{"FL_NORMAL_LABEL",0,normal_cb},
|
|
|
|
{"FL_SYMBOL_LABEL",0,symbol_cb},
|
|
|
|
{"FL_SHADOW_LABEL",0,shadow_cb},
|
|
|
|
{"FL_ENGRAVED_LABEL",0,engraved_cb},
|
|
|
|
{"FL_EMBOSSED_LABEL",0,embossed_cb},
|
|
|
|
{0}};
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2010-04-08 03:17:33 +04:00
|
|
|
img = new Fl_Pixmap(blast_xpm);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
window = new Fl_Double_Window(440,420);
|
|
|
|
|
|
|
|
input = new Fl_Input(70,375,350,25,"Label:");
|
1998-10-06 22:21:25 +04:00
|
|
|
input->static_value("The quick brown fox jumped over the lazy dog.");
|
|
|
|
input->when(FL_WHEN_CHANGED);
|
|
|
|
input->callback(input_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
input->tooltip("label text");
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
sizes= new Fl_Hor_Value_Slider(70,350,350,25,"Size:");
|
1998-10-06 22:21:25 +04:00
|
|
|
sizes->align(FL_ALIGN_LEFT);
|
|
|
|
sizes->bounds(1,64);
|
|
|
|
sizes->step(1);
|
|
|
|
sizes->value(14);
|
|
|
|
sizes->callback(size_cb);
|
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
fonts=new Fl_Hor_Value_Slider(70,325,350,25,"Font:");
|
1998-10-06 22:21:25 +04:00
|
|
|
fonts->align(FL_ALIGN_LEFT);
|
|
|
|
fonts->bounds(0,15);
|
|
|
|
fonts->step(1);
|
|
|
|
fonts->value(0);
|
|
|
|
fonts->callback(font_cb);
|
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
Fl_Group *g = new Fl_Group(70,275,350,50);
|
|
|
|
imageb = new Fl_Toggle_Button(70,275,50,25,"image");
|
2010-04-08 03:17:33 +04:00
|
|
|
imageb->callback(image_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
imageb->tooltip("show image");
|
|
|
|
|
|
|
|
imageovertextb = new Fl_Toggle_Button(120,275,50,25,"T o I");
|
2010-04-08 03:17:33 +04:00
|
|
|
imageovertextb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
imageovertextb->tooltip("FL_ALIGN_TEXT_OVER_IMAGE");
|
|
|
|
|
|
|
|
imagenexttotextb = new Fl_Toggle_Button(170,275,50,25,"I | T");
|
2010-04-08 03:17:33 +04:00
|
|
|
imagenexttotextb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
imagenexttotextb->tooltip("FL_ALIGN_IMAGE_NEXT_TO_TEXT");
|
|
|
|
|
|
|
|
imagebackdropb = new Fl_Toggle_Button(220,275,50,25,"back");
|
2010-04-08 03:17:33 +04:00
|
|
|
imagebackdropb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
imagebackdropb->tooltip("FL_ALIGN_IMAGE_BACKDROP");
|
|
|
|
|
|
|
|
leftb = new Fl_Toggle_Button(70,300,50,25,"left");
|
1998-10-06 22:21:25 +04:00
|
|
|
leftb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
leftb->tooltip("FL_ALIGN_LEFT");
|
|
|
|
|
|
|
|
rightb = new Fl_Toggle_Button(120,300,50,25,"right");
|
1998-10-06 22:21:25 +04:00
|
|
|
rightb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
rightb->tooltip("FL_ALIGN_RIGHT");
|
|
|
|
|
|
|
|
topb = new Fl_Toggle_Button(170,300,50,25,"top");
|
1998-10-06 22:21:25 +04:00
|
|
|
topb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
topb->tooltip("FL_ALIGN_TOP");
|
|
|
|
|
|
|
|
bottomb = new Fl_Toggle_Button(220,300,50,25,"bottom");
|
1998-10-06 22:21:25 +04:00
|
|
|
bottomb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
bottomb->tooltip("FL_ALIGN_BOTTOM");
|
|
|
|
|
|
|
|
insideb = new Fl_Toggle_Button(270,300,50,25,"inside");
|
1998-10-06 22:21:25 +04:00
|
|
|
insideb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
insideb->tooltip("FL_ALIGN_INSIDE");
|
|
|
|
|
|
|
|
wrapb = new Fl_Toggle_Button(320,300,50,25,"wrap");
|
1998-10-06 22:21:25 +04:00
|
|
|
wrapb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
wrapb->tooltip("FL_ALIGN_WRAP");
|
|
|
|
|
|
|
|
clipb = new Fl_Toggle_Button(370,300,50,25,"clip");
|
1998-10-06 22:21:25 +04:00
|
|
|
clipb->callback(button_cb);
|
2015-03-05 15:40:32 +03:00
|
|
|
clipb->tooltip("FL_ALIGN_CLIP");
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
g->resizable(insideb);
|
2008-12-21 18:38:52 +03:00
|
|
|
g->end();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
Fl_Choice *c = new Fl_Choice(70,250,200,25);
|
1998-10-06 22:21:25 +04:00
|
|
|
c->menu(choices);
|
|
|
|
|
2015-03-05 15:40:32 +03:00
|
|
|
text = new Fl_Box(FL_FRAME_BOX,120,75,200,100,input->value());
|
1998-10-06 22:21:25 +04:00
|
|
|
text->align(FL_ALIGN_CENTER);
|
2015-03-05 15:40:32 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
window->resizable(text);
|
2008-12-21 18:38:52 +03:00
|
|
|
window->end();
|
1998-10-06 22:21:25 +04:00
|
|
|
window->show(argc,argv);
|
|
|
|
return Fl::run();
|
|
|
|
}
|
1998-10-20 17:25:25 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|