cpyx.c 25 KB

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