function selection_ok(c_sel) { local color = c_sel.get_color(); // local color = c_sel.get_color(array(0.0, 0.0, 0.0, 0.0)); princ("\nThe color selected has the following characteristics:\n"); // princ(color, "\n"); princ(format("RGB: (%5.3f %5.3f %5.3f) \nOpacity: %5.3f", color[0], color[1], color[2], color[3]), "\n"); c_sel.set_color(color); } function changed(c_sel) { /*Note: these can be used if desired.*/ // local color = c_sel.get_color(); // princ (format("RGB: (%5.3f %5.3f %5.3f) Opacity: %5.3f", // color[0], color[1], color[2], color[3]), "\n"); } function create_color_selection () { win_color_selection = new (GtkColorSelectionDialog); win_color_selection.signal ("destroy", #win_color_selection = nil); win_color_selection.title = "color selection dialog"; win_color_selection.border_width = 10; win_color_selection.set_position(GTK_WIN_POS_CENTER); win_color_selection.colorsel.policy = GTK_UPDATE_CONTINUOUS; win_color_selection.colorsel.use_opacity = 1; /* Create an initial setting */ win_color_selection.colorsel.set_color(array(.25,.9,.8,.85)); win_color_selection.colorsel.signal("color_changed", `(changed(@win_color_selection.colorsel))); win_color_selection.ok_button.signal("clicked", `(selection_ok(@win_color_selection.colorsel))); win_color_selection.cancel_button.signal("clicked", `(@win_color_selection).destroy()); win_color_selection.show_all(); win_color_selection; } function main () { local window, win_color_selection; TRUE=1; FALSE=0; window = create_color_selection (); window.signal ("destroy", #exit_program(0)); init_ipc("color_sel", "color_selq"); gtk_main (); }
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.