Back to index

im-sdk  12.3.91
Functions | Variables
PaletteAux.c File Reference
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <Xm/XmAll.h>
#include <Xm/MwmUtil.h>
#include "trace_message.h"
#include "xaux_common.h"
#include "xaux_ext_common.h"
#include "sampleja3_xaux.h"

Go to the source code of this file.

Functions

void xt_ext_event_handler (Widget, XtPointer, XEvent *, Boolean *b)
Bool xaux_ext_Start (xaux_class_t *xc, aux_ext_data_t *aux_ext_data)
Bool xaux_ext_Draw (xaux_class_t *xc, aux_ext_data_t *aux_ext_data)
Bool xaux_ext_Done (xaux_class_t *xc, aux_ext_data_t *aux_ext_data)
void ButtonCallback (Widget w, XtPointer client_data, XtPointer call_data)
int main (int argc, char **argv)
 ReturnToEngine (int integer_count, int *integers, int string_count, char **strings)

Variables

xaux_class_t xaux_class
Widget toplevel
Widget aux
Widget button_text
static xaux_class_txc_ = 0
static int im_ = 0
static int ic_ = 0

Function Documentation

void ButtonCallback ( Widget  w,
XtPointer  client_data,
XtPointer  call_data 
)

Definition at line 174 of file PaletteAux.c.

{
    int integers[5];
    char *strings[5];

    integers[0] = 1;
    integers[1] = 2;
    integers[2] = 3;
    integers[3] = 4;
    strings[0] = "test_string1";
    strings[1] = "test_string2";
    strings[2] = "test_string3";
    strings[3] = "test_string4";
    ReturnToEngine(4, integers, 4, strings);

HelpInvoke("a.html");

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 195 of file PaletteAux.c.

{
    XtAppContext app;
    Display *display;
    int narg;
    Arg args[10];
Widget textfield;

    TRACE_MESSAGE_INIT("TRACE_AUX_EXT");

    setlocale(LC_ALL, NULL);
    XtSetLanguageProc(NULL, NULL, NULL);

    narg = 0;
    XtSetArg(args[narg], XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_RESIZE); narg++;
    XtSetArg(args[narg], XmNx, 10); narg++;
    XtSetArg(args[narg], XmNy, 10); narg++;
    XtSetArg(args[narg], XmNtitle, "Motif Palette"); narg++;


    toplevel = XtAppInitialize(&app, "aux", NULL, 0,
                            &argc, argv, NULL, args, narg);

    display = XtDisplay(toplevel);

    aux = XtVaCreateManagedWidget("aux", xmRowColumnWidgetClass,
                              toplevel, NULL, 0);

    button_text = XtCreateManagedWidget("button", xmPushButtonWidgetClass,
                                   aux, NULL, 0);
    XtVaSetValues(button_text,
                XtVaTypedArg, XmNlabelString,
                 XmRString, "Test", strlen("Test") + 1,
                NULL);

    XtAddCallback(button_text, XmNarmCallback, ButtonCallback, NULL);

       narg = 0;
        XtSetArg(args[narg], XmNcolumns, 30);  ++narg;

    textfield = XmCreateTextField(aux, "textfield", args, narg);
       XtManageChild(textfield);

    XtRealizeWidget(toplevel);

    /* Register aux class */
    if (xaux_ext_init_classes(XtDisplay(toplevel),
                     &xaux_class, XtWindow(toplevel)) == False) {
       return 2;
    }

    /* Register event handler */
    XtAddEventHandler(toplevel, PropertyChangeMask, False,
                    xt_ext_event_handler, NULL);

    XtAddEventHandler(toplevel, NoEventMask, True,
                    xt_ext_event_handler, NULL);

    XtAppMainLoop(app);

    return 0;
}

Here is the call graph for this function:

ReturnToEngine ( int  integer_count,
int *  integers,
int  string_count,
char **  strings 
)

Definition at line 258 of file PaletteAux.c.

{
    int i;

    aux_ext_data_t *aux_data;

    if (!im_ || !ic_ || !xc_)
       return;

    if (!integer_count && !string_count)
       return;

    aux_data = (aux_ext_data_t *) calloc(1, sizeof(aux_ext_data_t));

    aux_data->im = im_;
    aux_data->ic = ic_;
    aux_data->integer_count = integer_count;
    aux_data->string_count = string_count;

    if (aux_data->integer_count) {
       aux_data->integer_list = (int *) calloc(1, sizeof(int) * aux_data->integer_count);
       for (i = 0; i < aux_data->integer_count; i++) {
           aux_data->integer_list[i] = integers[i];
       }
    }
    if (aux_data->string_count) {
       aux_data->string_list = (aux_ext_string_t *) calloc(1,
               sizeof(aux_ext_string_t) * aux_data->string_count);
       for (i = 0; i < aux_data->string_count; i++) {
           aux_ext_string_t *p = &aux_data->string_list[i];
           p->length = strlen(strings[i]);
           p->ptr = (unsigned char *) strdup(strings[i]);
       }
    }
    xaux_ext_SetValue(XtDisplay(toplevel), xc_, aux_data);

    if (aux_data->integer_list)
       free(aux_data->integer_list);
    if (aux_data->string_list) {
       for (i = 0; i < aux_data->string_count; i++) {
           aux_ext_string_t *p = &aux_data->string_list[i];
           if (p && p->ptr)
              free(p->ptr);
       }
       free(aux_data->string_list);
    }
    free(aux_data);
}

Here is the call graph for this function:

Bool xaux_ext_Done ( xaux_class_t xc,
aux_ext_data_t aux_ext_data 
)

Definition at line 157 of file PaletteAux.c.

{
    int i;
    char buf[256];

    strncpy(buf, (const char *) aux_ext_data->aux_name,
           aux_ext_data->aux_name_length);

    printf("ext_Done[%s] im:0x%x, ic_id:0x%x\n",
          buf, aux_ext_data->im, aux_ext_data->ic);

    return True;
}
Bool xaux_ext_Draw ( xaux_class_t xc,
aux_ext_data_t aux_ext_data 
)

Definition at line 107 of file PaletteAux.c.

{
    size_t i;
    char *sp;
    Bool rv = True;
    char buf[256];

    strncpy(buf, (const char *) aux_ext_data->aux_name,
           aux_ext_data->aux_name_length);

    printf("ext_Draw[%s] im:0x%x, ic:0x%x\n",
          buf, aux_ext_data->im, aux_ext_data->ic);


    for (i = 0; i < aux_ext_data->integer_count; i++) {
       printf("\tiv[%02d]=%d\n", i, aux_ext_data->integer_list[i]);
    }

    for (i = 0; i < aux_ext_data->string_count; i++) {
       printf("\tsv[%02d]=%s\n", i,
              aux_ext_data->string_list[i].ptr);
    }

    im_ = aux_ext_data->im;
    ic_ = aux_ext_data->ic;
    xc_ = xc;

    if (aux_ext_data->integer_count == 1) {
       switch (aux_ext_data->integer_list[0]) {
       case SAMPLEJA3_AUXPALETTE_CONVON:
           XtVaSetValues(button_text,
                       XtVaTypedArg, XmNlabelString,
           XmRString, "conversion ON", strlen("conversion ON") + 1,
                       NULL);
           break;
       case SAMPLEJA3_AUXPALETTE_CONVOFF:
           XtVaSetValues(button_text,
                       XtVaTypedArg, XmNlabelString,
                       XmRString, "conversion OFF", strlen("conversion OFF") + 1,
                       NULL);
           break;
       }
    }
    return True;
}

Here is the call graph for this function:

Bool xaux_ext_Start ( xaux_class_t xc,
aux_ext_data_t aux_ext_data 
)

Definition at line 98 of file PaletteAux.c.

{
    return True;
}

Here is the caller graph for this function:

void xt_ext_event_handler ( Widget  w,
XtPointer  client_data,
XEvent *  event,
Boolean b 
)

Variable Documentation

Widget aux

Definition at line 66 of file PaletteAux.c.

Widget button_text

Definition at line 67 of file PaletteAux.c.

int ic_ = 0 [static]

Definition at line 71 of file PaletteAux.c.

int im_ = 0 [static]

Definition at line 70 of file PaletteAux.c.

Widget toplevel

Definition at line 65 of file PaletteAux.c.

Initial value:
 {
    "com.sun.sampleja3.PaletteAux", 1,
    (Window) 0, (Window) 0,
    (Atom) 0, (Atom) 0, (Atom) 0, (Atom) 0, (Atom) 0,
    NULL,
}

Definition at line 58 of file PaletteAux.c.

xaux_class_t* xc_ = 0 [static]

Definition at line 69 of file PaletteAux.c.