Read a Widget File and Create its Widgets

Gamma/Photon: Using Gamma™ with the Photon microGUIŽ, Version 4.0
Prev | Chapter 4. Building Applications - a Tutorial | Next

# 4.5. Read a Widget File and Create its Widgets

    #!/usr/cogent/bin/phgamma

    /* This example is the second of three ways to incorporate a
     * PhAB-created GUI into a Gamma program.  It produces the same output
     * as the previous example, but instead of using the PhabLoad()
     * function, it calls PhabReadWidgetFile() and PhabCreateWidgets().
     * This allows for naming the widgets locally, and independently of
     * their original names, unlike PhabLoad(), which assigns global
     * variables that correspond to widget names.  */

    require_lisp("PhotonWidgets.lsp");
    require_lisp("PhabTemplate.lsp");
    PtInit(nil);

    /*
     * Read the widget file.
     */
    wfile = PhabReadWidgetFile ("WidgetFiles/wgt/colortest.wgtw");

    /*
     * Create widgets from the widget file that was read.
     */
    window = PhabCreateWidgets(wfile, nil, nil);

    /*
     * Find the widgets to be used, and assign them new names.
     */
    ct = PhabLookupWidget(window,#colortest,nil);
    eb = PhabLookupWidget(window,#entrybox,nil);
    pn = PhabLookupWidget(window,#pane,nil);
    bt = PhabLookupWidget(window,#but,nil);

    PtAttachCallback(eb,Pt_CB_TEXT_CHANGED,
                     #entry = parse_string(eb.text_string));
    PtAttachCallback(eb,Pt_CB_ACTIVATE,#pn.fill_color = entry);
    PtAttachCallback(bt,Pt_CB_ACTIVATE,#exit_program(-1));

    PtRealizeWidget(ct);
    PtMainLoop();

Prev | Home | Next
Load a Window Created in PhAB | Up | Read a Widget File and Assign its Widgets to a Class

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