selectx.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  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. /* 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 $ */
  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 <Xm/Xm.h>
  39. #include <Xm/Form.h>
  40. #include <Xm/PushB.h>
  41. #include <Xm/Text.h>
  42. #include <Xm/TextF.h>
  43. #include <Xm/Label.h>
  44. #include <Xm/SeparatoG.h>
  45. #include <Xm/List.h>
  46. #include <Xm/ToggleB.h>
  47. #include <Xm/MessageB.h>
  48. #include <Xm/RowColumn.h>
  49. #include <Xm/Frame.h>
  50. #include <Xm/Label.h>
  51. /*
  52. * There is no public header file for this function (only an
  53. * internal header XmStringI.h).
  54. */
  55. extern XtPointer _XmStringUngenerate (XmString string,
  56. XmStringTag tag,
  57. XmTextType tag_type,
  58. XmTextType output_type);
  59. #include "xoakufont.h"
  60. #include "selectxlfd.h"
  61. extern Resource resource ;
  62. /*
  63. * parameters
  64. */
  65. FalFontData fullFontData;
  66. void PopupSelectXLFD(Widget top) ;
  67. static Widget CreateSelectXLFD(Widget top) ;
  68. extern void xlfdPopupDialog(Widget w);
  69. extern void ReadCB(Widget w, XtPointer client_data, XtPointer call_data);
  70. Widget xlfdDialog;
  71. static Widget xlfdWform;
  72. #define CS0 "Codeset 0"
  73. #define CS1 "Codeset 1"
  74. #define CS2 "Codeset 2"
  75. #define CS3 "Codeset 3"
  76. #define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)]
  77. static Widget pull1, pull2, pull3, pull4, scrolllist;
  78. static int xlf_count = 0;
  79. static XmString *xlf=NULL;
  80. static int udc_count = 0;
  81. static Boolean udc_flag = False;
  82. static int *udc=NULL;
  83. static int udc_val;
  84. static int sty_count = 0;
  85. static Boolean sty_flag = False;
  86. static char **sty=NULL;
  87. static char *sty_val=NULL;
  88. static int wls_count = 0;
  89. static Boolean wls_flag = False;
  90. static int *wls=NULL;
  91. static int wls_val;
  92. static int hls_count = 0;
  93. static Boolean hls_flag = False;
  94. static int *hls=NULL;
  95. static int hls_val;
  96. static Widget *button1=NULL;
  97. static Widget *button2=NULL;
  98. static Widget *button3=NULL;
  99. static Widget *button4=NULL;
  100. /****************************************************************
  101. * callbacks *
  102. ***************************************************************/
  103. static char *
  104. spc(char *str, char ch, int count)
  105. {
  106. char *p;
  107. p = str + strlen(str);
  108. for(;count && (str < p);p--) {
  109. if (*p == ch)
  110. count --;
  111. }
  112. if (! count)
  113. return(p+1);
  114. else
  115. return(NULL);
  116. }
  117. static void OpenWindowCB(void)
  118. {
  119. char *str, *p;
  120. XmStringTable st;
  121. XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
  122. if( st == NULL ){
  123. fullFontData.xlfdname = NULL;
  124. return ;
  125. }
  126. str = (char *) _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
  127. p = spc(str, '-', 4);
  128. p++;
  129. if (*p == 'p' || *p == 'P') {
  130. fullFontData.xlfdname = (char *)-1;
  131. return ;
  132. }
  133. fullFontData.xlfdname = str;
  134. if(udc_flag == True)
  135. fullFontData.cd_set = udc_val;
  136. else
  137. fullFontData.cd_set = -1;
  138. }
  139. /**
  140. ** contents : "Cancel" button callback
  141. ** ------------------------
  142. **
  143. **
  144. **/
  145. /*ARGSUSED*/
  146. static void
  147. OpenCancelCB(Widget widget, caddr_t clientData, caddr_t callData)
  148. {
  149. extern void ForcePopdownDialog();
  150. if ( !editPtnW ){
  151. exit( 0 );
  152. }
  153. ForcePopdownDialog(xlfdDialog);
  154. }
  155. /*
  156. * create selection window view
  157. */
  158. void
  159. PopupSelectXLFD(Widget top)
  160. {
  161. if( xlfdDialog == NULL ){
  162. if( (xlfdDialog = CreateSelectXLFD( top )) == NULL ){
  163. exit( -1 ) ;
  164. }
  165. }
  166. /* pop up select window */
  167. xlfdPopupDialog( xlfdDialog );
  168. }
  169. static void
  170. create_xlfd(void)
  171. {
  172. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  173. FalFontData key;
  174. FalFontDataList *fontlist;
  175. FalFontData *f;
  176. int i;
  177. if (udc_flag == True) {
  178. key.cd_set = udc_val;
  179. mask |= FAL_FONT_MASK_CODE_SET;
  180. }
  181. if (sty_flag == True) {
  182. key.style.name = sty_val;
  183. mask |= FAL_FONT_MASK_STYLE_NAME;
  184. }
  185. if (wls_flag == True) {
  186. key.size.w = wls_val;
  187. mask |= FAL_FONT_MASK_SIZE_W;
  188. }
  189. if (hls_flag == True) {
  190. key.size.h = hls_val;
  191. mask |= FAL_FONT_MASK_SIZE_H;
  192. }
  193. xlf_count = 0;
  194. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  195. return;
  196. }
  197. if(fontlist->num == 0) {
  198. FalFreeFontList(fontlist);
  199. return;
  200. }
  201. if (xlf) {
  202. for (i=0; i < xlf_count; i++) {
  203. XmStringFree(xlf[i]);
  204. }
  205. XtFree((char *)xlf);
  206. }
  207. xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
  208. for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
  209. xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
  210. }
  211. FalFreeFontList(fontlist);
  212. }
  213. static void
  214. udc_call(Widget w)
  215. {
  216. XmString label;
  217. char *moji;
  218. XtVaGetValues(w, XmNlabelString, &label, NULL);
  219. moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
  220. if(strncmp(moji, "*", 1) == 0) {
  221. udc_flag = False;
  222. } else if(strcmp(moji, CS0) == 0) {
  223. udc_val = FAL_FONT_CS0;
  224. udc_flag = True;
  225. } else if(strcmp(moji, CS1) == 0) {
  226. udc_val = FAL_FONT_CS1;
  227. udc_flag = True;
  228. } else if(strcmp(moji, CS2) == 0) {
  229. udc_val = FAL_FONT_CS2;
  230. udc_flag = True;
  231. } else if(strcmp(moji, CS3) == 0) {
  232. udc_val = FAL_FONT_CS3;
  233. udc_flag = True;
  234. } else {
  235. udc_flag = False;
  236. }
  237. XtFree(moji);
  238. create_xlfd();
  239. XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
  240. }
  241. static void
  242. sty_call(Widget w)
  243. {
  244. XmString label;
  245. char *moji;
  246. if (sty_val) {
  247. XtFree(sty_val);
  248. sty_val = NULL;
  249. }
  250. XtVaGetValues(w, XmNlabelString, &label, NULL);
  251. moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
  252. if(strncmp(moji, "*", 1) == 0) {
  253. sty_flag = False;
  254. }
  255. else {
  256. sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1));
  257. strcpy(sty_val, moji);
  258. sty_flag = True;
  259. }
  260. XtFree(moji);
  261. create_xlfd();
  262. XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
  263. }
  264. static void
  265. wls_call(Widget w)
  266. {
  267. XmString label;
  268. char *moji;
  269. XtVaGetValues(w, XmNlabelString, &label, NULL);
  270. moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
  271. if(strncmp(moji, "*", 1) == 0) {
  272. wls_flag = False;
  273. }
  274. else {
  275. wls_val = atoi(moji);
  276. wls_flag = True;
  277. }
  278. XmStringFree(label);
  279. XtFree(moji);
  280. create_xlfd();
  281. XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
  282. }
  283. static void
  284. hls_call(Widget w)
  285. {
  286. XmString label;
  287. char *moji;
  288. XtVaGetValues(w, XmNlabelString, &label, NULL);
  289. moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
  290. if(strncmp(moji, "*", 1) == 0) {
  291. hls_flag = False;
  292. }
  293. else {
  294. hls_val = atoi(moji);
  295. hls_flag = True;
  296. }
  297. XmStringFree(label);
  298. XtFree(moji);
  299. create_xlfd();
  300. XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
  301. }
  302. static void
  303. button_set1(void)
  304. {
  305. int i, j;
  306. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  307. FalFontData key;
  308. FalFontDataList *fontlist;
  309. FalFontData *f;
  310. Boolean found;
  311. if (sty_flag == True) {
  312. key.style.name = sty_val;
  313. mask |= FAL_FONT_MASK_STYLE_NAME;
  314. }
  315. if (wls_flag == True) {
  316. key.size.w = wls_val;
  317. mask |= FAL_FONT_MASK_SIZE_W;
  318. }
  319. if (hls_flag == True) {
  320. key.size.h = hls_val;
  321. mask |= FAL_FONT_MASK_SIZE_H;
  322. }
  323. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  324. for (j=0; j<udc_count; j++)
  325. XtSetSensitive(button1[j], False);
  326. return;
  327. }
  328. if(fontlist->num == 0) {
  329. for (j=0; j<udc_count; j++)
  330. XtSetSensitive(button1[j], False);
  331. FalFreeFontList(fontlist);
  332. return;
  333. }
  334. for (j=0; j<udc_count; j++) {
  335. for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
  336. if(udc[j] == f->cd_set) {
  337. found = True;
  338. break;
  339. }
  340. }
  341. if(found == False)
  342. XtSetSensitive(button1[j], False);
  343. else
  344. XtSetSensitive(button1[j], True);
  345. }
  346. FalFreeFontList(fontlist);
  347. }
  348. static void
  349. button_set2(void)
  350. {
  351. int i, j;
  352. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  353. FalFontData key;
  354. FalFontDataList *fontlist;
  355. FalFontData *f;
  356. Boolean found;
  357. if (udc_flag == True) {
  358. key.cd_set = udc_val;
  359. mask |= FAL_FONT_MASK_CODE_SET;
  360. }
  361. if (wls_flag == True) {
  362. key.size.w = wls_val;
  363. mask |= FAL_FONT_MASK_SIZE_W;
  364. }
  365. if (hls_flag == True) {
  366. key.size.h = hls_val;
  367. mask |= FAL_FONT_MASK_SIZE_H;
  368. }
  369. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  370. for (j=0; j<sty_count; j++)
  371. XtSetSensitive(button2[j], False);
  372. return;
  373. }
  374. if(fontlist->num == 0) {
  375. for (j=0; j<sty_count; j++)
  376. XtSetSensitive(button2[j], False);
  377. FalFreeFontList(fontlist);
  378. return;
  379. }
  380. for (j=0; j<sty_count; j++) {
  381. for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
  382. if(strcmp(sty[j], f->style.name) == 0) {
  383. found = True;
  384. break;
  385. }
  386. }
  387. if(found == False)
  388. XtSetSensitive(button2[j], False);
  389. else
  390. XtSetSensitive(button2[j], True);
  391. }
  392. FalFreeFontList(fontlist);
  393. }
  394. static void
  395. button_set3(void)
  396. {
  397. int i, j;
  398. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  399. FalFontData key;
  400. FalFontDataList *fontlist;
  401. FalFontData *f;
  402. Boolean found;
  403. if (udc_flag == True) {
  404. key.cd_set = udc_val;
  405. mask |= FAL_FONT_MASK_CODE_SET;
  406. }
  407. if (sty_flag == True) {
  408. key.style.name = sty_val;
  409. mask |= FAL_FONT_MASK_STYLE_NAME;
  410. }
  411. if (hls_flag == True) {
  412. key.size.h = hls_val;
  413. mask |= FAL_FONT_MASK_SIZE_H;
  414. }
  415. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  416. for (j=0; j<wls_count; j++)
  417. XtSetSensitive(button3[j], False);
  418. return;
  419. }
  420. if(fontlist->num == 0) {
  421. for (j=0; j<wls_count; j++)
  422. XtSetSensitive(button3[j], False);
  423. FalFreeFontList(fontlist);
  424. return;
  425. }
  426. for (j=0; j<wls_count; j++) {
  427. for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
  428. if(wls[j] == f->size.w) {
  429. found = True;
  430. break;
  431. }
  432. }
  433. if(found == False)
  434. XtSetSensitive(button3[j], False);
  435. else
  436. XtSetSensitive(button3[j], True);
  437. }
  438. FalFreeFontList(fontlist);
  439. }
  440. static void
  441. button_set4(void)
  442. {
  443. int i, j;
  444. int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
  445. FalFontData key;
  446. FalFontDataList *fontlist;
  447. FalFontData *f;
  448. Boolean found;
  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 (wls_flag == True) {
  458. key.size.w = wls_val;
  459. mask |= FAL_FONT_MASK_SIZE_W;
  460. }
  461. if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
  462. for (j=0; j<hls_count; j++)
  463. XtSetSensitive(button4[j], False);
  464. return;
  465. }
  466. if(fontlist->num == 0) {
  467. for (j=0; j<hls_count; j++)
  468. XtSetSensitive(button4[j], False);
  469. FalFreeFontList(fontlist);
  470. return;
  471. }
  472. for (j=0; j<hls_count; j++) {
  473. for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
  474. if(hls[j] == f->size.h) {
  475. found = True;
  476. break;
  477. }
  478. }
  479. if (found == False)
  480. XtSetSensitive(button4[j], False);
  481. else
  482. XtSetSensitive(button4[j], True);
  483. }
  484. FalFreeFontList(fontlist);
  485. }
  486. void
  487. data_sort(int *data, int count)
  488. {
  489. int *p1, *p2, tmp, i;
  490. for (; count; count--) {
  491. for (i=1, p1=data, p2=data+1; i < count; i++, p1++, p2++) {
  492. if( *p1 > *p2) {
  493. tmp = *p2;
  494. *p2 = *p1;
  495. *p1 = tmp;
  496. }
  497. }
  498. }
  499. }
  500. static void
  501. font_init(void)
  502. {
  503. FalFontDataList *fontlist;
  504. FalFontData *f;
  505. Boolean found;
  506. int i, j;
  507. char tmp[16];
  508. char err[128];
  509. Widget button;
  510. extern void Error_message();
  511. xlf_count = udc_count = sty_count = wls_count = hls_count = 0;
  512. if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED |
  513. FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) {
  514. strcpy(err, FAL_ERROR_STR);
  515. Error_message((Widget)NULL, err);
  516. return;
  517. }
  518. if(fontlist->num == 0) {
  519. FalFreeFontList(fontlist);
  520. strcpy(err, resource.mn_no_font);
  521. Error_message((Widget)NULL, err);
  522. return;
  523. }
  524. udc = (int *)XtMalloc(sizeof(int) * fontlist->num);
  525. sty = (char **)XtMalloc(sizeof(char *) * fontlist->num);
  526. wls = (int *)XtMalloc(sizeof(int) * fontlist->num);
  527. hls = (int *)XtMalloc(sizeof(int) * fontlist->num);
  528. for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
  529. for (j=0,found=False; j<udc_count; j++) {
  530. if(udc[j] == f->cd_set) {
  531. found=True;
  532. break;
  533. }
  534. }
  535. if (found == False) {
  536. udc[udc_count++] = f->cd_set;
  537. }
  538. for (j=0,found=False; j<sty_count; j++) {
  539. if(strcmp(sty[j], f->style.name) == 0) {
  540. found=True;
  541. break;
  542. }
  543. }
  544. if (found == False) {
  545. sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1));
  546. strcpy(sty[sty_count++], f->style.name);
  547. }
  548. if (f->size.w != -1) {
  549. for (j=0,found=False; j<wls_count; j++) {
  550. if(wls[j] == f->size.w) {
  551. found=True;
  552. break;
  553. }
  554. }
  555. if (found == False) {
  556. wls[wls_count++] = f->size.w;
  557. }
  558. }
  559. for (j=0,found=False; j<hls_count; j++) {
  560. if(hls[j] == f->size.h) {
  561. found=True;
  562. break;
  563. }
  564. }
  565. if (found == False) {
  566. hls[hls_count++] = f->size.h;
  567. }
  568. }
  569. FalFreeFontList(fontlist);
  570. data_sort(udc, udc_count);
  571. data_sort(wls, wls_count);
  572. data_sort(hls, hls_count);
  573. button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count);
  574. button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count);
  575. button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count);
  576. button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count);
  577. button = XmCreatePushButton(pull1, "*", NULL, 0);
  578. XtManageChild(button);
  579. XtAddCallback(button, XmNactivateCallback,
  580. (XtCallbackProc)udc_call, NULL);
  581. for (i=0; i < udc_count; i++) {
  582. if(udc[i] == FAL_FONT_CS0)
  583. sprintf(tmp, CS0);
  584. else if(udc[i] == FAL_FONT_CS1)
  585. sprintf(tmp, CS1);
  586. else if(udc[i] == FAL_FONT_CS2)
  587. sprintf(tmp, CS2);
  588. else if(udc[i] == FAL_FONT_CS3)
  589. sprintf(tmp, CS3);
  590. else
  591. sprintf(tmp, "Codeset %x?", udc[i]);
  592. button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0);
  593. XtManageChild(button1[i]);
  594. XtAddCallback(button1[i], XmNactivateCallback,
  595. (XtCallbackProc)udc_call, NULL);
  596. }
  597. button = XmCreatePushButton(pull2, "*", NULL, 0);
  598. XtManageChild(button);
  599. XtAddCallback(button, XmNactivateCallback,
  600. (XtCallbackProc)sty_call, NULL);
  601. for (i=0; i < sty_count; i++) {
  602. button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0);
  603. XtManageChild(button2[i]);
  604. XtAddCallback(button2[i], XmNactivateCallback,
  605. (XtCallbackProc)sty_call, NULL);
  606. }
  607. button = XmCreatePushButton(pull3, "*", NULL, 0);
  608. XtManageChild(button);
  609. XtAddCallback(button, XmNactivateCallback,
  610. (XtCallbackProc)wls_call, NULL);
  611. for (i=0; i < wls_count; i++) {
  612. sprintf(tmp, "%d", wls[i]);
  613. button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0);
  614. XtManageChild(button3[i]);
  615. XtAddCallback(button3[i], XmNactivateCallback,
  616. (XtCallbackProc)wls_call, NULL);
  617. }
  618. button = XmCreatePushButton(pull4, "*", NULL, 0);
  619. XtManageChild(button);
  620. XtAddCallback(button, XmNactivateCallback,
  621. (XtCallbackProc)hls_call, NULL);
  622. for (i=0; i < hls_count; i++) {
  623. sprintf(tmp, "%d", hls[i]);
  624. button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0);
  625. XtManageChild(button4[i]);
  626. XtAddCallback(button4[i], XmNactivateCallback,
  627. (XtCallbackProc)hls_call, NULL);
  628. }
  629. }
  630. static Widget
  631. CreateSelectXLFD(Widget top)
  632. {
  633. int n;
  634. Arg args[16];
  635. XmString xms, xms1 ;
  636. Widget editW ;
  637. Widget frame, row1, label1, row2, cas1, cas2, cas3, cas4;
  638. XmString str;
  639. udc_flag = sty_flag = wls_flag = hls_flag = False;
  640. /*
  641. * create base window
  642. */
  643. n = 0 ;
  644. XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
  645. XtSetArg( args[n], XmNnoResize, True ) ; n++ ;
  646. XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ;
  647. xms = XmStringCreateLocalized( resource.exec_label ) ;
  648. XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ;
  649. xms1 = XmStringCreateLocalized( resource.quit_label) ;
  650. XtSetArg( args[n], XmNhelpLabelString, xms1 ) ; n++ ;
  651. XtSetArg( args[n], XmNtitle, resource.l_open_title ) ; n++ ;
  652. editW = XmCreateTemplateDialog( top, "open_dialog", args, n );
  653. XmStringFree( xms ) ;
  654. XmStringFree( xms1 ) ;
  655. n = 0;
  656. pull1 = XmCreatePulldownMenu(toplevel, "pull", args, n);
  657. pull2 = XmCreatePulldownMenu(toplevel, "pull", args, n);
  658. pull3 = XmCreatePulldownMenu(toplevel, "pull", args, n);
  659. pull4 = XmCreatePulldownMenu(toplevel, "pull", args, n);
  660. n = 0 ;
  661. xlfdWform = XmCreateRowColumn( editW, "BaseForm", args, n );
  662. XtManageChild( xlfdWform );
  663. n = 0;
  664. frame = XmCreateFrame( xlfdWform, "frame", args, n);
  665. XtManageChild( frame );
  666. n = 0 ;
  667. row1 = XmCreateRowColumn( frame, "row", args, n );
  668. XtManageChild( row1 );
  669. n = 0;
  670. str = XmStringCreateLocalized(resource.l_selectitem) ;
  671. XtSetArg(args[n], XmNlabelString, str); n++;
  672. label1 = XmCreateLabel( row1, "SelectItems", args, n);
  673. XtManageChild( label1 );
  674. XmStringFree(str);
  675. n = 0 ;
  676. row2 = XmCreateRowColumn( row1, "row", args, n );
  677. XtManageChild( row2 );
  678. n = 0 ;
  679. str = XmStringCreateLocalized(resource.l_codeset) ;
  680. XtSetArg(args[n], XmNlabelString, str); n++;
  681. XtSetArg(args[n], XmNsubMenuId, pull1); n++;
  682. cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n );
  683. XtManageChild( cas1 );
  684. XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback,
  685. (XtCallbackProc)button_set1, NULL);
  686. XmStringFree(str);
  687. n = 0 ;
  688. str = XmStringCreateLocalized(resource.l_style) ;
  689. XtSetArg(args[n], XmNlabelString, str); n++;
  690. XtSetArg(args[n], XmNsubMenuId, pull2); n++;
  691. cas2 = XmCreateOptionMenu( row2, "Style", args, n );
  692. XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback,
  693. (XtCallbackProc)button_set2, NULL);
  694. XtManageChild( cas2 );
  695. XmStringFree(str);
  696. n = 0 ;
  697. str = XmStringCreateLocalized(resource.l_width) ;
  698. XtSetArg(args[n], XmNlabelString, str); n++;
  699. XtSetArg(args[n], XmNsubMenuId, pull3); n++;
  700. cas3 = XmCreateOptionMenu( row2, "Width", args, n );
  701. XtManageChild( cas3 );
  702. XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback,
  703. (XtCallbackProc)button_set3, NULL);
  704. XmStringFree(str);
  705. n = 0 ;
  706. str = XmStringCreateLocalized(resource.l_height) ;
  707. XtSetArg(args[n], XmNlabelString, str); n++;
  708. XtSetArg(args[n], XmNsubMenuId, pull4); n++;
  709. cas4 = XmCreateOptionMenu( row2, "Height", args, n );
  710. XtManageChild( cas4 );
  711. XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback,
  712. (XtCallbackProc)button_set4, NULL);
  713. XmStringFree(str);
  714. font_init();
  715. create_xlfd();
  716. n = 0;
  717. XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ;
  718. XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ;
  719. XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ;
  720. XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ;
  721. XtSetArg(args[n], XmNitems, xlf) ; n++ ;
  722. XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ;
  723. scrolllist = XmCreateScrolledList(xlfdWform, "scrolllist", args, n);
  724. XtManageChild(scrolllist);
  725. /*
  726. * Error_Messege
  727. */
  728. XtAddCallback(editW, XmNokCallback, (XtCallbackProc)OpenWindowCB, NULL);
  729. XtAddCallback(editW, XmNokCallback, (XtCallbackProc)ReadCB, NULL);
  730. XtAddCallback(editW, XmNhelpCallback,
  731. (XtCallbackProc)OpenCancelCB, NULL);
  732. return( editW ) ;
  733. }