summaryrefslogtreecommitdiff
path: root/test/label.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:21:25 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:21:25 +0000
commitf9039b2ae21988783feae9b362818e7923e82d14 (patch)
tree6d6fe3679d73448758f9794e7d4d4f6b22a4adad /test/label.cxx
parent67e89232f9ba067825a158734a09e0fa21aacbe3 (diff)
Initial revision
git-svn-id: file:///fltk/svn/fltk/trunk@2 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/label.cxx')
-rw-r--r--test/label.cxx137
1 files changed, 137 insertions, 0 deletions
diff --git a/test/label.cxx b/test/label.cxx
new file mode 100644
index 000000000..d1ca5be10
--- /dev/null
+++ b/test/label.cxx
@@ -0,0 +1,137 @@
+/* Test all the built-in labeltypes, and fl_font
+
+ This is also a good double-buffering test.
+
+*/
+
+#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>
+#include <FL/fl_draw.H>
+
+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;
+
+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;
+ text->align(i);
+ window->redraw();
+}
+
+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) {
+ window = new Fl_Double_Window(400,400);
+
+ input = new Fl_Input(50,0,350,25);
+ input->static_value("The quick brown fox jumped over the lazy dog.");
+ input->when(FL_WHEN_CHANGED);
+ input->callback(input_cb);
+
+ sizes= new Fl_Hor_Value_Slider(50,25,350,25,"Size:");
+ sizes->align(FL_ALIGN_LEFT);
+ sizes->bounds(1,64);
+ sizes->step(1);
+ sizes->value(14);
+ sizes->callback(size_cb);
+
+ fonts=new Fl_Hor_Value_Slider(50,50,350,25,"Font:");
+ fonts->align(FL_ALIGN_LEFT);
+ fonts->bounds(0,15);
+ fonts->step(1);
+ fonts->value(0);
+ fonts->callback(font_cb);
+
+ Fl_Group *g = new Fl_Group(0,0,0,0);
+ leftb = new Fl_Toggle_Button(50,75,50,25,"left");
+ leftb->callback(button_cb);
+ rightb = new Fl_Toggle_Button(100,75,50,25,"right");
+ rightb->callback(button_cb);
+ topb = new Fl_Toggle_Button(150,75,50,25,"top");
+ topb->callback(button_cb);
+ bottomb = new Fl_Toggle_Button(200,75,50,25,"bottom");
+ bottomb->callback(button_cb);
+ insideb = new Fl_Toggle_Button(250,75,50,25,"inside");
+ insideb->callback(button_cb);
+ wrapb = new Fl_Toggle_Button(300,75,50,25,"wrap");
+ wrapb->callback(button_cb);
+ clipb = new Fl_Toggle_Button(350,75,50,25,"clip");
+ clipb->callback(button_cb);
+ g->resizable(insideb);
+ g->forms_end();
+
+ Fl_Choice *c = new Fl_Choice(50,100,200,25);
+ c->menu(choices);
+
+ text= new Fl_Box(FL_FRAME_BOX,100,225,200,100,input->value());
+ text->align(FL_ALIGN_CENTER);
+ window->resizable(text);
+ window->forms_end();
+ window->show(argc,argv);
+ return Fl::run();
+}