2 // "$Id: pack.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Fl_Pack test program for the Fast Light Tool Kit (FLTK).
6 // Rather crude test of the Fl_Pack object.
7 // Changing the type() of an Fl_Pack after it is displayed is not supported
8 // so I have to do a lot of resizing of things before that.
10 // Copyright 1998-2010 by Bill Spitzak and others.
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Library General Public
14 // License as published by the Free Software Foundation; either
15 // version 2 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Library General Public License for more details.
22 // You should have received a copy of the GNU Library General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 // Please report all bugs and problems on the following page:
29 // http://www.fltk.org/str.php
33 #include <FL/Fl_Button.H>
34 #include <FL/Fl_Light_Button.H>
35 #include <FL/Fl_Double_Window.H>
36 #include <FL/Fl_Scroll.H>
37 #include <FL/Fl_Value_Slider.H>
38 #include <FL/Fl_Pack.H>
43 void type_cb(Fl_Light_Button
*, long v
) {
44 for (int i
= 0; i
< pack
->children(); i
++) {
45 Fl_Widget
* o
= pack
->child(i
);
48 pack
->resize(scroll
->x(),scroll
->y(),scroll
->w(),scroll
->h());
49 pack
->parent()->redraw();
54 void spacing_cb(Fl_Value_Slider
*o
, long) {
55 pack
->spacing(int(o
->value()));
59 int main(int argc
, char **argv
) {
61 {Fl_Double_Window
* o
= new Fl_Double_Window(360, 370);
63 scroll
= new Fl_Scroll(10,10,340,285);
64 {Fl_Pack
* o
= new Fl_Pack(10, 10, 340, 285);
66 o
->box(FL_DOWN_FRAME
);
67 //o->box(FL_ENGRAVED_FRAME);
68 new Fl_Button(35, 35, 25, 25, "b1");
69 new Fl_Button(45, 45, 25, 25, "b2");
70 new Fl_Button(55, 55, 25, 25, "b3");
71 new Fl_Button(65, 65, 25, 25, "b4");
72 new Fl_Button(75, 75, 25, 25, "b5");
73 new Fl_Button(85, 85, 25, 25, "b6");
74 new Fl_Button(95, 95, 25, 25, "b7");
75 new Fl_Button(105, 105, 25, 25, "b8");
76 new Fl_Button(115, 115, 25, 25, "b9");
77 new Fl_Button(125, 125, 25, 25, "b10");
78 new Fl_Button(135, 135, 25, 25, "b11");
79 new Fl_Button(145, 145, 25, 25, "b12");
80 new Fl_Button(155, 155, 25, 25, "b13");
81 new Fl_Button(165, 165, 25, 25, "b14");
82 new Fl_Button(175, 175, 25, 25, "b15");
83 new Fl_Button(185, 185, 25, 25, "b16");
84 new Fl_Button(195, 195, 25, 25, "b17");
85 new Fl_Button(205, 205, 25, 25, "b18");
86 new Fl_Button(215, 215, 25, 25, "b19");
87 new Fl_Button(225, 225, 25, 25, "b20");
88 new Fl_Button(235, 235, 25, 25, "b21");
89 new Fl_Button(245, 245, 25, 25, "b22");
90 new Fl_Button(255, 255, 25, 25, "b23");
91 new Fl_Button(265, 265, 25, 25, "b24");
96 {Fl_Light_Button
* o
= new Fl_Light_Button(10, 305, 165, 25, "HORIZONTAL");
97 o
->type(FL_RADIO_BUTTON
);
98 o
->callback((Fl_Callback
*)type_cb
, (void*)(Fl_Pack::HORIZONTAL
));
100 {Fl_Light_Button
* o
= new Fl_Light_Button(185, 305, 165, 25, "VERTICAL");
101 o
->type(FL_RADIO_BUTTON
);
103 o
->callback((Fl_Callback
*)type_cb
, (void*)(Fl_Pack::VERTICAL
));
105 {Fl_Value_Slider
* o
= new Fl_Value_Slider(100, 335, 250, 25, "Spacing: ");
106 o
->align(FL_ALIGN_LEFT
);
107 o
->type(FL_HORIZONTAL
);
110 o
->callback((Fl_Callback
*)spacing_cb
);
119 // End of "$Id: pack.cxx 7903 2010-11-28 21:06:39Z matt $".