Blame test/pack.cxx

Packit 328d5c
//
Packit 328d5c
// "$Id: pack.cxx 8864 2011-07-19 04:49:30Z greg.ercolano $"
Packit 328d5c
//
Packit 328d5c
// Fl_Pack test program for the Fast Light Tool Kit (FLTK).
Packit 328d5c
//
Packit 328d5c
// Rather crude test of the Fl_Pack object.
Packit 328d5c
// Changing the type() of an Fl_Pack after it is displayed is not supported
Packit 328d5c
// so I have to do a lot of resizing of things before that.
Packit 328d5c
//
Packit 328d5c
// Copyright 1998-2010 by Bill Spitzak and others.
Packit 328d5c
//
Packit 328d5c
// This library is free software. Distribution and use rights are outlined in
Packit 328d5c
// the file "COPYING" which should have been included with this file.  If this
Packit 328d5c
// file is missing or damaged, see the license at:
Packit 328d5c
//
Packit 328d5c
//     http://www.fltk.org/COPYING.php
Packit 328d5c
//
Packit 328d5c
// Please report all bugs and problems on the following page:
Packit 328d5c
//
Packit 328d5c
//     http://www.fltk.org/str.php
Packit 328d5c
//
Packit 328d5c
Packit 328d5c
#include <FL/Fl.H>
Packit 328d5c
#include <FL/Fl_Button.H>
Packit 328d5c
#include <FL/Fl_Light_Button.H>
Packit 328d5c
#include <FL/Fl_Double_Window.H>
Packit 328d5c
#include <FL/Fl_Scroll.H>
Packit 328d5c
#include <FL/Fl_Value_Slider.H>
Packit 328d5c
#include <FL/Fl_Pack.H>
Packit 328d5c
Packit 328d5c
Fl_Pack *pack;
Packit 328d5c
Fl_Scroll *scroll;
Packit 328d5c
Packit 328d5c
void type_cb(Fl_Light_Button*, long v) {
Packit 328d5c
  for (int i = 0; i < pack->children(); i++) {
Packit 328d5c
    Fl_Widget* o = pack->child(i);
Packit 328d5c
    o->resize(0,0,25,25);
Packit 328d5c
  }
Packit 328d5c
  pack->resize(scroll->x(),scroll->y(),scroll->w(),scroll->h());
Packit 328d5c
  pack->parent()->redraw();
Packit 328d5c
  pack->type(uchar(v));
Packit 328d5c
  pack->redraw();
Packit 328d5c
}
Packit 328d5c
Packit 328d5c
void spacing_cb(Fl_Value_Slider*o, long) {
Packit 328d5c
  pack->spacing(int(o->value()));
Packit 328d5c
  scroll->redraw();
Packit 328d5c
}
Packit 328d5c
Packit 328d5c
int main(int argc, char **argv) {
Packit 328d5c
 Fl_Double_Window *w;
Packit 328d5c
 {Fl_Double_Window* o = new Fl_Double_Window(360, 370);
Packit 328d5c
  w = o;
Packit 328d5c
  scroll = new Fl_Scroll(10,10,340,285);
Packit 328d5c
 {Fl_Pack* o = new Fl_Pack(10, 10, 340, 285);
Packit 328d5c
  pack = o;
Packit 328d5c
  o->box(FL_DOWN_FRAME);
Packit 328d5c
  //o->box(FL_ENGRAVED_FRAME);
Packit 328d5c
 new Fl_Button(35, 35, 25, 25, "b1");
Packit 328d5c
 new Fl_Button(45, 45, 25, 25, "b2");
Packit 328d5c
 new Fl_Button(55, 55, 25, 25, "b3");
Packit 328d5c
 new Fl_Button(65, 65, 25, 25, "b4");
Packit 328d5c
 new Fl_Button(75, 75, 25, 25, "b5");
Packit 328d5c
 new Fl_Button(85, 85, 25, 25, "b6");
Packit 328d5c
 new Fl_Button(95, 95, 25, 25, "b7");
Packit 328d5c
 new Fl_Button(105, 105, 25, 25, "b8");
Packit 328d5c
 new Fl_Button(115, 115, 25, 25, "b9");
Packit 328d5c
 new Fl_Button(125, 125, 25, 25, "b10");
Packit 328d5c
 new Fl_Button(135, 135, 25, 25, "b11");
Packit 328d5c
 new Fl_Button(145, 145, 25, 25, "b12");
Packit 328d5c
 new Fl_Button(155, 155, 25, 25, "b13");
Packit 328d5c
 new Fl_Button(165, 165, 25, 25, "b14");
Packit 328d5c
 new Fl_Button(175, 175, 25, 25, "b15");
Packit 328d5c
 new Fl_Button(185, 185, 25, 25, "b16");
Packit 328d5c
 new Fl_Button(195, 195, 25, 25, "b17");
Packit 328d5c
 new Fl_Button(205, 205, 25, 25, "b18");
Packit 328d5c
 new Fl_Button(215, 215, 25, 25, "b19");
Packit 328d5c
 new Fl_Button(225, 225, 25, 25, "b20");
Packit 328d5c
 new Fl_Button(235, 235, 25, 25, "b21");
Packit 328d5c
 new Fl_Button(245, 245, 25, 25, "b22");
Packit 328d5c
 new Fl_Button(255, 255, 25, 25, "b23");
Packit 328d5c
 new Fl_Button(265, 265, 25, 25, "b24");
Packit 328d5c
  o->end();
Packit 328d5c
  w->resizable(o);
Packit 328d5c
 }
Packit 328d5c
 scroll->end();
Packit 328d5c
 {Fl_Light_Button* o = new Fl_Light_Button(10, 305, 165, 25, "HORIZONTAL");
Packit 328d5c
 o->type(FL_RADIO_BUTTON);
Packit 328d5c
  o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::HORIZONTAL));
Packit 328d5c
 }
Packit 328d5c
 {Fl_Light_Button* o = new Fl_Light_Button(185, 305, 165, 25, "VERTICAL");
Packit 328d5c
 o->type(FL_RADIO_BUTTON);
Packit 328d5c
 o->value(1);
Packit 328d5c
  o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::VERTICAL));
Packit 328d5c
 }
Packit 328d5c
 {Fl_Value_Slider* o = new Fl_Value_Slider(100, 335, 250, 25, "Spacing: ");
Packit 328d5c
 o->align(FL_ALIGN_LEFT);
Packit 328d5c
 o->type(FL_HORIZONTAL);
Packit 328d5c
 o->range(0,30);
Packit 328d5c
 o->step(1);
Packit 328d5c
 o->callback((Fl_Callback*)spacing_cb);
Packit 328d5c
 }
Packit 328d5c
 w->end();
Packit 328d5c
 }
Packit 328d5c
 w->show(argc, argv);
Packit 328d5c
 return Fl::run();
Packit 328d5c
}
Packit 328d5c
Packit 328d5c
//
Packit 328d5c
// End of "$Id: pack.cxx 8864 2011-07-19 04:49:30Z greg.ercolano $".
Packit 328d5c
//