Range Controls

Gamma/GTK: Using Gamma™ with GTK, Version 0.9
Prev | Appendix A. Example Code | Next

# A.12. Range Controls

    function create_range_controls ()
    {
      local box1, box2, adjustment, scale, scrollbar, separator, button;

      win_range_controls = new (GtkWindow);
      win_range_controls.signal ("destroy", #win_range_controls = nil);
      win_range_controls.title = "range controls";
      win_range_controls.border_width = 0;

      box1 = new (GtkVBox);
      win_range_controls.add (box1);
      box1.show();

      box2 = new (GtkVBox);
      box2.spacing = 10;
      box2.border_width = 10;
      box1.pack_start (box2, TRUE, TRUE, 0);
      box2.show();

      adjustment = gtk_adjustment_new (0, 0.0, 101.0, 0.1, 1.0, 1.0);

      scale = new(GtkHScale);
      scale.set_adjustment(adjustment);
      scale.set_usize(150, 30);
      scale.set_update_policy(GTK_UPDATE_DELAYED);
      scale.set_digits(1);
      scale.set_draw_value(TRUE);
      box2.pack_start(scale, TRUE, TRUE, 0);
      scale.show();

      scrollbar = new(GtkHScrollbar);
      scrollbar.set_adjustment(adjustment);
      scrollbar.set_update_policy(GTK_UPDATE_CONTINUOUS);
      box2.pack_start (scrollbar, TRUE, TRUE, 0);
      scrollbar.show();

      separator = new(GtkHSeparator);
      box1.pack_start(separator, FALSE, TRUE, 0);
      separator.show();

      box2 = new (GtkVBox);
      box2.spacing = 10;
      box2.border_width = 10;
      box1.pack_start (box2, FALSE, TRUE, 0);
      box2.show();

      button = new(GtkButton);
      button.label = "close";
      button.signal("clicked", `(@win_range_controls).destroy());
      box2.pack_start (button, TRUE, TRUE, 0);
      button.can_default = TRUE;
      button.grab_default();
      button.show();

      win_range_controls.show_all();
      win_range_controls;
    }

    function main ()
    {
      local window, win_range_controls;
      TRUE=1;
      FALSE=0;
      window = create_range_controls ();
      window.signal ("destroy", #exit_program(0));
      init_ipc("range_con", "range_conq");
      gtk_main ();
    }

Prev | Home | Next
Radio Buttons | Up | Reparent

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.