source: rtems-graphics-toolkit/fltk-1.3.0/test/label.cxx @ 855379e

Last change on this file since 855379e was f5c9e9c, checked in by Alexandru-Sever Horin <alex.sever.h@…>, on 07/05/12 at 09:33:03

Aded FLTK 1.3.0

  • Property mode set to 100644
File size: 5.3 KB
Line 
1//
2// "$Id: label.cxx 7903 2010-11-28 21:06:39Z matt $"
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; 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_Pixmap.H>
36#include <FL/fl_draw.H>
37
38#include "pixmaps/blast.xpm"
39
40Fl_Toggle_Button *imageb, *imageovertextb, *imagenexttotextb, *imagebackdropb;
41Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
42Fl_Box *text;
43Fl_Input *input;
44Fl_Hor_Value_Slider *fonts;
45Fl_Hor_Value_Slider *sizes;
46Fl_Double_Window *window;
47Fl_Pixmap *img;
48
49void button_cb(Fl_Widget *,void *) {
50  int i = 0;
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;
61  text->align(i);
62  window->redraw();
63}
64
65void image_cb(Fl_Widget *,void *) {
66  if (imageb->value())
67    text->image(img);
68  else
69    text->image(0);
70  window->redraw();
71}
72
73void font_cb(Fl_Widget *,void *) {
74  text->labelfont(int(fonts->value()));
75  window->redraw();
76}
77
78void size_cb(Fl_Widget *,void *) {
79  text->labelsize(int(sizes->value()));
80  window->redraw();
81}
82
83void input_cb(Fl_Widget *,void *) {
84  text->label(input->value());
85  window->redraw();
86}
87
88void normal_cb(Fl_Widget *,void *) {
89  text->labeltype(FL_NORMAL_LABEL);
90  window->redraw();
91}
92
93void symbol_cb(Fl_Widget *,void *) {
94  text->labeltype(FL_SYMBOL_LABEL);
95  if (input->value()[0] != '@') {
96    input->static_value("@->");
97    text->label("@->");
98  }
99  window->redraw();
100}
101
102void shadow_cb(Fl_Widget *,void *) {
103  text->labeltype(FL_SHADOW_LABEL);
104  window->redraw();
105}
106
107void embossed_cb(Fl_Widget *,void *) {
108  text->labeltype(FL_EMBOSSED_LABEL);
109  window->redraw();
110}
111
112void engraved_cb(Fl_Widget *,void *) {
113  text->labeltype(FL_ENGRAVED_LABEL);
114  window->redraw();
115}
116
117Fl_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},
123  {0}};
124
125int main(int argc, char **argv) {
126  img = new Fl_Pixmap(blast_xpm);
127 
128  window = new Fl_Double_Window(400,400);
129
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);
134
135  sizes= new Fl_Hor_Value_Slider(50,350,350,25,"Size:");
136  sizes->align(FL_ALIGN_LEFT);
137  sizes->bounds(1,64);
138  sizes->step(1);
139  sizes->value(14);
140  sizes->callback(size_cb);
141
142  fonts=new Fl_Hor_Value_Slider(50,325,350,25,"Font:");
143  fonts->align(FL_ALIGN_LEFT);
144  fonts->bounds(0,15);
145  fonts->step(1);
146  fonts->value(0);
147  fonts->callback(font_cb);
148
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);
173  g->end();
174
175  Fl_Choice *c = new Fl_Choice(50,250,200,25);
176  c->menu(choices);
177
178  text= new Fl_Box(FL_FRAME_BOX,100,75,200,100,input->value());
179  text->align(FL_ALIGN_CENTER);
180  window->resizable(text);
181  window->end();
182  window->show(argc,argv);
183  return Fl::run();
184}
185
186//
187// End of "$Id: label.cxx 7903 2010-11-28 21:06:39Z matt $".
188//
Note: See TracBrowser for help on using the repository browser.