QNX Photon: Changing a Resource of a Widget's Parent

Widget's have a parent (container) object. For instance, in the case of a button on a window, the parent of the PtButton widget is the PtWindow widget that contains it. Photon has the concept of containers and parents. ??? This needs more explanation ???

  1. Create a base window.
  2. Add a PtButton widget to the window, and give it a suitable name.
  3. Set its Text resource (Pt_ARG_TEXT_STRING) to Show Dialog.
  4. Select the button widget, and go to the Callbacks control panel.
  5. Click the Activate event, and the Callback editor appears.
  6. Ensure the code button is depressed, and click on the Function name text box.
  7. Enter a suitable name for the function (e.g. SetParentBlue). The function needn't exist yet, appbuilder will create the file and the function stub for you.
  8. Go the the Application menu, and select Build + Run.
  9. Ensure the correct platform is selected, and click Generate.
  10. In the list of module files, select the module containing the function you named earlier (the file probably has the same name as the function).
  11. Click Edit.
  12. In the following code sample, the changes you need to make to the generated function stub are stongly emphasised like this.
    
    /* Standard headers */
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    
    /* Local headers */
    #include "ablibs.h"
    #include "abimport.h"
    #include "proto.h"
    
    int
    SetParentBlue( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
    
       {
       PtWidget_t *myParent;
       
       /* eliminate 'unreferenced' warnings */
       widget = widget, apinfo = apinfo, cbinfo = cbinfo;
       
     myParent = PtGetParent(widget, PtWindow);
       PtSetResource( myParent, Pt_ARG_FILL_COLOR, Pg_BLUE, 0);
    
       return( Pt_CONTINUE );
       }
    
    

Explanation


Home About Me
Copyright © Neil Carter

Content last updated: 2003-09-23