UIfeedback.C

This shows the results of using each of the different kinds of UI devices available to the programmer.

/* 
    plugin Tutorial
    example 3 - UIfeedback.C 
    demonstrate warning and error messages
*/

#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <memory.h>
#include <string.h>
#include "cpi.h"

// some constants to make the code more readable
#define TAB_NAME        "Parameter Area"
#define HOW_MANY        "How Many"
#define SEE_ERR            "Show Error"
#define LANGUAGE        "Language"

#define MAX_STRING        256

char    *menu[] = { "Dutch",
                    "English", 
                    "French", 
                    "German", 
                    NULL};

// define the user interface tabs and gadgets
CPIDSOEXPORT void upiCreateParameters( void )
{
    // define parameters
    cpiAddTab( TAB_NAME );
    cpiAddInteger( HOW_MANY, 1, 0, 10, P_ANIMATE );
    cpiAddMenu( LANGUAGE, 1, menu, 0);
    cpiAddToggle( SEE_ERR, 0, 0);
}

// warning/error messages can only be sent during cooking, so
// we check for errors in upiProcessImage()
CPIDSOEXPORT int upiProcessImage(CPI_Image *result)
{
    int        count, choice, state;

    // get the parameter values
    cpiGetInteger(HOW_MANY, result->info.time, &count);
    cpiGetInteger(SEE_ERR, result->info.time, &state);
    cpiGetInteger(LANGUAGE, result->info.time, &choice);

    if (state)
        cpiError("Language is %s", menu[choice]);
    else
        cpiWarning("%d Sample(s)", count);

    return 0;
}
[ Table of Contents ] [ Index]

Copyright © 1998 Silicon Grail Inc.
710 Seward Street, Hollywood, CA 90038