udcexp.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. /* $XConsortium: udcexp.c /main/5 1996/10/14 14:45:34 barstow $ */
  24. /*
  25. * (c) Copyright 1995 FUJITSU LIMITED
  26. * This is source code modified by FUJITSU LIMITED under the Joint
  27. * Development Agreement for the CDEnext PST.
  28. * This is unpublished proprietary source code of FUJITSU LIMITED
  29. */
  30. #include "excutil.h"
  31. #include <Xm/MessageB.h>
  32. #include <Xm/RowColumn.h>
  33. #include <Xm/List.h>
  34. #include <Xm/Form.h>
  35. #include <Xm/Label.h>
  36. void setselectedcode();
  37. extern char *maintitle;
  38. void udcexp(Exc_data * ed)
  39. {
  40. ed->function = EXPORT;
  41. strcpy(ed->bdfmode,"w");
  42. PopupSelectXLFD(ed->toplevel);
  43. }
  44. void createbdf(Exc_data * ed)
  45. {
  46. int i = 0;
  47. char *comment_list[] = {""};
  48. int comment_num = 0;
  49. char *msg;
  50. int ans;
  51. msg = GETMESSAGE(10, 2, "Failed to make the BDF file");
  52. i = ExpGpftoBDF(ed->fontfile, ed->bdffile,
  53. ed->code_num, ed->gpf_code_list,
  54. comment_num, comment_list, 0);
  55. if (i != 0) {
  56. AskUser(ed->toplevel, ed, msg, &ans, "error");
  57. }
  58. excterminate(ed);
  59. }
  60. void selcharokCB(Widget widget, ListData * ld, XtPointer call_data)
  61. {
  62. int num;
  63. Exc_data *ed;
  64. int ans;
  65. char *msg;
  66. msg = GETMESSAGE(10, 4, "No indexes are selected");
  67. XtVaGetValues(ld->list, XmNselectedItemCount, &num, NULL);
  68. if (num == 0) {
  69. /* AskUser(widget, ld->ed, msg, &ans, "error");*/
  70. return;
  71. } else {
  72. setselectedcode(ld);
  73. XtUnmanageChild(XtParent(widget));
  74. ed = ld->ed;
  75. freeld(ld);
  76. getbdffn(ed);
  77. }
  78. }
  79. void selcharcancelCB(Widget widget, ListData * ld, XtPointer call_data)
  80. {
  81. Exc_data *ed;
  82. ed = ld->ed;
  83. freeld(ld);
  84. excterminate(ed);
  85. }
  86. XmString * setxmslist(ListData * ld)
  87. {
  88. char **cp;
  89. XmString *xmslist, *xmsp;
  90. int i;
  91. if ((xmslist = (XmString *) calloc(ld->existcode_num, sizeof(XmString *)))
  92. == NULL) {
  93. excerror(ld->ed, EXCERRMALLOC, "setxmslist", "exit");
  94. }
  95. cp = ld->existcode_c;
  96. xmsp = xmslist;
  97. for (i = 0; i < ld->existcode_num; i++) {
  98. *xmsp = XmStringCreateLocalized(*cp);
  99. xmsp++;
  100. cp++;
  101. }
  102. return (xmslist);
  103. }
  104. void freexmslist(ListData * ld, XmString * xmslist)
  105. {
  106. XmString *xmsp;
  107. int i;
  108. if (xmslist != NULL) {
  109. xmsp = xmslist;
  110. for (i = 0; i < ld->existcode_num; i++) {
  111. XmStringFree(*xmsp);
  112. xmsp++;
  113. }
  114. free(xmslist);
  115. }
  116. }
  117. void selcharcd(Exc_data * ed)
  118. {
  119. Widget mainw, selcd, ok, cancel;
  120. Widget slctLabel, form;
  121. Arg args[20];
  122. Cardinal n;
  123. char *oklabel;
  124. char *cancellabel;
  125. XmString *xmslist;
  126. extern ListData *ld;
  127. char *p;
  128. oklabel = GETMESSAGE(10, 6, "OK");
  129. cancellabel = GETMESSAGE(10, 8, "Cancel");
  130. n = 0;
  131. XtSetArg(args[n], XmNautoUnmanage, False); n++;
  132. XtSetArg(args[n], XmNtitle, maintitle); n++;
  133. mainw = XmCreateTemplateDialog(ed->toplevel, "mainw", args, n);
  134. n = 0;
  135. form = XmCreateForm( mainw, "form", args, n);
  136. XtManageChild(form);
  137. p = GETMESSAGE(10, 10, "glyph indexes");
  138. n = 0;
  139. XtSetArg( args[n], XmNx, 20 ) ; n++;
  140. XtSetArg( args[n], XmNheight, 20 ) ; n++ ;
  141. XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
  142. XtSetArg( args[n], XmNtopOffset, 10 ) ; n++ ;
  143. slctLabel = XmCreateLabel( form, p, args, n);
  144. XtManageChild(slctLabel);
  145. n = 0;
  146. xmslist = setxmslist(ld);
  147. XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
  148. XtSetArg( args[n], XmNleftOffset, 20 ) ; n++ ;
  149. XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++ ;
  150. XtSetArg( args[n], XmNtopOffset, 5 ) ; n++ ;
  151. XtSetArg( args[n], XmNwidth, 200 ) ; n++ ;
  152. XtSetArg (args[n], XmNtopWidget, slctLabel ); n++;
  153. XtSetArg(args[n], XmNitems, xmslist); n++;
  154. XtSetArg(args[n], XmNitemCount, ld->existcode_num); n++;
  155. XtSetArg(args[n], XmNvisibleItemCount, 10); n++;
  156. XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); n++;
  157. XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
  158. XtSetArg(args[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++;
  159. selcd = XmCreateScrolledList(form, "Select codes", args, n);
  160. freexmslist(ld, xmslist);
  161. XtManageChild(selcd);
  162. ld->list = selcd;
  163. ok = excCreatePushButton(mainw, "ok", oklabel,
  164. (XtCallbackProc) selcharokCB, (XtPointer) ld);
  165. cancel = excCreatePushButton(mainw, "cancel", cancellabel,
  166. (XtCallbackProc) selcharcancelCB,
  167. (XtPointer) ld);
  168. XtManageChild(mainw);
  169. }
  170. void setselectedcode(ListData *ld)
  171. {
  172. int *position_list;
  173. int position_count;
  174. int i;
  175. int *codep;
  176. XmListGetSelectedPos(ld->list, &position_list, &position_count);
  177. ld->ed->code_num = position_count;
  178. ld->ed->gpf_code_list = (int *) calloc(position_count, sizeof(int));
  179. codep = ld->ed->gpf_code_list;
  180. for (i = 0; i < position_count; i++) {
  181. *codep = *((ld->existcode)+(position_list[i]-1));
  182. codep++;
  183. }
  184. }