~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to gui/GraphLib/libsrc/uimxR5/src/utype.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*---------------------------------------------------------------------
 
2
 * $Date: 2009-08-18 15:23:20 $             $Revision: 1.2 $
 
3
 *---------------------------------------------------------------------
 
4
 * 
 
5
 *
 
6
 *             Copyright (c) 1992, Visual Edge Software Ltd.
 
7
 *
 
8
 * ALL  RIGHTS  RESERVED.  Permission  to  use,  copy,  modify,  and
 
9
 * distribute  this  software  and its documentation for any purpose
 
10
 * and  without  fee  is  hereby  granted,  provided  that the above
 
11
 * copyright  notice  appear  in  all  copies  and  that  both  that
 
12
 * copyright  notice and this permission notice appear in supporting
 
13
 * documentation,  and that  the name of Visual Edge Software not be
 
14
 * used  in advertising  or publicity  pertaining to distribution of
 
15
 * the software without specific, written prior permission. The year
 
16
 * included in the notice is the year of the creation of the work.
 
17
 *-------------------------------------------------------------------*/
 
18
 
 
19
/*-------------------------------------------------------------------
 
20
  DESCRIPTION:  Conversions between UIMX and X types.
 
21
                The conversion routines to go between X types and UIMX types
 
22
                are registered in a table :
 
23
 
 
24
                        UxUimx_x[uimx_type][x_type]
 
25
 
 
26
                The indices are the values of the UxUT_ and UxXT_ variables
 
27
                which are initialized by UxUtype_init().
 
28
                This table is managed by routines in <types.h>.
 
29
 
 
30
                The general format for these conversion routines is:
 
31
 
 
32
                int <utype>_<xtype>(sw, udata, xdata, flag)
 
33
                        swidget sw      - swidget requesting the conversion
 
34
                        <utype> *udata  - input or output of uimx value
 
35
                        <xtype> *xdata  - input or output of Xt value
 
36
                        int     flag    - TO_UIMX to convert to uimx or
 
37
                                          TO_X to convert to Xt.
 
38
 
 
39
                The conversions are performed generically by calling the
 
40
                function 'UxCallConverter()' with the appropriate arguments.
 
41
                Note: When the converter function is called from
 
42
                      UxCallConverter()
 
43
                there is a 5th argument which is the x_type, but most of the
 
44
                converters only have the above 4 arguments.
 
45
 
 
46
 
 
47
CREATION:       19 April 1988
 
48
REVISIONS:      5 July 1989
 
49
                -- added features to make it possible to compile with runtime
 
50
                library with no modification; added function for properties
 
51
                that have no resource converter in the X Toolkit
 
52
                30 Aug 1990
 
53
                -- added National Language Support
 
54
                11 Jan 1991
 
55
                -- moved enumerated-type resources to enum_type.c
 
56
 
 
57
.VERSION
 
58
 090818         last modif KB
 
59
 
 
60
-----------------------------------------------------------------------------*/
 
61
 
 
62
/*--- include files ---*/
 
63
#include "version.h"
 
64
#include <stdio.h>
 
65
#include <stdlib.h>
 
66
#include <string.h>
 
67
/* CG. Not needed and values.h does not exist on VMS
 
68
#include <values.h>
 
69
*/
 
70
#include <ctype.h>
 
71
 
 
72
#include <X11/StringDefs.h>
 
73
#include <X11/IntrinsicP.h>     /* needed for the def'n of WidgetClass */
 
74
#include <X11/Intrinsic.h>
 
75
#include <X11/Shell.h>
 
76
#include <X11/Xatom.h>
 
77
 
 
78
#include <Xm/Xm.h>
 
79
 
 
80
/* We need to include the header files for all the widget classes
 
81
   in order to get the extern declarations of the widget-class pointers
 
82
   for use in string_WidgetClass() */
 
83
#include <Xm/ArrowB.h>
 
84
#include <Xm/ArrowBG.h>
 
85
#include <Xm/BulletinB.h>
 
86
#include <Xm/CascadeB.h>
 
87
#include <Xm/CascadeBG.h>
 
88
#include <Xm/Command.h>
 
89
#include <Xm/DrawingA.h>
 
90
#include <Xm/DrawnB.h>
 
91
#include <Xm/FileSB.h>
 
92
#include <Xm/Form.h>
 
93
#include <Xm/Frame.h>
 
94
#include <Xm/Label.h>
 
95
#include <Xm/LabelG.h>
 
96
#include <Xm/List.h>
 
97
#include <Xm/MainW.h>
 
98
#include <Xm/MessageB.h>
 
99
#include <Xm/PanedW.h>
 
100
#include <Xm/PushB.h>
 
101
#include <Xm/PushBG.h>
 
102
#include <Xm/RowColumn.h>
 
103
#include <Xm/Scale.h>
 
104
#include <Xm/ScrollBar.h>
 
105
#include <Xm/ScrolledW.h>
 
106
#include <Xm/SelectioB.h>
 
107
#include <Xm/SeparatoG.h>
 
108
#include <Xm/Separator.h>
 
109
#include <Xm/Text.h>
 
110
#include <Xm/TextF.h>
 
111
#include <Xm/ToggleB.h>
 
112
#include <Xm/ToggleBG.h>
 
113
 
 
114
#include "uxproto.h"
 
115
 
 
116
#ifndef RUNTIME
 
117
 
 
118
#include "veos.h"
 
119
#include "prim.cl.h"
 
120
#include "swidget.h"
 
121
#include "text.cl.h"
 
122
#include "textF.cl.h"
 
123
#include "Ux.h"
 
124
#include "tkdefaults.h"
 
125
#include "ttapp.h"
 
126
 
 
127
#else
 
128
 
 
129
#include "UxLib.h"
 
130
#include "UxLibP.h"
 
131
 
 
132
#endif /* ! RUNTIME */
 
133
 
 
134
#include "utype.h"
 
135
#include "types.h"
 
136
#include "resload.h"
 
137
#include "vtypes.h"
 
138
#include "valloc.h"
 
139
#include "global.h"
 
140
#include "colors.h"
 
141
#include "uimx_cat.h"
 
142
#include "misc1_ds.h"
 
143
 
 
144
 
 
145
/*--- macro symbolic constants ---*/
 
146
 
 
147
/*--- macro functions ---*/
 
148
/* X/OPEN message catalog macros. These will make the code more compact. */
 
149
#define CGETS(ms,ds_ms)                 UxCatGets(MC_MISC1,ms,ds_ms)
 
150
 
 
151
/*--- types ---*/
 
152
 
 
153
/*--- external functions ---*/
 
154
 
 
155
extern int UxStrEqual(), UxLoadPixmapFromPixmapOrBitmapFile();
 
156
extern int Ux_wcslen();
 
157
extern void UxSwidgetSetWinGroupFlag(), UxSwidgetUnsetWinGroupFlag();
 
158
extern void UxAddXValues(), UxAddUserDefXtypes();
 
159
 
 
160
 
 
161
/*--- external variables ---*/
 
162
 
 
163
/*--- global variables ---*/
 
164
 
 
165
/*--- file global variables ---*/
 
166
M_FILE_VERSION("$Header")
 
167
int UxConvertMaxStringTable = 10;
 
168
int UxRingBufferSize = 10;  /* size for converters rotating buffers */
 
169
 
 
170
/*--- forward declaration of static functions ---*/
 
171
static  int     string_XmStringTable
 
172
                        UXPROTO((char*, swidget, char**, XmString**, int));
 
173
 
 
174
/*------------------------------------------------------------
 
175
 * COMMENT_BOX
 
176
 *-----------------------------------------------------------*/
 
177
 
 
178
 
 
179
/*-----------------------------------------------------------------------------
 
180
NAME:           static Boolean GetNextString(n, src, dst)
 
181
INPUT:          int     n;              - number of times called before
 
182
                                          for this source string
 
183
                char    **src;          - input string
 
184
OUTPUT:         char    **dst;          - next component
 
185
RETURN:         Boolean                 - false if at end of string
 
186
DESCRIPTION:    Extracts the next component (delimited by a comma or a NULL)
 
187
                from the src string and outputs it in the dst string.
 
188
CREATION:       HP                      Jul 28/1990
 
189
REVISIONS:      1 August 1990   bugfix 865
 
190
                -- fixed bug where it could not catch an empty component 
 
191
                   at the end of the source string (e.g. "aa,bb,") by leaving
 
192
                   the comma to start the next component, and adding a special
 
193
                   case for the first component
 
194
-----------------------------------------------------------------------------*/
 
195
 
 
196
static  Boolean GetNextString(n, src, dst)
 
197
int             n;
 
198
char            **src;
 
199
char            **dst;
 
200
{
 
201
        char *c;
 
202
 
 
203
        /* if we have hit the end of the src, we are done... */
 
204
        if (!**src)
 
205
            return(False);
 
206
 
 
207
        /* skip the comma which separates entries later than the first
 
208
         * from their successor 
 
209
         */
 
210
        if ((n > 0) && (**src == ','))
 
211
            (*src)++;
 
212
 
 
213
        /* skip leading white space... */
 
214
        while (**src && isspace(**src))
 
215
            (*src)++;
 
216
 
 
217
        /* allocate space for the src and start copying.  This space
 
218
         * needs to be freed after it is used...
 
219
         */
 
220
        *dst = (char *) UxMalloc(strlen(*src) + 1);
 
221
        c = *dst;
 
222
 
 
223
        while (**src) {
 
224
            /* look for quoted ','s... */
 
225
            if ((**src == '\\') && (*((*src) + 1) == ',')) {
 
226
                *c++ = ',';
 
227
                (*src) += 2;
 
228
            }
 
229
            /* look for terminating (unquoted) ','s... */
 
230
            else if (**src == ',') {
 
231
                *c = '\0';
 
232
                /* do not increment src pointer; the next component will    */
 
233
                /* start with a comma                                       */
 
234
                return(True);
 
235
            }
 
236
            /* otherwise it is a straight character... */
 
237
            else {
 
238
                *c++ = *(*src)++;
 
239
            }
 
240
        }
 
241
 
 
242
        /* we hit the end of the original src, so we need to null
 
243
         * terminate our target...
 
244
         */
 
245
        *c = '\0';
 
246
 
 
247
        return(True);
 
248
}
 
249
 
 
250
/******************************************************************************
 
251
NAME:           void _string_XmStringTable (args, num_args, from_val, to_val);
 
252
INPUT:          XrmValuePtr     args            - ignored
 
253
                Cardinal        *num_args       - ignored
 
254
                XrmValue        *from_val       - char string to convert from
 
255
                XrmValue        *to_val         - place to deposite table
 
256
RETURN:         nothing
 
257
DESCRIPTION:    Performs the resource conversion from char strings to
 
258
                XmStringTable's for list widgets.  Maintains a circular
 
259
                list of XmStringTables to allow them to survive until then
 
260
                are use.
 
261
CREATION:       HP                      Jul 28/1990
 
262
REVISIONS:      1 August 1990   bugfix 865
 
263
                -- fixed bug where it could not catch an empty component 
 
264
                   at the end of the source string (e.g. "aa,bb,"); added
 
265
                   serial order parameter as first argument to GetNextString()
 
266
-----------------------------------------------------------------------------*/
 
267
 
 
268
static  void    _string_XmStringTable(args, num_args, from_val, to_val)
 
269
XrmValuePtr     args;
 
270
Cardinal        *num_args;
 
271
XrmValue        *from_val;
 
272
XrmValue        *to_val;
 
273
{
 
274
        static int MaxStringTable = 0;
 
275
        static XmStringTable *tableList = (XmStringTable *) 0;
 
276
        static int CurrentStringTable = 0;
 
277
        static Boolean StringTableFull = False;
 
278
        int max;
 
279
        int i;
 
280
        XmStringTable *tmpTableList = (XmStringTable *) 0;
 
281
        char *c;
 
282
        char *curr;
 
283
 
 
284
        /* the lower limit for string tables will be 10... */
 
285
        if (UxConvertMaxStringTable < 10)
 
286
            UxConvertMaxStringTable = 10;
 
287
 
 
288
        if (MaxStringTable < UxConvertMaxStringTable) {
 
289
            /* let's grow the table... */
 
290
            tmpTableList = (XmStringTable *)
 
291
                    UxMalloc(UxConvertMaxStringTable * sizeof(*tableList));
 
292
            if (StringTableFull) {
 
293
                /* The table is full, now that it isn't full anymore, we will
 
294
                 * need to reorder it.  CurrentStringTable points to the next
 
295
                 * one to use, which is also the next one to free, which is
 
296
                 * also the first one of the new list...
 
297
                 */
 
298
                for (i = 0; i < MaxStringTable; i++) {
 
299
                    tmpTableList[i] = tableList[(i +
 
300
                            CurrentStringTable) % MaxStringTable];
 
301
                }
 
302
                CurrentStringTable = MaxStringTable;
 
303
                StringTableFull = 0;
 
304
            } else {
 
305
                /* The table is not full, so just copy the first
 
306
                 * CurrentStringTable entries...
 
307
                 */
 
308
                for (i = 0; i < CurrentStringTable; i++) {
 
309
                    tmpTableList[i] = tableList[i];
 
310
                }
 
311
            }
 
312
            if (tableList) {
 
313
                (void) UxFree(tableList);
 
314
            }
 
315
            tableList = tmpTableList;
 
316
            MaxStringTable = UxConvertMaxStringTable;
 
317
        }
 
318
 
 
319
        /* do we need to free up this entry... */
 
320
        if (StringTableFull) {
 
321
            for (i = 0; tableList[CurrentStringTable][i]; i++) {
 
322
                (void) XmStringFree(tableList[CurrentStringTable][i]);
 
323
            }
 
324
            (void) UxFree(tableList[CurrentStringTable]);
 
325
        }
 
326
 
 
327
        c = (char *) from_val->addr;
 
328
        max = 100;
 
329
        tableList[CurrentStringTable] =
 
330
                (XmStringTable) UxMalloc(max * sizeof(XmString));
 
331
 
 
332
        for (i = 0; GetNextString(i, &c, &curr); i++) {
 
333
            if (i >= max) {
 
334
                max += 100;
 
335
                tableList[CurrentStringTable] =
 
336
                        (XmStringTable) UxRealloc(tableList[CurrentStringTable],
 
337
                        max * sizeof(XmString));
 
338
            }
 
339
            tableList[CurrentStringTable][i] =
 
340
                    XmStringCreateLtoR(curr, XmSTRING_DEFAULT_CHARSET);
 
341
            UxFree(curr);
 
342
        }
 
343
 
 
344
        /* we need to the array with one extra element so that we can
 
345
         * null terminate it... */
 
346
        tableList[CurrentStringTable] =
 
347
                (XmStringTable) UxRealloc(tableList[CurrentStringTable],
 
348
                (i + 1) * sizeof(XmString));
 
349
 
 
350
        /* null terminate the array... */
 
351
        tableList[CurrentStringTable][i] = (XmString) NULL;
 
352
 
 
353
        /* set up the return value... */
 
354
        to_val->addr = (caddr_t) &tableList[CurrentStringTable];
 
355
        to_val->size = sizeof(caddr_t);
 
356
 
 
357
        /* increment the CurrentStringTable... */
 
358
        (void) CurrentStringTable++;
 
359
        if (CurrentStringTable >= MaxStringTable) {
 
360
            CurrentStringTable = 0;
 
361
            StringTableFull = True;
 
362
        }
 
363
}
 
364
 
 
365
/* ------------------------------------------------------------------------*/
 
366
 
 
367
static  char * uSelectionArray[] = {
 
368
        "select_position", "select_whitespace", 
 
369
        "select_word", "select_line",
 
370
        "select_all" , "select_paragraph"
 
371
};
 
372
static  XmTextScanType xSelectionArray[] = {
 
373
        XmSELECT_POSITION, XmSELECT_WHITESPACE,
 
374
        XmSELECT_WORD, XmSELECT_LINE,
 
375
        XmSELECT_ALL, XmSELECT_PARAGRAPH
 
376
};
 
377
 
 
378
#ifndef RUNTIME
 
379
int UxValuesOfSelectionArray(lst, n)
 
380
char ***lst;
 
381
int *n;
 
382
{
 
383
        static char *values[7] = {
 
384
                "",
 
385
                "   select_position",
 
386
                "   select_whitespace",
 
387
                "   select_word",
 
388
                "   select_line",
 
389
                "   select_all",
 
390
                "   select_paragraph"};
 
391
 
 
392
        static int  first_time = 1;
 
393
 
 
394
        if (first_time)
 
395
        {
 
396
                values[0] = UxCopyString(CGETS(MS_MISC_SELECTARRAY_ERR, 
 
397
                                        DS_MS_MISC_SELECTARRAY_ERR));
 
398
                first_time = 0;
 
399
        }
 
400
 
 
401
        *lst = values;
 
402
        *n = 6;
 
403
        return 0;
 
404
}
 
405
 
 
406
/******************************************************************************
 
407
 ==== GLOBAL =================================================================
 
408
*******************************************************************************
 
409
NAME:           int             UxValidateSelectionArray(rs, s)
 
410
 
 
411
INPUT:          rswidget        *rs             - text/textF widget
 
412
                char            *s              - selection array variable
 
413
 
 
414
RETURN:         ERROR / NO_ERROR
 
415
 
 
416
REVISIONS:      Jul 16/1990
 
417
                      - fixed logic of strtok loop
 
418
-----------------------------------------------------------------------------*/
 
419
 
 
420
int UxValidateSelectionArray(rs, s)
 
421
rswidget *rs;
 
422
char *s;
 
423
{
 
424
        char    *c1;
 
425
        char    *temp;
 
426
        int     d, count, n = XtNumber(uSelectionArray);
 
427
        text    *tx;
 
428
        textField       *tf;
 
429
 
 
430
        /* a null string is invalid */
 
431
        if (s == NULL)
 
432
            return ERROR;
 
433
 
 
434
        /* determine the array count:   
 
435
         *   if there is a value in the swidget, take it;
 
436
         *   otherwise, use the default.
 
437
         */
 
438
        d = UX_DEFAULT_SELECTION_ARRAY_COUNT;
 
439
        (void) UxFindValue (rs, UxGetRD_selectionArrayCount(rs), &d);
 
440
 
 
441
        /* an empty string is valid if the array count is 0 */
 
442
        if (!s[0])
 
443
            return (d==0 ? NO_ERROR : ERROR);
 
444
 
 
445
        /* create temporary  copy of string to parse */
 
446
        temp = UxMalloc(strlen(s) + 1);
 
447
        (void) strcpy(temp, s);
 
448
 
 
449
        /* check that each element of the array is valid, and count them */
 
450
        c1 = strtok(temp, " ");
 
451
        count = 0;
 
452
 
 
453
        while(c1 != NULL)
 
454
        {
 
455
            int i, match;
 
456
 
 
457
            count++;
 
458
            match = 0;
 
459
            for (i=0; i<n; i++)
 
460
            {
 
461
                if (!strcmp(c1, uSelectionArray[i]))
 
462
                {
 
463
                    match = 1;
 
464
                    break;
 
465
                }
 
466
            }
 
467
            if (!match)
 
468
            {
 
469
                /* one of the items in the array is invalid */
 
470
                UxFree(temp);
 
471
                return ERROR;
 
472
            }
 
473
 
 
474
            c1= strtok(NULL, " ");
 
475
        }
 
476
 
 
477
        /* free the temporary copy */
 
478
        UxFree(temp);
 
479
 
 
480
        /* error occurs if array count is greater than the number of items */
 
481
        return (d>count ? ERROR : NO_ERROR);
 
482
}
 
483
 
 
484
int UxValuesOfSelectionArrayCount(lst, n)
 
485
char ***lst;
 
486
int *n;
 
487
{
 
488
        static char *values[1];
 
489
        static int  first_time = 1;
 
490
 
 
491
        if (first_time)
 
492
        {
 
493
                values[0] = UxCopyString(CGETS(MS_MISC_NUM_ELEM_SEL, 
 
494
                                        DS_MS_MISC_NUM_ELEM_SEL));
 
495
                first_time = 0;
 
496
        }
 
497
 
 
498
        *lst = values;
 
499
        *n = 1;
 
500
        return 0;
 
501
}
 
502
 
 
503
int UxValidateSelectionArrayCount(rs, d)
 
504
rswidget *rs;
 
505
int  d;
 
506
{
 
507
        char    *s;
 
508
        int     n;
 
509
        text    *tx;
 
510
        textField       *tf;
 
511
 
 
512
        /* a negative count value is always wrong */
 
513
        if (d < 0)
 
514
           return ERROR;
 
515
 
 
516
        /* determine the selection array string:                        */
 
517
        /*   if not used in the swidget, we use the default             */
 
518
        /*   otherwise, we get the string from the swidget              */
 
519
 
 
520
        s = UX_DEFAULT_SELECTION_ARRAY;
 
521
        (void) UxFindValue (rs, UxGetRD_selectionArray(rs), &s);
 
522
 
 
523
        if (s == NULL || !s[0])
 
524
        {
 
525
            /* selectionArray string is empty or null, so count must be 0 */
 
526
            n = 0;
 
527
        }
 
528
        else
 
529
        {
 
530
            char *temp, *sp;
 
531
            int  i;
 
532
 
 
533
            /* determine the number of items in the selection array string */
 
534
            /* and compare to the selectionArrayCount value                */
 
535
 
 
536
            /* create temp copy of string to parse */
 
537
            temp = UxMalloc(strlen(s) + 1);
 
538
            (void) strcpy(temp, s);
 
539
 
 
540
            /* count the items in the string */
 
541
            n = 0;
 
542
            sp = strtok(temp, " ");
 
543
            do 
 
544
            {
 
545
                n++;
 
546
            } while (sp = strtok(NULL, " "));
 
547
 
 
548
            /* free the temporary copy */
 
549
            UxFree(temp);
 
550
        }
 
551
 
 
552
        /* error if array count is greater than # items in the array string */
 
553
        return (d > n ? ERROR : NO_ERROR);
 
554
}
 
555
 
 
556
#endif /* ! RUNTIME */
 
557
 
 
558
/* ------------------------------------------------------------------------*/
 
559
 
 
560
static int _utype, _xtype;
 
561
 
 
562
/******************************************************************************
 
563
NAME:           int             string_String(sw, udata, xdata, flag)
 
564
INPUT:          swidget         sw              - swidget
 
565
                char            **udata         - string representation
 
566
                XmString        **xdata         - Motif Menu Post string
 
567
                int             flag            - TO_UIMX or TO_X
 
568
RETURN:         ERROR/NO_ERROR
 
569
 
 
570
DESCRIPTION:    Converts between string and a String. 
 
571
                Xt-side NULL       is converted to ""
 
572
                UIM/X-side NULL    is NOT allowed
 
573
 
 
574
CREATION:       31 July 1991    (fix2773)
 
575
 
 
576
-----------------------------------------------------------------------------*/
 
577
 
 
578
static int string_String(sw, udata, xdata, flag)
 
579
swidget sw;
 
580
char **udata;
 
581
char **xdata;
 
582
int flag;
 
583
{
 
584
        if (flag == TO_UIMX)
 
585
        {
 
586
                if (*xdata)
 
587
                    *udata = *xdata;
 
588
                else
 
589
                    *udata = "";
 
590
        }
 
591
        else if (flag == TO_X)
 
592
        {
 
593
                if (*udata == NULL) 
 
594
                    return ERROR;
 
595
 
 
596
                *xdata = *udata;
 
597
        }
 
598
        else
 
599
        {
 
600
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
601
                return ERROR;
 
602
        }
 
603
        return NO_ERROR;
 
604
}
 
605
 
 
606
/******************************************************************************
 
607
NAME:           int             string_StringOrNull(sw, udata, xdata, flag)
 
608
INPUT:          swidget         sw              - swidget
 
609
                char            **udata         - Uimx-side string
 
610
                XmString        **xdata         - Toolkit-side string
 
611
                int             flag            - TO_UIMX or TO_X
 
612
RETURN:         ERROR/NO_ERROR
 
613
 
 
614
DESCRIPTION:    Converts between string and a String. 
 
615
                UIM/X-side ""   is converted to NULL.
 
616
                Xt-side    NULL is converted to ""
 
617
                UIM/X-side NULL is NOT allowed.
 
618
 
 
619
CREATION:       31 July 1991    (fix2773)
 
620
-----------------------------------------------------------------------------*/
 
621
 
 
622
static int string_StringOrNull(sw, udata, xdata, flag)
 
623
swidget sw;
 
624
char **udata;
 
625
char **xdata;
 
626
int flag;
 
627
{
 
628
        if (flag == TO_UIMX)
 
629
        {
 
630
                if (*xdata)
 
631
                    *udata = *xdata;
 
632
                else
 
633
                    *udata = "";
 
634
        }
 
635
        else if (flag == TO_X)
 
636
        {
 
637
                if (*udata == NULL) 
 
638
                    return ERROR;
 
639
 
 
640
                if (UxStrEqual (*udata, ""))
 
641
                    *xdata = (char *) NULL;
 
642
                else
 
643
                    *xdata = *udata;
 
644
        }
 
645
        else
 
646
        {
 
647
                UxStandardError(CGETS(MS_MISC_WRONG_FLAG, 
 
648
                                      DS_MS_MISC_WRONG_FLAG));
 
649
                return ERROR;
 
650
        }
 
651
        return NO_ERROR;
 
652
}
 
653
 
 
654
/*******************************************************************/
 
655
static int convert(from_name, from_size, from_addr, to_name, to_addr)
 
656
char *from_name;
 
657
unsigned int from_size;
 
658
caddr_t from_addr;
 
659
char *to_name;
 
660
caddr_t to_addr;
 
661
{
 
662
        XrmValue from, to;
 
663
 
 
664
        from.size = from_size;
 
665
        from.addr = from_addr;
 
666
        XtConvert(UxTopLevel, from_name, &from, to_name, &to);
 
667
 
 
668
        /* check for conversion error... */
 
669
        if (to.addr == NULL)
 
670
        {
 
671
                return(ERROR);
 
672
        }
 
673
 
 
674
        /* convert 'unsigned char' and 'short' to 'int';
 
675
           do not perform a memory copy */
 
676
        if (to.size == sizeof (unsigned char)
 
677
            && strcmp (to_name, "Boolean") != 0)
 
678
        {
 
679
                * (int *) to_addr = * (unsigned char *) to.addr;
 
680
                return(NO_ERROR);
 
681
        }
 
682
        else if (to.size == sizeof (short))
 
683
        {
 
684
                * (int *) to_addr = * (short *) to.addr;
 
685
                return(NO_ERROR);
 
686
        }
 
687
 
 
688
        memcpy(to_addr, to.addr, to.size);
 
689
        return(NO_ERROR);
 
690
}
 
691
 
 
692
/*******************************************************************/
 
693
/* This function is probably not used any more and will have to be
 
694
   removed soon.  
 
695
   In UxUtype_init(), remove line that adds string_FontStruct() converter
 
696
   and lines that add types. (Dec. 01 1992)
 
697
*/
 
698
/*******************************************************************/
 
699
static int string_FontStruct(sw, udata, xdata, flag)
 
700
swidget sw;
 
701
char **udata;
 
702
XFontStruct **xdata;
 
703
int flag;
 
704
{
 
705
        if (flag == TO_UIMX)
 
706
            *udata = "";
 
707
        else if (flag == TO_X)
 
708
            return( convert(XtRString, strlen(*udata), *udata, 
 
709
                                       x_name(UxXT_FontStruct), xdata));
 
710
        else {
 
711
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
712
            return ERROR;
 
713
        }
 
714
        return NO_ERROR;
 
715
}
 
716
 
 
717
/*******************************************************************/
 
718
static int string_Pixel(sw, udata, xdata, flag)
 
719
swidget sw;
 
720
char **udata;
 
721
Pixel *xdata;
 
722
int flag;
 
723
{
 
724
        if (flag == TO_UIMX) 
 
725
        {
 
726
            *udata = UxPixel_to_name(*xdata);
 
727
        }
 
728
        else if (flag == TO_X)
 
729
        {
 
730
            /* Protect strlen from NULL */
 
731
 
 
732
            if (*udata) {
 
733
                return(convert(XtRString, strlen(*udata), *udata, 
 
734
                               x_name(UxXT_Pixel), xdata));
 
735
            } else {
 
736
                return ERROR;
 
737
            }
 
738
 
 
739
        } else {
 
740
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
741
            return ERROR;
 
742
        }
 
743
        return NO_ERROR;
 
744
}
 
745
 
 
746
/*******************************************************************/
 
747
/*      Pixmap table                                               */
 
748
/*******************************************************************/
 
749
static char **pixmap_names = (char **) 0;
 
750
static Pixmap *pixmaps = (Pixmap *) 0;
 
751
static int num_allocated = 0, num_used = 0;
 
752
 
 
753
static int store_pixmap(pixmap, name)
 
754
Pixmap pixmap;
 
755
char *name;
 
756
{
 
757
    int i;
 
758
 
 
759
    for (i = 0; i < num_used; i++) {
 
760
        if (pixmaps[i] == pixmap) {
 
761
            if (strcmp(pixmap_names[i], name)) {
 
762
                UxFree(pixmap_names[i]);
 
763
                pixmap_names[i] = (char *) UxMalloc(strlen(name) + 1);
 
764
                strcpy(pixmap_names[i], name);
 
765
                return(NO_ERROR);
 
766
            }
 
767
            return(NO_ERROR);
 
768
        }
 
769
    }
 
770
 
 
771
    if (num_used == num_allocated) {
 
772
        num_allocated += 10;
 
773
        pixmap_names = (char **) UxRealloc(pixmap_names,
 
774
                num_allocated * sizeof(*pixmap_names));
 
775
        pixmaps = (Pixmap *) UxRealloc(pixmaps,
 
776
                num_allocated * sizeof(*pixmaps));
 
777
    }
 
778
 
 
779
    pixmaps[num_used] = pixmap;
 
780
    pixmap_names[num_used] = (char *) UxMalloc(strlen(name) + 1);
 
781
    strcpy(pixmap_names[num_used], name);
 
782
    num_used++;
 
783
   return(NO_ERROR);
 
784
}
 
785
 
 
786
static char
 
787
*get_pixmap(pixmap)
 
788
Pixmap pixmap;
 
789
{
 
790
    int i;
 
791
 
 
792
    for (i = 0; i < num_used; i++)
 
793
        if (pixmaps[i] == pixmap)
 
794
                return(pixmap_names[i]);
 
795
 
 
796
    return("");
 
797
}
 
798
 
 
799
/******************************************************************************
 
800
NAME:           int             string_Pixmap(sw, udata, xdata, flag)
 
801
                int             string_HighlightPixmap(sw, udata, xdata, flag)
 
802
                int             string_TopShadowPixmap(sw, udata, xdata, flag)
 
803
                int             string_BottomShadowPixmap(sw, udata, xdata, flag)
 
804
INPUT:          swidget         sw              - swidget
 
805
                char            **udata         - string representation
 
806
                XmString        **xdata         - Motif StringTable
 
807
                int             flag            - TO_UIMX or TO_X
 
808
RETURN:         ERROR/NO_ERROR
 
809
DESCRIPTION:    Uses the resource converter to convert between a pixmap name
 
810
                represented as a string and a Motif Pixmap
 
811
CREATION:       19 July 1990
 
812
LAST REV:       August 1, 1991          See bugfix 2857
 
813
                - Handle new BORDER pixmap case.
 
814
                - Removed code that obtained colors when widget did not
 
815
                  exist because this always returned "" which is not a
 
816
                  valid color.  If widget does not exist just use screen
 
817
                  black and white colors.
 
818
-----------------------------------------------------------------------------*/
 
819
#define PIXMAP         0
 
820
#define HIGHLIGHT      1
 
821
#define TOPSHADOW      2
 
822
#define BOTTOMSHADOW   3
 
823
#define BORDER         4
 
824
 
 
825
static int string_XmPixmap UXPROTO((int, swidget, char**, Pixmap*, int));
 
826
 
 
827
/*******************************************************************/
 
828
 
 
829
static  int     string_Pixmap(sw, udata, xdata, flag)
 
830
        swidget sw;
 
831
        char    **udata;
 
832
        Pixmap  *xdata;
 
833
        int     flag;
 
834
{
 
835
 
 
836
#ifdef RUNTIME 
 
837
        if(UxIsShellClass(UxGetClass(sw))){
 
838
#else
 
839
        if(UxIsExplicitShell(sw)) {
 
840
#endif /* RUNTIME */
 
841
 
 
842
             *xdata = XmUNSPECIFIED_PIXMAP;
 
843
             return NO_ERROR;
 
844
        }
 
845
        return string_XmPixmap (PIXMAP, sw, udata, xdata, flag);
 
846
}
 
847
 
 
848
static  int     string_BorderPixmap(sw, udata, xdata, flag)
 
849
        swidget sw;
 
850
        char    **udata;
 
851
        Pixmap  *xdata;
 
852
        int     flag;
 
853
{
 
854
        return string_XmPixmap (BORDER, sw, udata, xdata, flag);
 
855
}
 
856
 
 
857
static  int     string_HighlightPixmap(sw, udata, xdata, flag)
 
858
        swidget sw;
 
859
        char    **udata;
 
860
        Pixmap  *xdata;
 
861
        int     flag;
 
862
{
 
863
        return string_XmPixmap (HIGHLIGHT, sw, udata, xdata, flag);
 
864
}
 
865
 
 
866
static  int     string_TopShadowPixmap(sw, udata, xdata, flag)
 
867
        swidget sw;
 
868
        char    **udata;
 
869
        Pixmap  *xdata;
 
870
        int     flag;
 
871
{
 
872
        return string_XmPixmap (TOPSHADOW, sw, udata, xdata, flag);
 
873
}
 
874
 
 
875
static  int     string_BottomShadowPixmap(sw, udata, xdata, flag)
 
876
        swidget sw;
 
877
        char    **udata;
 
878
        Pixmap  *xdata;
 
879
        int     flag;
 
880
{
 
881
        return string_XmPixmap (BOTTOMSHADOW, sw, udata, xdata, flag);
 
882
}
 
883
 
 
884
/* prop indicates how the foreground color will be chosen. 
 
885
   It is one of PIXMAP, HIGHLIGHT, BOTTOMSHADOW or TOPSHADOW */
 
886
 
 
887
static int string_XmPixmap(prop, sw, udata, xdata, flag)
 
888
       int      prop;
 
889
       swidget  sw;
 
890
       char     **udata;
 
891
       Pixmap   *xdata;
 
892
       int      flag;
 
893
{
 
894
 
 
895
        if (flag == TO_UIMX)
 
896
            *udata = get_pixmap((Pixmap) *xdata);
 
897
        else if (flag == TO_X) {
 
898
            char        *fname;
 
899
            Screen      *screen;
 
900
            Pixel       UxName_to_pixel();
 
901
            Pixmap      pixmap;
 
902
            char        *pixmap_name;
 
903
            static char *unspecified_pixmap = "unspecified_pixmap";
 
904
            int         rtrn;
 
905
 
 
906
            pixmap_name = *udata;
 
907
            /* deal with empty string... */
 
908
            if (!pixmap_name || !*pixmap_name)
 
909
                pixmap_name = unspecified_pixmap;
 
910
 
 
911
            /* skip leading whitespace... */
 
912
            while (isspace(*pixmap_name))
 
913
                (void) pixmap_name++;
 
914
 
 
915
            /* deal with blank string... */
 
916
            if (!*pixmap_name)
 
917
                pixmap_name = unspecified_pixmap;
 
918
                
 
919
            if (!strcmp(pixmap_name, unspecified_pixmap)) {
 
920
                /* set to unspecified (no) pixmap... */
 
921
                *xdata = XmUNSPECIFIED_PIXMAP;
 
922
            } 
 
923
            else {
 
924
                Widget wid;
 
925
                Pixel fore, back;
 
926
 
 
927
                fname = UxExpandBitmapFilename(pixmap_name);
 
928
 
 
929
                if (fname == NULL)
 
930
                    fname = pixmap_name;
 
931
 
 
932
                screen= XtScreen(UxTopLevel);
 
933
 
 
934
#ifdef  RUNTIME
 
935
                wid = UxGetWidget(sw);
 
936
                if ( (wid) && (XmIsGadget(wid)))
 
937
                        wid = UxGetWidget(UxGetParent(sw));
 
938
#else
 
939
                if (!UxIsGadget(sw))
 
940
                        wid = UxGetWidget(sw);
 
941
                else
 
942
                        wid = UxGetWidget(UxGetParent(sw));
 
943
#endif /* RUNTIME */
 
944
 
 
945
                if (wid) {
 
946
                        char    *fg_resource;
 
947
                        Arg     args[2];
 
948
                        int     n = 0;
 
949
 
 
950
                        switch (prop) {
 
951
                             case PIXMAP:
 
952
                                  fg_resource = XmNforeground;
 
953
                                  break;
 
954
                             case HIGHLIGHT:
 
955
                                  fg_resource = XmNhighlightColor;
 
956
                                  break;
 
957
                             case TOPSHADOW:
 
958
                                  fg_resource = XmNtopShadowColor;
 
959
                                  break;
 
960
                             case BOTTOMSHADOW:
 
961
                                  fg_resource = XmNbottomShadowColor;
 
962
                                  break;
 
963
                             case BORDER:
 
964
                                  fg_resource = XmNborderColor;
 
965
                                  break;
 
966
                             default:
 
967
                                  fg_resource = XmNforeground;
 
968
                                  break;
 
969
                        }
 
970
                        XtSetArg(args[n], fg_resource, &fore); n++;
 
971
                        XtSetArg(args[n], XmNbackground, &back); n++;
 
972
                        XtGetValues(wid, args, n);
 
973
                        rtrn = UxLoadPixmapFromPixmapOrBitmapFile(sw,fname,&pixmap,0,0,fore,back);
 
974
                }
 
975
                else {
 
976
                        rtrn = UxLoadPixmapFromPixmapOrBitmapFile(sw,fname,&pixmap,0,0,
 
977
                                             BlackPixel(UxDisplay, UxScreen),
 
978
                                             WhitePixel(UxDisplay, UxScreen));
 
979
                }
 
980
 
 
981
                /* check for successful return... */
 
982
                if (rtrn == ERROR) {
 
983
                     UxStandardError (CGETS( MS_MISC_NO_MATCH,
 
984
                                        DS_MS_MISC_NO_MATCH));
 
985
                     return ERROR;
 
986
                }
 
987
                *xdata= pixmap;
 
988
                store_pixmap(pixmap, pixmap_name);
 
989
            }
 
990
 
 
991
        } 
 
992
        else {
 
993
              UxStandardError(CGETS(MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
994
              return ERROR;
 
995
        }
 
996
        return NO_ERROR;
 
997
}
 
998
 
 
999
/*******************************************************************/
 
1000
static int string_bitmap(sw, udata, xdata, flag)
 
1001
swidget sw;
 
1002
char **udata;
 
1003
Pixmap *xdata;
 
1004
int flag;
 
1005
{
 
1006
    if (flag == TO_UIMX)
 
1007
       *udata = get_pixmap((Pixmap) *xdata);
 
1008
    else if (flag == TO_X)
 
1009
    {
 
1010
        int     x;
 
1011
        char    *fname;
 
1012
        Window  rw;
 
1013
        unsigned int    width, height;
 
1014
        int     screen;
 
1015
        Pixmap  pmap;
 
1016
 
 
1017
 
 
1018
        fname = UxExpandBitmapFilename(*udata);
 
1019
        if (fname == NULL) 
 
1020
        {
 
1021
 
 
1022
            *xdata = (Pixmap)NULL;
 
1023
            return NO_ERROR;
 
1024
        }
 
1025
 
 
1026
        screen = DefaultScreen(UxDisplay);
 
1027
        rw = RootWindow(UxDisplay, screen);
 
1028
 
 
1029
        if (XReadBitmapFile(UxDisplay,
 
1030
                            rw, fname, &width, &height,
 
1031
                            &pmap, &x, &x) != BitmapSuccess)
 
1032
            return(ERROR);
 
1033
 
 
1034
        *xdata = pmap;
 
1035
        store_pixmap(pmap, *udata);
 
1036
    }
 
1037
    return(NO_ERROR);
 
1038
}
 
1039
 
 
1040
/******************************************************************************
 
1041
NAME:           int             string_Pointer (sw, udata, xdata, flag)
 
1042
INPUT:          swidget         sw              - swidget
 
1043
                char            **udata         - uimx value address
 
1044
                caddr_t         *xdata          - x value address
 
1045
                int             flag            - TO_UIMX or TO_X
 
1046
RETURN:         ERROR/NO_ERROR
 
1047
DESCRIPTION:    Converts char* <--> caddr_t representations.
 
1048
-----------------------------------------------------------------------------*/
 
1049
 
 
1050
static  int     string_Pointer(sw, udata, xdata, flag)
 
1051
swidget sw;
 
1052
char    **udata;
 
1053
caddr_t *xdata;
 
1054
int     flag;
 
1055
{
 
1056
        if (flag == TO_UIMX) {
 
1057
                *udata = (char*) *xdata;
 
1058
        } else if (flag == TO_X) {
 
1059
                *xdata = (caddr_t) *udata;
 
1060
        } else {
 
1061
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1062
                return ERROR;
 
1063
        }
 
1064
        return NO_ERROR;
 
1065
}
 
1066
 
 
1067
/******************************************************************************
 
1068
NAME:           int             string_ValueWcs (sw, udata, xdata, flag)
 
1069
INPUT:          swidget         sw              - swidget
 
1070
                char            **udata         - string representation
 
1071
                wchar_t         **xdata         - ANSI C wide character string
 
1072
                int             flag            - TO_UIMX or TO_X
 
1073
RETURN:         ERROR/NO_ERROR
 
1074
DESCRIPTION:    Performs a conversion from/to multibyte strings to/from wide
 
1075
                character strings.
 
1076
                Xt-side NULL       remains NULL on UIM/X side
 
1077
                UIM/X-side NULL    is allowed (remains NULL on Xt side)
 
1078
 
 
1079
CREATION:       fix3805         Jan 2/1992
 
1080
LAST REVISION:  February 22, 1993       Rewrite converter so that only standard
 
1081
                                        functionality of ANSI wide character
 
1082
                                        string functions are used.
 
1083
                                        (Use Ux_wcslen() defined in str.c)
 
1084
                Sept 93         fix4491 sun4 MB_CUR_MAX workaround.
 
1085
-----------------------------------------------------------------------------*/
 
1086
 
 
1087
static int string_ValueWcs(sw, udata, xdata, flag)
 
1088
swidget sw;
 
1089
char **udata;
 
1090
wchar_t **xdata;
 
1091
int flag;
 
1092
{
 
1093
        static char **RotatingBuffer;
 
1094
        static int BufferIndex = -1;
 
1095
        char *buffer;
 
1096
 
 
1097
        if (flag == TO_UIMX)
 
1098
        {
 
1099
                if (*xdata == NULL)
 
1100
                        *udata = NULL;
 
1101
                else
 
1102
                {
 
1103
 
 
1104
                        int next_size = Ux_wcslen(*xdata);
 
1105
 
 
1106
#ifdef sun4
 
1107
                        buffer = UxMalloc(next_size * (MB_CUR_MAX > 0 ? MB_CUR_MAX : 1) + 1);
 
1108
#else
 
1109
                        buffer = UxMalloc(next_size * MB_CUR_MAX + 1);
 
1110
#endif /* sun4 */
 
1111
 
 
1112
                        if (wcstombs(buffer, *xdata, next_size + 1) < 0) {
 
1113
                                UxFree(buffer);
 
1114
                                *udata = NULL;
 
1115
                                return ERROR;
 
1116
                        }
 
1117
                        UxUpdateRotatingBuffer
 
1118
                        (&BufferIndex, &RotatingBuffer, buffer, UxFree);
 
1119
                        *udata = RotatingBuffer[BufferIndex];
 
1120
                }
 
1121
        }
 
1122
        else if (flag == TO_X)
 
1123
        {
 
1124
                if (*udata == NULL)
 
1125
                        *xdata = NULL;
 
1126
                else
 
1127
                {
 
1128
                        int next_size = strlen(*udata);
 
1129
 
 
1130
                        buffer = UxMalloc((next_size + 1) * sizeof(wchar_t));
 
1131
 
 
1132
                        if (mbstowcs((wchar_t *)buffer, *udata, next_size + 1)
 
1133
                            < 0) {
 
1134
                                UxFree(buffer);
 
1135
                                *xdata = NULL;
 
1136
                                return ERROR;
 
1137
                        }
 
1138
                        *xdata = (wchar_t *)buffer;
 
1139
                }
 
1140
        }
 
1141
        else
 
1142
        {
 
1143
                UxStandardError
 
1144
                (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1145
                return ERROR;
 
1146
        }
 
1147
        return NO_ERROR;
 
1148
}
 
1149
 
 
1150
/*******************************************************************/
 
1151
 
 
1152
static int string_Widget(sw, udata, xdata, flag)
 
1153
swidget sw;
 
1154
char **udata;
 
1155
Widget *xdata;
 
1156
int flag;
 
1157
{
 
1158
        int     isswidget;
 
1159
        
 
1160
        if (flag == TO_UIMX)
 
1161
        {
 
1162
            if (*xdata)
 
1163
                *udata = XtName( *xdata );
 
1164
            else
 
1165
                *udata = "";
 
1166
        }
 
1167
        else if (flag == TO_X) 
 
1168
        {
 
1169
            swidget     rs;
 
1170
 
 
1171
            if (*udata == NULL)
 
1172
                    return ERROR;
 
1173
            
 
1174
            isswidget = UxIsSwidget((swidget) *udata);
 
1175
            if ( ! isswidget && UxStrEqual (*udata, "")) {
 
1176
                *xdata = NULL;
 
1177
            } else {
 
1178
                rs = isswidget ? * (swidget*) udata 
 
1179
                               : UxNameToSwidget (sw,*udata);   
 
1180
 
 
1181
#ifdef RUNTIME
 
1182
                *xdata = rs ? UxGetWidget(rs) : NULL;
 
1183
#else 
 
1184
                *xdata = rs ? UxGetWidget(UxGetUserSwidget(rs)) : NULL;
 
1185
#endif
 
1186
                if (*xdata == NULL)
 
1187
                    return ERROR;
 
1188
            }
 
1189
        } 
 
1190
        else 
 
1191
        {
 
1192
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1193
            return ERROR;
 
1194
        }
 
1195
        return NO_ERROR;
 
1196
}
 
1197
 
 
1198
static int string_Window (sw, udata, xdata, flag)
 
1199
swidget sw;
 
1200
char    **udata;
 
1201
Window  *xdata;
 
1202
int     flag;
 
1203
{
 
1204
        Widget  w = NULL;
 
1205
 
 
1206
        if (flag == TO_UIMX)
 
1207
        {
 
1208
#ifdef RUNTIME
 
1209
                w  = UxWindowToWidget(*xdata);
 
1210
#else
 
1211
                rswidget        *rs, *UxWindowToSwidget();
 
1212
 
 
1213
                rs = UxWindowToSwidget (*xdata);
 
1214
                if ( rs != NULL )
 
1215
                        w = (Widget) UxGetWidget (rs);
 
1216
#endif /* RUNTIME */
 
1217
 
 
1218
                if ( w != NULL )
 
1219
                        *udata = XtName( w );
 
1220
                else
 
1221
                        *udata = "";
 
1222
        }
 
1223
        else if (flag == TO_X)
 
1224
        {
 
1225
                if (*udata == NULL || **udata == '\0') 
 
1226
                {
 
1227
                        /* 
 
1228
                         * Handle the default case. Note that string_Window
 
1229
                         * converter is only used for the WindowGroup 
 
1230
                         * resource.
 
1231
                         */
 
1232
                        *xdata = XtUnspecifiedWindowGroup;
 
1233
                        return (NO_ERROR);
 
1234
                } 
 
1235
                else if (NO_ERROR == string_Widget (sw, udata, &w, flag)
 
1236
                    && w != NULL)
 
1237
                {
 
1238
#ifdef RUNTIME
 
1239
                        /* set the window group flag if widget pointing
 
1240
                           to itself  (see bug866) */
 
1241
 
 
1242
                        char    *sw_name, *UxGetName();
 
1243
 
 
1244
                        if((sw_name = UxGetName(sw)) &&
 
1245
                        (strcmp(sw_name,*udata) == 0))
 
1246
                                UxSwidgetSetWinGroupFlag(sw);
 
1247
                        else
 
1248
                                UxSwidgetUnsetWinGroupFlag(sw);
 
1249
#endif /* RUNTIME */
 
1250
 
 
1251
                        *xdata = XtWindow (w);
 
1252
                }
 
1253
                else
 
1254
                        return ERROR;
 
1255
        }
 
1256
        else
 
1257
        {
 
1258
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1259
                return ERROR;
 
1260
        }
 
1261
        return NO_ERROR;
 
1262
}
 
1263
 
 
1264
static int string_XID (sw, udata, xdata, flag)
 
1265
swidget sw;
 
1266
char    **udata;
 
1267
XID     *xdata;
 
1268
int     flag;
 
1269
{
 
1270
        return string_Window (sw, udata, xdata, flag);
 
1271
}
 
1272
 
 
1273
/******************************************************************************
 
1274
NAME:           static int      string_translations(sw, udata, xdata, flag)
 
1275
INPUTS:         swidget         sw      - swidget
 
1276
                char            **udata - UIMX string
 
1277
                char            **xdata - pointer to X translation
 
1278
                int             flag    - TO_UIMX or TO_X
 
1279
RETURN:         ERROR/NO_ERROR
 
1280
DESCRIPTION:    Converts a string to a translation.
 
1281
CREATION:       ???
 
1282
REVISIONS:      20 July 90  [bug705]
 
1283
                -- translations are char*, with hidden table name.
 
1284
                July 12 1990
 
1285
                -- check first if UxTStringForX() returns a valid value.
 
1286
-----------------------------------------------------------------------------*/
 
1287
static int string_translations(sw, udata, xdata, flag)
 
1288
        swidget sw;
 
1289
        char    **udata;
 
1290
        char    **xdata;
 
1291
        int     flag;
 
1292
{
 
1293
 
 
1294
        if (flag == TO_UIMX)
 
1295
        {
 
1296
            /* can't do it */
 
1297
            *udata = NULL;
 
1298
        }
 
1299
        else if (flag == TO_X) 
 
1300
        {
 
1301
#ifndef RUNTIME
 
1302
            /* Make sure we strip the hidden name if any
 
1303
             * before passing the string to XtParse...
 
1304
             */
 
1305
            char        *trans;
 
1306
 
 
1307
            trans = UxTStringForX(*udata,sw);
 
1308
            if (trans)
 
1309
                *xdata = (char *) XtParseTranslationTable(trans);
 
1310
#else
 
1311
            if(*udata)
 
1312
                *xdata  = (char*) XtParseTranslationTable(*udata);
 
1313
 
 
1314
#endif /* ! RUNTIME */
 
1315
            else
 
1316
                return ERROR;
 
1317
        } 
 
1318
        else 
 
1319
        {
 
1320
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1321
            return ERROR;
 
1322
        }
 
1323
        return NO_ERROR;
 
1324
}
 
1325
 
 
1326
/******************************************************************************
 
1327
NAME:           static int      string_accelerators(sw, udata, xdata, flag)
 
1328
INPUTS:         swidget         sw      - swidget
 
1329
                char            **udata - UIMX string
 
1330
                char            **xdata - Pointer to X translation
 
1331
                int             flag    - TO_UIMX or TO_X
 
1332
RETURN:         ERROR/NO_ERROR
 
1333
DESCRIPTION:    Converts a string to a translation.
 
1334
CREATION:       ???
 
1335
REVISIONS:      20 July 90  [bug705]
 
1336
                -- translations are char*, with hidden table name.
 
1337
                July 12 1990
 
1338
                -- replace call to XtParseTranslationTable() by call to
 
1339
                   XtParseAcceleratorTable() ... makes sense !
 
1340
                   and verify return value from UxTStringForX().
 
1341
-----------------------------------------------------------------------------*/
 
1342
static int string_accelerators(sw, udata, xdata, flag)
 
1343
        swidget sw;
 
1344
        char    **udata;
 
1345
        char    **xdata;
 
1346
        int     flag;
 
1347
{
 
1348
        if (flag == TO_UIMX)
 
1349
        {
 
1350
            /* can't do it */
 
1351
            *udata = NULL;
 
1352
        }
 
1353
        else if (flag == TO_X) 
 
1354
        {
 
1355
#ifndef RUNTIME
 
1356
            char        *acc;
 
1357
 
 
1358
            acc = UxTStringForX(*udata,sw);
 
1359
            if (acc)
 
1360
                *xdata = (char *) XtParseAcceleratorTable(acc);
 
1361
#else
 
1362
            if(*udata)
 
1363
                *xdata = (char*) XtParseAcceleratorTable(*udata);
 
1364
 
 
1365
#endif /* ! RUNTIME */
 
1366
            else
 
1367
                return ERROR;
 
1368
        } 
 
1369
        else 
 
1370
        {
 
1371
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1372
            return ERROR;
 
1373
        }
 
1374
        return NO_ERROR;
 
1375
}
 
1376
 
 
1377
/******************************************************************************
 
1378
NAME:           static  int     voidFunction_GenericProc(sw, udata, xdata, flag, func)
 
1379
        swidget         sw;             - The swidget
 
1380
        voidFunction    *udata;         - The UIM/X repository
 
1381
        voidFunction    *xdata;         - The X repository
 
1382
        int             flag;           - The direction flag (for conversion)
 
1383
        voidFunction    func;           - The function to return.
 
1384
RETURN:         ERROR NO_ERROR
 
1385
DESCRIPTION:    This function was created in order to simplify the code. It
 
1386
                is the same as the previous ones but they all call this one
 
1387
                now. The new parameter was the only difference between the 
 
1388
                functions.
 
1389
CREATION:       January 29 1991         (bug2032)
 
1390
REVISIONS:      
 
1391
-----------------------------------------------------------------------------*/
 
1392
/*
 
1393
static int voidFunction_GenericProc(sw, udata, xdata, flag, func)
 
1394
        swidget         sw;
 
1395
        voidFunction    *udata;
 
1396
        voidFunction    *xdata;
 
1397
        int             flag;
 
1398
        voidFunction    func;
 
1399
{
 
1400
 
 
1401
        if (flag == TO_UIMX)
 
1402
        {
 
1403
#ifdef RUNTIME
 
1404
            *udata = *xdata;
 
1405
#else
 
1406
            /. never used ./
 
1407
#endif /. RUNTIME ./
 
1408
        }
 
1409
        else if (flag == TO_X) 
 
1410
        {
 
1411
#ifdef RUNTIME
 
1412
            *xdata = *udata;
 
1413
#else
 
1414
            *xdata = func;
 
1415
#endif /. RUNTIME ./
 
1416
        } 
 
1417
        else 
 
1418
        {
 
1419
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1420
            return ERROR;
 
1421
        }
 
1422
 
 
1423
        return NO_ERROR;
 
1424
}
 
1425
*/
 
1426
        
 
1427
/******************************************************************************
 
1428
NAME:   static int voidFunction_createPopupChildProc(sw, udata, xdata, flag)    
 
1429
        swidget         sw;     - The swidget
 
1430
        voidFunction    *udata; - The UIM/X repository
 
1431
        voidFunction    *xdata; - The X repository
 
1432
        int             flag;   - The direction flag
 
1433
RETURN:         ERROR or NO_ERROR
 
1434
DESCRIPTION:    
 
1435
CREATION:       January 29 1991         (bug2032)
 
1436
REVISIONS:      
 
1437
-----------------------------------------------------------------------------*/
 
1438
 
 
1439
/*
 
1440
static int voidFunction_createPopupChildProc(sw, udata, xdata, flag)
 
1441
        swidget         sw;
 
1442
        voidFunction    *udata;
 
1443
        voidFunction    *xdata;
 
1444
        int             flag;
 
1445
        
 
1446
{
 
1447
        voidFunction    func;
 
1448
#ifdef  RUNTIME
 
1449
        func = ( voidFunction ) NULL;
 
1450
#else
 
1451
        func = ( voidFunction ) UxCreatePopupChildProc;
 
1452
#endif
 
1453
        return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
 
1454
}
 
1455
*/
 
1456
 
 
1457
/******************************************************************************
 
1458
NAME:   static int cardFunction_insertPosition(sw, udata, xdata, flag)
 
1459
        swidget         sw;     - The swidget
 
1460
        voidFunction    *udata; - The UIM/X repository
 
1461
        voidFunction    *xdata; - The X repository
 
1462
        int             flag;   - The direction flag
 
1463
RETURN:         ERROR or NO_ERROR
 
1464
DESCRIPTION:    
 
1465
CREATION:       January 29 1991         (bug2032)
 
1466
REVISIONS:      
 
1467
-----------------------------------------------------------------------------*/
 
1468
 
 
1469
/*
 
1470
static int cardFunction_insertPosition(sw, udata, xdata, flag)
 
1471
        swidget         sw;
 
1472
        cardFunction    *udata;
 
1473
        cardFunction    *xdata;
 
1474
        int             flag;
 
1475
{
 
1476
        voidFunction    func;
 
1477
#ifdef  RUNTIME
 
1478
        func = ( voidFunction ) NULL;
 
1479
#else
 
1480
        func = ( voidFunction ) UxInsertPosition;
 
1481
#endif
 
1482
        return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
 
1483
}
 
1484
*/
 
1485
 
 
1486
/******************************************************************************
 
1487
NAME:   static int voidFunction_fileSearchProc(sw, udata, xdata, flag)
 
1488
        swidget         sw;     - The swidget
 
1489
        voidFunction    *udata; - The UIM/X repository
 
1490
        voidFunction    *xdata; - The X repository
 
1491
        int             flag;   - The direction flag
 
1492
RETURN:         ERROR or NO_ERROR
 
1493
DESCRIPTION:    
 
1494
CREATION:       January 29 1991         (bug2032)
 
1495
REVISIONS:      
 
1496
-----------------------------------------------------------------------------*/
 
1497
 
 
1498
/* 
 
1499
static int voidFunction_fileSearchProc(sw, udata, xdata, flag)
 
1500
        swidget         sw;
 
1501
        voidFunction    *udata;
 
1502
        voidFunction    *xdata;
 
1503
        int             flag;
 
1504
{
 
1505
        voidFunction    func;
 
1506
#ifdef  RUNTIME
 
1507
        func = ( voidFunction ) NULL;
 
1508
#else
 
1509
        func = ( voidFunction ) UxFileSearchProc;
 
1510
#endif
 
1511
        return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
 
1512
}
 
1513
*/
 
1514
 
 
1515
/******************************************************************************
 
1516
NAME:   static int voidFunction_dirSearchProc(sw, udata, xdata, flag)
 
1517
        swidget         sw;     - The swidget
 
1518
        voidFunction    *udata; - The UIM/X repository
 
1519
        voidFunction    *xdata; - The X repository
 
1520
        int             flag;   - The direction flag
 
1521
RETURN:         ERROR or NO_ERROR
 
1522
DESCRIPTION:    
 
1523
CREATION:       January 29 1991         (bug2032)
 
1524
REVISIONS:      
 
1525
-----------------------------------------------------------------------------*/
 
1526
 
 
1527
/* 
 
1528
static int voidFunction_dirSearchProc(sw, udata, xdata, flag)
 
1529
        swidget         sw;
 
1530
        voidFunction    *udata;
 
1531
        voidFunction    *xdata;
 
1532
        int             flag;
 
1533
{
 
1534
        voidFunction    func;
 
1535
#ifdef  RUNTIME
 
1536
        func = ( voidFunction ) NULL;
 
1537
#else
 
1538
        func = ( voidFunction ) UxDirSearchProc;
 
1539
#endif
 
1540
        return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
 
1541
}
 
1542
*/
 
1543
 
 
1544
/******************************************************************************
 
1545
NAME:   static int voidFunction_qualifySearchDataProc(sw, udata, xdata, flag)
 
1546
        swidget         sw;     - The swidget
 
1547
        voidFunction    *udata; - The UIM/X repository
 
1548
        voidFunction    *xdata; - The X repository
 
1549
        int             flag;   - The direction flag
 
1550
RETURN:         ERROR or NO_ERROR
 
1551
DESCRIPTION:    
 
1552
CREATION:       January 29 1991         (bug2032)
 
1553
REVISIONS:      
 
1554
-----------------------------------------------------------------------------*/
 
1555
 
 
1556
/*
 
1557
static int voidFunction_qualifySearchDataProc(sw, udata, xdata, flag)
 
1558
        swidget         sw;
 
1559
        voidFunction    *udata;
 
1560
        voidFunction    *xdata;
 
1561
        int             flag;
 
1562
{
 
1563
        voidFunction    func;
 
1564
#ifdef  RUNTIME
 
1565
        func = ( voidFunction ) NULL;
 
1566
#else
 
1567
        func = ( voidFunction ) UxQualifySearchDataProc;
 
1568
#endif
 
1569
        return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
 
1570
}
 
1571
*/
 
1572
 
 
1573
/* ---------------------------------------------------------------------------
 
1574
NAME:           int UxCallConverter(sw, utype, udata, xtype, xdata, flag)
 
1575
INPUT:          swidget sw      -- swidget
 
1576
                int utype       -- Uimx type id
 
1577
                char **udata    -- Address for uimx data
 
1578
                int xtype       -- X type id
 
1579
                char *xdata     -- Address for X data
 
1580
                int flag        -- TO_X / TO_UIMX flag
 
1581
RETURNS:        ERROR/NO_ERROR
 
1582
DESCRIPTION:    Calls the converter needed to convert data between
 
1583
                uimx and x types. The flag determines the direction
 
1584
                of the conversion.
 
1585
                
 
1586
CREATION:       Apr 19 1988  Visual Edge Software
 
1587
LAST REV:       Jan 09 1993  Name Changed.
 
1588
---------------------------------------------------------------------------*/
 
1589
int UxCallConverter(sw, utype, udata, xtype, xdata, flag)
 
1590
        swidget sw;
 
1591
        int utype;
 
1592
        char **udata;
 
1593
        int xtype;
 
1594
        char *xdata;
 
1595
        int flag;
 
1596
{
 
1597
        /* Simply look up the conversion routine and call it */
 
1598
        _utype = utype;
 
1599
        _xtype = xtype;
 
1600
        if (UxUimx_x[utype][xtype])
 
1601
                return (UxUimx_x[utype][xtype])(sw, udata, xdata, flag, xtype);
 
1602
        
 
1603
        if (flag == TO_UIMX)
 
1604
          UxInternalError(__FILE__, __LINE__,
 
1605
                CGETS( MS_MISC_NO_CONV_ROUTINE,DS_MS_MISC_NO_CONV_ROUTINE),
 
1606
                x_name(xtype), u_name(utype));
 
1607
        else
 
1608
          UxInternalError(__FILE__, __LINE__,
 
1609
                CGETS( MS_MISC_NO_CONV_ROUTINE,DS_MS_MISC_NO_CONV_ROUTINE),
 
1610
                u_name(utype), x_name(xtype));
 
1611
 
 
1612
        return ERROR;
 
1613
}
 
1614
 
 
1615
/* ---------------------------------------------------------------------------
 
1616
NAME:           int UxUimx_to_x(sw, utype, udata, xtype, xdata, flag)
 
1617
INPUT:          swidget sw      -- swidget
 
1618
                int utype       -- Uimx type id
 
1619
                char **udata    -- Address for uimx data
 
1620
                int xtype       -- X type id
 
1621
                char *xdata     -- Address for X data
 
1622
                int flag        -- TO_X / TO_UIMX flag
 
1623
RETURNS:        ERROR/NO_ERROR
 
1624
DESCRIPTION:    Wrapper function for UxCallConverter(). Exists strictly
 
1625
                for backward compatibility purposes. 
 
1626
                
 
1627
CREATION:       Jan 93  fix3820    UxUimx_to_x renamed UxCallConverter
 
1628
---------------------------------------------------------------------------*/
 
1629
int UxUimx_to_x(sw, utype, udata, xtype, xdata, flag)
 
1630
        swidget sw;
 
1631
        int utype;
 
1632
        char **udata;
 
1633
        int xtype;
 
1634
        char *xdata;
 
1635
        int flag;
 
1636
{
 
1637
        return UxCallConverter(sw, utype, udata, xtype, xdata, flag);
 
1638
}
 
1639
 
 
1640
/*----------------------------------------------------------------------
 
1641
 * NAME:        < static int string_SelectionArray (sw, udata, xdata, flag, 
 
1642
                  XT_type>
 
1643
 * DESCRIPTION: < For the TO_UIMX case,
 
1644
   a rotating buffer will contain the strings. For the first pass, the buffer
 
1645
   is filled up to its size and for the subsequent strings to be stored, the
 
1646
   location is first reallocated before the new string takes its place.
 
1647
   Every time the buffer index reaches the size of the buffer, it is reset
 
1648
   to 0 to create the rotating buffer. This way, we avoid system crashes
 
1649
   because the pointer will always point to valid memory addresses but
 
1650
   the memory content may not be the right one if the user waited too long
 
1651
   (more than "size of buffer" calls to this converter) before using the value
 
1652
   returned. >
 
1653
 * PARAMETERS: 
 
1654
                swidget         sw              - swidget
 
1655
                char            **udata         - UIMX string representation
 
1656
                XmTextScanType  *xdata          - XmTextScanType Xm enum array
 
1657
                int             flag            - TO_UIMX or TO_X
 
1658
                int             XT_type         - the type identifier
 
1659
 * RETURN:      ERROR/NO_ERROR  
 
1660
 * EXT REFS:    globals_used
 
1661
 * EXT EFFECTS: globals or other things altered
 
1662
 * ASSUMPTIONS:
 
1663
 * REVISIONS:   04/07/89        creation        
 
1664
                xx/05/92        fix3571 runtime library rewrite
 
1665
                19/11/92        fix3723 fix memory leak calling UxUpdateRotating
 
1666
                                        Buffer for TO_UIMX case 
 
1667
                01/12/92        fix3749 fix memory leak TO_X case
 
1668
 *--------------------------------------------------------------------*/
 
1669
static  int     string_SelectionArray(sw, udata, xdata, flag, XT_type)
 
1670
        swidget         sw;
 
1671
        char            **udata;
 
1672
        XmTextScanType  **xdata;
 
1673
        int             flag;
 
1674
        int             XT_type;
 
1675
{
 
1676
        int             i, match, err = 0;
 
1677
        char            **uconv = UxStr_conv[XT_type].strings;
 
1678
        XmTextScanType  *xconv = (XmTextScanType *) UxStr_conv[XT_type].values;
 
1679
        int             n = UxStr_conv[XT_type].size;
 
1680
        static char **RotatingBuffer;
 
1681
        static int BufferIndex = -1;
 
1682
 
 
1683
        if (flag == TO_UIMX)
 
1684
        {
 
1685
            Arg     a[1];
 
1686
            Widget  w;
 
1687
            int     count;
 
1688
            char    *s=0;
 
1689
 
 
1690
            /* get the current size of the selection array */
 
1691
 
 
1692
            w = UxGetWidget(sw);
 
1693
 
 
1694
            if (!w)
 
1695
            {   
 
1696
                *udata = "";
 
1697
                return NO_ERROR;
 
1698
            }
 
1699
 
 
1700
            XtSetArg(a[0], "selectionArrayCount", &count);
 
1701
            XtGetValues(w, a, 1);
 
1702
 
 
1703
            if (count == 0)
 
1704
            {   
 
1705
                *udata = "";
 
1706
                return NO_ERROR;
 
1707
            }
 
1708
 
 
1709
            /* assemble the uimx strings into one string, separated by  */
 
1710
            /* spaces                                                   */
 
1711
            
 
1712
            for (i=0; i<count; i++)
 
1713
            {
 
1714
                XmTextScanType  val;
 
1715
                int             j, match;
 
1716
 
 
1717
                val = (*xdata)[i];
 
1718
 
 
1719
                /* search the xconv array for the current array element */
 
1720
                /* if it is found, concatenate the corresponding uconv  */
 
1721
                /* element onto the output string                       */
 
1722
 
 
1723
                match = 0;
 
1724
                for (j=0; j<n; j++)
 
1725
                {
 
1726
                    if (val == xconv[j])
 
1727
                    {
 
1728
                        match = 1;
 
1729
                        if (s)
 
1730
                        {
 
1731
                            s = UxRealloc(s, strlen(s) + strlen(uconv[j]) + 2);
 
1732
                            strcat(s, " ");
 
1733
                            strcat(s, uconv[j]);
 
1734
                        }
 
1735
                        else
 
1736
                        {
 
1737
                            s = UxMalloc(strlen(uconv[j]) + 1);
 
1738
                            strcpy(s, uconv[j]);
 
1739
                        }
 
1740
                        break;
 
1741
                    }
 
1742
                }
 
1743
 
 
1744
                /* if the current array element was not found in the xconv */
 
1745
                /* array, then it is invalid, and we return an error       */
 
1746
 
 
1747
                if (!match)
 
1748
                {
 
1749
                    /* the ith element of the array is invalid; we free the */
 
1750
                    /* string allocated so far and set the output to ""     */
 
1751
                    if (s)
 
1752
                        UxFree(s);
 
1753
                    *udata = "";
 
1754
                    return ERROR;
 
1755
                }
 
1756
            }
 
1757
        
 
1758
            UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, s, UxFree);
 
1759
            *udata = RotatingBuffer[BufferIndex];
 
1760
            return NO_ERROR;
 
1761
        }
 
1762
        else if (flag == TO_X)
 
1763
        {
 
1764
            char *c1;
 
1765
            char *c2;
 
1766
            char *temp;
 
1767
            XmTextScanType array[20];
 
1768
            int array_length;
 
1769
 
 
1770
            /* protect strlen from NULL */
 
1771
            if (!*udata) return ERROR;
 
1772
 
 
1773
            /* create temp copy of string to parse... */
 
1774
            temp = XtMalloc(strlen(*udata) + 1);
 
1775
            (void) strcpy(temp, *udata);
 
1776
            c1 = temp;
 
1777
 
 
1778
            for (array_length = 0; *c1 &&
 
1779
                    (array_length < (sizeof(array) / sizeof(array[0]))); )
 
1780
            {
 
1781
                /* skip over leading whitespace... */
 
1782
                while (isspace(*c1))
 
1783
                    (void) c1++;
 
1784
 
 
1785
                /* skip to end of string... */
 
1786
                c2 = c1;
 
1787
                while (*c2 && !isspace(*c2))
 
1788
                    (void) c2++;
 
1789
 
 
1790
                /* null terminate this chunk... */
 
1791
                if (*c2)
 
1792
                    *c2++ = '\0';
 
1793
 
 
1794
                /* find a match... */
 
1795
                for (i = 0, match = 0; i < n; i++)
 
1796
                {
 
1797
                    if (strcmp(c1, uconv[i]) == 0)
 
1798
                    {
 
1799
                        match = 1;
 
1800
                        break;
 
1801
                    }
 
1802
                }
 
1803
                if (match)
 
1804
                    array[array_length++] = xconv[i];
 
1805
                else
 
1806
                    err = 1;
 
1807
 
 
1808
                /* move to start of next chunk... */
 
1809
                c1 = c2;
 
1810
            }
 
1811
            if (array_length > 0) {
 
1812
                /* create a return table.  This is a memory leak, but normally
 
1813
                 * this is only created once per widget...
 
1814
                 */
 
1815
                *xdata = (XmTextScanType *)
 
1816
                        XtMalloc((unsigned) (array_length * sizeof(array[0])));
 
1817
                (void) memcpy(*xdata, array, array_length * sizeof(array[0]));
 
1818
            } else {
 
1819
                *xdata = (XmTextScanType *) NULL;
 
1820
            }
 
1821
 
 
1822
            /* now we can free the temp buffer... */
 
1823
            XtFree(temp);
 
1824
        }
 
1825
        else
 
1826
        {
 
1827
            UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1828
            return ERROR;
 
1829
        }
 
1830
        if (!err)
 
1831
            return NO_ERROR;
 
1832
        else
 
1833
        {
 
1834
            UxStandardError(CGETS( MS_MISC_NO_MATCH, DS_MS_MISC_NO_MATCH));
 
1835
            return ERROR;
 
1836
        }
 
1837
}
 
1838
 
 
1839
/******************************************************************************
 
1840
NAME:           static int              string_WidgetClass ()
 
1841
INPUTS:         char            **udata - UIMX string
 
1842
                WidgetClass     *xdata  - WidgetClass pointer
 
1843
                int             flag    - TO_UIMX or TO_X
 
1844
RETURN:         ERROR/NO_ERROR
 
1845
DESCRIPTION:    Converts a string to a WidgetClass pointer.
 
1846
CREATION:       Jun 30/1989
 
1847
REVISIONS:      July 12 1990
 
1848
                -- previous converter used to convert only one class.
 
1849
                   Made the converter general.
 
1850
                July 29 1990
 
1851
                   change to static function 
 
1852
                August 06 1990
 
1853
                -- converter uses now 2 static arrays to do the conversion
 
1854
-----------------------------------------------------------------------------*/
 
1855
 
 
1856
static int      string_WidgetClass (sw, udata, xdata, flag)
 
1857
swidget sw;
 
1858
char            **udata;
 
1859
WidgetClass     *xdata;
 
1860
int             flag;
 
1861
{
 
1862
        int i;
 
1863
        static char *uWidgetClass[] = {
 
1864
                "arrowButtonGadget",
 
1865
                "arrowButton",
 
1866
                "bulletinBoard",
 
1867
                "cascadeButtonGadget",
 
1868
                "cascadeButton",
 
1869
                "command",
 
1870
                "drawingArea",
 
1871
                "drawnButton",
 
1872
                "fileSelectionBox",
 
1873
                "form",
 
1874
                "frame",
 
1875
                "labelGadget",
 
1876
                "label",
 
1877
                "list",
 
1878
                "mainWindow",
 
1879
                "messageBox",
 
1880
                "panedWindow",
 
1881
                "pushButtonGadget",
 
1882
                "pushButton",
 
1883
                "rowColumn",
 
1884
                "scale",
 
1885
                "scrollBar",
 
1886
                "scrolledWindow",
 
1887
                "selectionBox",
 
1888
                "separatorGadget",
 
1889
                "separator",
 
1890
                "text",
 
1891
                "textField",
 
1892
                "toggleButtonGadget",
 
1893
                "toggleButton"
 
1894
        };
 
1895
 
 
1896
        static WidgetClass *xWidgetClass[]= {
 
1897
                &xmArrowButtonGadgetClass,
 
1898
                &xmArrowButtonWidgetClass,
 
1899
                &xmBulletinBoardWidgetClass,
 
1900
                &xmCascadeButtonGadgetClass,
 
1901
                &xmCascadeButtonWidgetClass,
 
1902
                &xmCommandWidgetClass,
 
1903
                &xmDrawingAreaWidgetClass,
 
1904
                &xmDrawnButtonWidgetClass,
 
1905
                &xmFileSelectionBoxWidgetClass,
 
1906
                &xmFormWidgetClass,
 
1907
                &xmFrameWidgetClass,
 
1908
                &xmLabelGadgetClass,
 
1909
                &xmLabelWidgetClass,
 
1910
                &xmListWidgetClass,
 
1911
                &xmMainWindowWidgetClass,
 
1912
                &xmMessageBoxWidgetClass,
 
1913
                &xmPanedWindowWidgetClass,
 
1914
                &xmPushButtonGadgetClass,
 
1915
                &xmPushButtonWidgetClass,
 
1916
                &xmRowColumnWidgetClass,
 
1917
                &xmScaleWidgetClass,
 
1918
                &xmScrollBarWidgetClass,
 
1919
                &xmScrolledWindowWidgetClass,
 
1920
                &xmSelectionBoxWidgetClass,
 
1921
                &xmSeparatorGadgetClass,
 
1922
                &xmSeparatorWidgetClass,
 
1923
                &xmTextWidgetClass,
 
1924
                &xmTextFieldWidgetClass,
 
1925
                &xmToggleButtonGadgetClass,
 
1926
                &xmToggleButtonWidgetClass,
 
1927
        };
 
1928
        
 
1929
 
 
1930
        if (flag == TO_UIMX)
 
1931
        {
 
1932
                if (*xdata)
 
1933
                {
 
1934
                        int num = XtNumber(uWidgetClass);
 
1935
                        char *pntr;
 
1936
                        char *wclass;
 
1937
 
 
1938
                        pntr = (char *)
 
1939
                            UxMalloc(strlen((*xdata)->core_class.class_name)+1);
 
1940
 
 
1941
                        strcpy(pntr, (*xdata)->core_class.class_name);
 
1942
                        wclass = pntr;
 
1943
                        if ((pntr[0] == 'X') && (pntr[1] == 'm'))
 
1944
                        {
 
1945
                                pntr[2] = tolower(pntr[2]);
 
1946
                                wclass = &pntr[2];
 
1947
                        }
 
1948
 
 
1949
                        for (i=0; i < num; i++)
 
1950
                        {
 
1951
 
 
1952
                           if (strcmp(uWidgetClass[i], wclass) == 0)
 
1953
                           {
 
1954
                                *udata = uWidgetClass[i];
 
1955
                                break;
 
1956
                           }
 
1957
                        }
 
1958
                        UxFree(pntr);
 
1959
                }
 
1960
                else
 
1961
                {
 
1962
                        *udata = "";
 
1963
                }
 
1964
        }
 
1965
        else if (flag == TO_X)
 
1966
        {
 
1967
                int num = XtNumber(uWidgetClass);
 
1968
 
 
1969
                if (!strcmp(*udata, ""))
 
1970
                {
 
1971
                        *xdata = (WidgetClass) NULL;
 
1972
                }
 
1973
 
 
1974
                *xdata = (WidgetClass) NULL;
 
1975
                for (i=0; i < num; i++)
 
1976
                {
 
1977
                        if (strcmp(uWidgetClass[i], *udata) == 0)
 
1978
                        {
 
1979
                                *xdata = *xWidgetClass[i];
 
1980
                                break;
 
1981
                        }
 
1982
                }
 
1983
        }
 
1984
        else
 
1985
        {
 
1986
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
1987
                return ERROR;
 
1988
        }
 
1989
        return NO_ERROR;
 
1990
}
 
1991
 
 
1992
/******************************************************************************
 
1993
NAME:           int             int_Position (sw, udata, xdata, flag)
 
1994
INPUT:          swidget         sw              - swidget
 
1995
                int             *udata          - uimx value int address
 
1996
                Position        *xdata          - x value Position address
 
1997
                int             flag            - TO_UIMX or TO_X
 
1998
RETURN:         ERROR/NO_ERROR
 
1999
DESCRIPTION:    Converts int <--> Position representations.
 
2000
                In MOTIF 1.1, Position is the standard Xt typedef of short.
 
2001
-----------------------------------------------------------------------------*/
 
2002
 
 
2003
static  int     int_Position(sw, udata, xdata, flag)
 
2004
swidget sw;
 
2005
int      *udata;
 
2006
Position *xdata;
 
2007
int     flag;
 
2008
{
 
2009
        if (flag == TO_UIMX) {
 
2010
                *udata = (int) *xdata;
 
2011
        } else if (flag == TO_X) {
 
2012
                *xdata = (Position) *udata;
 
2013
        } else {
 
2014
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2015
                return ERROR;
 
2016
        }
 
2017
        return NO_ERROR;
 
2018
}
 
2019
 
 
2020
/******************************************************************************
 
2021
NAME:           int             long_Colormap (sw, udata, xdata, flag)
 
2022
INPUT:          swidget         sw              - swidget
 
2023
                long            *udata          - uimx value long address
 
2024
                Colormap        *xdata          - x value Colormap address
 
2025
                int             flag            - TO_UIMX or TO_X
 
2026
RETURN:         ERROR/NO_ERROR
 
2027
DESCRIPTION:    Converts long <--> Colormap representations.
 
2028
-----------------------------------------------------------------------------*/
 
2029
 
 
2030
static  int     long_Colormap(sw, udata, xdata, flag)
 
2031
swidget sw;
 
2032
long      *udata;
 
2033
Colormap *xdata;
 
2034
int     flag;
 
2035
{
 
2036
        if (flag == TO_UIMX) {
 
2037
                *udata = (long) *xdata;
 
2038
        } else if (flag == TO_X) {
 
2039
                *xdata = (Colormap) *udata;
 
2040
        } else {
 
2041
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2042
                return ERROR;
 
2043
        }
 
2044
        return NO_ERROR;
 
2045
}
 
2046
 
 
2047
/******************************************************************************
 
2048
NAME:           int             int_Dimension (sw, udata, xdata, flag)
 
2049
INPUT:          swidget         sw              - swidget
 
2050
                int             *udata          - uimx value int address
 
2051
                Dimension       *xdata          - x value Dimension address
 
2052
                int             flag            - TO_UIMX or TO_X
 
2053
RETURN:         ERROR/NO_ERROR
 
2054
DESCRIPTION:    Converts int <--> Dimension representations.
 
2055
                In MOTIF 1.1, Dimension is the standard Xt typedef of ushort
 
2056
-----------------------------------------------------------------------------*/
 
2057
 
 
2058
static  int     int_Dimension(sw, udata, xdata, flag)
 
2059
swidget sw;
 
2060
int       *udata;
 
2061
Dimension *xdata;
 
2062
int     flag;
 
2063
{
 
2064
        if (flag == TO_UIMX) {
 
2065
                *udata = (int) *xdata;
 
2066
        } else if (flag == TO_X) {
 
2067
                *xdata = (Dimension) *udata;
 
2068
        } else {
 
2069
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2070
                return ERROR;
 
2071
        }
 
2072
        return NO_ERROR;
 
2073
}
 
2074
 
 
2075
/******************************************************************************
 
2076
NAME:           int             int_short (sw, udata, xdata, flag)
 
2077
INPUT:          swidget         sw              - swidget
 
2078
                int             *udata          - uimx value short address
 
2079
                short           *xdata          - x value int address
 
2080
                int             flag            - TO_UIMX or TO_X
 
2081
RETURN:         ERROR/NO_ERROR
 
2082
DESCRIPTION:    Converts int <--> short representations.
 
2083
CREATION:       2 Apr 90
 
2084
REVISIONS:      --
 
2085
-----------------------------------------------------------------------------*/
 
2086
 
 
2087
static  int     int_short(sw, udata, xdata, flag)
 
2088
swidget sw;
 
2089
int     *udata;
 
2090
short   *xdata;
 
2091
int     flag;
 
2092
{
 
2093
        if (flag == TO_UIMX)
 
2094
                *udata = *xdata;
 
2095
        else if (flag == TO_X)
 
2096
                *xdata = *udata;
 
2097
        else
 
2098
        {
 
2099
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2100
                return ERROR;
 
2101
        }
 
2102
        return NO_ERROR;
 
2103
}
 
2104
 
 
2105
/******************************************************************************
 
2106
NAME:           int             short_int (sw, udata, xdata, flag)
 
2107
INPUT:          swidget         sw              - swidget
 
2108
                short           *udata          - uimx value short address
 
2109
                int             *xdata          - x value int address
 
2110
                int             flag            - TO_UIMX or TO_X
 
2111
RETURN:         ERROR/NO_ERROR
 
2112
DESCRIPTION:    Converts short <--> int representations.
 
2113
CREATION:       2 Apr 90
 
2114
REVISIONS:      --
 
2115
-----------------------------------------------------------------------------*/
 
2116
 
 
2117
static  int     short_int(sw, udata, xdata, flag)
 
2118
swidget sw;
 
2119
short   *udata;
 
2120
int     *xdata;
 
2121
int     flag;
 
2122
{
 
2123
        if (flag == TO_UIMX)
 
2124
                *udata = *xdata;
 
2125
        else if (flag == TO_X)
 
2126
                *xdata = *udata;
 
2127
        else
 
2128
        {
 
2129
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2130
                return ERROR;
 
2131
        }
 
2132
        return NO_ERROR;
 
2133
}
 
2134
 
 
2135
 
 
2136
/*----------------------------------------------------------------------
 
2137
 * NAME:        < int string_Atom (sw, udata, xdata, flag)>
 
2138
 * DESCRIPTION: < Converts Atom -- String representations. For the TO_UIMX case,
 
2139
   a rotating buffer will contain the strings. For the first pass, the buffer
 
2140
   is filled up to its size and for the subsequent strings to be stored, the
 
2141
   location is first reallocated before the new string takes its place.
 
2142
   Every time the buffer index reaches the size of the buffer, it is reset
 
2143
   to 0 to create the rotating buffer. This way, we avoid system crashes
 
2144
   because the pointer will always point to valid memory addresses but
 
2145
   the memory content may not be the right one if the user waited too long
 
2146
   (more than "size of buffer" calls to this converter) before using the value
 
2147
   returned.> 
 
2148
 * PARAMETERS: 
 
2149
                swidget         sw              - swidget
 
2150
                char            **udata         - uimx value char * address
 
2151
                Atom            *xdata          - x value Atom address
 
2152
                int             flag            - TO_UIMX or TO_X
 
2153
 * RETURN:      ERROR/NO_ERROR  
 
2154
 * EXT REFS:    globals_used
 
2155
 * EXT EFFECTS: globals or other things altered
 
2156
 * ASSUMPTIONS:
 
2157
 * LAST REVISION: March 15, 1993        Test for invalid zero value Atom
 
2158
 *--------------------------------------------------------------------*/
 
2159
static  int     string_Atom(sw, udata, xdata, flag)
 
2160
swidget sw;
 
2161
char    **udata;
 
2162
Atom *xdata;
 
2163
int     flag;
 
2164
{
 
2165
        if (flag == TO_UIMX) {
 
2166
                char *atom_name;
 
2167
                static char **RotatingBuffer;
 
2168
                static int BufferIndex = -1;
 
2169
 
 
2170
                if (*xdata) {
 
2171
                        atom_name = XGetAtomName(UxDisplay, *xdata);
 
2172
                        UxUpdateRotatingBuffer
 
2173
                        (&BufferIndex, &RotatingBuffer, atom_name,(func_ptr) XFree);
 
2174
                        *udata = RotatingBuffer[BufferIndex];
 
2175
                }
 
2176
                else
 
2177
                        *udata = "";
 
2178
        } 
 
2179
        else if (flag == TO_X) 
 
2180
        {
 
2181
                /* Create the atom if it does not exist */
 
2182
                *xdata = XInternAtom(UxDisplay, *udata, False);
 
2183
        } 
 
2184
        else {
 
2185
                UxStandardError(CGETS( MS_MISC_WRONG_FLAG, 
 
2186
                                       DS_MS_MISC_WRONG_FLAG));
 
2187
                return ERROR;
 
2188
        }
 
2189
        return NO_ERROR;
 
2190
}
 
2191
/******************************************************************************
 
2192
NAME:           int             string_Keysym (sw, udata, xdata, flag)
 
2193
INPUT:          swidget         sw              - swidget
 
2194
                char            **udata         - string representation
 
2195
                char            *xdata          - character representation
 
2196
                int             flag            - TO_UIMX or TO_X
 
2197
RETURN:         ERROR/NO_ERROR
 
2198
DESCRIPTION:    Converts string <--> keysym representations.
 
2199
CREATION:       November 05 1990
 
2200
REVISIONS:      July 30, 1991           (fix2773)
 
2201
                - Don't allow NULL as udata and convert NULL xdata to "".
 
2202
-----------------------------------------------------------------------------*/
 
2203
 
 
2204
static  int     string_Keysym (sw, udata, xdata, flag)
 
2205
    swidget     sw;
 
2206
    char        **udata;
 
2207
    KeySym      *xdata;
 
2208
    int         flag;
 
2209
{
 
2210
        if (flag == TO_UIMX)
 
2211
        {
 
2212
                if (*xdata == NoSymbol)
 
2213
                {
 
2214
                        *udata = "";
 
2215
                }
 
2216
                else if ((*udata = XKeysymToString (*xdata)) == NULL)
 
2217
                {
 
2218
                        *udata = "";
 
2219
                        return ERROR;
 
2220
                }
 
2221
        }
 
2222
        else if (flag == TO_X)
 
2223
        {
 
2224
                if (*udata == NULL)
 
2225
                    return ERROR;
 
2226
 
 
2227
                if (UxStrEqual (*udata, "")) {
 
2228
                        *xdata = NoSymbol;
 
2229
                } else {
 
2230
                        *xdata = XStringToKeysym (*udata);
 
2231
                        if (*xdata == NoSymbol)
 
2232
                                return ERROR;
 
2233
                }
 
2234
        }
 
2235
        else
 
2236
        {
 
2237
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, 
 
2238
                                        DS_MS_MISC_WRONG_FLAG));
 
2239
                return ERROR;
 
2240
        }
 
2241
        return NO_ERROR;
 
2242
}
 
2243
 
 
2244
 
 
2245
/******************************************************************************
 
2246
NAME:           Boolean         UxFontListCreate ( udata, xdata)
 
2247
INPUT:          char            *udata          - string representation
 
2248
                XmFontList      *xdata          - Motif XmFontList structure
 
2249
RETURN:         True/False                      - if succeeded
 
2250
DESCRIPTION:    This will convert from a string representation into a
 
2251
                XmFontList.
 
2252
 
 
2253
                The caller should not call XmFontListFree on the returned
 
2254
                value.
 
2255
 
 
2256
CREATION:       3 Avril 1992
 
2257
-----------------------------------------------------------------------------*/
 
2258
 
 
2259
Boolean
 
2260
UxFontListCreate( udata, xdata)
 
2261
char *udata;
 
2262
XmFontList *xdata;
 
2263
{
 
2264
        XrmValue    from, to;
 
2265
        from.size = strlen( udata ) + 1;
 
2266
        from.addr = udata;
 
2267
        to.size = sizeof(XmFontList);
 
2268
        to.addr = (caddr_t) xdata ;
 
2269
        return( XtConvertAndStore( UxTopLevel, XmRString, &from,
 
2270
                XmRFontList, &to));
 
2271
}
 
2272
 
 
2273
 
 
2274
/*----------------------------------------------------------------------
 
2275
 * NAME:        <int string_XmFontList (sw, udata, xdata, flag)>
 
2276
 * DESCRIPTION: <Performs the conversion from a font name to a Motif XmFontList
 
2277
   and the reverse. A rotating buffer of strings is supported for the TO_UIMX 
 
2278
   case.
 
2279
   A rotating buffer will contain the strings. For the first pass, the buffer
 
2280
   is filled up to its size and for the subsequent strings to be stored, the
 
2281
   location is first reallocated before the new string takes its place.
 
2282
   Every time the buffer index reaches the size of the buffer, it is reset
 
2283
   to 0 to create the rotating buffer. This way, we avoid system crashes
 
2284
   because the pointer will always point to valid memory addresses but
 
2285
   the memory content may not be the right one if the user waited too long
 
2286
   (more than "size of buffer" calls to this converter) before using the value
 
2287
   returned.> 
 
2288
 * PARAMETERS: 
 
2289
                swidget         sw              - swidget
 
2290
                char            **udata - string representation
 
2291
                XmFontList      *xdata  - Motif XmFontList structure
 
2292
                int             flag            - TO_UIMX or TO_X
 
2293
 * RETURN:      ERROR/NO_ERROR  
 
2294
 * EXT REFS:    globals_used
 
2295
 * EXT EFFECTS: globals or other things altered
 
2296
 * ASSUMPTIONS:
 
2297
 * REVISIONS:   04/07/89        creation        
 
2298
                                03/01/91        Motif 1.1 modifications in font struct.
 
2299
                                07/12/92        fix3767 support Motif 1.2       
 
2300
                                20/08/93        fix4447 Correct UxGet...
 
2301
 *--------------------------------------------------------------------*/
 
2302
static  int     string_XmFontList (sw, udata, xdata, flag)
 
2303
swidget         sw;
 
2304
char            **udata;
 
2305
XmFontList      *xdata;
 
2306
int             flag;
 
2307
{
 
2308
        if (flag == TO_UIMX)
 
2309
        {
 
2310
                XFontStruct     *font_struct;
 
2311
                XFontSet        font_set;
 
2312
                XmFontListEntry font_list_entry;
 
2313
                XmFontType      type_ret;
 
2314
                XtPointer       font_or_fontset;
 
2315
                unsigned long   *ret;
 
2316
                XmFontContext   fc;
 
2317
                char *font_tag;
 
2318
                int len;
 
2319
                char *font = "";
 
2320
                char *ListOfFonts = NULL;
 
2321
                char *PtrInList;
 
2322
                static char **RotatingBuffer;
 
2323
                static int BufferIndex = -1;
 
2324
 
 
2325
                if (*xdata)
 
2326
                {
 
2327
                        if (!XmFontListInitFontContext (&fc, *xdata))
 
2328
                        {
 
2329
                                UxStandardError (CGETS( MS_MISC_WRONG_FLAG,
 
2330
                                                DS_MS_MISC_WRONG_FLAG));
 
2331
                                return ERROR ;
 
2332
                        }
 
2333
                        
 
2334
                        while ((font_list_entry = XmFontListNextEntry (fc)) != NULL)
 
2335
                        {
 
2336
                                font_or_fontset = XmFontListEntryGetFont(font_list_entry, 
 
2337
                                                                                                &type_ret);
 
2338
                                if (type_ret == XmFONT_IS_FONT)
 
2339
                                {       
 
2340
                                        font_struct = (XFontStruct *) font_or_fontset;
 
2341
                                        XGetFontProperty(font_struct, XA_FONT, (unsigned long*)&ret);
 
2342
                                        font = XGetAtomName(UxDisplay, (Atom)ret);
 
2343
                                }
 
2344
                                else if (type_ret == XmFONT_IS_FONTSET)
 
2345
                                {
 
2346
                                        char * comma;
 
2347
                                        font_set = (XFontSet) font_or_fontset;
 
2348
                                        font = XBaseFontNameListOfFontSet(font_set);
 
2349
                                        comma = font;
 
2350
                                        while ((comma = strpbrk(comma,",")))
 
2351
                                        {
 
2352
                                                *comma++ = ';';
 
2353
                                        }
 
2354
                                }
 
2355
 
 
2356
                                if (ListOfFonts == NULL)
 
2357
                                {
 
2358
                                        ListOfFonts = UxMalloc(strlen(font) + 1);
 
2359
                                        PtrInList = ListOfFonts;
 
2360
                                }
 
2361
                                else
 
2362
                                {
 
2363
                                        len = strlen(ListOfFonts);
 
2364
                                        ListOfFonts = UxRealloc(ListOfFonts, len + strlen(font) + 2);
 
2365
                                        PtrInList = &ListOfFonts[len];
 
2366
                                        *PtrInList++ = ',';
 
2367
                                }
 
2368
                                strcpy(PtrInList, font);
 
2369
 
 
2370
                                font_tag = XmFontListEntryGetTag(font_list_entry);
 
2371
                                len = strlen(ListOfFonts);
 
2372
                                if (font_tag)
 
2373
                                {
 
2374
                                        ListOfFonts = UxRealloc(ListOfFonts, len + strlen(font_tag) + 2);
 
2375
                                        PtrInList = &ListOfFonts[len];
 
2376
                                        if (type_ret == XmFONT_IS_FONT)
 
2377
                                                *PtrInList++ = '=';
 
2378
                                        else if (type_ret == XmFONT_IS_FONTSET)
 
2379
                                                *PtrInList++ = ':';
 
2380
                                        strcpy(PtrInList, font_tag);
 
2381
                                        XtFree(font_tag);
 
2382
                                }
 
2383
                                else if (type_ret == XmFONT_IS_FONTSET)
 
2384
                                {
 
2385
                                        ListOfFonts = UxRealloc(ListOfFonts, len + 2);
 
2386
                                        PtrInList = &ListOfFonts[len];
 
2387
                                        *PtrInList++ = ':';
 
2388
                                }
 
2389
 
 
2390
                                /* the value returned by XGetAtomName() has to be freed but not
 
2391
                                   the one returned by XBaseFontNameListOfFontSet() */
 
2392
                                if (type_ret == XmFONT_IS_FONT)
 
2393
                                        XFree(font);
 
2394
                        }       
 
2395
        
 
2396
                        XmFontListFreeFontContext (fc);
 
2397
 
 
2398
                        /* if it is NULL, the first call to XmFontListNextEntry() returned
 
2399
                           NULL and we don't have a font list */
 
2400
                        if (ListOfFonts)
 
2401
                        {       
 
2402
                        UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, 
 
2403
                                                                                ListOfFonts, UxFree);
 
2404
                        *udata = RotatingBuffer[BufferIndex];
 
2405
                                return NO_ERROR;
 
2406
                        }
 
2407
                        else
 
2408
                        {
 
2409
                                UxStandardError (CGETS( MS_MISC_WRONG_FLAG,
 
2410
                                                DS_MS_MISC_WRONG_FLAG));
 
2411
                                return ERROR ;
 
2412
                        }
 
2413
                } 
 
2414
            *udata = "";        /* CAN'T CONVERT TO UIMX */
 
2415
        } 
 
2416
 
 
2417
        else if (flag == TO_X)
 
2418
        {
 
2419
            if (!strcmp(*udata, ""))
 
2420
                *xdata = (XmFontList)NULL;
 
2421
            else
 
2422
            {
 
2423
            if (!UxFontListCreate( *udata, xdata))
 
2424
                *xdata = (XmFontList)NULL;
 
2425
            }
 
2426
        }
 
2427
 
 
2428
        else
 
2429
        {
 
2430
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2431
                return ERROR;
 
2432
        }
 
2433
        return NO_ERROR;
 
2434
}
 
2435
 
 
2436
 
 
2437
/*----------------------------------------------------------------------
 
2438
 * NAME:        <int string_XmString (sw, udata, xdata, flag)>
 
2439
 * DESCRIPTION: <Performs a fixed conversion of strings. For the TO_UIMX case,
 
2440
                a rotating buffer of strings is supported.
 
2441
   A rotating buffer will contain the strings. For the first pass, the buffer
 
2442
   is filled up to its size and for the subsequent strings to be stored, the
 
2443
   location is first reallocated before the new string takes its place. 
 
2444
   Every time the buffer index reaches the size of the buffer, it is reset 
 
2445
   to 0 to create the rotating buffer. This way, we avoid system crashes
 
2446
   because the pointer will always point to valid memory addresses but
 
2447
   the memory content may not be the right one if the user waited too long
 
2448
   (more than "size of buffer" calls to this converter) before using the 
 
2449
   value returned.> 
 
2450
 * PARAMETERS: 
 
2451
                swidget         sw              - swidget
 
2452
                char            **udata         - string representation
 
2453
                XmString        *xdata          - Motif XmString representation
 
2454
                int             flag            - TO_UIMX or TO_X
 
2455
 * RETURN:      ERROR/NO_ERROR  
 
2456
 * EXT REFS:    globals_used
 
2457
 * EXT EFFECTS: globals or other things altered
 
2458
 * ASSUMPTIONS:
 
2459
 * REVISIONS:   04/07/89        creation        
 
2460
                HP              Mar 22/1990
 
2461
                Apr 11/1990
 
2462
                -- had to add a kludge to check if we are the end of the
 
2463
                XmString, because there is a motif bug which allows the call to
 
2464
                'XmStringGetNextComponent()' to read past the end of the string
 
2465
                Aug 2/1990
 
2466
                        - check for NULL string (no useful components) and
 
2467
                          return "" instead.
 
2468
                Jan 03 1991     bug1065
 
2469
                -- Porting to Motif 1.1
 
2470
                8 Jan 91        byug1089
 
2471
                -- Motif 1.1: strcmp test for DEFAULT_CHARSET
 
2472
                dd/mm/yy        fix#    fix_description
 
2473
 *--------------------------------------------------------------------*/
 
2474
static  int     string_XmString (sw, udata, xdata, flag)
 
2475
swidget sw;
 
2476
char            **udata;
 
2477
XmString        *xdata;
 
2478
int             flag;
 
2479
{
 
2480
        if (flag == TO_UIMX)
 
2481
        {
 
2482
                char *txt;
 
2483
                XmStringComponentType type;
 
2484
                XmStringContext context;
 
2485
                XmStringCharSet charset;
 
2486
                XmStringDirection direction;
 
2487
                XmStringComponentType unknown_tag;
 
2488
                unsigned short unknown_length;
 
2489
                unsigned char *unknown_value;
 
2490
                int ignore_strings = False; /* give the benifit of the doubt */
 
2491
                char *c1 = NULL;
 
2492
                char *c2;
 
2493
                static char **RotatingBuffer;
 
2494
                static int BufferIndex = -1;
 
2495
 
 
2496
                if (!XmStringInitContext(&context, *xdata))
 
2497
                    *udata = "";
 
2498
                else {
 
2499
                    while (XmSTRING_COMPONENT_END != (type =
 
2500
                            XmStringGetNextComponent(context,
 
2501
                            &txt, &charset, &direction, &unknown_tag,
 
2502
                            &unknown_length, &unknown_value))) {
 
2503
                        switch (type) {
 
2504
 
 
2505
                        case XmSTRING_COMPONENT_CHARSET:
 
2506
 
 
2507
                            /* We need more work here to decide how
 
2508
                             * to deal with non-default charsets.
 
2509
                             * In 1.1, a lot of XmStrings have
 
2510
                             * charset "ISO8859-1".
 
2511
                             * For the moment, we accumulate all text,
 
2512
                             * no matter what the charset,
 
2513
                             * by setting ignore_strings always to false.
 
2514
                             * We still identify DEFAULT_CHARSET components
 
2515
                             * so we can free the other charset names.
 
2516
                             */
 
2517
#if !defined(HP)
 
2518
                            /* The standard Motif distribution uses
 
2519
                             *   #define XmSTRING_DEFAULT_CHARSET ""
 
2520
                             * so equality testing doesn't work.
 
2521
                             */
 
2522
                            if (charset
 
2523
                                && !strcmp(charset,XmSTRING_DEFAULT_CHARSET))
 
2524
#else
 
2525
                            /* The HP distribution uses 
 
2526
                             *   extern char* XmSTRING_DEFAULT_CHARSET
 
2527
                             * so we can test for pointer equality (much faster)
 
2528
                             */
 
2529
                            if (charset ==
 
2530
                                     (XmStringCharSet) XmSTRING_DEFAULT_CHARSET)
 
2531
#endif /* !defined(HP) */
 
2532
                            {
 
2533
                                ignore_strings = False;
 
2534
                            } else {
 
2535
                                ignore_strings = False;
 
2536
                                /* If it is not DEFAULT_CHARSET, then we
 
2537
                                 * need to free it.  If it is DEFAULT_CHARSET,
 
2538
                                 * then we must not free it.
 
2539
                                 */
 
2540
                                XtFree((char *) charset);
 
2541
                            }
 
2542
                            break;
 
2543
                        case XmSTRING_COMPONENT_LOCALE_TEXT:
 
2544
                        case XmSTRING_COMPONENT_TEXT:
 
2545
                            if (ignore_strings)
 
2546
                                break;
 
2547
                            if (c1) {
 
2548
                                /* concatenate the 2 strings...
 
2549
                                 */
 
2550
                                c2 = XtMalloc(strlen(c1) + strlen(txt) + 1);
 
2551
                                (void) strcpy(c2, c1);
 
2552
                                (void) strcat(c2, txt);
 
2553
                                (void) XtFree(c1);
 
2554
                                c1 = c2;
 
2555
                                (void) free(txt);
 
2556
                            } else {
 
2557
                                /* txt was XtMalloc'ed by
 
2558
                                 * XmStringGetNextComponent, so we don't need
 
2559
                                 * to recreate it (we will need to free it
 
2560
                                 * though)...
 
2561
                                 */
 
2562
                                c1 = txt;
 
2563
                            }
 
2564
                            break;
 
2565
 
 
2566
                        case XmSTRING_COMPONENT_SEPARATOR:
 
2567
                            if (c1) {
 
2568
                                /* append a '\n' as the separator just like
 
2569
                                 * XmStringCreateLtoR does...
 
2570
                                 */
 
2571
                                c2 = XtMalloc(strlen(c1) + strlen("\n") + 1);
 
2572
                                (void) strcpy(c2, c1);
 
2573
                                (void) strcat(c2, "\n");
 
2574
                                (void) XtFree(c1);
 
2575
                                c1 = c2;
 
2576
                            } else {
 
2577
                                /* create the initial string of "\n"...
 
2578
                                 */
 
2579
                                c1 = XtMalloc(strlen("\n") + 1);
 
2580
                                (void) strcpy(c1, "\n");
 
2581
                            }
 
2582
                            break;
 
2583
 
 
2584
                        default:
 
2585
                            /* ignore everything else...
 
2586
                             */
 
2587
                            break;
 
2588
                        }
 
2589
                    }
 
2590
 
 
2591
                UxUpdateRotatingBuffer(&BufferIndex, 
 
2592
                                        &RotatingBuffer, c1, XtFree);
 
2593
                *udata = RotatingBuffer[BufferIndex];
 
2594
                (void) XmStringFreeContext(context);
 
2595
                }
 
2596
        }
 
2597
        else if (flag == TO_X)
 
2598
        {
 
2599
                *xdata = XmStringLtoRCreate (*udata, XmSTRING_DEFAULT_CHARSET);
 
2600
        }
 
2601
        else
 
2602
        {
 
2603
                UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2604
                return ERROR;
 
2605
        }
 
2606
        return NO_ERROR;
 
2607
}
 
2608
 
 
2609
/******************************************************************************
 
2610
NAME:           int             string_HistoryItems(sw, udata, xdata, flag)
 
2611
                int             string_Items(sw, udata, xdata, flag)
 
2612
                int             string_ListItems(sw, udata, xdata, flag)
 
2613
                int             string_SelectedItems(sw, udata, xdata, flag)
 
2614
                int             string_DirListItems(sw, udata, xdata, flag)
 
2615
                int             string_FileListItems(sw, udata, xdata, flag)
 
2616
INPUT:          swidget         sw              - swidget
 
2617
                char            **udata         - string representation
 
2618
                XmString        **xdata         - Motif StringTable
 
2619
                int             flag            - TO_UIMX or TO_X
 
2620
RETURN:         ERROR/NO_ERROR
 
2621
DESCRIPTION:    Uses the resource converter to convert between a string table
 
2622
                represented as a single string with entries separated by
 
2623
                commas, and a Motif XmStringTable. 
 
2624
CREATION:       18 April 1990
 
2625
REVISION:       29 Janvier 1991
 
2626
                -- Added new conversion routines for dirListItems and
 
2627
                fileListItems.
 
2628
-----------------------------------------------------------------------------*/
 
2629
 
 
2630
 
 
2631
static  int     string_HistoryItems(sw, udata, xdata, flag)
 
2632
        swidget   sw;
 
2633
        char      **udata;
 
2634
        XmString  **xdata;
 
2635
        int       flag;
 
2636
{
 
2637
        return string_XmStringTable(XmNhistoryItemCount,sw, udata, xdata, flag);
 
2638
}
 
2639
 
 
2640
static  int     string_Items(sw, udata, xdata, flag)
 
2641
        swidget   sw;
 
2642
        char      **udata;
 
2643
        XmString  **xdata;
 
2644
        int       flag;
 
2645
{
 
2646
        return string_XmStringTable(XmNitemCount, sw, udata, xdata, flag);
 
2647
}
 
2648
 
 
2649
static  int     string_ListItems(sw, udata, xdata, flag)
 
2650
        swidget   sw;
 
2651
        char      **udata;
 
2652
        XmString  **xdata;
 
2653
        int       flag;
 
2654
{
 
2655
        return string_XmStringTable(XmNlistItemCount, sw, udata, xdata, flag);
 
2656
}
 
2657
 
 
2658
static  int     string_SelectedItems(sw, udata, xdata, flag)
 
2659
        swidget   sw;
 
2660
        char      **udata;
 
2661
        XmString  **xdata;
 
2662
        int       flag;
 
2663
{
 
2664
        return string_XmStringTable(XmNselectedItemCount,sw,udata, xdata, flag);
 
2665
}
 
2666
 
 
2667
static  int     string_FileListItems(sw, udata, xdata, flag)
 
2668
        swidget   sw;
 
2669
        char      **udata;
 
2670
        XmString  **xdata;
 
2671
        int       flag;
 
2672
{
 
2673
        return string_XmStringTable(XmNfileListItemCount, sw, udata, xdata, flag);
 
2674
}
 
2675
 
 
2676
static  int     string_DirListItems(sw, udata, xdata, flag)
 
2677
        swidget   sw;
 
2678
        char      **udata;
 
2679
        XmString  **xdata;
 
2680
        int       flag;
 
2681
{
 
2682
        return string_XmStringTable(XmNdirListItemCount, sw, udata, xdata, flag);
 
2683
}
 
2684
 
 
2685
 
 
2686
/*----------------------------------------------------------------------
 
2687
 * NAME:        <int     string_XmStringTable(pname, sw, udata, xdata, flag)>
 
2688
 * DESCRIPTION: <Uses the resource converter to convert between a string table
 
2689
                represented as a single string with entries separated by 
 
2690
                commas, and a Motif XmStringTable. For the TO_UIMX case, 
 
2691
   a rotating buffer will contain the strings. For the first pass, the buffer
 
2692
   is filled up to its size and for the subsequent strings to be stored, the
 
2693
   location is first reallocated before the new string takes its place. 
 
2694
   Every time the buffer index reaches the size of the buffer, it is reset 
 
2695
   to 0 to create the rotating buffer. This way, we avoid system crashes
 
2696
   because the pointer will always point to valid memory addresses but
 
2697
   the memory content may not be the right one if the user waited too long
 
2698
   (more than "size of buffer" calls to this converter) before using the value
 
2699
   returned.> 
 
2700
 * PARAMETERS: 
 
2701
                char            *pname          - the XmN property name
 
2702
                swidget         sw              - swidget
 
2703
                char            **udata         - string representation
 
2704
                XmString        **xdata         - Motif StringTable
 
2705
                int             flag            - TO_UIMX or TO_X
 
2706
 *              parameter       [I|I/O|O]       parameter_description
 
2707
 * RETURN:      ERROR/NO_ERROR  
 
2708
 * EXT REFS:    globals_used
 
2709
 * EXT EFFECTS: globals or other things altered
 
2710
 * ASSUMPTIONS:
 
2711
 * REVISIONS:   05/07/89        creation
 
2712
                xx/05/92        fix3571 runtime library rewrite         
 
2713
                dd/mm/yy        fix#    fix_description
 
2714
 *--------------------------------------------------------------------*/
 
2715
static  int     string_XmStringTable(pname, sw, udata, xdata, flag)
 
2716
        char      *pname;
 
2717
        swidget   sw;
 
2718
        char      **udata;
 
2719
        XmString  **xdata;
 
2720
        int       flag;
 
2721
{
 
2722
        if (flag == TO_UIMX)
 
2723
        {
 
2724
            Arg     a[1];
 
2725
            int     i, n;
 
2726
            Widget  w;
 
2727
            char    *t = "";
 
2728
 
 
2729
            static char **RotatingBuffer;
 
2730
            static int BufferIndex = -1;
 
2731
 
 
2732
            /* First determine the size of the string table, by asking
 
2733
               the widget for its item count; the item count property
 
2734
               name was passed in as pname */
 
2735
 
 
2736
            w = UxGetWidget(sw);
 
2737
 
 
2738
            if (!w)
 
2739
            {
 
2740
                *udata = "";
 
2741
                return NO_ERROR;
 
2742
            }
 
2743
 
 
2744
            XtSetArg(a[0], pname, &n);
 
2745
            XtGetValues(w, a, 1);
 
2746
 
 
2747
            if (n == 0)
 
2748
            {
 
2749
                *udata = "";
 
2750
                return NO_ERROR;
 
2751
            }
 
2752
 
 
2753
            /* Now construct a uimx string in which the x strings of the     */
 
2754
            /* string table are concatenated, separated by commas.  Commas   */
 
2755
            /* inside an X string have to be escaped with a double backslash */
 
2756
            /* in the uimx string.  We do not worry about \n characters in   */
 
2757
            /* any of the XmStrings, since this would not be appropriate for */
 
2758
            /* a list.                                                       */
 
2759
 
 
2760
            for (i=0; i<n; i++)
 
2761
            {
 
2762
                XmString xm;
 
2763
                char     *s, *sp, *tp;
 
2764
                int      j, comma_count;
 
2765
 
 
2766
                xm = (*xdata)[i];
 
2767
                string_XmString(sw, &s, &xm, TO_UIMX);
 
2768
 
 
2769
                /* Count the number of commas, so we know how much space   */
 
2770
                /* to allocated for the resulting uimx string              */
 
2771
 
 
2772
                comma_count = 0;
 
2773
                for (j=0; s[j]; j++)
 
2774
                    if (s[j] == ',')
 
2775
                        comma_count++;
 
2776
 
 
2777
                /* Allocate or reallocate the uimx string array used to    */
 
2778
                /* accumulate the x strings                                */
 
2779
 
 
2780
                if (i==0)
 
2781
                {
 
2782
                    t = UxMalloc(strlen(s) + comma_count + 1);
 
2783
                    tp = t;
 
2784
                }
 
2785
                else
 
2786
                {
 
2787
                    int len = strlen(t);
 
2788
 
 
2789
                    t = UxRealloc(t, len + strlen(s) + comma_count + 2);
 
2790
                    tp = &t[len];
 
2791
                    *tp++ = ',';        /* a comma separates the x strings */
 
2792
                }
 
2793
 
 
2794
                /* Add the current x string onto the end of the uimx string, */
 
2795
                /* escaping commas with double backslashes                   */
 
2796
 
 
2797
                sp = s;
 
2798
                while (*sp)
 
2799
                {
 
2800
                    if (*sp == ',')
 
2801
                        *tp++ = '\\';
 
2802
                    *tp++ = *sp++;
 
2803
                }
 
2804
                *tp = '\0';
 
2805
            }
 
2806
            UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, t, UxFree);
 
2807
            *udata = RotatingBuffer[BufferIndex];
 
2808
        }
 
2809
        else if (flag == TO_X)
 
2810
        {
 
2811
            XrmValue    from_val, to_val;
 
2812
 
 
2813
            from_val.addr = *udata;
 
2814
 
 
2815
            /* note: in _string_XmStringTable(), the args and num_args  */
 
2816
            /* parameters and from_val.size are not used.               */
 
2817
            _string_XmStringTable(NULL, NULL, &from_val, &to_val);
 
2818
 
 
2819
            *xdata = *((XmString **)(to_val.addr));
 
2820
        }
 
2821
        else
 
2822
        {
 
2823
            UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2824
            return ERROR;
 
2825
        }
 
2826
        return NO_ERROR;
 
2827
}
 
2828
 
 
2829
/******************************************************************************
 
2830
NAME:           int     stringTable_WidgetList (sw, udata, xdata, flag)
 
2831
INPUT:          swidget         sw              - swidget
 
2832
                stringTable     *udata          - UIM/X string table
 
2833
                WidgetList      *xdata          - Motif WidgetList
 
2834
                int             flag            - TO_UIMX or TO_X
 
2835
RETURN:         ERROR/NO_ERROR
 
2836
DESCRIPTION:    Converts from a Motif WidgetList to a UIM/X stringTable, i.e.
 
2837
                an array of widget names.
 
2838
CREATION:       January 28/1991
 
2839
-----------------------------------------------------------------------------*/
 
2840
 
 
2841
static  int     stringTable_WidgetList (sw, udata, xdata, flag)
 
2842
        swidget         sw;
 
2843
        stringTable     *udata;
 
2844
        WidgetList      *xdata;
 
2845
        int             flag;
 
2846
{
 
2847
        if (flag == TO_X)
 
2848
        {
 
2849
            /* Function is only used to convert to UIM/X */
 
2850
            *udata = (stringTable) NULL;
 
2851
            return ERROR;
 
2852
        }
 
2853
        else if (flag == TO_UIMX)
 
2854
        {
 
2855
            Widget w;
 
2856
            WidgetList wList;
 
2857
            static stringTable wNames = (stringTable) NULL;
 
2858
            char     *wName;
 
2859
            static int wNum = 0;
 
2860
            int i;
 
2861
 
 
2862
            w = UxGetWidget(sw);
 
2863
 
 
2864
            for (i=0; i < wNum; i++)
 
2865
                UxFree (wNames[i]);
 
2866
                
 
2867
            XtVaGetValues (w,
 
2868
                           XmNchildren, &wList,
 
2869
                           XmNnumChildren, &wNum,
 
2870
                           NULL);
 
2871
 
 
2872
            wNames = (stringTable) UxRealloc (wNames,
 
2873
                                        wNum * sizeof(wName));  
 
2874
            for (i = 0; i < wNum; i++)
 
2875
            {
 
2876
                        wNames[i] = (char *) UxMalloc (strlen (XtName (wList[i]) )+1);
 
2877
                        strcpy (wNames[i], XtName (wList[i]));
 
2878
            }
 
2879
            *udata = wNames;
 
2880
            return NO_ERROR;
 
2881
        }
 
2882
        else
 
2883
        {
 
2884
            UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
 
2885
            return ERROR;
 
2886
        }
 
2887
}
 
2888
 
 
2889
 
 
2890
/* ---------------------------------------------------------------------------
 
2891
NAME:           UxUtype_init()
 
2892
INPUT:          ---
 
2893
OUTPUT:         ---
 
2894
RETURNS:        void
 
2895
DESCRIPTION:    Adds UIMX types, X types and converters.
 
2896
                UIMX should call this function at startup time.
 
2897
CREATION:       May 11 1988  Visual Edge Software
 
2898
LAST REV:       August 1, 1991          See bugfix 2857
 
2899
                - Added new type and converter for UxXT_BorderPixmap
 
2900
---------------------------------------------------------------------------*/
 
2901
void UxUtype_init()
 
2902
{
 
2903
        char    **font_names;
 
2904
        int     num_fonts;
 
2905
        void    UxInitEnumTypes();
 
2906
 
 
2907
        /* UIMX types */
 
2908
 
 
2909
        UxUT_float      = UxAdd_utype("float", sizeof(float), T_FLOAT);
 
2910
        UxUT_int        = UxAdd_utype("int", sizeof(int), T_INT);
 
2911
        UxUT_short      = UxAdd_utype("short", sizeof(short), T_SHORT);
 
2912
        UxUT_string     = UxAdd_utype("string", sizeof(char*), T_PNTR);
 
2913
        UxUT_vhandle    = UxAdd_utype("vhandle", sizeof(char*), T_STRUCT);
 
2914
        UxUT_char       = UxAdd_utype("char", sizeof (char), T_CHAR);
 
2915
        UxUT_long       = UxAdd_utype("long", sizeof (long), T_LONG);
 
2916
        UxUT_stringTable = UxAdd_utype("stringTable", sizeof(char**), T_PNTR);
 
2917
        UxUT_cardFunction = UxAdd_utype("cardFunction", sizeof(Cardinal (*)()),
 
2918
                                                                T_PNTR);
 
2919
        UxUT_voidFunction = UxAdd_utype("voidFunction", sizeof(void (*)()), 
 
2920
                                                                T_PNTR);
 
2921
        UxUT_visualPointer = UxAdd_utype("visualPointer", 
 
2922
                                         sizeof(Visual *),
 
2923
                                         T_PNTR);
 
2924
        UxUT_XmTextSource = UxAdd_utype("XmTextSource", 
 
2925
                                         sizeof(XmTextSource),
 
2926
                                         T_PNTR);
 
2927
 
 
2928
        /* Add the xtypes and register the converters for enumerated-types */
 
2929
        UxInitEnumTypes();
 
2930
 
 
2931
 
 
2932
        /* X types in alphabetical order */
 
2933
 
 
2934
        UxXT_Atom       = UxAddXtype("Atom",           sizeof(Atom));
 
2935
        UxXT_Dimension  = UxAddXtype(XtRDimension,      sizeof(Dimension));
 
2936
        UxXT_FontStruct = UxAddXtype(XtRFontStruct,     sizeof(XFontStruct*));
 
2937
        UxXT_KeySym     = UxAddXtype(XmRKeySym,         sizeof (KeySym));
 
2938
        UxXT_Pixel      = UxAddXtype(XtRPixel,  sizeof(Pixel));
 
2939
        UxXT_Pixmap     = UxAddXtype(XtRPixmap,         sizeof(Pixmap));
 
2940
        UxXT_Pointer    = UxAddXtype("Pointer",         sizeof(caddr_t));
 
2941
        UxXT_BorderPixmap = UxAddXtype("BorderPixmap", sizeof(Pixmap));
 
2942
        UxXT_HighlightPixmap = UxAddXtype("HighlightPixmap", sizeof(Pixmap));
 
2943
        UxXT_TopShadowPixmap = UxAddXtype("TopShadowPixmap", sizeof(Pixmap));
 
2944
        UxXT_BottomShadowPixmap
 
2945
                = UxAddXtype("BottomShadowPixmap",      sizeof(Pixmap));
 
2946
        UxXT_bitmap     = UxAddXtype("bitmap",  sizeof(Pixmap));
 
2947
        UxXT_Position   = UxAddXtype(XtRPosition,       sizeof(Position));
 
2948
        UxXT_String     = UxAddXtype(XtRString,         sizeof(char*));
 
2949
        UxXT_StringTable = UxAddXtype("StringTable",    sizeof (char **));
 
2950
        UxXT_InsertPosition 
 
2951
                = UxAddXtype("InsertPosition",  sizeof(Cardinal (*)()));
 
2952
        UxXT_CreatePopupChildProc 
 
2953
                = UxAddXtype("CreatePopupChildProc",    sizeof(void (*)()));
 
2954
        UxXT_FileSearchProc 
 
2955
                = UxAddXtype("FileSearchProc",  sizeof(void (*)()));
 
2956
        UxXT_QualifySearchDataProc 
 
2957
                = UxAddXtype("QualifySearchDataProc",  sizeof(void (*)()));
 
2958
        UxXT_DirSearchProc 
 
2959
                = UxAddXtype("DirSearchProc",           sizeof(void (*)()));
 
2960
        UxXT_Widget     = UxAddXtype("Widget",  sizeof(Widget));
 
2961
        UxXT_WidgetList = UxAddXtype("WidgetList",      sizeof(caddr_t));
 
2962
        UxXT_Window     = UxAddXtype(XtRWindow,         sizeof(Window));
 
2963
        UxXT_XID        = UxAddXtype("XID",             sizeof (XID));
 
2964
        UxXT_Translations = UxAddXtype("Translations", sizeof(caddr_t));
 
2965
        UxXT_Accelerators = UxAddXtype("Accelerators", sizeof(caddr_t));
 
2966
 
 
2967
        UxXT_HistoryItems = UxAddXtype("HistoryItems", sizeof(XmStringTable));
 
2968
        UxXT_Items = UxAddXtype(XmRItems,               sizeof(XmStringTable));
 
2969
        UxXT_ListItems = UxAddXtype("ListItems",        sizeof(XmStringTable));
 
2970
        UxXT_StringOrNull = UxAddXtype("StringOrNull",  sizeof(char *));
 
2971
 
 
2972
        UxXT_FileListItems = UxAddXtype("FileListItems",sizeof(XmStringTable));
 
2973
        UxXT_DirListItems = UxAddXtype("DirListItems", sizeof(XmStringTable));
 
2974
        UxXT_SelectedItems
 
2975
                = UxAddXtype(XmRSelectedItems,  sizeof(XmStringTable));
 
2976
        UxXT_SelectionArray
 
2977
                = UxAddXtype ("SelectionArray",         sizeof (XmTextScanType *));
 
2978
        UxXT_WidgetClass = UxAddXtype ("WidgetClass",   sizeof (WidgetClass));
 
2979
        UxXT_char = UxAddXtype ("char",                 sizeof (char));
 
2980
        UxXT_XmFontList = UxAddXtype (XmRFontList,      sizeof (XmFontList));
 
2981
        UxXT_XmString = UxAddXtype (XmRXmString,        sizeof (XmString));
 
2982
        UxXT_XmTextSource = UxAddXtype ("XmTextSource", sizeof (XmTextSource));
 
2983
        UxXT_Colormap = UxAddXtype ("Colormap", sizeof (Colormap));
 
2984
        UxXT_VisualPointer= UxAddXtype (XtRVisual, sizeof (Visual *));
 
2985
        UxXT_ValueWcs= UxAddXtype (XmRValueWcs, sizeof (wchar_t *));
 
2986
 
 
2987
        UxXT_short      = UxAddXtype("short",           sizeof(short));
 
2988
        UxXT_int        = UxAddXtype("int",             sizeof(int));
 
2989
 
 
2990
        font_names = XListFonts(UxDisplay, "*", 200, &num_fonts);
 
2991
        UxAdd_values(X_TYPE, UxXT_FontStruct, num_fonts, font_names);
 
2992
        XFreeFontNames(font_names);
 
2993
 
 
2994
        /* values in alphabetical order */
 
2995
 
 
2996
        UxAddXValues(UxXT_SelectionArray, uSelectionArray, 
 
2997
                xSelectionArray, XtNumber(uSelectionArray));
 
2998
 
 
2999
        /* converters in alphabetical order */
 
3000
 
 
3001
        UxAddConv(UxUT_string, UxXT_Atom, string_Atom);
 
3002
        UxAddConv(UxUT_int, UxXT_short, int_short);
 
3003
        UxAddConv(UxUT_int, UxXT_Position, int_Position);
 
3004
        UxAddConv(UxUT_int, UxXT_Dimension, int_Dimension);
 
3005
        UxAddConv(UxUT_long, UxXT_Colormap, long_Colormap);
 
3006
        UxAddConv(UxUT_short, UxXT_int, short_int);
 
3007
#ifndef RUNTIME
 
3008
        UxAddConv(UxUT_voidFunction, UxXT_CreatePopupChildProc, 
 
3009
                                        voidFunction_createPopupChildProc);
 
3010
        UxAddConv(UxUT_cardFunction, UxXT_InsertPosition, 
 
3011
                                        cardFunction_insertPosition);
 
3012
        UxAddConv(UxUT_voidFunction, UxXT_FileSearchProc, 
 
3013
                                        voidFunction_fileSearchProc);
 
3014
        UxAddConv(UxUT_voidFunction, UxXT_DirSearchProc, 
 
3015
                                        voidFunction_dirSearchProc);
 
3016
        UxAddConv(UxUT_voidFunction, UxXT_QualifySearchDataProc, 
 
3017
                                        voidFunction_qualifySearchDataProc);
 
3018
#endif /* ! RUNTIME */
 
3019
        UxAddConv(UxUT_string, UxXT_KeySym,   string_Keysym);
 
3020
        UxAddConv(UxUT_string, UxXT_Translations, string_translations);
 
3021
        UxAddConv(UxUT_string, UxXT_Accelerators, string_accelerators);
 
3022
        UxAddConv(UxUT_string, UxXT_FontStruct, string_FontStruct);
 
3023
 
 
3024
        UxAddConv(UxUT_string, UxXT_Pixel, string_Pixel);
 
3025
        UxAddConv(UxUT_string, UxXT_Pixmap, string_Pixmap);
 
3026
        UxAddConv(UxUT_string, UxXT_Pointer, string_Pointer);
 
3027
        UxAddConv(UxUT_string, UxXT_BorderPixmap, string_BorderPixmap);
 
3028
        UxAddConv(UxUT_string, UxXT_HighlightPixmap, string_HighlightPixmap);
 
3029
        UxAddConv(UxUT_string, UxXT_TopShadowPixmap, string_TopShadowPixmap);
 
3030
        UxAddConv(UxUT_string, UxXT_BottomShadowPixmap,
 
3031
                                                string_BottomShadowPixmap);
 
3032
        UxAddConv(UxUT_string, UxXT_bitmap, string_bitmap);
 
3033
        UxAddConv(UxUT_string, UxXT_StringOrNull, string_StringOrNull);
 
3034
        UxAddConv(UxUT_string, UxXT_String, string_String);
 
3035
        UxAddConv(UxUT_string, UxXT_ValueWcs, string_ValueWcs);
 
3036
        UxAddConv(UxUT_string, UxXT_Widget, string_Widget);
 
3037
        UxAddConv(UxUT_string, UxXT_Window, string_Window);
 
3038
        UxAddConv(UxUT_string, UxXT_XID, string_XID);
 
3039
        UxAddConv(UxUT_string, UxXT_HistoryItems, string_HistoryItems);
 
3040
        UxAddConv(UxUT_string, UxXT_Items, string_Items);
 
3041
        UxAddConv(UxUT_string, UxXT_ListItems, string_ListItems);
 
3042
        UxAddConv(UxUT_string, UxXT_FileListItems, string_FileListItems);
 
3043
        UxAddConv(UxUT_string, UxXT_DirListItems, string_DirListItems);
 
3044
        UxAddConv(UxUT_string, UxXT_SelectedItems, string_SelectedItems);
 
3045
        UxAddConv(UxUT_string, UxXT_SelectionArray, string_SelectionArray);
 
3046
        UxAddConv(UxUT_string, UxXT_WidgetClass, string_WidgetClass);
 
3047
        UxAddConv(UxUT_string, UxXT_XmFontList, string_XmFontList);
 
3048
        UxAddConv(UxUT_string, UxXT_XmString, string_XmString);
 
3049
        UxAddConv(UxUT_stringTable, UxXT_WidgetList, stringTable_WidgetList);
 
3050
 
 
3051
        /********************************************************
 
3052
         * At this moment we are ready to add any new xtypes    *
 
3053
         * and converter the users wants.                       *
 
3054
         ********************************************************/
 
3055
 
 
3056
        UxAddUserDefXtypes();
 
3057
 
 
3058
        /* We register our string-to-XmStringTable converter with Xt */
 
3059
 
 
3060
        XtAppAddConverter(UxAppContext, XmRString, XmRXmStringTable,
 
3061
                                        _string_XmStringTable, NULL, 0);
 
3062
}
 
3063
 
 
3064
 
 
3065
/*----------------------------------------------------------------------
 
3066
 * NAME:        <void UxUpdateRotatingBuffer(BufIndex, RingBuffer, Val, func)>
 
3067
 * DESCRIPTION: <This function copies the value Val at position BufIndex in the
 
3068
             RingBuffer and then destroys the value Val using function func.
 
3069
             The ring buffer is allocated the first time the function is entered
 
3070
             with Bufindex = -1 and space is reallocated for the specified 
 
3071
             BufIndex. When BufIndex reaches the end of the buffer, it is set
 
3072
             back to 0 to create the effect of the ring buffer.> 
 
3073
 * PARAMETERS: 
 
3074
                int *BufIndex;           - index in the ring buffer 
 
3075
                char ***RingBuffer;      - ring buffer 
 
3076
                char *Val;               - value to store
 
3077
                func_ptr func;           - function to free variable Val
 
3078
 * RETURN:      nothing 
 
3079
 * EXT REFS:    UxRingBufferSize        
 
3080
 * EXT EFFECTS: globals or other things altered
 
3081
 * ASSUMPTIONS:
 
3082
 * REVISIONS:   19/11/92        creation        
 
3083
                dd/mm/yy        fix#    fix_description
 
3084
 *--------------------------------------------------------------------*/
 
3085
void UxUpdateRotatingBuffer(BufIndex, RingBuffer, Val, free_func)
 
3086
int *BufIndex;
 
3087
char ***RingBuffer;
 
3088
char *Val;
 
3089
func_ptr free_func;
 
3090
{
 
3091
            if (*BufIndex == -1)
 
3092
               *RingBuffer = (char **) UxMalloc(UxRingBufferSize * sizeof(char *));
 
3093
            (*BufIndex)++;              
 
3094
            if (*BufIndex >= UxRingBufferSize)
 
3095
               *BufIndex = 0;
 
3096
           if (!Val)
 
3097
           {
 
3098
                (*RingBuffer)[*BufIndex] = 
 
3099
                        UxRealloc((*RingBuffer)[*BufIndex], 1);
 
3100
                (*RingBuffer)[*BufIndex][0] = '\0';     
 
3101
                return;
 
3102
           }    
 
3103
           (*RingBuffer)[*BufIndex] = 
 
3104
               UxRealloc((*RingBuffer)[*BufIndex], strlen(Val) + 1);
 
3105
            strcpy((*RingBuffer)[*BufIndex], Val);
 
3106
            free_func(Val);
 
3107
}