source: rtems-graphics-toolkit/fltk-1.1.10/test/symbols.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: 3.9 KB
Line 
1//
2// "$Id$"
3//
4// Symbol 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 <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <ctype.h>
32#include <FL/Fl.H>
33#include <FL/Fl_Single_Window.H>
34#include <FL/Fl_Box.H>
35#include <FL/Fl_Value_Slider.H>
36#include <FL/fl_draw.H>
37
38int N = 0;
39#define W 70
40#define H 70
41#define ROWS 6
42#define COLS 6
43
44Fl_Window *window;
45Fl_Value_Slider *orientation;
46Fl_Value_Slider *size;
47
48void slider_cb(Fl_Widget *, void *) {
49  static char buf[80];
50  int val = (int)orientation->value();
51  int sze = (int)size->value();
52  for (int i = window->children(); i--; ) {          // all window children
53    Fl_Widget *wc = window->child(i);
54    const char *l = (const char *)(wc->user_data());
55    if ( l && *l == '@' ) {                       // all children with '@'
56      l ++;
57      if ( wc->box() == FL_NO_BOX ) {             // ascii legend?
58        if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l);
59        else if (val) sprintf(buf, "@@%d%s", val, l);
60        else if (sze) sprintf(buf, "@@%+d%s", sze, l);
61        else          sprintf(buf, "@@%s", l);
62      } else {                                    // box with symbol
63        if (val&&sze) sprintf(buf, "@%+d%d%s", sze, val, l);
64        else if (val) sprintf(buf, "@%d%s", val, l);
65        else if (sze) sprintf(buf, "@%+d%s", sze, l);
66        else          sprintf(buf, "@%s", l);
67      }
68      wc->copy_label(buf);
69    }
70  }
71  window->redraw();
72}
73
74void bt(const char *name) {
75  int x = N%COLS;
76  int y = N/COLS;
77  char buf[255];
78  N++;
79  x = x*W+10;
80  y = y*H+10;
81  sprintf(buf, "@%s", name);
82  Fl_Box *a = new Fl_Box(x,y,W-20,H-20);
83  a->box(FL_NO_BOX);
84  a->copy_label(buf);
85  a->align(FL_ALIGN_BOTTOM);
86  a->labelsize(11);
87  a->user_data((void *)name);
88  Fl_Box *b = new Fl_Box(x,y,W-20,H-20);
89  b->box(FL_UP_BOX);
90  b->copy_label(name);
91  b->labelcolor(FL_DARK3);
92  b->user_data((void *)name);
93}
94
95int main(int argc, char ** argv) {
96  window = new Fl_Single_Window(COLS*W,ROWS*H+60);
97bt("@->");
98bt("@>");
99bt("@>>");
100bt("@>|");
101bt("@>[]");
102bt("@|>");
103bt("@<-");
104bt("@<");
105bt("@<<");
106bt("@|<");
107bt("@[]<");
108bt("@<|");
109bt("@<->");
110bt("@-->");
111bt("@+");
112bt("@->|");
113bt("@||");
114bt("@arrow");
115bt("@returnarrow");
116bt("@square");
117bt("@circle");
118bt("@line");
119bt("@menu");
120bt("@UpArrow");
121bt("@DnArrow");
122bt("@search");
123bt("@FLTK");
124bt("@filenew");
125bt("@fileopen");
126bt("@filesave");
127bt("@filesaveas");
128bt("@fileprint");
129bt("@refresh");
130bt("@reload");
131bt("@undo");
132bt("@redo");
133
134  orientation = new Fl_Value_Slider(
135    (int)(window->w()*.05+.5), window->h()-40,
136    (int)(window->w()*.42+.5), 16, "Orientation");
137  orientation->type(FL_HORIZONTAL);
138  orientation->range(0.0, 9.0);
139  orientation->value(0.0);
140  orientation->step(1);
141  orientation->callback(slider_cb, 0);
142
143  size = new Fl_Value_Slider(
144    (int)(window->w()*.53+.5), window->h()-40,
145    (int)(window->w()*.42+.5), 16, "Size");
146  size->type(FL_HORIZONTAL);
147  size->range(-3.0, 9.0);
148  size->value(0.0);
149  size->step(1);
150  size->callback(slider_cb, 0);
151
152  window->resizable(window);
153  window->show(argc,argv);
154  return Fl::run();
155}
156
157//
158// End of "$Id$".
159//
Note: See TracBrowser for help on using the repository browser.