function create_pane_options(pn, frame_label, label1, label2) { local child1, child2, frame, table, label, button_r, button_s; frame = new(GtkFrame); frame.label = frame_label; frame.border_width = 4; child1 = car(pn.children()); child2 = cadr(pn.children()); table = new(GtkTable); table.n_rows = 3; table.n_columns = 2; table.homogeneous = TRUE; label = new(GtkLabel); label.set_text(label1); table.attach_defaults(label, 0, 1, 0, 1); button_r = new(GtkCheckButton); button_r.label = "Resize"; button_r.set_active(TRUE); table.attach_defaults(button_r, 0, 1, 1, 2); button_s = new(GtkCheckButton); button_s.label = "Shrink"; button_s.set_active(TRUE); table.attach_defaults(button_s, 0, 1, 2, 3); button_r.signal("toggled", `toggle_resize(@pn, @child1, (@button_r).get_active(), (@button_s).get_active())); button_s.signal("toggled", `toggle_resize(@pn, @child1, (@button_r).get_active(), (@button_s).get_active())); label = new(GtkLabel); label.set_text(label2); table.attach_defaults(label, 1, 2, 0, 1); button_r = new(GtkCheckButton); button_r.label = "Resize"; button_r.set_active(TRUE); table.attach_defaults(button_r, 1, 2, 1, 2); button_s = new(GtkCheckButton); button_s.label = "Shrink"; button_s.set_active(TRUE); table.attach_defaults(button_s, 1, 2, 2, 3); button_r.signal("toggled", `toggle_resize(@pn, @child2, (@button_r).get_active(), (@button_s).get_active())); button_s.signal("toggled", `toggle_resize(@pn, @child2, (@button_r).get_active(), (@button_s).get_active())); frame.add(table); frame; } function toggle_resize(t_pane, t_child, check_r, check_s) { if (check_r == TRUE) { if (check_s == TRUE) change_frame(t_pane, t_child, TRUE, TRUE); else change_frame(t_pane, t_child, TRUE, FALSE); } else { if (check_s == TRUE) change_frame(t_pane, t_child, FALSE, TRUE); else change_frame(t_pane, t_child, FALSE, FALSE); } } function change_frame(pane, child, resize, shrink) { local child1 = car(pane.children()); child.ref(); if (child == child1) { pane.remove(child); pane.pack1(child, resize, shrink); } else { pane.remove(child); pane.pack2(child, resize, shrink); } child.unref(); } function create_panes () { local vbox, hbox, frame1, frame2; win_panes = new (GtkWindow); win_panes.signal ("destroy", #win_panes = nil); win_panes.title = "Panes"; vbox = new(GtkVBox); win_panes.add(vbox); vpaned = new(GtkVPaned); vbox.pack_start(vpaned, TRUE, TRUE, 0); vpaned.border_width = 5; hpaned = new(GtkHPaned); vpaned.add1(hpaned); button = new(GtkButton); button.label = "Hi there"; frame1 = new(GtkFrame); frame1.set_shadow_type(GTK_SHADOW_IN); frame1.set_usize(60, 60); hpaned.pack1(frame1, TRUE, TRUE); frame1.add(button); frame2 = new(GtkFrame); frame2.set_shadow_type(GTK_SHADOW_IN); frame2.set_usize(80, 60); hpaned.pack2(frame2, TRUE, TRUE); framev = new(GtkFrame); framev.set_shadow_type( GTK_SHADOW_IN); framev.set_usize(60, 80); vpaned.pack2(framev, TRUE, TRUE); options = create_pane_options(hpaned, "Horizontal", "Left", "Right"); vbox.pack_start(options, TRUE, TRUE, 0); options = create_pane_options(vpaned, "Vertical", "Top", "Bottom"); vbox.pack_start(options, TRUE, TRUE, 0); win_panes.show_all(); win_panes; } function main () { local window, win_panes; TRUE=1; FALSE=0; window = create_panes (); window.signal ("destroy", #exit_program(0)); init_ipc("panes", "panesq"); gtk_main (); }
Copyright İ 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.