1
/*---------------------------------------------------------------------
2
* $Date: 2009-08-18 15:23:20 $ $Revision: 1.2 $
3
*---------------------------------------------------------------------
6
* Copyright (c) 1992, Visual Edge Software Ltd.
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
*-------------------------------------------------------------------*/
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 :
24
UxUimx_x[uimx_type][x_type]
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>.
30
The general format for these conversion routines is:
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.
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
43
there is a 5th argument which is the x_type, but most of the
44
converters only have the above 4 arguments.
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
53
-- added National Language Support
55
-- moved enumerated-type resources to enum_type.c
60
-----------------------------------------------------------------------------*/
62
/*--- include files ---*/
67
/* CG. Not needed and values.h does not exist on VMS
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>
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>
95
#include <Xm/LabelG.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>
110
#include <Xm/TextF.h>
111
#include <Xm/ToggleB.h>
112
#include <Xm/ToggleBG.h>
122
#include "textF.cl.h"
124
#include "tkdefaults.h"
132
#endif /* ! RUNTIME */
141
#include "uimx_cat.h"
142
#include "misc1_ds.h"
145
/*--- macro symbolic constants ---*/
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)
153
/*--- external functions ---*/
155
extern int UxStrEqual(), UxLoadPixmapFromPixmapOrBitmapFile();
156
extern int Ux_wcslen();
157
extern void UxSwidgetSetWinGroupFlag(), UxSwidgetUnsetWinGroupFlag();
158
extern void UxAddXValues(), UxAddUserDefXtypes();
161
/*--- external variables ---*/
163
/*--- global variables ---*/
165
/*--- file global variables ---*/
166
M_FILE_VERSION("$Header")
167
int UxConvertMaxStringTable = 10;
168
int UxRingBufferSize = 10; /* size for converters rotating buffers */
170
/*--- forward declaration of static functions ---*/
171
static int string_XmStringTable
172
UXPROTO((char*, swidget, char**, XmString**, int));
174
/*------------------------------------------------------------
176
*-----------------------------------------------------------*/
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
-----------------------------------------------------------------------------*/
196
static Boolean GetNextString(n, src, dst)
203
/* if we have hit the end of the src, we are done... */
207
/* skip the comma which separates entries later than the first
208
* from their successor
210
if ((n > 0) && (**src == ','))
213
/* skip leading white space... */
214
while (**src && isspace(**src))
217
/* allocate space for the src and start copying. This space
218
* needs to be freed after it is used...
220
*dst = (char *) UxMalloc(strlen(*src) + 1);
224
/* look for quoted ','s... */
225
if ((**src == '\\') && (*((*src) + 1) == ',')) {
229
/* look for terminating (unquoted) ','s... */
230
else if (**src == ',') {
232
/* do not increment src pointer; the next component will */
233
/* start with a comma */
236
/* otherwise it is a straight character... */
242
/* we hit the end of the original src, so we need to null
243
* terminate our target...
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
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
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
-----------------------------------------------------------------------------*/
268
static void _string_XmStringTable(args, num_args, from_val, to_val)
274
static int MaxStringTable = 0;
275
static XmStringTable *tableList = (XmStringTable *) 0;
276
static int CurrentStringTable = 0;
277
static Boolean StringTableFull = False;
280
XmStringTable *tmpTableList = (XmStringTable *) 0;
284
/* the lower limit for string tables will be 10... */
285
if (UxConvertMaxStringTable < 10)
286
UxConvertMaxStringTable = 10;
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...
298
for (i = 0; i < MaxStringTable; i++) {
299
tmpTableList[i] = tableList[(i +
300
CurrentStringTable) % MaxStringTable];
302
CurrentStringTable = MaxStringTable;
305
/* The table is not full, so just copy the first
306
* CurrentStringTable entries...
308
for (i = 0; i < CurrentStringTable; i++) {
309
tmpTableList[i] = tableList[i];
313
(void) UxFree(tableList);
315
tableList = tmpTableList;
316
MaxStringTable = UxConvertMaxStringTable;
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]);
324
(void) UxFree(tableList[CurrentStringTable]);
327
c = (char *) from_val->addr;
329
tableList[CurrentStringTable] =
330
(XmStringTable) UxMalloc(max * sizeof(XmString));
332
for (i = 0; GetNextString(i, &c, &curr); i++) {
335
tableList[CurrentStringTable] =
336
(XmStringTable) UxRealloc(tableList[CurrentStringTable],
337
max * sizeof(XmString));
339
tableList[CurrentStringTable][i] =
340
XmStringCreateLtoR(curr, XmSTRING_DEFAULT_CHARSET);
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));
350
/* null terminate the array... */
351
tableList[CurrentStringTable][i] = (XmString) NULL;
353
/* set up the return value... */
354
to_val->addr = (caddr_t) &tableList[CurrentStringTable];
355
to_val->size = sizeof(caddr_t);
357
/* increment the CurrentStringTable... */
358
(void) CurrentStringTable++;
359
if (CurrentStringTable >= MaxStringTable) {
360
CurrentStringTable = 0;
361
StringTableFull = True;
365
/* ------------------------------------------------------------------------*/
367
static char * uSelectionArray[] = {
368
"select_position", "select_whitespace",
369
"select_word", "select_line",
370
"select_all" , "select_paragraph"
372
static XmTextScanType xSelectionArray[] = {
373
XmSELECT_POSITION, XmSELECT_WHITESPACE,
374
XmSELECT_WORD, XmSELECT_LINE,
375
XmSELECT_ALL, XmSELECT_PARAGRAPH
379
int UxValuesOfSelectionArray(lst, n)
383
static char *values[7] = {
386
" select_whitespace",
390
" select_paragraph"};
392
static int first_time = 1;
396
values[0] = UxCopyString(CGETS(MS_MISC_SELECTARRAY_ERR,
397
DS_MS_MISC_SELECTARRAY_ERR));
406
/******************************************************************************
407
==== GLOBAL =================================================================
408
*******************************************************************************
409
NAME: int UxValidateSelectionArray(rs, s)
411
INPUT: rswidget *rs - text/textF widget
412
char *s - selection array variable
414
RETURN: ERROR / NO_ERROR
416
REVISIONS: Jul 16/1990
417
- fixed logic of strtok loop
418
-----------------------------------------------------------------------------*/
420
int UxValidateSelectionArray(rs, s)
426
int d, count, n = XtNumber(uSelectionArray);
430
/* a null string is invalid */
434
/* determine the array count:
435
* if there is a value in the swidget, take it;
436
* otherwise, use the default.
438
d = UX_DEFAULT_SELECTION_ARRAY_COUNT;
439
(void) UxFindValue (rs, UxGetRD_selectionArrayCount(rs), &d);
441
/* an empty string is valid if the array count is 0 */
443
return (d==0 ? NO_ERROR : ERROR);
445
/* create temporary copy of string to parse */
446
temp = UxMalloc(strlen(s) + 1);
447
(void) strcpy(temp, s);
449
/* check that each element of the array is valid, and count them */
450
c1 = strtok(temp, " ");
461
if (!strcmp(c1, uSelectionArray[i]))
469
/* one of the items in the array is invalid */
474
c1= strtok(NULL, " ");
477
/* free the temporary copy */
480
/* error occurs if array count is greater than the number of items */
481
return (d>count ? ERROR : NO_ERROR);
484
int UxValuesOfSelectionArrayCount(lst, n)
488
static char *values[1];
489
static int first_time = 1;
493
values[0] = UxCopyString(CGETS(MS_MISC_NUM_ELEM_SEL,
494
DS_MS_MISC_NUM_ELEM_SEL));
503
int UxValidateSelectionArrayCount(rs, d)
512
/* a negative count value is always wrong */
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 */
520
s = UX_DEFAULT_SELECTION_ARRAY;
521
(void) UxFindValue (rs, UxGetRD_selectionArray(rs), &s);
523
if (s == NULL || !s[0])
525
/* selectionArray string is empty or null, so count must be 0 */
533
/* determine the number of items in the selection array string */
534
/* and compare to the selectionArrayCount value */
536
/* create temp copy of string to parse */
537
temp = UxMalloc(strlen(s) + 1);
538
(void) strcpy(temp, s);
540
/* count the items in the string */
542
sp = strtok(temp, " ");
546
} while (sp = strtok(NULL, " "));
548
/* free the temporary copy */
552
/* error if array count is greater than # items in the array string */
553
return (d > n ? ERROR : NO_ERROR);
556
#endif /* ! RUNTIME */
558
/* ------------------------------------------------------------------------*/
560
static int _utype, _xtype;
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
570
DESCRIPTION: Converts between string and a String.
571
Xt-side NULL is converted to ""
572
UIM/X-side NULL is NOT allowed
574
CREATION: 31 July 1991 (fix2773)
576
-----------------------------------------------------------------------------*/
578
static int string_String(sw, udata, xdata, flag)
591
else if (flag == TO_X)
600
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
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.
619
CREATION: 31 July 1991 (fix2773)
620
-----------------------------------------------------------------------------*/
622
static int string_StringOrNull(sw, udata, xdata, flag)
635
else if (flag == TO_X)
640
if (UxStrEqual (*udata, ""))
641
*xdata = (char *) NULL;
647
UxStandardError(CGETS(MS_MISC_WRONG_FLAG,
648
DS_MS_MISC_WRONG_FLAG));
654
/*******************************************************************/
655
static int convert(from_name, from_size, from_addr, to_name, to_addr)
657
unsigned int from_size;
664
from.size = from_size;
665
from.addr = from_addr;
666
XtConvert(UxTopLevel, from_name, &from, to_name, &to);
668
/* check for conversion error... */
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)
679
* (int *) to_addr = * (unsigned char *) to.addr;
682
else if (to.size == sizeof (short))
684
* (int *) to_addr = * (short *) to.addr;
688
memcpy(to_addr, to.addr, to.size);
692
/*******************************************************************/
693
/* This function is probably not used any more and will have to be
695
In UxUtype_init(), remove line that adds string_FontStruct() converter
696
and lines that add types. (Dec. 01 1992)
698
/*******************************************************************/
699
static int string_FontStruct(sw, udata, xdata, flag)
707
else if (flag == TO_X)
708
return( convert(XtRString, strlen(*udata), *udata,
709
x_name(UxXT_FontStruct), xdata));
711
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
717
/*******************************************************************/
718
static int string_Pixel(sw, udata, xdata, flag)
726
*udata = UxPixel_to_name(*xdata);
728
else if (flag == TO_X)
730
/* Protect strlen from NULL */
733
return(convert(XtRString, strlen(*udata), *udata,
734
x_name(UxXT_Pixel), xdata));
740
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
746
/*******************************************************************/
748
/*******************************************************************/
749
static char **pixmap_names = (char **) 0;
750
static Pixmap *pixmaps = (Pixmap *) 0;
751
static int num_allocated = 0, num_used = 0;
753
static int store_pixmap(pixmap, name)
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);
771
if (num_used == num_allocated) {
773
pixmap_names = (char **) UxRealloc(pixmap_names,
774
num_allocated * sizeof(*pixmap_names));
775
pixmaps = (Pixmap *) UxRealloc(pixmaps,
776
num_allocated * sizeof(*pixmaps));
779
pixmaps[num_used] = pixmap;
780
pixmap_names[num_used] = (char *) UxMalloc(strlen(name) + 1);
781
strcpy(pixmap_names[num_used], name);
792
for (i = 0; i < num_used; i++)
793
if (pixmaps[i] == pixmap)
794
return(pixmap_names[i]);
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
-----------------------------------------------------------------------------*/
822
#define BOTTOMSHADOW 3
825
static int string_XmPixmap UXPROTO((int, swidget, char**, Pixmap*, int));
827
/*******************************************************************/
829
static int string_Pixmap(sw, udata, xdata, flag)
837
if(UxIsShellClass(UxGetClass(sw))){
839
if(UxIsExplicitShell(sw)) {
842
*xdata = XmUNSPECIFIED_PIXMAP;
845
return string_XmPixmap (PIXMAP, sw, udata, xdata, flag);
848
static int string_BorderPixmap(sw, udata, xdata, flag)
854
return string_XmPixmap (BORDER, sw, udata, xdata, flag);
857
static int string_HighlightPixmap(sw, udata, xdata, flag)
863
return string_XmPixmap (HIGHLIGHT, sw, udata, xdata, flag);
866
static int string_TopShadowPixmap(sw, udata, xdata, flag)
872
return string_XmPixmap (TOPSHADOW, sw, udata, xdata, flag);
875
static int string_BottomShadowPixmap(sw, udata, xdata, flag)
881
return string_XmPixmap (BOTTOMSHADOW, sw, udata, xdata, flag);
884
/* prop indicates how the foreground color will be chosen.
885
It is one of PIXMAP, HIGHLIGHT, BOTTOMSHADOW or TOPSHADOW */
887
static int string_XmPixmap(prop, sw, udata, xdata, flag)
896
*udata = get_pixmap((Pixmap) *xdata);
897
else if (flag == TO_X) {
900
Pixel UxName_to_pixel();
903
static char *unspecified_pixmap = "unspecified_pixmap";
906
pixmap_name = *udata;
907
/* deal with empty string... */
908
if (!pixmap_name || !*pixmap_name)
909
pixmap_name = unspecified_pixmap;
911
/* skip leading whitespace... */
912
while (isspace(*pixmap_name))
913
(void) pixmap_name++;
915
/* deal with blank string... */
917
pixmap_name = unspecified_pixmap;
919
if (!strcmp(pixmap_name, unspecified_pixmap)) {
920
/* set to unspecified (no) pixmap... */
921
*xdata = XmUNSPECIFIED_PIXMAP;
927
fname = UxExpandBitmapFilename(pixmap_name);
932
screen= XtScreen(UxTopLevel);
935
wid = UxGetWidget(sw);
936
if ( (wid) && (XmIsGadget(wid)))
937
wid = UxGetWidget(UxGetParent(sw));
940
wid = UxGetWidget(sw);
942
wid = UxGetWidget(UxGetParent(sw));
952
fg_resource = XmNforeground;
955
fg_resource = XmNhighlightColor;
958
fg_resource = XmNtopShadowColor;
961
fg_resource = XmNbottomShadowColor;
964
fg_resource = XmNborderColor;
967
fg_resource = XmNforeground;
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);
976
rtrn = UxLoadPixmapFromPixmapOrBitmapFile(sw,fname,&pixmap,0,0,
977
BlackPixel(UxDisplay, UxScreen),
978
WhitePixel(UxDisplay, UxScreen));
981
/* check for successful return... */
983
UxStandardError (CGETS( MS_MISC_NO_MATCH,
984
DS_MS_MISC_NO_MATCH));
988
store_pixmap(pixmap, pixmap_name);
993
UxStandardError(CGETS(MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
999
/*******************************************************************/
1000
static int string_bitmap(sw, udata, xdata, flag)
1006
if (flag == TO_UIMX)
1007
*udata = get_pixmap((Pixmap) *xdata);
1008
else if (flag == TO_X)
1013
unsigned int width, height;
1018
fname = UxExpandBitmapFilename(*udata);
1022
*xdata = (Pixmap)NULL;
1026
screen = DefaultScreen(UxDisplay);
1027
rw = RootWindow(UxDisplay, screen);
1029
if (XReadBitmapFile(UxDisplay,
1030
rw, fname, &width, &height,
1031
&pmap, &x, &x) != BitmapSuccess)
1035
store_pixmap(pmap, *udata);
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
-----------------------------------------------------------------------------*/
1050
static int string_Pointer(sw, udata, xdata, flag)
1056
if (flag == TO_UIMX) {
1057
*udata = (char*) *xdata;
1058
} else if (flag == TO_X) {
1059
*xdata = (caddr_t) *udata;
1061
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
1076
Xt-side NULL remains NULL on UIM/X side
1077
UIM/X-side NULL is allowed (remains NULL on Xt side)
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
-----------------------------------------------------------------------------*/
1087
static int string_ValueWcs(sw, udata, xdata, flag)
1093
static char **RotatingBuffer;
1094
static int BufferIndex = -1;
1097
if (flag == TO_UIMX)
1104
int next_size = Ux_wcslen(*xdata);
1107
buffer = UxMalloc(next_size * (MB_CUR_MAX > 0 ? MB_CUR_MAX : 1) + 1);
1109
buffer = UxMalloc(next_size * MB_CUR_MAX + 1);
1112
if (wcstombs(buffer, *xdata, next_size + 1) < 0) {
1117
UxUpdateRotatingBuffer
1118
(&BufferIndex, &RotatingBuffer, buffer, UxFree);
1119
*udata = RotatingBuffer[BufferIndex];
1122
else if (flag == TO_X)
1128
int next_size = strlen(*udata);
1130
buffer = UxMalloc((next_size + 1) * sizeof(wchar_t));
1132
if (mbstowcs((wchar_t *)buffer, *udata, next_size + 1)
1138
*xdata = (wchar_t *)buffer;
1144
(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
1150
/*******************************************************************/
1152
static int string_Widget(sw, udata, xdata, flag)
1160
if (flag == TO_UIMX)
1163
*udata = XtName( *xdata );
1167
else if (flag == TO_X)
1174
isswidget = UxIsSwidget((swidget) *udata);
1175
if ( ! isswidget && UxStrEqual (*udata, "")) {
1178
rs = isswidget ? * (swidget*) udata
1179
: UxNameToSwidget (sw,*udata);
1182
*xdata = rs ? UxGetWidget(rs) : NULL;
1184
*xdata = rs ? UxGetWidget(UxGetUserSwidget(rs)) : NULL;
1192
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
1198
static int string_Window (sw, udata, xdata, flag)
1206
if (flag == TO_UIMX)
1209
w = UxWindowToWidget(*xdata);
1211
rswidget *rs, *UxWindowToSwidget();
1213
rs = UxWindowToSwidget (*xdata);
1215
w = (Widget) UxGetWidget (rs);
1216
#endif /* RUNTIME */
1219
*udata = XtName( w );
1223
else if (flag == TO_X)
1225
if (*udata == NULL || **udata == '\0')
1228
* Handle the default case. Note that string_Window
1229
* converter is only used for the WindowGroup
1232
*xdata = XtUnspecifiedWindowGroup;
1235
else if (NO_ERROR == string_Widget (sw, udata, &w, flag)
1239
/* set the window group flag if widget pointing
1240
to itself (see bug866) */
1242
char *sw_name, *UxGetName();
1244
if((sw_name = UxGetName(sw)) &&
1245
(strcmp(sw_name,*udata) == 0))
1246
UxSwidgetSetWinGroupFlag(sw);
1248
UxSwidgetUnsetWinGroupFlag(sw);
1249
#endif /* RUNTIME */
1251
*xdata = XtWindow (w);
1258
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
1264
static int string_XID (sw, udata, xdata, flag)
1270
return string_Window (sw, udata, xdata, flag);
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.
1282
REVISIONS: 20 July 90 [bug705]
1283
-- translations are char*, with hidden table name.
1285
-- check first if UxTStringForX() returns a valid value.
1286
-----------------------------------------------------------------------------*/
1287
static int string_translations(sw, udata, xdata, flag)
1294
if (flag == TO_UIMX)
1299
else if (flag == TO_X)
1302
/* Make sure we strip the hidden name if any
1303
* before passing the string to XtParse...
1307
trans = UxTStringForX(*udata,sw);
1309
*xdata = (char *) XtParseTranslationTable(trans);
1312
*xdata = (char*) XtParseTranslationTable(*udata);
1314
#endif /* ! RUNTIME */
1320
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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.
1335
REVISIONS: 20 July 90 [bug705]
1336
-- translations are char*, with hidden table name.
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)
1348
if (flag == TO_UIMX)
1353
else if (flag == TO_X)
1358
acc = UxTStringForX(*udata,sw);
1360
*xdata = (char *) XtParseAcceleratorTable(acc);
1363
*xdata = (char*) XtParseAcceleratorTable(*udata);
1365
#endif /* ! RUNTIME */
1371
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
1389
CREATION: January 29 1991 (bug2032)
1391
-----------------------------------------------------------------------------*/
1393
static int voidFunction_GenericProc(sw, udata, xdata, flag, func)
1395
voidFunction *udata;
1396
voidFunction *xdata;
1401
if (flag == TO_UIMX)
1407
#endif /. RUNTIME ./
1409
else if (flag == TO_X)
1415
#endif /. RUNTIME ./
1419
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
1435
CREATION: January 29 1991 (bug2032)
1437
-----------------------------------------------------------------------------*/
1440
static int voidFunction_createPopupChildProc(sw, udata, xdata, flag)
1442
voidFunction *udata;
1443
voidFunction *xdata;
1449
func = ( voidFunction ) NULL;
1451
func = ( voidFunction ) UxCreatePopupChildProc;
1453
return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
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
1465
CREATION: January 29 1991 (bug2032)
1467
-----------------------------------------------------------------------------*/
1470
static int cardFunction_insertPosition(sw, udata, xdata, flag)
1472
cardFunction *udata;
1473
cardFunction *xdata;
1478
func = ( voidFunction ) NULL;
1480
func = ( voidFunction ) UxInsertPosition;
1482
return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
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
1494
CREATION: January 29 1991 (bug2032)
1496
-----------------------------------------------------------------------------*/
1499
static int voidFunction_fileSearchProc(sw, udata, xdata, flag)
1501
voidFunction *udata;
1502
voidFunction *xdata;
1507
func = ( voidFunction ) NULL;
1509
func = ( voidFunction ) UxFileSearchProc;
1511
return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
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
1523
CREATION: January 29 1991 (bug2032)
1525
-----------------------------------------------------------------------------*/
1528
static int voidFunction_dirSearchProc(sw, udata, xdata, flag)
1530
voidFunction *udata;
1531
voidFunction *xdata;
1536
func = ( voidFunction ) NULL;
1538
func = ( voidFunction ) UxDirSearchProc;
1540
return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
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
1552
CREATION: January 29 1991 (bug2032)
1554
-----------------------------------------------------------------------------*/
1557
static int voidFunction_qualifySearchDataProc(sw, udata, xdata, flag)
1559
voidFunction *udata;
1560
voidFunction *xdata;
1565
func = ( voidFunction ) NULL;
1567
func = ( voidFunction ) UxQualifySearchDataProc;
1569
return( voidFunction_GenericProc(sw, udata, xdata, flag, func));
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
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)
1597
/* Simply look up the conversion routine and call it */
1600
if (UxUimx_x[utype][xtype])
1601
return (UxUimx_x[utype][xtype])(sw, udata, xdata, flag, xtype);
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));
1608
UxInternalError(__FILE__, __LINE__,
1609
CGETS( MS_MISC_NO_CONV_ROUTINE,DS_MS_MISC_NO_CONV_ROUTINE),
1610
u_name(utype), x_name(xtype));
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.
1627
CREATION: Jan 93 fix3820 UxUimx_to_x renamed UxCallConverter
1628
---------------------------------------------------------------------------*/
1629
int UxUimx_to_x(sw, utype, udata, xtype, xdata, flag)
1637
return UxCallConverter(sw, utype, udata, xtype, xdata, flag);
1640
/*----------------------------------------------------------------------
1641
* NAME: < static int string_SelectionArray (sw, udata, xdata, flag,
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
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
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)
1672
XmTextScanType **xdata;
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;
1683
if (flag == TO_UIMX)
1690
/* get the current size of the selection array */
1692
w = UxGetWidget(sw);
1700
XtSetArg(a[0], "selectionArrayCount", &count);
1701
XtGetValues(w, a, 1);
1709
/* assemble the uimx strings into one string, separated by */
1712
for (i=0; i<count; i++)
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 */
1726
if (val == xconv[j])
1731
s = UxRealloc(s, strlen(s) + strlen(uconv[j]) + 2);
1733
strcat(s, uconv[j]);
1737
s = UxMalloc(strlen(uconv[j]) + 1);
1738
strcpy(s, uconv[j]);
1744
/* if the current array element was not found in the xconv */
1745
/* array, then it is invalid, and we return an error */
1749
/* the ith element of the array is invalid; we free the */
1750
/* string allocated so far and set the output to "" */
1758
UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, s, UxFree);
1759
*udata = RotatingBuffer[BufferIndex];
1762
else if (flag == TO_X)
1767
XmTextScanType array[20];
1770
/* protect strlen from NULL */
1771
if (!*udata) return ERROR;
1773
/* create temp copy of string to parse... */
1774
temp = XtMalloc(strlen(*udata) + 1);
1775
(void) strcpy(temp, *udata);
1778
for (array_length = 0; *c1 &&
1779
(array_length < (sizeof(array) / sizeof(array[0]))); )
1781
/* skip over leading whitespace... */
1782
while (isspace(*c1))
1785
/* skip to end of string... */
1787
while (*c2 && !isspace(*c2))
1790
/* null terminate this chunk... */
1794
/* find a match... */
1795
for (i = 0, match = 0; i < n; i++)
1797
if (strcmp(c1, uconv[i]) == 0)
1804
array[array_length++] = xconv[i];
1808
/* move to start of next chunk... */
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...
1815
*xdata = (XmTextScanType *)
1816
XtMalloc((unsigned) (array_length * sizeof(array[0])));
1817
(void) memcpy(*xdata, array, array_length * sizeof(array[0]));
1819
*xdata = (XmTextScanType *) NULL;
1822
/* now we can free the temp buffer... */
1827
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
1834
UxStandardError(CGETS( MS_MISC_NO_MATCH, DS_MS_MISC_NO_MATCH));
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.
1851
change to static function
1853
-- converter uses now 2 static arrays to do the conversion
1854
-----------------------------------------------------------------------------*/
1856
static int string_WidgetClass (sw, udata, xdata, flag)
1863
static char *uWidgetClass[] = {
1864
"arrowButtonGadget",
1867
"cascadeButtonGadget",
1892
"toggleButtonGadget",
1896
static WidgetClass *xWidgetClass[]= {
1897
&xmArrowButtonGadgetClass,
1898
&xmArrowButtonWidgetClass,
1899
&xmBulletinBoardWidgetClass,
1900
&xmCascadeButtonGadgetClass,
1901
&xmCascadeButtonWidgetClass,
1902
&xmCommandWidgetClass,
1903
&xmDrawingAreaWidgetClass,
1904
&xmDrawnButtonWidgetClass,
1905
&xmFileSelectionBoxWidgetClass,
1907
&xmFrameWidgetClass,
1908
&xmLabelGadgetClass,
1909
&xmLabelWidgetClass,
1911
&xmMainWindowWidgetClass,
1912
&xmMessageBoxWidgetClass,
1913
&xmPanedWindowWidgetClass,
1914
&xmPushButtonGadgetClass,
1915
&xmPushButtonWidgetClass,
1916
&xmRowColumnWidgetClass,
1917
&xmScaleWidgetClass,
1918
&xmScrollBarWidgetClass,
1919
&xmScrolledWindowWidgetClass,
1920
&xmSelectionBoxWidgetClass,
1921
&xmSeparatorGadgetClass,
1922
&xmSeparatorWidgetClass,
1924
&xmTextFieldWidgetClass,
1925
&xmToggleButtonGadgetClass,
1926
&xmToggleButtonWidgetClass,
1930
if (flag == TO_UIMX)
1934
int num = XtNumber(uWidgetClass);
1939
UxMalloc(strlen((*xdata)->core_class.class_name)+1);
1941
strcpy(pntr, (*xdata)->core_class.class_name);
1943
if ((pntr[0] == 'X') && (pntr[1] == 'm'))
1945
pntr[2] = tolower(pntr[2]);
1949
for (i=0; i < num; i++)
1952
if (strcmp(uWidgetClass[i], wclass) == 0)
1954
*udata = uWidgetClass[i];
1965
else if (flag == TO_X)
1967
int num = XtNumber(uWidgetClass);
1969
if (!strcmp(*udata, ""))
1971
*xdata = (WidgetClass) NULL;
1974
*xdata = (WidgetClass) NULL;
1975
for (i=0; i < num; i++)
1977
if (strcmp(uWidgetClass[i], *udata) == 0)
1979
*xdata = *xWidgetClass[i];
1986
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
-----------------------------------------------------------------------------*/
2003
static int int_Position(sw, udata, xdata, flag)
2009
if (flag == TO_UIMX) {
2010
*udata = (int) *xdata;
2011
} else if (flag == TO_X) {
2012
*xdata = (Position) *udata;
2014
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
-----------------------------------------------------------------------------*/
2030
static int long_Colormap(sw, udata, xdata, flag)
2036
if (flag == TO_UIMX) {
2037
*udata = (long) *xdata;
2038
} else if (flag == TO_X) {
2039
*xdata = (Colormap) *udata;
2041
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
-----------------------------------------------------------------------------*/
2058
static int int_Dimension(sw, udata, xdata, flag)
2064
if (flag == TO_UIMX) {
2065
*udata = (int) *xdata;
2066
} else if (flag == TO_X) {
2067
*xdata = (Dimension) *udata;
2069
UxStandardError(CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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.
2085
-----------------------------------------------------------------------------*/
2087
static int int_short(sw, udata, xdata, flag)
2093
if (flag == TO_UIMX)
2095
else if (flag == TO_X)
2099
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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.
2115
-----------------------------------------------------------------------------*/
2117
static int short_int(sw, udata, xdata, flag)
2123
if (flag == TO_UIMX)
2125
else if (flag == TO_X)
2129
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
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
2157
* LAST REVISION: March 15, 1993 Test for invalid zero value Atom
2158
*--------------------------------------------------------------------*/
2159
static int string_Atom(sw, udata, xdata, flag)
2165
if (flag == TO_UIMX) {
2167
static char **RotatingBuffer;
2168
static int BufferIndex = -1;
2171
atom_name = XGetAtomName(UxDisplay, *xdata);
2172
UxUpdateRotatingBuffer
2173
(&BufferIndex, &RotatingBuffer, atom_name,(func_ptr) XFree);
2174
*udata = RotatingBuffer[BufferIndex];
2179
else if (flag == TO_X)
2181
/* Create the atom if it does not exist */
2182
*xdata = XInternAtom(UxDisplay, *udata, False);
2185
UxStandardError(CGETS( MS_MISC_WRONG_FLAG,
2186
DS_MS_MISC_WRONG_FLAG));
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
-----------------------------------------------------------------------------*/
2204
static int string_Keysym (sw, udata, xdata, flag)
2210
if (flag == TO_UIMX)
2212
if (*xdata == NoSymbol)
2216
else if ((*udata = XKeysymToString (*xdata)) == NULL)
2222
else if (flag == TO_X)
2227
if (UxStrEqual (*udata, "")) {
2230
*xdata = XStringToKeysym (*udata);
2231
if (*xdata == NoSymbol)
2237
UxStandardError (CGETS( MS_MISC_WRONG_FLAG,
2238
DS_MS_MISC_WRONG_FLAG));
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
2253
The caller should not call XmFontListFree on the returned
2256
CREATION: 3 Avril 1992
2257
-----------------------------------------------------------------------------*/
2260
UxFontListCreate( udata, xdata)
2265
from.size = strlen( udata ) + 1;
2267
to.size = sizeof(XmFontList);
2268
to.addr = (caddr_t) xdata ;
2269
return( XtConvertAndStore( UxTopLevel, XmRString, &from,
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
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
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
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)
2308
if (flag == TO_UIMX)
2310
XFontStruct *font_struct;
2312
XmFontListEntry font_list_entry;
2313
XmFontType type_ret;
2314
XtPointer font_or_fontset;
2320
char *ListOfFonts = NULL;
2322
static char **RotatingBuffer;
2323
static int BufferIndex = -1;
2327
if (!XmFontListInitFontContext (&fc, *xdata))
2329
UxStandardError (CGETS( MS_MISC_WRONG_FLAG,
2330
DS_MS_MISC_WRONG_FLAG));
2334
while ((font_list_entry = XmFontListNextEntry (fc)) != NULL)
2336
font_or_fontset = XmFontListEntryGetFont(font_list_entry,
2338
if (type_ret == XmFONT_IS_FONT)
2340
font_struct = (XFontStruct *) font_or_fontset;
2341
XGetFontProperty(font_struct, XA_FONT, (unsigned long*)&ret);
2342
font = XGetAtomName(UxDisplay, (Atom)ret);
2344
else if (type_ret == XmFONT_IS_FONTSET)
2347
font_set = (XFontSet) font_or_fontset;
2348
font = XBaseFontNameListOfFontSet(font_set);
2350
while ((comma = strpbrk(comma,",")))
2356
if (ListOfFonts == NULL)
2358
ListOfFonts = UxMalloc(strlen(font) + 1);
2359
PtrInList = ListOfFonts;
2363
len = strlen(ListOfFonts);
2364
ListOfFonts = UxRealloc(ListOfFonts, len + strlen(font) + 2);
2365
PtrInList = &ListOfFonts[len];
2368
strcpy(PtrInList, font);
2370
font_tag = XmFontListEntryGetTag(font_list_entry);
2371
len = strlen(ListOfFonts);
2374
ListOfFonts = UxRealloc(ListOfFonts, len + strlen(font_tag) + 2);
2375
PtrInList = &ListOfFonts[len];
2376
if (type_ret == XmFONT_IS_FONT)
2378
else if (type_ret == XmFONT_IS_FONTSET)
2380
strcpy(PtrInList, font_tag);
2383
else if (type_ret == XmFONT_IS_FONTSET)
2385
ListOfFonts = UxRealloc(ListOfFonts, len + 2);
2386
PtrInList = &ListOfFonts[len];
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)
2396
XmFontListFreeFontContext (fc);
2398
/* if it is NULL, the first call to XmFontListNextEntry() returned
2399
NULL and we don't have a font list */
2402
UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer,
2403
ListOfFonts, UxFree);
2404
*udata = RotatingBuffer[BufferIndex];
2409
UxStandardError (CGETS( MS_MISC_WRONG_FLAG,
2410
DS_MS_MISC_WRONG_FLAG));
2414
*udata = ""; /* CAN'T CONVERT TO UIMX */
2417
else if (flag == TO_X)
2419
if (!strcmp(*udata, ""))
2420
*xdata = (XmFontList)NULL;
2423
if (!UxFontListCreate( *udata, xdata))
2424
*xdata = (XmFontList)NULL;
2430
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
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
2459
* REVISIONS: 04/07/89 creation
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
2466
- check for NULL string (no useful components) and
2469
-- Porting to Motif 1.1
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)
2480
if (flag == TO_UIMX)
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 */
2493
static char **RotatingBuffer;
2494
static int BufferIndex = -1;
2496
if (!XmStringInitContext(&context, *xdata))
2499
while (XmSTRING_COMPONENT_END != (type =
2500
XmStringGetNextComponent(context,
2501
&txt, &charset, &direction, &unknown_tag,
2502
&unknown_length, &unknown_value))) {
2505
case XmSTRING_COMPONENT_CHARSET:
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.
2518
/* The standard Motif distribution uses
2519
* #define XmSTRING_DEFAULT_CHARSET ""
2520
* so equality testing doesn't work.
2523
&& !strcmp(charset,XmSTRING_DEFAULT_CHARSET))
2525
/* The HP distribution uses
2526
* extern char* XmSTRING_DEFAULT_CHARSET
2527
* so we can test for pointer equality (much faster)
2530
(XmStringCharSet) XmSTRING_DEFAULT_CHARSET)
2531
#endif /* !defined(HP) */
2533
ignore_strings = False;
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.
2540
XtFree((char *) charset);
2543
case XmSTRING_COMPONENT_LOCALE_TEXT:
2544
case XmSTRING_COMPONENT_TEXT:
2548
/* concatenate the 2 strings...
2550
c2 = XtMalloc(strlen(c1) + strlen(txt) + 1);
2551
(void) strcpy(c2, c1);
2552
(void) strcat(c2, txt);
2557
/* txt was XtMalloc'ed by
2558
* XmStringGetNextComponent, so we don't need
2559
* to recreate it (we will need to free it
2566
case XmSTRING_COMPONENT_SEPARATOR:
2568
/* append a '\n' as the separator just like
2569
* XmStringCreateLtoR does...
2571
c2 = XtMalloc(strlen(c1) + strlen("\n") + 1);
2572
(void) strcpy(c2, c1);
2573
(void) strcat(c2, "\n");
2577
/* create the initial string of "\n"...
2579
c1 = XtMalloc(strlen("\n") + 1);
2580
(void) strcpy(c1, "\n");
2585
/* ignore everything else...
2591
UxUpdateRotatingBuffer(&BufferIndex,
2592
&RotatingBuffer, c1, XtFree);
2593
*udata = RotatingBuffer[BufferIndex];
2594
(void) XmStringFreeContext(context);
2597
else if (flag == TO_X)
2599
*xdata = XmStringLtoRCreate (*udata, XmSTRING_DEFAULT_CHARSET);
2603
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
2628
-----------------------------------------------------------------------------*/
2631
static int string_HistoryItems(sw, udata, xdata, flag)
2637
return string_XmStringTable(XmNhistoryItemCount,sw, udata, xdata, flag);
2640
static int string_Items(sw, udata, xdata, flag)
2646
return string_XmStringTable(XmNitemCount, sw, udata, xdata, flag);
2649
static int string_ListItems(sw, udata, xdata, flag)
2655
return string_XmStringTable(XmNlistItemCount, sw, udata, xdata, flag);
2658
static int string_SelectedItems(sw, udata, xdata, flag)
2664
return string_XmStringTable(XmNselectedItemCount,sw,udata, xdata, flag);
2667
static int string_FileListItems(sw, udata, xdata, flag)
2673
return string_XmStringTable(XmNfileListItemCount, sw, udata, xdata, flag);
2676
static int string_DirListItems(sw, udata, xdata, flag)
2682
return string_XmStringTable(XmNdirListItemCount, sw, udata, xdata, flag);
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
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
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)
2722
if (flag == TO_UIMX)
2729
static char **RotatingBuffer;
2730
static int BufferIndex = -1;
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 */
2736
w = UxGetWidget(sw);
2744
XtSetArg(a[0], pname, &n);
2745
XtGetValues(w, a, 1);
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 */
2767
string_XmString(sw, &s, &xm, TO_UIMX);
2769
/* Count the number of commas, so we know how much space */
2770
/* to allocated for the resulting uimx string */
2773
for (j=0; s[j]; j++)
2777
/* Allocate or reallocate the uimx string array used to */
2778
/* accumulate the x strings */
2782
t = UxMalloc(strlen(s) + comma_count + 1);
2787
int len = strlen(t);
2789
t = UxRealloc(t, len + strlen(s) + comma_count + 2);
2791
*tp++ = ','; /* a comma separates the x strings */
2794
/* Add the current x string onto the end of the uimx string, */
2795
/* escaping commas with double backslashes */
2806
UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, t, UxFree);
2807
*udata = RotatingBuffer[BufferIndex];
2809
else if (flag == TO_X)
2811
XrmValue from_val, to_val;
2813
from_val.addr = *udata;
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);
2819
*xdata = *((XmString **)(to_val.addr));
2823
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
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
-----------------------------------------------------------------------------*/
2841
static int stringTable_WidgetList (sw, udata, xdata, flag)
2849
/* Function is only used to convert to UIM/X */
2850
*udata = (stringTable) NULL;
2853
else if (flag == TO_UIMX)
2857
static stringTable wNames = (stringTable) NULL;
2859
static int wNum = 0;
2862
w = UxGetWidget(sw);
2864
for (i=0; i < wNum; i++)
2868
XmNchildren, &wList,
2869
XmNnumChildren, &wNum,
2872
wNames = (stringTable) UxRealloc (wNames,
2873
wNum * sizeof(wName));
2874
for (i = 0; i < wNum; i++)
2876
wNames[i] = (char *) UxMalloc (strlen (XtName (wList[i]) )+1);
2877
strcpy (wNames[i], XtName (wList[i]));
2884
UxStandardError (CGETS( MS_MISC_WRONG_FLAG, DS_MS_MISC_WRONG_FLAG));
2890
/* ---------------------------------------------------------------------------
2891
NAME: UxUtype_init()
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
---------------------------------------------------------------------------*/
2905
void UxInitEnumTypes();
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 (*)()),
2919
UxUT_voidFunction = UxAdd_utype("voidFunction", sizeof(void (*)()),
2921
UxUT_visualPointer = UxAdd_utype("visualPointer",
2924
UxUT_XmTextSource = UxAdd_utype("XmTextSource",
2925
sizeof(XmTextSource),
2928
/* Add the xtypes and register the converters for enumerated-types */
2932
/* X types in alphabetical order */
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 **));
2951
= UxAddXtype("InsertPosition", sizeof(Cardinal (*)()));
2952
UxXT_CreatePopupChildProc
2953
= UxAddXtype("CreatePopupChildProc", sizeof(void (*)()));
2955
= UxAddXtype("FileSearchProc", sizeof(void (*)()));
2956
UxXT_QualifySearchDataProc
2957
= UxAddXtype("QualifySearchDataProc", sizeof(void (*)()));
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));
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 *));
2972
UxXT_FileListItems = UxAddXtype("FileListItems",sizeof(XmStringTable));
2973
UxXT_DirListItems = UxAddXtype("DirListItems", sizeof(XmStringTable));
2975
= UxAddXtype(XmRSelectedItems, sizeof(XmStringTable));
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 *));
2987
UxXT_short = UxAddXtype("short", sizeof(short));
2988
UxXT_int = UxAddXtype("int", sizeof(int));
2990
font_names = XListFonts(UxDisplay, "*", 200, &num_fonts);
2991
UxAdd_values(X_TYPE, UxXT_FontStruct, num_fonts, font_names);
2992
XFreeFontNames(font_names);
2994
/* values in alphabetical order */
2996
UxAddXValues(UxXT_SelectionArray, uSelectionArray,
2997
xSelectionArray, XtNumber(uSelectionArray));
2999
/* converters in alphabetical order */
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);
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);
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);
3051
/********************************************************
3052
* At this moment we are ready to add any new xtypes *
3053
* and converter the users wants. *
3054
********************************************************/
3056
UxAddUserDefXtypes();
3058
/* We register our string-to-XmStringTable converter with Xt */
3060
XtAppAddConverter(UxAppContext, XmRString, XmRXmStringTable,
3061
_string_XmStringTable, NULL, 0);
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.>
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
3079
* EXT REFS: UxRingBufferSize
3080
* EXT EFFECTS: globals or other things altered
3082
* REVISIONS: 19/11/92 creation
3083
dd/mm/yy fix# fix_description
3084
*--------------------------------------------------------------------*/
3085
void UxUpdateRotatingBuffer(BufIndex, RingBuffer, Val, free_func)
3091
if (*BufIndex == -1)
3092
*RingBuffer = (char **) UxMalloc(UxRingBufferSize * sizeof(char *));
3094
if (*BufIndex >= UxRingBufferSize)
3098
(*RingBuffer)[*BufIndex] =
3099
UxRealloc((*RingBuffer)[*BufIndex], 1);
3100
(*RingBuffer)[*BufIndex][0] = '\0';
3103
(*RingBuffer)[*BufIndex] =
3104
UxRealloc((*RingBuffer)[*BufIndex], strlen(Val) + 1);
3105
strcpy((*RingBuffer)[*BufIndex], Val);