Chapter 8. Photon Functions (in phsimple.g)

Table of Contents

8.1. Required Libraries and Initializing Photon
8.2. The Monitor Window - create_monitor
8.3. Button Functions - toggle_sym, change_settings
8.4. Callback Functions - slider_callback, num_callback
8.5. Trend Functions - accumulate_trends, update_trends
8.6. QNX 6-specific Function - numeric_assign
8.7. Complete program - phsimple.g

This code was written to run interchangeably on two operating systems (QNX 4 and QNX 6), each with its own respective version of Photon (1.14 and 2). Thus you will find in several places some if statements and/or variations in the code to allow for small differences in QNX and Photon versions. This problem is solved in a more complete way in Tutorial Two, where we use common and abstracted functions to incorporate Linux and GTK as well as QNX 4, QNX 6, and Photon into a truly cross-platform application.

This chapter presents the code for phsimple.g in several annotated sections. The program functions are arranged slightly out of order in this chapter, not exactly as they appear in the actual program. The complete program in proper sequence is shown in the final section of this chapter.

8.1. Required Libraries and Initializing Photon

To use Photon in Gamma we need a few extra libraries. The Gamma wrappers for Photon widgets are in PhotonWidgets.lsp, and there are functions that help us interface with PhAB in the PhabTemplate.lsp file. These are called in using the Gamma require_lisp function, because they are written in Lisp. We also have to initiate a graphics session with the Photon Window Manager, using the Gamma function PtInit.

   /********************************************************
    *                     STARTING UP                      *
    ********************************************************/
   
   require_lisp("PhotonWidgets.lsp");
   require_lisp("PhabTemplate.lsp");
   PtInit(nil);