2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* selectx.c 1.23 - Fujitsu source for CDEnext 96/10/30 13:13:45 */
24 /* $XConsortium: selectx.c /main/7 1996/11/08 01:54:18 cde-fuj $ */
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
48 #include <Xm/SeparatoG.h>
50 #include <Xm/ToggleB.h>
51 #include <Xm/MessageB.h>
52 #include <Xm/RowColumn.h>
57 * There is no public header file for this function (only an
58 * internal header XmStringI.h).
60 extern XtPointer _XmStringUngenerate (XmString string,
63 XmTextType output_type);
66 #include "xoakufont.h"
67 #include "selectxlfd.h"
69 extern Resource resource ;
75 FalFontData fullFontData;
77 void PopupSelectXLFD() ;
78 static Widget CreateSelectXLFD() ;
80 extern void xlfdPopupDialog() ;
81 extern int GetListsOfItems() ;
87 static Widget xlfdWform;
89 #define CS0 "Codeset 0"
90 #define CS1 "Codeset 1"
91 #define CS2 "Codeset 2"
92 #define CS3 "Codeset 3"
94 #define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)]
96 static Widget pull1, pull2, pull3, pull4, scrolllist;
97 static int xlf_count = 0;
98 static XmString *xlf=NULL;
99 static int udc_count = 0;
100 static Boolean udc_flag = False;
101 static int *udc=NULL;
103 static int sty_count = 0;
104 static Boolean sty_flag = False;
105 static char **sty=NULL;
106 static char *sty_val=NULL;
107 static int wls_count = 0;
108 static Boolean wls_flag = False;
109 static int *wls=NULL;
111 static int hls_count = 0;
112 static Boolean hls_flag = False;
113 static int *hls=NULL;
115 static Widget *button1=NULL;
116 static Widget *button2=NULL;
117 static Widget *button3=NULL;
118 static Widget *button4=NULL;
120 /****************************************************************
122 ***************************************************************/
131 p = str + strlen(str);
132 for(;count && (str < p);p--) {
142 static void OpenWindowCB()
147 XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
149 fullFontData.xlfdname = NULL;
152 str = (char *) _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
154 p = spc(str, '-', 4);
157 if (*p == 'p' || *p == 'P') {
158 fullFontData.xlfdname = (char *)-1;
162 fullFontData.xlfdname = str;
164 fullFontData.cd_set = udc_val;
166 fullFontData.cd_set = -1;
170 ** contents : "Cancel" button callback
171 ** ------------------------
178 OpenCancelCB( widget, clientData, callData )
183 extern void ForcePopdownDialog();
187 ForcePopdownDialog(xlfdDialog);
192 * create selection window view
195 PopupSelectXLFD( top )
199 if( xlfdDialog == NULL ){
200 if( (xlfdDialog = CreateSelectXLFD( top )) == NULL ){
204 /* pop up select window */
205 xlfdPopupDialog( xlfdDialog );
212 int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
214 FalFontDataList *fontlist;
218 if (udc_flag == True) {
219 key.cd_set = udc_val;
220 mask |= FAL_FONT_MASK_CODE_SET;
222 if (sty_flag == True) {
223 key.style.name = sty_val;
224 mask |= FAL_FONT_MASK_STYLE_NAME;
226 if (wls_flag == True) {
227 key.size.w = wls_val;
228 mask |= FAL_FONT_MASK_SIZE_W;
230 if (hls_flag == True) {
231 key.size.h = hls_val;
232 mask |= FAL_FONT_MASK_SIZE_H;
235 if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
238 if(fontlist->num == 0) {
239 FalFreeFontList(fontlist);
243 for (i=0; i < xlf_count; i++) {
244 XmStringFree(xlf[i]);
248 xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
249 for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
250 xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
252 FalFreeFontList(fontlist);
261 XtVaGetValues(w, XmNlabelString, &label, NULL);
262 moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
263 if(strncmp(moji, "*", 1) == 0) {
265 } else if(strcmp(moji, CS0) == 0) {
266 udc_val = FAL_FONT_CS0;
268 } else if(strcmp(moji, CS1) == 0) {
269 udc_val = FAL_FONT_CS1;
271 } else if(strcmp(moji, CS2) == 0) {
272 udc_val = FAL_FONT_CS2;
274 } else if(strcmp(moji, CS3) == 0) {
275 udc_val = FAL_FONT_CS3;
282 XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
295 XtVaGetValues(w, XmNlabelString, &label, NULL);
296 moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
297 if(strncmp(moji, "*", 1) == 0) {
301 sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1));
302 strcpy(sty_val, moji);
307 XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
316 XtVaGetValues(w, XmNlabelString, &label, NULL);
317 moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
318 if(strncmp(moji, "*", 1) == 0) {
322 wls_val = atoi(moji);
328 XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
337 XtVaGetValues(w, XmNlabelString, &label, NULL);
338 moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
339 if(strncmp(moji, "*", 1) == 0) {
343 hls_val = atoi(moji);
349 XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
356 int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
358 FalFontDataList *fontlist;
362 if (sty_flag == True) {
363 key.style.name = sty_val;
364 mask |= FAL_FONT_MASK_STYLE_NAME;
366 if (wls_flag == True) {
367 key.size.w = wls_val;
368 mask |= FAL_FONT_MASK_SIZE_W;
370 if (hls_flag == True) {
371 key.size.h = hls_val;
372 mask |= FAL_FONT_MASK_SIZE_H;
374 if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
375 for (j=0; j<udc_count; j++)
376 XtSetSensitive(button1[j], False);
379 if(fontlist->num == 0) {
380 for (j=0; j<udc_count; j++)
381 XtSetSensitive(button1[j], False);
382 FalFreeFontList(fontlist);
386 for (j=0; j<udc_count; j++) {
387 for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
388 if(udc[j] == f->cd_set) {
394 XtSetSensitive(button1[j], False);
396 XtSetSensitive(button1[j], True);
398 FalFreeFontList(fontlist);
405 int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
407 FalFontDataList *fontlist;
411 if (udc_flag == True) {
412 key.cd_set = udc_val;
413 mask |= FAL_FONT_MASK_CODE_SET;
415 if (wls_flag == True) {
416 key.size.w = wls_val;
417 mask |= FAL_FONT_MASK_SIZE_W;
419 if (hls_flag == True) {
420 key.size.h = hls_val;
421 mask |= FAL_FONT_MASK_SIZE_H;
423 if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
424 for (j=0; j<sty_count; j++)
425 XtSetSensitive(button2[j], False);
428 if(fontlist->num == 0) {
429 for (j=0; j<sty_count; j++)
430 XtSetSensitive(button2[j], False);
431 FalFreeFontList(fontlist);
435 for (j=0; j<sty_count; j++) {
436 for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
437 if(strcmp(sty[j], f->style.name) == 0) {
443 XtSetSensitive(button2[j], False);
445 XtSetSensitive(button2[j], True);
447 FalFreeFontList(fontlist);
454 int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
456 FalFontDataList *fontlist;
460 if (udc_flag == True) {
461 key.cd_set = udc_val;
462 mask |= FAL_FONT_MASK_CODE_SET;
464 if (sty_flag == True) {
465 key.style.name = sty_val;
466 mask |= FAL_FONT_MASK_STYLE_NAME;
468 if (hls_flag == True) {
469 key.size.h = hls_val;
470 mask |= FAL_FONT_MASK_SIZE_H;
472 if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
473 for (j=0; j<wls_count; j++)
474 XtSetSensitive(button3[j], False);
477 if(fontlist->num == 0) {
478 for (j=0; j<wls_count; j++)
479 XtSetSensitive(button3[j], False);
480 FalFreeFontList(fontlist);
484 for (j=0; j<wls_count; j++) {
485 for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
486 if(wls[j] == f->size.w) {
492 XtSetSensitive(button3[j], False);
494 XtSetSensitive(button3[j], True);
496 FalFreeFontList(fontlist);
503 int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
505 FalFontDataList *fontlist;
509 if (udc_flag == True) {
510 key.cd_set = udc_val;
511 mask |= FAL_FONT_MASK_CODE_SET;
513 if (sty_flag == True) {
514 key.style.name = sty_val;
515 mask |= FAL_FONT_MASK_STYLE_NAME;
517 if (wls_flag == True) {
518 key.size.w = wls_val;
519 mask |= FAL_FONT_MASK_SIZE_W;
521 if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
522 for (j=0; j<hls_count; j++)
523 XtSetSensitive(button4[j], False);
526 if(fontlist->num == 0) {
527 for (j=0; j<hls_count; j++)
528 XtSetSensitive(button4[j], False);
529 FalFreeFontList(fontlist);
533 for (j=0; j<hls_count; j++) {
534 for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
535 if(hls[j] == f->size.h) {
541 XtSetSensitive(button4[j], False);
543 XtSetSensitive(button4[j], True);
545 FalFreeFontList(fontlist);
549 data_sort(data, count)
553 int *p1, *p2, tmp, i;
555 for (; count; count--) {
556 for (i=1, p1=data, p2=data+1; i < count; i++, p1++, p2++) {
570 FalFontDataList *fontlist;
577 extern void Error_message();
579 xlf_count = udc_count = sty_count = wls_count = hls_count = 0;
580 if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED |
581 FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) {
582 strcpy(err, FAL_ERROR_STR);
583 Error_message((Widget)NULL, err);
586 if(fontlist->num == 0) {
587 FalFreeFontList(fontlist);
588 strcpy(err, resource.mn_no_font);
589 Error_message((Widget)NULL, err);
592 udc = (int *)XtMalloc(sizeof(int) * fontlist->num);
593 sty = (char **)XtMalloc(sizeof(char *) * fontlist->num);
594 wls = (int *)XtMalloc(sizeof(int) * fontlist->num);
595 hls = (int *)XtMalloc(sizeof(int) * fontlist->num);
596 for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
597 for (j=0,found=False; j<udc_count; j++) {
598 if(udc[j] == f->cd_set) {
603 if (found == False) {
604 udc[udc_count++] = f->cd_set;
606 for (j=0,found=False; j<sty_count; j++) {
607 if(strcmp(sty[j], f->style.name) == 0) {
612 if (found == False) {
613 sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1));
614 strcpy(sty[sty_count++], f->style.name);
616 if (f->size.w != -1) {
617 for (j=0,found=False; j<wls_count; j++) {
618 if(wls[j] == f->size.w) {
623 if (found == False) {
624 wls[wls_count++] = f->size.w;
627 for (j=0,found=False; j<hls_count; j++) {
628 if(hls[j] == f->size.h) {
633 if (found == False) {
634 hls[hls_count++] = f->size.h;
637 FalFreeFontList(fontlist);
639 data_sort(udc, udc_count);
640 data_sort(wls, wls_count);
641 data_sort(hls, hls_count);
643 button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count);
644 button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count);
645 button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count);
646 button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count);
648 button = XmCreatePushButton(pull1, "*", NULL, 0);
649 XtManageChild(button);
650 XtAddCallback(button, XmNactivateCallback,
651 (XtCallbackProc)udc_call, NULL);
652 for (i=0; i < udc_count; i++) {
653 if(udc[i] == FAL_FONT_CS0)
655 else if(udc[i] == FAL_FONT_CS1)
657 else if(udc[i] == FAL_FONT_CS2)
659 else if(udc[i] == FAL_FONT_CS3)
662 sprintf(tmp, "Codeset %x?", udc[i]);
663 button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0);
664 XtManageChild(button1[i]);
665 XtAddCallback(button1[i], XmNactivateCallback,
666 (XtCallbackProc)udc_call, NULL);
669 button = XmCreatePushButton(pull2, "*", NULL, 0);
670 XtManageChild(button);
671 XtAddCallback(button, XmNactivateCallback,
672 (XtCallbackProc)sty_call, NULL);
673 for (i=0; i < sty_count; i++) {
674 button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0);
675 XtManageChild(button2[i]);
676 XtAddCallback(button2[i], XmNactivateCallback,
677 (XtCallbackProc)sty_call, NULL);
680 button = XmCreatePushButton(pull3, "*", NULL, 0);
681 XtManageChild(button);
682 XtAddCallback(button, XmNactivateCallback,
683 (XtCallbackProc)wls_call, NULL);
684 for (i=0; i < wls_count; i++) {
685 sprintf(tmp, "%d", wls[i]);
686 button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0);
687 XtManageChild(button3[i]);
688 XtAddCallback(button3[i], XmNactivateCallback,
689 (XtCallbackProc)wls_call, NULL);
692 button = XmCreatePushButton(pull4, "*", NULL, 0);
693 XtManageChild(button);
694 XtAddCallback(button, XmNactivateCallback,
695 (XtCallbackProc)hls_call, NULL);
696 for (i=0; i < hls_count; i++) {
697 sprintf(tmp, "%d", hls[i]);
698 button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0);
699 XtManageChild(button4[i]);
700 XtAddCallback(button4[i], XmNactivateCallback,
701 (XtCallbackProc)hls_call, NULL);
707 CreateSelectXLFD( top )
715 Widget frame, row1, label1, row2, cas1, cas2, cas3, cas4;
717 udc_flag = sty_flag = wls_flag = hls_flag = False;
723 XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
724 XtSetArg( args[n], XmNnoResize, True ) ; n++ ;
725 XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ;
726 xms = XmStringCreateLocalized( resource.exec_label ) ;
727 XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ;
728 xms1 = XmStringCreateLocalized( resource.quit_label) ;
729 XtSetArg( args[n], XmNhelpLabelString, xms1 ) ; n++ ;
730 XtSetArg( args[n], XmNtitle, resource.l_open_title ) ; n++ ;
731 editW = XmCreateTemplateDialog( top, "open_dialog", args, n );
733 XmStringFree( xms ) ;
734 XmStringFree( xms1 ) ;
737 pull1 = XmCreatePulldownMenu(toplevel, "pull", args, n);
738 pull2 = XmCreatePulldownMenu(toplevel, "pull", args, n);
739 pull3 = XmCreatePulldownMenu(toplevel, "pull", args, n);
740 pull4 = XmCreatePulldownMenu(toplevel, "pull", args, n);
743 xlfdWform = XmCreateRowColumn( editW, "BaseForm", args, n );
744 XtManageChild( xlfdWform );
747 frame = XmCreateFrame( xlfdWform, "frame", args, n);
748 XtManageChild( frame );
751 row1 = XmCreateRowColumn( frame, "row", args, n );
752 XtManageChild( row1 );
755 str = XmStringCreateLocalized(resource.l_selectitem) ;
756 XtSetArg(args[n], XmNlabelString, str); n++;
757 label1 = XmCreateLabel( row1, "SelectItems", args, n);
758 XtManageChild( label1 );
762 row2 = XmCreateRowColumn( row1, "row", args, n );
763 XtManageChild( row2 );
766 str = XmStringCreateLocalized(resource.l_codeset) ;
767 XtSetArg(args[n], XmNlabelString, str); n++;
768 XtSetArg(args[n], XmNsubMenuId, pull1); n++;
769 cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n );
770 XtManageChild( cas1 );
771 XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback,
772 (XtCallbackProc)button_set1, NULL);
776 str = XmStringCreateLocalized(resource.l_style) ;
777 XtSetArg(args[n], XmNlabelString, str); n++;
778 XtSetArg(args[n], XmNsubMenuId, pull2); n++;
779 cas2 = XmCreateOptionMenu( row2, "Style", args, n );
780 XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback,
781 (XtCallbackProc)button_set2, NULL);
782 XtManageChild( cas2 );
786 str = XmStringCreateLocalized(resource.l_width) ;
787 XtSetArg(args[n], XmNlabelString, str); n++;
788 XtSetArg(args[n], XmNsubMenuId, pull3); n++;
789 cas3 = XmCreateOptionMenu( row2, "Width", args, n );
790 XtManageChild( cas3 );
791 XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback,
792 (XtCallbackProc)button_set3, NULL);
796 str = XmStringCreateLocalized(resource.l_height) ;
797 XtSetArg(args[n], XmNlabelString, str); n++;
798 XtSetArg(args[n], XmNsubMenuId, pull4); n++;
799 cas4 = XmCreateOptionMenu( row2, "Height", args, n );
800 XtManageChild( cas4 );
801 XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback,
802 (XtCallbackProc)button_set4, NULL);
809 XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ;
810 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ;
811 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ;
812 XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ;
813 XtSetArg(args[n], XmNitems, xlf) ; n++ ;
814 XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ;
815 scrolllist = XmCreateScrolledList(xlfdWform, "scrolllist", args, n);
816 XtManageChild(scrolllist);
822 XtAddCallback(editW, XmNokCallback, (XtCallbackProc)OpenWindowCB, NULL);
823 XtAddCallback(editW, XmNokCallback, (XtCallbackProc)ReadCB, NULL);
824 XtAddCallback(editW, XmNhelpCallback,
825 (XtCallbackProc)OpenCancelCB, NULL);