source: rtems-graphics-toolkit/fltk-1.1.10/test/label.cxx @ 513eea1

Last change on this file since 513eea1 was 513eea1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/09/10 at 22:43:24

2010-01-08 Joel Sherrill <joel.sherrill@…>

fltk 1.1.10. imported

  • ORIGIN: Updated.
  • Property mode set to 100644
File size: 4.3 KB
Line 
1//
2// "$Id$"
3//
4// Label test program for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2005 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_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_draw.H>
36
37Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
38Fl_Box *text;
39Fl_Input *input;
40Fl_Hor_Value_Slider *fonts;
41Fl_Hor_Value_Slider *sizes;
42Fl_Double_Window *window;
43
44void button_cb(Fl_Widget *,void *) {
45  int i = 0;
46  if (leftb->value()) i |= FL_ALIGN_LEFT;
47  if (rightb->value()) i |= FL_ALIGN_RIGHT;
48  if (topb->value()) i |= FL_ALIGN_TOP;
49  if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
50  if (insideb->value()) i |= FL_ALIGN_INSIDE;
51  if (clipb->value()) i |= FL_ALIGN_CLIP;
52  if (wrapb->value()) i |= FL_ALIGN_WRAP;
53  text->align(i);
54  window->redraw();
55}
56
57void font_cb(Fl_Widget *,void *) {
58  text->labelfont(int(fonts->value()));
59  window->redraw();
60}
61
62void size_cb(Fl_Widget *,void *) {
63  text->labelsize(int(sizes->value()));
64  window->redraw();
65}
66
67void input_cb(Fl_Widget *,void *) {
68  text->label(input->value());
69  window->redraw();
70}
71
72void normal_cb(Fl_Widget *,void *) {
73  text->labeltype(FL_NORMAL_LABEL);
74  window->redraw();
75}
76
77void symbol_cb(Fl_Widget *,void *) {
78  text->labeltype(FL_SYMBOL_LABEL);
79  if (input->value()[0] != '@') {
80    input->static_value("@->");
81    text->label("@->");
82  }
83  window->redraw();
84}
85
86void shadow_cb(Fl_Widget *,void *) {
87  text->labeltype(FL_SHADOW_LABEL);
88  window->redraw();
89}
90
91void embossed_cb(Fl_Widget *,void *) {
92  text->labeltype(FL_EMBOSSED_LABEL);
93  window->redraw();
94}
95
96void engraved_cb(Fl_Widget *,void *) {
97  text->labeltype(FL_ENGRAVED_LABEL);
98  window->redraw();
99}
100
101Fl_Menu_Item choices[] = {
102  {"FL_NORMAL_LABEL",0,normal_cb},
103  {"FL_SYMBOL_LABEL",0,symbol_cb},
104  {"FL_SHADOW_LABEL",0,shadow_cb},
105  {"FL_ENGRAVED_LABEL",0,engraved_cb},
106  {"FL_EMBOSSED_LABEL",0,embossed_cb},
107  {0}};
108
109int main(int argc, char **argv) {
110  window = new Fl_Double_Window(400,400);
111
112  input = new Fl_Input(50,0,350,25);
113  input->static_value("The quick brown fox jumped over the lazy dog.");
114  input->when(FL_WHEN_CHANGED);
115  input->callback(input_cb);
116
117  sizes= new Fl_Hor_Value_Slider(50,25,350,25,"Size:");
118  sizes->align(FL_ALIGN_LEFT);
119  sizes->bounds(1,64);
120  sizes->step(1);
121  sizes->value(14);
122  sizes->callback(size_cb);
123
124  fonts=new Fl_Hor_Value_Slider(50,50,350,25,"Font:");
125  fonts->align(FL_ALIGN_LEFT);
126  fonts->bounds(0,15);
127  fonts->step(1);
128  fonts->value(0);
129  fonts->callback(font_cb);
130
131  Fl_Group *g = new Fl_Group(0,0,0,0);
132  leftb = new Fl_Toggle_Button(50,75,50,25,"left");
133  leftb->callback(button_cb);
134  rightb = new Fl_Toggle_Button(100,75,50,25,"right");
135  rightb->callback(button_cb);
136  topb = new Fl_Toggle_Button(150,75,50,25,"top");
137  topb->callback(button_cb);
138  bottomb = new Fl_Toggle_Button(200,75,50,25,"bottom");
139  bottomb->callback(button_cb);
140  insideb = new Fl_Toggle_Button(250,75,50,25,"inside");
141  insideb->callback(button_cb);
142  wrapb = new Fl_Toggle_Button(300,75,50,25,"wrap");
143  wrapb->callback(button_cb);
144  clipb = new Fl_Toggle_Button(350,75,50,25,"clip");
145  clipb->callback(button_cb);
146  g->resizable(insideb);
147  g->forms_end();
148
149  Fl_Choice *c = new Fl_Choice(50,100,200,25);
150  c->menu(choices);
151
152  text= new Fl_Box(FL_FRAME_BOX,100,225,200,100,input->value());
153  text->align(FL_ALIGN_CENTER);
154  window->resizable(text);
155  window->forms_end();
156  window->show(argc,argv);
157  return Fl::run();
158}
159
160//
161// End of "$Id$".
162//
Note: See TracBrowser for help on using the repository browser.