udcexc.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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: udcexc.c /main/4 1996/09/02 18:50:32 cde-fuj $ */
  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 "xoakufont.h"
  32. #include "selectxlfd.h"
  33. #include <locale.h>
  34. #include <Xm/RowColumn.h>
  35. #include <Xm/ToggleB.h>
  36. #include <Xm/MessageB.h>
  37. #include <Xm/MainW.h>
  38. void callexpCB();
  39. void callimpCB();
  40. void exitCB();
  41. void helpCB();
  42. void udcexp();
  43. void udcimp();
  44. #define ERROR_1 errmsg_org[fal_utyerrno & 0xff]
  45. /*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/
  46. /*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/
  47. Widget toplevel, mainw;
  48. Exc_data *ed = NULL;
  49. ListData *ld = NULL;
  50. char *maintitle;
  51. /*char *terminatemsg = "Do you want to terminate dtudcexch";*/
  52. /*
  53. * Error messages(by origin)
  54. * fal_errmsg_org
  55. */
  56. char *errmsg_org[0xff];
  57. Rsrc resource ;
  58. #define Rchar(name, class, member,def){ \
  59. name, class, XtRString, sizeof(char *), \
  60. XtOffsetOf(Rsrc, member), XtRString, (XtPointer)def }
  61. Widget excCreateRadioButton(Widget parent, String name, String label,
  62. XtCallbackProc callback_func,
  63. XtPointer client_data)
  64. {
  65. Widget widget;
  66. XmString xms;
  67. widget = XtVaCreateManagedWidget(name,
  68. xmToggleButtonWidgetClass, parent,
  69. XmNindicatorType, XmONE_OF_MANY,
  70. NULL);
  71. XtAddCallback(widget, XmNvalueChangedCallback,
  72. (XtCallbackProc) callback_func,
  73. (XtPointer) client_data);
  74. xms = XmStringCreateLocalized(label);
  75. XtVaSetValues(widget,
  76. XmNlabelString, xms,
  77. NULL);
  78. XmStringFree(xms);
  79. return (widget);
  80. }
  81. int main(int argc, char * argv[])
  82. {
  83. XtAppContext app_context;
  84. Widget row, expfunc, impfunc, exit/*, help*/;
  85. Arg args[20];
  86. Cardinal n;
  87. static char *explabel;
  88. static char *implabel;
  89. static char *exitlabel;
  90. /* static char helplabel[] = "Help";*/
  91. /* char msg1[] = "Failed in the start of dtudcexch";*/
  92. char err[128];
  93. int ans;
  94. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  95. FalFontData key;
  96. FalFontDataList *fontlist;
  97. /* appinitialize */
  98. XtSetLanguageProc(NULL,NULL,NULL);
  99. _DtEnvControl(0);
  100. n = 0;
  101. toplevel = XtAppInitialize(&app_context, "UDCexchange",
  102. (XrmOptionDescList) NULL,
  103. 0, (int *) &argc, argv, (String *) NULL,
  104. args, n);
  105. maintitle = GETMESSAGE(8, 2, "UDC data exchange utitlity");
  106. errmsg_org[0] = GETMESSAGE(8, 4, "Fatal error occurred.");
  107. errmsg_org[1] = GETMESSAGE(8, 6, "Cannot open the font file.");
  108. errmsg_org[2] = GETMESSAGE(8, 8, "Cannot read the font file.");
  109. errmsg_org[3] = GETMESSAGE(8, 10, "There is no more memory.");
  110. errmsg_org[4] = GETMESSAGE(8, 12, "Fatal error occurred.");
  111. errmsg_org[5] = GETMESSAGE(8, 14, "The specified font file does not exist.");
  112. errmsg_org[6] = GETMESSAGE(8, 16, "This font is not a pcf or snf font.");
  113. errmsg_org[7] = GETMESSAGE(8, 18, "Cannot open fonts.list file.");
  114. errmsg_org[8] = GETMESSAGE(8, 20, "The format of fonts.list file is illegal.");
  115. errmsg_org[9] = GETMESSAGE(8, 22, "The descriptions of the fonts.list file are incorrect.");
  116. errmsg_org[10] = GETMESSAGE(8, 24, "The format of fonts.list file is illegal.");
  117. errmsg_org[11] = GETMESSAGE(8, 26, "Cannot open fonts.dir file.");
  118. errmsg_org[12] = GETMESSAGE(8, 28, "Cannot read fonts.dir file.");
  119. errmsg_org[13] = GETMESSAGE(8, 30, "Cannot read font properties.");
  120. errmsg_org[14] = GETMESSAGE(8, 32, "Cannot get FONT property.");
  121. errmsg_org[15] = GETMESSAGE(8, 34, "Cannot get FAMILY_NAME property.");
  122. errmsg_org[16] = GETMESSAGE(8, 36, "This font file is already opened by other application.");
  123. errmsg_org[17] = GETMESSAGE(8, 38, "Cannot lock font file.");
  124. errmsg_org[18] = GETMESSAGE(8, 40, "Cannot unlock font file.");
  125. errmsg_org[19] = GETMESSAGE(8, 42, "Cannot get lock information from the font file.");
  126. errmsg_org[20] = GETMESSAGE(8, 44, "Cannot find the specified font file.");
  127. errmsg_org[21] = GETMESSAGE(8, 46, "Cannot read NLS database.");
  128. errmsg_org[22] = GETMESSAGE(8, 48, "Cannot get charset names from NLS database.");
  129. errmsg_org[23] = GETMESSAGE(8, 50, "Charset name not defined in NLS database.");
  130. errmsg_org[24] = GETMESSAGE(8, 52, "The specified font has not been opened.");
  131. errmsg_org[25] = GETMESSAGE(8, 54, "Fatal error occurred.");
  132. resource.xlfd_label = GETMESSAGE(8, 56, "XLFD name :" ),
  133. resource.copy_xlfd_label = GETMESSAGE(8, 58, "Original font (XLFD name) :");
  134. resource.code_label = GETMESSAGE(8, 60, "UDC code area :");
  135. resource.style_label = GETMESSAGE(8, 62, "Style :");
  136. resource.size_label = GETMESSAGE(8, 64, "Size (letter size) :");
  137. resource.exec_label = GETMESSAGE(8, 66, "Open");
  138. resource.quit_label = GETMESSAGE(8, 68, "Cancel");
  139. resource.ok_label = GETMESSAGE(8, 70, "OK");
  140. resource.cancel_label = GETMESSAGE(8, 72, "cancel");
  141. resource.copy_orgin = GETMESSAGE(8, 74, "Copy orgin code(hex) :");
  142. resource.copy_target = GETMESSAGE(8, 76, "Copy target code(hex) :");
  143. resource.copy_label = GETMESSAGE(8, 78, "Copy");
  144. resource.overlay_label = GETMESSAGE(8, 80, "Overlay");
  145. explabel = GETMESSAGE(8, 82, "export function");
  146. implabel = GETMESSAGE(8, 84, "import function");
  147. exitlabel = GETMESSAGE(8, 86, "Cancel");
  148. /* initialize ed */
  149. if ((ed = (Exc_data *) malloc(sizeof(Exc_data))) == NULL) {
  150. excerror(ed, EXCERRMALLOC, "main", "exit");
  151. }
  152. memset(ed,0x00,sizeof(Exc_data));
  153. ed->app = app_context;
  154. ed->toplevel = toplevel;
  155. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  156. fprintf( stderr, "GetFontList Err\n" );
  157. sprintf(err, "%s", ERROR_1);
  158. AskUser(ed->toplevel, ed, err, &ans, "error");
  159. /* AskUser(ed->toplevel, ed, msg1, &ans, "error");*/
  160. excexit(ed);
  161. }
  162. FalFreeFontList(fontlist);
  163. /* make main window */
  164. n = 0;
  165. XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
  166. XtSetArg(args[n], XmNtitle, maintitle); n++;
  167. mainw = XmCreateTemplateDialog(toplevel, "mainw", args, n);
  168. row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, mainw,
  169. XmNradioBehavior, True,
  170. XmNradioAlwaysOne, True,
  171. NULL);
  172. expfunc = excCreateRadioButton(row, "expfunc", explabel,
  173. (XtCallbackProc) callexpCB, (XtPointer) ed);
  174. impfunc = excCreateRadioButton(row, "impfunc", implabel,
  175. (XtCallbackProc) callimpCB, (XtPointer) ed);
  176. exit = excCreatePushButton(mainw, "exit", exitlabel,
  177. (XtCallbackProc) exitCB, (XtPointer) ed);
  178. /* help = excCreatePushButton(mainw, "help", helplabel,
  179. (XtCallbackProc) helpCB, (XtPointer) ed);
  180. */
  181. XtVaSetValues(mainw,
  182. XmNmessageWindow, exit,
  183. NULL);
  184. XtManageChild(mainw);
  185. /* XtRealizeWidget(toplevel);*/
  186. XtAppMainLoop(app_context);
  187. }
  188. void callexpCB(Widget widget, Exc_data * ed, XtPointer call_data)
  189. {
  190. XtUnmanageChild(mainw);
  191. udcexp(ed);
  192. }
  193. void callimpCB(Widget widget, Exc_data * ed, XtPointer call_data)
  194. {
  195. XtUnmanageChild(mainw);
  196. udcimp(ed);
  197. }
  198. void exitCB(Widget widget, Exc_data * ed, XtPointer call_data)
  199. {
  200. excexit(ed);
  201. }
  202. /*void helpCB(Widget widget, Exc_data * ed, XtPointer call_data)
  203. {
  204. }*/