Convert uses of XKeycodeToKeysym (deprecated) to XkbKeycodeToKeysym
[oweals/cde.git] / cde / programs / dtudcfonted / cpyx.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* cpyx.c 1.29 - Fujitsu source for CDEnext    96/10/30 13:13:45      */
24 /* $XConsortium: cpyx.c /main/8 1996/11/08 01:52:55 cde-fuj $ */
25 /*
26  *  (c) Copyright 1995 FUJITSU LIMITED
27  *  This is source code modified by FUJITSU LIMITED under the Joint
28  *  Development Agreement for the CDEnext PST.
29  *  This is unpublished proprietary source code of FUJITSU LIMITED
30  */
31
32
33 #include <string.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <nl_types.h>
37
38 #include<X11/Xlib.h>
39 #include<X11/Xutil.h>
40 #include<X11/Xatom.h>
41
42 #include <Xm/XmAll.h>
43
44 /*
45  * There is no public header file for this function (only an
46  * internal header XmStringI.h).
47  */
48 extern XtPointer _XmStringUngenerate (XmString string,
49                         XmStringTag tag,
50                         XmTextType tag_type,
51                         XmTextType output_type);
52
53 #include "util.h"
54 #include "selectxlfd.h"
55 #include "xoakufont.h"
56
57 #include "xpm.h"
58 #ifdef XPM
59 #define ReadXpm XpmCreatePixmapFromData
60 #else
61 #define ReadXpm _DtXpmCreatePixmapFromData
62 #endif
63 #include "pixmaps/arrow.pm"
64
65 static Widget   CreateCopyXLFD(Widget Top);
66 static void     CpyXLFDCB(Widget w, caddr_t client_data, caddr_t *call_data);
67
68 extern  int     CreateOtherLabelAndText(int     num,
69                                         Widget  owner,
70                                         Widget  baseForm,
71                                         Widget  *slctBLabel,
72                                         Widget  topW,
73                                         Widget  *slctBText,
74                                         Widget  *slctButton);
75 extern  Widget  xlfdCreateScrolledList(Widget owner,
76                                        char *name,
77                                        Arg *args,
78                                        int n);
79 extern  int     GetItemsToDisplay(int num, int *itemcnt, XmString **xms_list);
80
81 extern  void    xlfdPopupDialog(Widget w);
82
83 extern  void    InitCpyPtn(void);
84 extern  void    _unmap(void);
85 extern  void    CpyCB(Widget w, XtPointer cdata);
86 extern  void    PopdownCpyPtn(void);
87 extern  void    AddPopupProc(Widget w, void(*popupcb)());
88
89 extern FalFontData fullFontData;
90
91 /*
92  * parameters
93  */
94
95 FalFontData     copyFontData;
96
97 extern  Widget  toplevel ;
98 Widget  cpyDialog=NULL;
99 static Widget codeLabel[COPYLABELS];
100 static Widget codeText[COPYLABELS+1];
101
102 extern  TextField SrcTf;
103 extern  TextField DestTf;
104
105 extern  char AreaStr[160];
106
107 /*
108  *  resource database
109  */
110 extern  Resource resource ;
111
112 #define CS0 "Codeset 0"
113 #define CS1 "Codeset 1"
114 #define CS2 "Codeset 2"
115 #define CS3 "Codeset 3"
116
117 #define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)]
118
119 static Widget           pull1, pull2, pull3, pull4, scrolllist;
120 static int      xlf_count = 0;
121 static XmString *xlf=NULL;
122 static int      udc_count = 0;
123 static Boolean  udc_flag = False;
124 static int      *udc=NULL;
125 static int      udc_val;
126 static int      sty_count = 0;
127 static Boolean  sty_flag = False;
128 static char     **sty=NULL;
129 static char     *sty_val=NULL;
130 static int      wls_count = 0;
131 static Boolean  wls_flag = False;
132 static int      *wls=NULL;
133 static int      wls_val;
134 static int      hls_count = 0;
135 static Boolean  hls_flag = False;
136 static int      *hls=NULL;
137 static int      hls_val;
138 static Widget       *button1=NULL;
139 static Widget       *button2=NULL;
140 static Widget       *button3=NULL;
141 static Widget       *button4=NULL;
142 static Widget       focus_widget=NULL;
143
144 /****************************************************************
145  * callbacks                                                    *
146  ***************************************************************/
147
148
149 /*ARGSUSED*/
150 static void
151 CpyXLFDCB(Widget w, caddr_t client_data, caddr_t *call_data)
152 {
153     char        *str;
154     XmStringTable       st;
155     /* get font file name (str:  XLFD name)     */
156     /* get font file name (str:  XLFD name)     */
157     XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
158     if( st == NULL ){
159         copyFontData.xlfdname = NULL;
160         return ;
161     }
162     str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
163     copyFontData.xlfdname = str;
164     if(udc_flag == True)
165         copyFontData.cd_set = udc_val;
166     else
167         copyFontData.cd_set = -1;
168 }
169
170
171 void
172 CpyPtnXLFD(void)
173 {
174     if( cpyDialog == NULL )
175     {
176         CreateCopyXLFD( toplevel ) ;
177
178         /*
179          * add callbacks
180          */
181         XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)_unmap, NULL);
182         XtAddCallback(cpyDialog, XmNokCallback,
183                                         (XtCallbackProc)CpyXLFDCB, NULL);
184         XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)CpyCB, NULL);
185
186         XtAddCallback(cpyDialog, XmNcancelCallback,
187                                 (XtCallbackProc)_unmap, (XtPointer)1);
188         XtAddCallback(cpyDialog, XmNcancelCallback,
189                                 (XtCallbackProc)CpyXLFDCB,  (XtPointer)1);
190         XtAddCallback(cpyDialog, XmNcancelCallback,
191                                 (XtCallbackProc)CpyCB, (XtPointer)1);
192         XtAddCallback(cpyDialog, XmNhelpCallback, (XtCallbackProc)_unmap, NULL);
193         XtAddCallback(cpyDialog, XmNhelpCallback,
194                                 (XtCallbackProc)PopdownCpyPtn, NULL);
195
196         AddPopupProc( cpyDialog, InitCpyPtn ) ;
197
198         SrcTf.w1  = codeText[0] ;
199         SrcTf.w2  = codeText[1] ;
200         DestTf.w1 = codeText[2] ;
201         DestTf.w2 = NULL;
202
203     }
204     xlfdPopupDialog( cpyDialog );
205 }
206
207
208 static void
209 create_xlfd(void)
210 {
211         int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
212         FalFontData key;
213         FalFontDataList *fontlist;
214         FalFontData *f;
215         int i;
216
217         if (udc_flag == True) {
218                 key.cd_set = udc_val;
219                 mask |= FAL_FONT_MASK_CODE_SET;
220         }
221         if (sty_flag == True) {
222                 key.style.name = sty_val;
223                 mask |= FAL_FONT_MASK_STYLE_NAME;
224         }
225         if (wls_flag == True) {
226                 key.size.w = wls_val;
227                 mask |= FAL_FONT_MASK_SIZE_W;
228         }
229         if (hls_flag == True) {
230                 key.size.h = hls_val;
231                 mask |= FAL_FONT_MASK_SIZE_H;
232         }
233         xlf_count = 0;
234         if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
235                 return;
236         }
237         if(fontlist->num == 0) {
238                 FalFreeFontList(fontlist);
239                 return;
240         }
241         xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
242         for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
243             xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
244         }
245         FalFreeFontList(fontlist);
246 }
247
248 static void
249 udc_call(Widget w)
250 {
251         XmString label;
252         char *moji;
253         XtVaGetValues(w, XmNlabelString, &label, NULL);
254         moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
255         if(strncmp(moji, "*", 1) == 0) {
256                 udc_flag = False;
257         } else if(strcmp(moji, CS0) == 0) {
258                 udc_val = FAL_FONT_CS0;
259                 udc_flag = True;
260         } else if(strcmp(moji, CS1) == 0) {
261                 udc_val = FAL_FONT_CS1;
262                 udc_flag = True;
263         } else if(strcmp(moji, CS2) == 0) {
264                 udc_val = FAL_FONT_CS2;
265                 udc_flag = True;
266         } else if(strcmp(moji, CS3) == 0) {
267                 udc_val = FAL_FONT_CS3;
268                 udc_flag = True;
269         } else {
270                 udc_flag = False;
271         }
272         XtFree(moji);
273         create_xlfd();
274         XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
275 }
276
277 static void
278 sty_call(Widget w)
279 {
280         XmString label;
281         char *moji;
282         if (sty_val) {
283                 XtFree(sty_val);
284                 sty_val = NULL;
285         }
286         XtVaGetValues(w, XmNlabelString, &label, NULL);
287         moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
288         if(strncmp(moji, "*", 1) == 0) {
289                 sty_flag = False;
290         }
291         else {
292                 sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1));
293                 strcpy(sty_val, moji);
294                 sty_flag = True;
295         }
296         XtFree(moji);
297         create_xlfd();
298         XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
299 }
300
301 static void
302 wls_call(Widget w)
303 {
304         XmString label;
305         char *moji;
306         XtVaGetValues(w, XmNlabelString, &label, NULL);
307         moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
308         if(strncmp(moji, "*", 1) == 0) {
309                 wls_flag = False;
310         }
311         else {
312                 wls_val = atoi(moji);
313                 wls_flag = True;
314         }
315         XmStringFree(label);
316         XtFree(moji);
317         create_xlfd();
318         XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
319 }
320
321 static void
322 hls_call(Widget w)
323 {
324         XmString label;
325         char *moji;
326         XtVaGetValues(w, XmNlabelString, &label, NULL);
327         moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
328         if(strncmp(moji, "*", 1) == 0) {
329                 hls_flag = False;
330         }
331         else {
332                 hls_val = atoi(moji);
333                 hls_flag = True;
334         }
335         XmStringFree(label);
336         XtFree(moji);
337         create_xlfd();
338         XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
339 }
340
341 static void
342 button_set1(void)
343 {
344     int         i, j;
345     int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
346     FalFontData key;
347     FalFontDataList *fontlist;
348     FalFontData *f;
349     Boolean found;
350
351     if (sty_flag == True) {
352         key.style.name = sty_val;
353         mask |= FAL_FONT_MASK_STYLE_NAME;
354     }
355     if (wls_flag == True) {
356         key.size.w = wls_val;
357         mask |= FAL_FONT_MASK_SIZE_W;
358     }
359     if (hls_flag == True) {
360         key.size.h = hls_val;
361         mask |= FAL_FONT_MASK_SIZE_H;
362     }
363     if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
364         for (j=0; j<udc_count; j++)
365             XtSetSensitive(button1[j], False);
366         return;
367     }
368     if(fontlist->num == 0) {
369         FalFreeFontList(fontlist);
370         for (j=0; j<udc_count; j++)
371             XtSetSensitive(button1[j], False);
372         return;
373     }
374
375     for (j=0; j<udc_count; j++) {
376         for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
377             if(udc[j] == f->cd_set) {
378                 found = True;
379                 break;
380             }
381         }
382         if(found == False)
383             XtSetSensitive(button1[j], False);
384         else
385             XtSetSensitive(button1[j], True);
386     }
387     FalFreeFontList(fontlist);
388 }
389
390 static void
391 button_set2(void)
392 {
393     int         i, j;
394     int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
395     FalFontData key;
396     FalFontDataList *fontlist;
397     FalFontData *f;
398     Boolean found;
399
400     if (udc_flag == True) {
401         key.cd_set = udc_val;
402         mask |= FAL_FONT_MASK_CODE_SET;
403     }
404     if (wls_flag == True) {
405         key.size.w = wls_val;
406         mask |= FAL_FONT_MASK_SIZE_W;
407     }
408     if (hls_flag == True) {
409         key.size.h = hls_val;
410         mask |= FAL_FONT_MASK_SIZE_H;
411     }
412     if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
413         for (j=0; j<sty_count; j++)
414             XtSetSensitive(button2[j], False);
415         return;
416     }
417     if(fontlist->num == 0) {
418         for (j=0; j<sty_count; j++)
419             XtSetSensitive(button2[j], False);
420         FalFreeFontList(fontlist);
421         return;
422     }
423
424     for (j=0; j<sty_count; j++) {
425         for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
426             if(strcmp(sty[j], f->style.name) == 0) {
427                 found = True;
428                 break;
429             }
430         }
431         if(found == False)
432             XtSetSensitive(button2[j], False);
433         else
434             XtSetSensitive(button2[j], True);
435     }
436     FalFreeFontList(fontlist);
437 }
438
439 static void
440 button_set3(void)
441 {
442     int         i, j;
443     int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
444     FalFontData key;
445     FalFontDataList *fontlist;
446     FalFontData *f;
447     Boolean found;
448
449     if (udc_flag == True) {
450         key.cd_set = udc_val;
451         mask |= FAL_FONT_MASK_CODE_SET;
452     }
453     if (sty_flag == True) {
454         key.style.name = sty_val;
455         mask |= FAL_FONT_MASK_STYLE_NAME;
456     }
457     if (hls_flag == True) {
458         key.size.h = hls_val;
459         mask |= FAL_FONT_MASK_SIZE_H;
460     }
461     if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
462        for (j=0; j<wls_count; j++)
463             XtSetSensitive(button3[j], False);
464         return;
465     }
466     if(fontlist->num == 0) {
467        for (j=0; j<wls_count; j++)
468             XtSetSensitive(button3[j], False);
469         FalFreeFontList(fontlist);
470         return;
471     }
472
473     for (j=0; j<wls_count; j++) {
474         for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
475             if(wls[j] == f->size.w) {
476                 found = True;
477                 break;
478             }
479         }
480         if(found == False)
481             XtSetSensitive(button3[j], False);
482         else
483             XtSetSensitive(button3[j], True);
484     }
485     FalFreeFontList(fontlist);
486 }
487
488 static void
489 button_set4(void)
490 {
491     int         i, j;
492     int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
493     FalFontData key;
494     FalFontDataList *fontlist;
495     FalFontData *f;
496     Boolean found;
497
498     if (udc_flag == True) {
499         key.cd_set = udc_val;
500         mask |= FAL_FONT_MASK_CODE_SET;
501     }
502     if (sty_flag == True) {
503         key.style.name = sty_val;
504         mask |= FAL_FONT_MASK_STYLE_NAME;
505     }
506     if (wls_flag == True) {
507         key.size.w = wls_val;
508         mask |= FAL_FONT_MASK_SIZE_W;
509     }
510     if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
511         for (j=0; j<hls_count; j++)
512             XtSetSensitive(button4[j], False);
513         return;
514     }
515     if(fontlist->num == 0) {
516         for (j=0; j<hls_count; j++)
517             XtSetSensitive(button4[j], False);
518         FalFreeFontList(fontlist);
519         return;
520     }
521
522     for (j=0; j<hls_count; j++) {
523         for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
524             if(hls[j] == f->size.h) {
525                 found = True;
526                 break;
527             }
528         }
529         if (found == False)
530             XtSetSensitive(button4[j], False);
531         else
532             XtSetSensitive(button4[j], True);
533     }
534     FalFreeFontList(fontlist);
535 }
536
537
538 static void
539 font_init(void)
540 {
541         FalFontDataList *fontlist;
542         FalFontData     *f;
543         Boolean         found;
544         int             i, j;
545         char            tmp[16];
546         char            err[128];
547         Widget          button;
548         extern void     data_sort();
549         extern void     Error_message();
550
551         xlf_count = udc_count = sty_count = wls_count = hls_count = 0;
552         if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED |
553                         FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) {
554                 snprintf(err, sizeof(err), "%s", FAL_ERROR_STR);
555                 Error_message((Widget)NULL, err);
556                 return;
557         }
558         if(fontlist->num == 0) {
559                 FalFreeFontList(fontlist);
560                 snprintf(err, sizeof(err), "%s", resource.mn_no_font);
561                 Error_message((Widget)NULL, err);
562                 return;
563         }
564         xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
565         udc = (int *)XtMalloc(sizeof(int) * fontlist->num);
566         sty = (char **)XtMalloc(sizeof(char *) * fontlist->num);
567         wls = (int *)XtMalloc(sizeof(int) * fontlist->num);
568         hls = (int *)XtMalloc(sizeof(int) * fontlist->num);
569         for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
570             xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
571             for (j=0,found=False; j<udc_count; j++) {
572                 if(udc[j] == f->cd_set) {
573                         found=True;
574                         break;
575                 }
576             }
577             if (found == False) {
578                 udc[udc_count++] = f->cd_set;
579             }
580             for (j=0,found=False; j<sty_count; j++) {
581                 if(strcmp(sty[j], f->style.name) == 0) {
582                         found=True;
583                         break;
584                 }
585             }
586             if (found == False) {
587                 sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1));
588                 strcpy(sty[sty_count++], f->style.name);
589             }
590             if (f->size.w != -1) {
591             for (j=0,found=False; j<wls_count; j++) {
592                 if(wls[j] == f->size.w) {
593                         found=True;
594                         break;
595                 }
596             }
597             if (found == False) {
598                 wls[wls_count++] = f->size.w;
599             }
600             }
601             for (j=0,found=False; j<hls_count; j++) {
602                 if(hls[j] == f->size.h) {
603                         found=True;
604                         break;
605                 }
606             }
607             if (found == False) {
608                 hls[hls_count++] = f->size.h;
609             }
610         }
611         FalFreeFontList(fontlist);
612
613         data_sort(udc, udc_count);
614         data_sort(wls, wls_count);
615         data_sort(hls, hls_count);
616
617         button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count);
618         button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count);
619         button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count);
620         button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count);
621
622         button = XmCreatePushButton(pull1, "*", NULL, 0);
623         XtManageChild(button);
624         XtAddCallback(button, XmNactivateCallback,
625                                                 (XtCallbackProc)udc_call, NULL);
626         for (i=0; i < udc_count; i++) {
627                 if(udc[i] == FAL_FONT_CS0)
628                         snprintf(tmp, sizeof(tmp), "%s", CS0);
629                 else if(udc[i] == FAL_FONT_CS1)
630                         snprintf(tmp, sizeof(tmp), "%s", CS1);
631                 else if(udc[i] == FAL_FONT_CS2)
632                         snprintf(tmp, sizeof(tmp), "%s", CS2);
633                 else if(udc[i] == FAL_FONT_CS3)
634                         snprintf(tmp, sizeof(tmp), "%s", CS3);
635                 else
636                         snprintf(tmp, sizeof(tmp), "Codeset %x?", udc[i]);
637                 button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0);
638                 XtManageChild(button1[i]);
639                 XtAddCallback(button1[i], XmNactivateCallback,
640                                                 (XtCallbackProc)udc_call, NULL);
641         }
642
643         button = XmCreatePushButton(pull2, "*", NULL, 0);
644         XtManageChild(button);
645         XtAddCallback(button, XmNactivateCallback,
646                                                 (XtCallbackProc)sty_call, NULL);
647         for (i=0; i < sty_count; i++) {
648                 button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0);
649                 XtManageChild(button2[i]);
650                 XtAddCallback(button2[i], XmNactivateCallback,
651                                                 (XtCallbackProc)sty_call, NULL);
652         }
653
654         button = XmCreatePushButton(pull3, "*", NULL, 0);
655         XtManageChild(button);
656         XtAddCallback(button, XmNactivateCallback,
657                                                 (XtCallbackProc)wls_call, NULL);
658         for (i=0; i < wls_count; i++) {
659                 snprintf(tmp, sizeof(tmp), "%d", wls[i]);
660                 button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0);
661                 XtManageChild(button3[i]);
662                 XtAddCallback(button3[i], XmNactivateCallback,
663                                                 (XtCallbackProc)wls_call, NULL);
664         }
665
666         button = XmCreatePushButton(pull4, "*", NULL, 0);
667         XtManageChild(button);
668         XtAddCallback(button, XmNactivateCallback,
669                                                 (XtCallbackProc)hls_call, NULL);
670         for (i=0; i < hls_count; i++) {
671                 snprintf(tmp, sizeof(tmp), "%d", hls[i]);
672                 button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0);
673                 XtManageChild(button4[i]);
674                 XtAddCallback(button4[i], XmNactivateCallback,
675                                                 (XtCallbackProc)hls_call, NULL);
676         }
677 }
678
679 /*ARGSUSED*/
680 static void
681 arrow_change(Widget w, Widget wid)
682 {
683     if (XtIsSensitive(wid)) {
684         XtSetSensitive(wid, False);
685     } else {
686         XtSetSensitive(wid, True);
687     }
688 }
689
690 static void
691 focus(Widget w)
692 {
693     focus_widget = w;
694 }
695
696 static void
697 code_input(void)
698 {
699     char        *str;
700     XmStringTable       st;
701     extern void CodeWindow();
702     XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
703     if( st == NULL ){
704         return ;
705     }
706     str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
707     CodeWindow(focus_widget, str, True);
708 }
709
710 static void
711 code_input2(void)
712 {
713     extern void CodeWindow();
714     CodeWindow(codeText[2], fullFontData.xlfdname, False);
715 }
716
717 static Widget
718 CreateCopyXLFD( Widget top )
719 {
720
721         int             n;
722         Arg             args[16];
723         XmString        xms, xms1, xms2 ;
724         Widget          frame, row, label1, row1, row2, row3, row4, row5;
725         Widget          sep, cas1, cas2, cas3, cas4;
726         Widget          arrow, code;
727         XmString        str;
728         extern Pixmap   arrow_pix;
729         Display             *disp;
730         Window              root;
731         Pixmap              mask;
732         XpmAttributes       attr;
733
734         udc_flag = sty_flag = wls_flag = hls_flag = False;
735
736         /*
737         *  create base window
738         */
739         n = 0 ;
740         XtSetArg( args[n], XmNautoUnmanage,     False ) ;        n++ ;
741         xms = XmStringCreateLocalized( resource.l_copy ) ;
742         XtSetArg( args[n], XmNokLabelString,    xms ) ;         n++ ;
743         xms1 = XmStringCreateLocalized( resource.l_overlay ) ;
744         XtSetArg( args[n], XmNcancelLabelString, xms1 ) ;       n++ ;
745         xms2 = XmStringCreateLocalized( resource.quit_label) ;
746         XtSetArg( args[n], XmNhelpLabelString,  xms2 ) ;        n++ ;
747         XtSetArg( args[n], XmNnoResize,         True ) ;        n++ ;
748         XtSetArg( args[n], XmNminimizeButtons,  True ) ;        n++ ;
749         XtSetArg( args[n], XmNtitle,    resource.l_copy_title) ;        n++ ;
750         cpyDialog = XmCreateTemplateDialog( top, "copy_dialog", args, n );
751
752         XmStringFree( xms ) ;
753         XmStringFree( xms1 ) ;
754         XmStringFree( xms2 ) ;
755
756         n = 0;
757         pull1 = XmCreatePulldownMenu(top, "pull", args, n);
758         pull2 = XmCreatePulldownMenu(top, "pull", args, n);
759         pull3 = XmCreatePulldownMenu(top, "pull", args, n);
760         pull4 = XmCreatePulldownMenu(top, "pull", args, n);
761
762         n = 0 ;
763         row  = XmCreateRowColumn( cpyDialog, "BaseForm", args, n );
764         XtManageChild( row );
765
766         n = 0;
767         frame = XmCreateFrame( row, "frame", args, n);
768         XtManageChild( frame );
769
770         n = 0 ;
771         row1  = XmCreateRowColumn( frame, "row", args, n );
772         XtManageChild( row1 );
773
774         n = 0;
775         str = XmStringCreateLocalized(resource.l_selectitem) ;
776         XtSetArg(args[n], XmNlabelString, str);  n++;
777         label1 = XmCreateLabel( row1, "SelectItems", args, n);
778         XtManageChild( label1 );
779         XmStringFree(str);
780
781         n = 0 ;
782         row2  = XmCreateRowColumn( row1, "row", args, n );
783         XtManageChild( row2 );
784
785         n = 0 ;
786         str = XmStringCreateLocalized(resource.l_codeset) ;
787         XtSetArg(args[n], XmNlabelString, str);  n++;
788         XtSetArg(args[n], XmNsubMenuId, pull1);  n++;
789         cas1  = XmCreateOptionMenu( row2, "CodeSet", args, n );
790         XtManageChild( cas1 );
791         XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback,
792                                         (XtCallbackProc)button_set1, NULL);
793         XmStringFree(str);
794
795         n = 0 ;
796         str = XmStringCreateLocalized(resource.l_style) ;
797         XtSetArg(args[n], XmNlabelString, str);  n++;
798         XtSetArg(args[n], XmNsubMenuId, pull2);  n++;
799         cas2  = XmCreateOptionMenu( row2, "Style", args, n );
800         XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback,
801                                         (XtCallbackProc)button_set2, NULL);
802         XtManageChild( cas2 );
803         XmStringFree(str);
804
805         n = 0 ;
806         str = XmStringCreateLocalized(resource.l_width) ;
807         XtSetArg(args[n], XmNlabelString, str);  n++;
808         XtSetArg(args[n], XmNsubMenuId, pull3);  n++;
809         cas3  = XmCreateOptionMenu( row2, "Width", args, n );
810         XtManageChild( cas3 );
811         XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback,
812                                         (XtCallbackProc)button_set3, NULL);
813         XmStringFree(str);
814
815         n = 0 ;
816         str = XmStringCreateLocalized(resource.l_height) ;
817         XtSetArg(args[n], XmNlabelString, str);  n++;
818         XtSetArg(args[n], XmNsubMenuId, pull4);  n++;
819         cas4  = XmCreateOptionMenu( row2, "Height", args, n );
820         XtManageChild( cas4 );
821         XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback,
822                                         (XtCallbackProc)button_set4, NULL);
823         XmStringFree(str);
824
825         font_init();
826
827         n = 0;
828         XtSetArg(args[n], XmNvisibleItemCount, 10) ;    n++ ;
829         XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ;      n++ ;
830         XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ;        n++ ;
831         XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ;        n++ ;
832         XtSetArg(args[n], XmNitems, xlf) ;      n++ ;
833         XtSetArg(args[n], XmNitemCount, xlf_count) ;    n++ ;
834         scrolllist = XmCreateScrolledList(row, "scrolllist", args, n);
835         XtManageChild(scrolllist);
836
837         n = 0;
838         sep = XmCreateSeparator(row, "sep", args, n);
839         XtManageChild(sep);
840
841         n = 0 ;
842         row3  = XmCreateRowColumn( row, "row", args, n );
843         XtManageChild( row3 );
844
845         if (! arrow_pix) {
846             disp = XtDisplay(row);
847             root = DefaultRootWindow(disp);
848             attr.valuemask = 0;
849             ReadXpm(disp, root, arrow_pm, &arrow_pix, &mask, &attr);
850         }
851
852         n = 0 ;
853         XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ;       n++ ;
854         row4  = XmCreateRowColumn( row3, "row", args, n );
855         XtManageChild( row4 );
856
857         xms = XmStringCreateLocalized(resource.l_copy_src_code);
858         n = 0;
859         XtSetArg(args[n], XmNlabelString, xms); n++ ;
860         codeLabel[0] = XmCreateLabel(row4 , "copylabel", args, n);
861         XtManageChild(codeLabel[0]);
862         XmStringFree( xms ) ;
863
864         n = 0;
865         XtSetArg(args[n], XmNcolumns,   4);                     n++;
866         XtSetArg(args[n], XmNmaxLength, 4);                     n++;
867         XtSetArg(args[n], XmNeditable,  True);                  n++;
868         XtSetArg(args[n], XmNcursorPositionVisible, True);      n++;
869         focus_widget = codeText[0] = XmCreateText(row4 , "copytext",
870                                                                 args, n);
871         XtManageChild(codeText[0]);
872
873         XtAddCallback(codeText[0], XmNfocusCallback, (XtCallbackProc)focus, NULL);
874
875         n = 0;
876         XtSetArg(args[n], XmNlabelPixmap, arrow_pix);  n++;
877         XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
878         XtSetArg(args[n], XmNindicatorOn, False); n++;
879         XtSetArg(args[n], XmNshadowThickness, 2); n++;
880         XtSetArg(args[n], XmNfillOnSelect, False); n++;
881         XtSetArg(args[n], XmNhighlightThickness, 0); n++;
882         arrow = XmCreateToggleButton(row4, "arrow", args, n);
883         XtManageChild(arrow);
884
885         n = 0;
886         XtSetArg(args[n], XmNcolumns,   4);                     n++;
887         XtSetArg(args[n], XmNmaxLength, 4);                     n++;
888         XtSetArg(args[n], XmNeditable,  True);                  n++;
889         XtSetArg(args[n], XmNcursorPositionVisible, True);      n++;
890         codeText[1] = XmCreateText(row4 , "copytext", args, n);
891         XtManageChild(codeText[1]);
892         XtSetSensitive(codeText[1], False);
893
894         XtAddCallback(codeText[1], XmNfocusCallback, (XtCallbackProc)focus, NULL);
895
896         XtAddCallback(arrow, XmNvalueChangedCallback,
897                         (XtCallbackProc)arrow_change, (XtPointer)codeText[1]);
898
899         n = 0;
900         xms = XmStringCreateLocalized(resource.code) ;
901         XtSetArg(args[n], XmNlabelString, xms); n++;
902         XtSetArg(args[n], XmNhighlightThickness, 0); n++;
903         code = XmCreatePushButton(row4, "Code", args, n);
904         XtManageChild(code);
905         XmStringFree(xms);
906
907         XtAddCallback(code, XmNactivateCallback,
908                         (XtCallbackProc)code_input, (XtPointer)NULL);
909
910         n = 0 ;
911         XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ;       n++ ;
912         row5  = XmCreateRowColumn( row3, "row", args, n );
913         XtManageChild( row5 );
914
915         xms = XmStringCreateLocalized(resource.l_copy_dest_code);
916
917         n = 0;
918         XtSetArg(args[n], XmNlabelString, xms); n++ ;
919         codeLabel[1] = XmCreateLabel(row5 , "copylabel", args, n);
920         XtManageChild(codeLabel[1]);
921         XmStringFree( xms ) ;
922
923         n = 0;
924         XtSetArg(args[n], XmNcolumns,   4);                     n++;
925         XtSetArg(args[n], XmNmaxLength, 4);                     n++;
926         XtSetArg(args[n], XmNeditable,  True);                  n++;
927         XtSetArg(args[n], XmNcursorPositionVisible, True);      n++;
928         codeText[2] = XmCreateText(row5 , "copytext", args, n);
929         XtManageChild(codeText[2]);
930
931         n = 0;
932         xms = XmStringCreateLocalized(resource.code) ;
933         XtSetArg(args[n], XmNlabelString, xms); n++;
934         XtSetArg(args[n], XmNhighlightThickness, 0); n++;
935         code = XmCreatePushButton(row5, "Code", args, n);
936         XtManageChild(code);
937         XmStringFree(xms);
938
939         XtAddCallback(code, XmNactivateCallback,
940                         (XtCallbackProc)code_input2, (XtPointer)NULL);
941
942         return( cpyDialog ) ;
943 }