home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / bibview / part17 < prev    next >
Encoding:
Text File  |  1992-08-26  |  50.3 KB  |  1,569 lines

  1. Path: uunet!dtix!darwin.sura.net!jvnc.net!yale.edu!yale!gumby!destroyer!sol.ctr.columbia.edu!usc!elroy.jpl.nasa.gov!swrinde!mips!msi!dcmartin
  2. From: liebla@informatik.tu-muenchen.de (Armin Liebl)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i115: bibview - BibTeX GUI, Part17/20
  5. Message-ID: <1992Aug27.161815.26083@msi.com>
  6. Date: 27 Aug 92 16:18:15 GMT
  7. References: <csx-18i099-bibview@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1555
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Armin Liebl <liebla@informatik.tu-muenchen.de>
  15. Posting-number: Volume 18, Issue 115
  16. Archive-name: bibview/part17
  17.  
  18. #!/bin/sh
  19. # this is part.17 (part 17 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file gui_card.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 17; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping gui_card.c'
  37. else
  38. echo 'x - continuing file gui_card.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'gui_card.c' &&
  40. X   if ((cdp->year = glbNewString(str)) == NULL)
  41. X      return(ERR_NOMALLOC);
  42. X
  43. X   return(OK);
  44. }
  45. X
  46. X
  47. /*********************************************************************/
  48. /* SaveUnpublishedWidgets:                                           */
  49. /*    Saves data from widget to new card                             */
  50. /*********************************************************************/
  51. static Errcode
  52. SaveUnpublishedWidgets (CardPtr cp)
  53. {
  54. CardWidgetsPtr cwp = &cp->cw->ct.cw;    /* ptr to widget ids */
  55. CardDataPtr cdp = cp->cd;        /* ptr to real card data */
  56. CardDataPtr cbp = &cp->cw->ct.buf;    /* ptr to text buffers */
  57. Widget card = cp->cw->cardFlds;        /* parent widget */
  58. String str;
  59. X
  60. X   XtVaGetValues(cwp->title, XtNstring, &str, NULL);
  61. X   if ((cdp->title = glbNewString(str)) == NULL)
  62. X      return(ERR_NOMALLOC);
  63. X   XtVaGetValues(cwp->author, XtNstring, &str, NULL);
  64. X   if ((cdp->author = glbNewString(str)) == NULL)
  65. X      return(ERR_NOMALLOC);
  66. X   XtVaGetValues(cwp->month, XtNstring, &str, NULL);
  67. X   if ((cdp->month = glbNewString(str)) == NULL)
  68. X      return(ERR_NOMALLOC);
  69. X   XtVaGetValues(cwp->year, XtNstring, &str, NULL);
  70. X   if ((cdp->year = glbNewString(str)) == NULL)
  71. X      return(ERR_NOMALLOC);
  72. X
  73. X   return(OK);
  74. }
  75. X
  76. X
  77. /*********************************************************************/
  78. /* createMenu:                                                       */
  79. /*    Build pulldown menus in a bibliography window                  */
  80. /*********************************************************************/
  81. static void
  82. createMenu (String menuName, MenuEntry item[], Widget parent, Widget *menu)
  83. {
  84. static Widget w;
  85. int i = 0;
  86. String iname;
  87. X
  88. X   *menu = XtVaCreatePopupShell(menuName, 
  89. X             simpleMenuWidgetClass, parent, NULL);
  90. X   i = 0;
  91. X   while ((iname = item[i].name) != NULL) { 
  92. X      if (strncmp("line", iname, 4) == 0)   /* use a line pane */
  93. X         w = XtVaCreateManagedWidget(iname,
  94. X               smeLineObjectClass, *menu, NULL);
  95. X      else {
  96. X         w = XtVaCreateManagedWidget(iname, 
  97. X           smeBSBObjectClass, *menu, NULL);
  98. X         XtAddCallback(w, XtNcallback, item[i].cb, (XtPointer) i);
  99. X      }
  100. X      i++;
  101. X   }
  102. }
  103. SHAR_EOF
  104. echo 'File gui_card.c is complete' &&
  105. chmod 0644 gui_card.c ||
  106. echo 'restore of gui_card.c failed'
  107. Wc_c="`wc -c < 'gui_card.c'`"
  108. test 111282 -eq "$Wc_c" ||
  109.     echo 'gui_card.c: original size 111282, current size' "$Wc_c"
  110. rm -f _shar_wnt_.tmp
  111. fi
  112. # ============= gui_edit.c ==============
  113. if test -f 'gui_edit.c' -a X"$1" != X"-c"; then
  114.     echo 'x - skipping gui_edit.c (File already exists)'
  115.     rm -f _shar_wnt_.tmp
  116. else
  117. > _shar_wnt_.tmp
  118. echo 'x - extracting gui_edit.c (Text)'
  119. sed 's/^X//' << 'SHAR_EOF' > 'gui_edit.c' &&
  120. /*********************************************************************/
  121. /*  bibView: Administration of bibTex-Databases                      */
  122. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  123. /*                                                                   */
  124. /*  Module:  gui_edit.c                                              */
  125. /*                                                                   */
  126. /*             GUI Edit Window                                       */
  127. /*                                                                   */
  128. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  129. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  130. /*                                                                   */
  131. /*  History:                                                         */
  132. /*    05.03.92  PMU  created                                         */
  133. /*    05.26.92       Version 1.0 released                            */
  134. /*                                                                   */
  135. /*  Copyright 1992 TU MUENCHEN                                       */
  136. /*    See ./Copyright for complete rights and liability information. */
  137. /*                                                                   */
  138. /*********************************************************************/
  139. X
  140. #include <stdio.h>
  141. #include <X11/Intrinsic.h>
  142. #include <X11/StringDefs.h>
  143. #include <X11/Xaw/Paned.h>
  144. #include <X11/Xaw/Form.h>
  145. #include <X11/Xaw/Box.h>
  146. #include <X11/Xaw/List.h>
  147. #include <X11/Xaw/Text.h>
  148. #include <X11/Xaw/AsciiText.h>
  149. #include <X11/Xaw/Viewport.h>
  150. #include <X11/Xaw/Command.h>
  151. #include <X11/Xaw/MenuButton.h>
  152. #include <X11/Xaw/SimpleMenu.h>
  153. #include <X11/Xaw/SmeBSB.h>
  154. #include <X11/Xaw/SmeLine.h>
  155. #include "bibview.h"
  156. X
  157. X
  158. /* imported global variables */
  159. /* ------------------------- */
  160. extern Widget topLevel, desktop;
  161. extern Pixmap macIconPixmap;
  162. X
  163. X
  164. /* macros and definitions */
  165. /* ---------------------- */
  166. X
  167. X
  168. /* local function prototypes */
  169. /* ------------------------- */
  170. X
  171. X
  172. /* exported variables */
  173. /* ------------------ */
  174. X
  175. X
  176. /* local global variables */
  177. /* ---------------------- */
  178. void gueSetEditChangeFlag (Widget w, XtPointer clientData, XtPointer callData);
  179. void gueSaveBibErrWinCmd (Widget w, XtPointer clientData, XtPointer callData);
  180. X
  181. X
  182. X
  183. /*********************************************************************/
  184. /* gueOpenMacroWin:                                                  */
  185. /*    Opens shell for editing macros of a bibliography               */
  186. /*********************************************************************/
  187. Errcode
  188. gueOpenMacroWin (BibPtr bp)
  189. {
  190. Position x, y;
  191. Dimension dwidth, dheight;
  192. MacroWinPtr mw;
  193. Errcode status;
  194. X
  195. X   /* allocate memory for new element of window list */
  196. X   if ((mw = (MacroWinPtr) malloc(sizeof(MacroWin))) == NULL) {
  197. X      /* error-handling is done in control modules */
  198. X      return(ERR_NOMALLOC);
  199. X   }
  200. X
  201. X   /* allocate memory for label of new shell */
  202. X   if ((mw->shellName = 
  203. X      (String) calloc(strlen(PROGNAME)+strlen(bp->filename)+12, 
  204. X              sizeof(char))) == NULL) {
  205. X      return(ERR_NOMALLOC);
  206. X   }
  207. X
  208. X   bp->mw = mw;
  209. X   sprintf(mw->shellName, "%s: Macros %s", PROGNAME, bp->filename);
  210. X   mw->changed = FALSE;
  211. X
  212. X   /* position window and icon */
  213. X   gueSetWindowCoords(bp, TRUE);
  214. X   if (cotIconizeOnDesktop())
  215. X      gueSetIconCoords(bp, TRUE);
  216. X
  217. X   /* create popup shell for new file */
  218. X   mw->macShell = XtVaCreatePopupShell("macShell",
  219. X          topLevelShellWidgetClass, topLevel, 
  220. /*            XtNtransient, TRUE,
  221. X          XtNwindowGroup, XtWindow(topLevel), */
  222. X                  XtNx, mw->winX,
  223. X          XtNy, mw->winY, 
  224. X                  XtNiconX, mw->iconX,
  225. X          XtNiconY, mw->iconY, 
  226. X          XtNtitle, mw->shellName, 
  227. X          XtNiconPixmap, macIconPixmap,
  228. X          XtNiconName, bp->filename, NULL);
  229. X   mw->macWin = XtVaCreateManagedWidget("macWin",
  230. X          panedWidgetClass, mw->macShell, NULL);
  231. X
  232. X   /* create command buttons */
  233. X   mw->cmdBox = XtVaCreateManagedWidget("commandBox", 
  234. X          boxWidgetClass, mw->macWin, NULL);
  235. X   mw->save   = XtVaCreateManagedWidget("save", 
  236. X              commandWidgetClass, mw->cmdBox, NULL);
  237. X   mw->close  = XtVaCreateManagedWidget("close", 
  238. X              commandWidgetClass, mw->cmdBox, NULL);
  239. X   mw->file   = XtVaCreateManagedWidget("macText", 
  240. X              asciiTextWidgetClass, mw->macWin, 
  241. X          XtNtype, XawAsciiFile,
  242. X          XtNeditType, XawtextEdit,
  243. X          XtNstring, bp->macrofile,
  244. X          XtNscrollHorizontal, XawtextScrollWhenNeeded,
  245. X          XtNscrollVertical, XawtextScrollWhenNeeded, NULL);
  246. X
  247. X   XtAddCallback(mw->close, XtNcallback, cseQuitMacrosCmd, (XtPointer)bp);
  248. X   XtAddCallback(mw->save, XtNcallback, cseSaveMacrosCmd, (XtPointer)bp);
  249. X   XtAddCallback(XawTextGetSource(mw->file), 
  250. X         XtNcallback, cseSetMacroChangeFlag, (XtPointer)bp);
  251. X   XtPopup(mw->macShell, XtGrabNone);
  252. X   return(OK);
  253. }
  254. X
  255. X
  256. /*********************************************************************/
  257. /* gueMacroWinExists:                                                */
  258. /*    TRUE, if macro window exists, else FALSE                       */
  259. /*********************************************************************/
  260. Boolean
  261. gueMacroWinExists (BibPtr bp)
  262. {
  263. X   return(bp->mw != NULL);
  264. }
  265. X
  266. X
  267. /*********************************************************************/
  268. /* gueCloseMacroWinCmd:                                              */
  269. /*    Callback function for macro window button close                */
  270. /*********************************************************************/
  271. void
  272. gueCloseMacroWinCmd (Widget w, XtPointer clientData, XtPointer callData)
  273. {
  274. BibPtr bp = (BibPtr) clientData;
  275. Errcode status;
  276. X
  277. X   if ((status = gueCloseMacroWin(bp)) != OK)
  278. X      guwError(status);
  279. }
  280. X
  281. X
  282. /*********************************************************************/
  283. /* gueCloseMacroWin:                                                 */
  284. /*    Close macro window                                             */
  285. /*********************************************************************/
  286. Errcode
  287. gueCloseMacroWin (BibPtr bp)
  288. {
  289. X   if (bp->mw != NULL) {
  290. X      XtPopdown(bp->mw->macShell);
  291. X      free(bp->mw->shellName);
  292. X      free(bp->mw);
  293. X      bp->mw = NULL; 
  294. X   }
  295. X   return(OK);
  296. }
  297. X
  298. X
  299. /*********************************************************************/
  300. /* gueSaveMacrosToFile:                                              */
  301. /*    Save macros to file                                            */
  302. /*********************************************************************/
  303. Errcode
  304. gueSaveMacrosToFile (BibPtr bp)
  305. {
  306. X   if (bp->mw != NULL) {
  307. X      if (!XawAsciiSave(XawTextGetSource(bp->mw->file)))
  308. X     return(ERR_SAVING_TMP);
  309. X      bp->mw->changed = FALSE;
  310. X   }
  311. X   return(OK);
  312. }
  313. X
  314. X
  315. /*********************************************************************/
  316. /* gueCascade:                                                       */
  317. /*    Reposition macro window                                        */
  318. /*********************************************************************/
  319. Errcode
  320. gueCascade (BibPtr bp)
  321. {
  322. X   if (bp->mw == NULL) /* is list window open? */
  323. X      return(OK);
  324. X
  325. X   gueSetWindowCoords(bp, FALSE);
  326. X   if (cotIconizeOnDesktop())
  327. X      gueSetIconCoords(bp, FALSE);
  328. X   return(OK);
  329. }
  330. X
  331. X
  332. /*********************************************************************/
  333. /* gueSetWindowCoords:                                               */
  334. /*    Set position of macro window                                   */
  335. /*********************************************************************/
  336. Errcode
  337. gueSetWindowCoords (BibPtr bp, Boolean calcOnly)
  338. {
  339. Dimension dwidth, dheight;
  340. Position x, y;
  341. MacroWinPtr mw = bp->mw;
  342. X
  343. X   if (mw == NULL) /* is list window open? */
  344. X      return(OK);
  345. X
  346. X   /* calculate position of window */
  347. X   XtVaGetValues(bp->bw->bibdesk,
  348. X         XtNwidth, &dwidth,
  349. X         XtNheight, &dheight, NULL);
  350. X   x = dwidth - SUBWIN_MARGIN;
  351. X   y = SUBWIN_MARGIN;
  352. X   XtTranslateCoords(bp->bw->bibdesk,
  353. X             x, y,
  354. X             &mw->winX, &mw->winY);
  355. X
  356. X   /* set values */
  357. X   if (!calcOnly) {
  358. X      XtVaSetValues(mw->macShell,
  359. X                    XtNx, mw->winX,
  360. X            XtNy, mw->winY, NULL);
  361. X      if (XtIsRealized(mw->macShell)) {
  362. X         XRaiseWindow(XtDisplay(mw->macShell),
  363. X              XtWindow(mw->macShell));
  364. X      }
  365. X   }
  366. X   return(OK);
  367. }
  368. X
  369. X
  370. /*********************************************************************/
  371. /* gueSetIconCoords:                                                 */
  372. /*    Set position of macro window icon                              */
  373. /*********************************************************************/
  374. Errcode
  375. gueSetIconCoords (BibPtr bp, Boolean calcOnly)
  376. {
  377. Dimension dwidth, dheight;
  378. Position x, y;
  379. MacroWinPtr mw = bp->mw;
  380. X
  381. X   if (mw == NULL) /* is list window open? */
  382. X      return(OK);
  383. X
  384. X   /* calculate position of icon */
  385. X   XtVaGetValues(bp->bw->bibdesk,
  386. X         XtNwidth, &dwidth,
  387. X         XtNheight, &dheight, NULL);
  388. X   x = dwidth - (2 * (LST_ICON_WIDTH + LST_ICON_MARGIN));
  389. X   y = LST_ICON_MARGIN;
  390. X   XtTranslateCoords(bp->bw->bibdesk,
  391. X                 x, y, 
  392. X             &mw->iconX, &mw->iconY);
  393. X
  394. X   /* set values */
  395. X   if (!calcOnly) {
  396. X      XtVaSetValues(mw->macShell,
  397. X            XtNiconX, mw->iconX,
  398. X            XtNiconY, mw->iconY, NULL);
  399. X   }
  400. X   return(OK);
  401. }
  402. X
  403. X
  404. /*********************************************************************/
  405. /* gueUnsetIconCoords:                                               */
  406. /*    Delete position of macro window icon                           */
  407. /*********************************************************************/
  408. Errcode
  409. gueUnsetIconCoords (BibPtr bp, Boolean calcOnly)
  410. {
  411. MacroWinPtr mw = bp->mw;
  412. X
  413. X   if (mw == NULL) /* is list window open? */
  414. X      return(OK);
  415. X
  416. X   mw->iconX = mw->iconY = -1;
  417. X   if (!calcOnly) {
  418. X      XtVaSetValues(mw->macShell,
  419. X            XtNiconX, mw->iconX,
  420. X            XtNiconY, mw->iconY, NULL);
  421. X   }
  422. X   return(OK);
  423. }
  424. X
  425. /*********************************************************************/
  426. /* gueErrorWinExists:                                                */
  427. /*    TRUE, if error window exists, else FALSE                       */
  428. /*********************************************************************/
  429. Boolean
  430. gueErrorWinExists (BibPtr bp)
  431. {
  432. X   return(bp->ew != NULL);
  433. }
  434. X
  435. X
  436. /*********************************************************************/
  437. /* gueOpenBibErrWin:                                                 */
  438. /*    Opens shell for editing  errors of a bibliography              */
  439. /*********************************************************************/
  440. Errcode
  441. gueOpenBibErrWin (BibPtr bp, int line)
  442. {
  443. Position x, y;
  444. Dimension dwidth, dheight;
  445. MacroWinPtr mw;
  446. Errcode status;
  447. FILE *countFile;
  448. int nbOfChar, i;
  449. char inh;
  450. X    
  451. X   if (gueErrorWinExists(bp)) {
  452. X      if (XtIsRealized(bp->ew->macShell)) {
  453. X     XRaiseWindow(XtDisplay(bp->ew->macShell),
  454. X              XtWindow(bp->ew->macShell));
  455. X      }
  456. X      return(OK);
  457. X   }
  458. X
  459. X   if (line == ERR_NOBIB) {
  460. X     guwError(ERR_NOBIB);
  461. X     return ERR_NOBIB;
  462. X   }
  463. X   countFile = fopen(bp->filepath, "r");
  464. X   nbOfChar = 0;
  465. X   i = 1;
  466. X   while (i < -line) {
  467. X     while((inh = (char)getc(countFile)) != '\n') nbOfChar++;
  468. X     i++;
  469. X     nbOfChar++;
  470. X   }
  471. X   fclose(countFile);
  472. X  
  473. X
  474. X   /* allocate memory for new element of window list */
  475. X   if ((mw = (MacroWinPtr) malloc(sizeof(MacroWin))) == NULL) {
  476. X      /* error-handling is done in control modules */
  477. X      return(ERR_NOMALLOC);
  478. X   }
  479. X
  480. X   /* allocate memory for label of new shell */
  481. X   if ((mw->shellName = 
  482. X      (String) calloc(strlen(PROGNAME)+strlen(bp->filename)+12, 
  483. X              sizeof(char))) == NULL) {
  484. X      return(ERR_NOMALLOC);
  485. X   }
  486. X
  487. X   bp->ew = mw;
  488. X   bp->ew->changed = FALSE;
  489. X   sprintf(mw->shellName, "%s: Errors %s", PROGNAME, bp->filename);
  490. X   gueSetWindowCoords(bp, TRUE);
  491. X   if (cotIconizeOnDesktop())
  492. X      gueSetIconCoords(bp, TRUE);
  493. X
  494. X   mw->macShell = XtVaCreatePopupShell("macShell",
  495. X          topLevelShellWidgetClass, topLevel, 
  496. /*            XtNtransient, TRUE,
  497. X          XtNwindowGroup, XtWindow(topLevel), */
  498. X                  XtNwidth, 400,
  499. X          XtNheight, 500, 
  500. X          XtNtitle, mw->shellName, 
  501. X          XtNiconPixmap, macIconPixmap,
  502. X          XtNiconName, bp->filename, NULL);
  503. X   mw->macWin = XtVaCreateManagedWidget("macWin",
  504. X          panedWidgetClass, mw->macShell, NULL);
  505. X   mw->cmdBox = XtVaCreateManagedWidget("commandBox", 
  506. X          boxWidgetClass, mw->macWin, NULL);
  507. X   mw->save   = XtVaCreateManagedWidget("save", 
  508. X              commandWidgetClass, mw->cmdBox, NULL);
  509. X   mw->close  = XtVaCreateManagedWidget("close", 
  510. X              commandWidgetClass, mw->cmdBox, NULL);
  511. X   mw->file   = XtVaCreateManagedWidget("macText", 
  512. X              asciiTextWidgetClass, mw->macWin, 
  513. X          XtNtype, XawAsciiFile,
  514. X          XtNstring, bp->filepath, 
  515. X          XtNdataCompression, False,
  516. X          XtNeditType, XawtextEdit, 
  517. X          XtNscrollHorizontal, XawtextScrollWhenNeeded,
  518. X          XtNscrollVertical, XawtextScrollWhenNeeded, NULL);
  519. X
  520. X   XtAddCallback(mw->close, XtNcallback, gueCloseBibErrWinCmd, (XtPointer)bp);
  521. X   XtAddCallback(mw->save, XtNcallback, gueSaveBibErrWinCmd, (XtPointer)bp);
  522. X   XtAddCallback(XawTextGetSource(mw->file), 
  523. X         XtNcallback, gueSetEditChangeFlag, (XtPointer)bp);
  524. X   XtPopup(mw->macShell, XtGrabNone); 
  525. X   guwError(ERR_ERROR_IN_FILE);
  526. X   XawTextSetInsertionPoint(mw->file, nbOfChar);
  527. X   XawTextSetSelection(mw->file, nbOfChar, nbOfChar + 10);
  528. X   return(OK);
  529. }
  530. X
  531. X
  532. X
  533. /*********************************************************************/
  534. /* gueCloseBibErrWinCmd:                                             */
  535. /*    Callback function for error window button close                */
  536. /*********************************************************************/
  537. void
  538. gueCloseBibErrWinCmd (Widget w, XtPointer clientData, XtPointer callData)
  539. {
  540. BibPtr bp = (BibPtr) clientData;
  541. Errcode status;
  542. X
  543. X   if ((status = gueCloseBibErrWin(bp)) != OK)
  544. X      guwError(status);
  545. }
  546. X
  547. X
  548. /*********************************************************************/
  549. /* gueCloseBibErrWin:                                                */
  550. /*    Close error window                                             */
  551. /*********************************************************************/
  552. Errcode
  553. gueCloseBibErrWin (BibPtr bp)
  554. {  
  555. X   if (bp->ew != NULL) {
  556. X      XtPopdown(bp->ew->macShell);
  557. X      XtDestroyWidget(bp->ew->macShell);
  558. X      XtDestroyWidget(bp->ew->macWin);
  559. X      XtDestroyWidget(bp->ew->cmdBox);
  560. X      XtDestroyWidget(bp->ew->save);
  561. X      XtDestroyWidget(bp->ew->close);
  562. X      XtDestroyWidget(bp->ew->file);
  563. X      free(bp->ew->shellName);
  564. X      free(bp->ew); 
  565. X      bp->ew = NULL; 
  566. X   }
  567. X   glbDelBibListEl(bp);  
  568. X   return(OK);
  569. }
  570. X
  571. X
  572. /*********************************************************************/
  573. /* gueSaveBibErrWinCmd:                                              */
  574. /*    Callback function for error window button save                 */
  575. /*********************************************************************/
  576. void
  577. gueSaveBibErrWinCmd (Widget w, XtPointer clientData, XtPointer callData)
  578. {
  579. BibPtr bp = (BibPtr) clientData;
  580. Errcode status;
  581. X
  582. X   if ((status = gueSaveBibErrWin(bp)) != OK)
  583. X     {guwError(status);
  584. X      return;
  585. X      }
  586. X   if (bp->ew != NULL) {
  587. X      XtPopdown(bp->ew->macShell);
  588. X      free(bp->ew->shellName);
  589. X      free(bp->ew); 
  590. X      bp->ew = NULL; 
  591. X   }
  592. X   glbDelBibListEl(bp);  
  593. X   return;
  594. }
  595. X
  596. X
  597. /*********************************************************************/
  598. /* gueSaveBibErrWin:                                                 */
  599. /*    Save  error window                                             */
  600. /*********************************************************************/
  601. Errcode
  602. gueSaveBibErrWin (BibPtr bp)
  603. {
  604. X   if (bp->ew != NULL) {
  605. X      if (XawAsciiSave(XawTextGetSource(bp->ew->file)) == FALSE) 
  606. X     return(ERR_SAVING_TMP); 
  607. X      bp->ew->changed = FALSE; 
  608. X   }
  609. X
  610. X   return(OK);
  611. }
  612. X
  613. X
  614. /*********************************************************************/
  615. /* gueSetEditChangeFlag:                                             */
  616. /*    Callback of text widget, sets flags when buffer changes        */
  617. /*********************************************************************/
  618. void
  619. gueSetEditChangeFlag (Widget w, XtPointer clientData, XtPointer callData)
  620. {
  621. BibPtr bp = (BibPtr)clientData;
  622. X
  623. X   bp->ew->changed = TRUE;
  624. }
  625. X
  626. X
  627. X
  628. X
  629. /*********************************************************************/
  630. /* LOCAL FUNCTIONS                                                   */
  631. /*********************************************************************/
  632. X
  633. X
  634. X
  635. X
  636. X
  637. SHAR_EOF
  638. chmod 0644 gui_edit.c ||
  639. echo 'restore of gui_edit.c failed'
  640. Wc_c="`wc -c < 'gui_edit.c'`"
  641. test 16232 -eq "$Wc_c" ||
  642.     echo 'gui_edit.c: original size 16232, current size' "$Wc_c"
  643. rm -f _shar_wnt_.tmp
  644. fi
  645. # ============= gui_list.c ==============
  646. if test -f 'gui_list.c' -a X"$1" != X"-c"; then
  647.     echo 'x - skipping gui_list.c (File already exists)'
  648.     rm -f _shar_wnt_.tmp
  649. else
  650. > _shar_wnt_.tmp
  651. echo 'x - extracting gui_list.c (Text)'
  652. sed 's/^X//' << 'SHAR_EOF' > 'gui_list.c' &&
  653. /*********************************************************************/
  654. /*  bibView: Administration of bibTex-Databases                      */
  655. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  656. /*                                                                   */
  657. /*  Module:  gui_list.c                                              */
  658. /*                                                                   */
  659. /*             GUI List Window                                       */
  660. /*                                                                   */
  661. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  662. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  663. /*                                                                   */
  664. /*  History:                                                         */
  665. /*    01.25.91  PMU  created                                         */
  666. /*    05.26.92       Version 1.0 released                            */
  667. /*                                                                   */
  668. /*  Copyright 1992 TU MUENCHEN                         */
  669. /*    See ./Copyright for complete rights and liability information. */
  670. /*                                                                   */
  671. /*********************************************************************/
  672. X
  673. #include <stdio.h>
  674. #include <X11/Intrinsic.h>
  675. #include <X11/StringDefs.h>
  676. #include <X11/Xaw/Paned.h>
  677. #include <X11/Xaw/Form.h>
  678. #include <X11/Xaw/Box.h>
  679. #include <X11/Xaw/List.h>
  680. #include <X11/Xaw/Viewport.h>
  681. #include <X11/Xaw/Command.h>
  682. #include <X11/Xaw/MenuButton.h>
  683. #include <X11/Xaw/SimpleMenu.h>
  684. #include <X11/Xaw/SmeBSB.h>
  685. #include <X11/Xaw/SmeLine.h>
  686. #include "bibview.h"
  687. X
  688. X
  689. /* imported global variables */
  690. /* ------------------------- */
  691. extern Widget topLevel, desktop;
  692. extern Pixmap lstIconPixmap;
  693. X
  694. X
  695. /* macros and definitions */
  696. /* ---------------------- */
  697. X
  698. X
  699. /* local function prototypes */
  700. /* ------------------------- */
  701. static Errcode MakeListStrings (LstWinPtr lw);
  702. X
  703. X
  704. /* exported variables */
  705. /* ------------------ */
  706. X
  707. X
  708. /* local global variables */
  709. /* ---------------------- */
  710. X
  711. X
  712. /*********************************************************************/
  713. /* gulOpenListWin:                                                   */
  714. /*    Create list window                                             */
  715. /*********************************************************************/
  716. Errcode
  717. gulOpenListWin (BibPtr bp, CardDataList cl) 
  718. {
  719. LstWinPtr lw;
  720. Errcode status;
  721. X
  722. X   /* if opened already, just replace data and raise window */
  723. X   if (bp->lw) {
  724. X      if ((status = gulReplaceListData(bp, cl)) != OK)
  725. X     return(status);
  726. X      if (XtIsRealized(bp->lw->lstShell)) {
  727. X     XRaiseWindow(XtDisplay(bp->lw->lstShell),
  728. X              XtWindow(bp->lw->lstShell));
  729. X      }
  730. X      return(OK);
  731. X   }
  732. X
  733. X   if ((lw = (LstWinPtr)malloc(sizeof(LstWin))) == NULL)
  734. X      return(ERR_NOMALLOC); 
  735. X
  736. X   /* build label of new shell */
  737. X   if ((lw->shellName = (String)calloc(strlen(PROGNAME) +
  738. X                           strlen(bp->filename)+10, 
  739. X                           sizeof(char))) == NULL) {
  740. X      return(ERR_NOMALLOC); 
  741. X   }
  742. X   sprintf(lw->shellName, "%s: List %s", PROGNAME, bp->filename);
  743. X
  744. X   /* create argc and argv for list window */
  745. X   lw->cardLst = cl;
  746. X   if ((status = MakeListStrings(lw)) != OK) {
  747. X      free(lw->shellName);
  748. X      free(lw);
  749. X      return(status); 
  750. X   }
  751. X
  752. X   /* register window in bib struct */
  753. X   bp->lw = lw;
  754. X
  755. X
  756. X   /* position window and icon */
  757. X   gulSetWindowCoords(bp, TRUE);
  758. X   if (cotIconizeOnDesktop())
  759. X      gulSetIconCoords(bp, TRUE);
  760. X
  761. X   /* create popup shell for new file */
  762. X   lw->lstShell = XtVaCreatePopupShell("listShell",
  763. X                topLevelShellWidgetClass, topLevel,
  764. X                    XtNx, lw->winX,
  765. X            XtNy, lw->winY, 
  766. X                    XtNiconX, lw->iconX,
  767. X            XtNiconY, lw->iconY, 
  768. X                    XtNtitle, lw->shellName,
  769. X                    XtNiconPixmap, lstIconPixmap,
  770. X                    XtNiconName, bp->filename, NULL);
  771. X   /* create windows of popup shell */
  772. X   lw->lstWin = XtVaCreateManagedWidget("listWin",
  773. X                 panedWidgetClass, lw->lstShell, NULL);
  774. X   lw->cmdBox = XtVaCreateManagedWidget("commandBox", 
  775. X             boxWidgetClass, lw->lstWin, NULL);
  776. X   lw->save = XtVaCreateManagedWidget("save", 
  777. X            commandWidgetClass, lw->cmdBox, NULL);
  778. X   lw->print = XtVaCreateManagedWidget("print", 
  779. X            commandWidgetClass, lw->cmdBox, NULL);
  780. X   lw->quit = XtVaCreateManagedWidget("quit", 
  781. X           commandWidgetClass, lw->cmdBox, NULL);
  782. X   lw->lstVp = XtVaCreateManagedWidget("listVport",
  783. X           viewportWidgetClass, lw->lstWin, 
  784. X           XtNallowVert, True, 
  785. X           XtNallowHoriz, True, 
  786. X           XtNuseBottom, TRUE, NULL);
  787. X   lw->vpWin = XtVaCreateManagedWidget("vportWin",
  788. X                 panedWidgetClass, lw->lstVp, NULL);
  789. X   lw->headBox = XtVaCreateManagedWidget("headBox", 
  790. X             boxWidgetClass, lw->vpWin, 
  791. X             XtNvSpace, 0, 
  792. X             XtNborderWidth, 0, NULL);
  793. X                 XtVaCreateManagedWidget("head1", 
  794. X              labelWidgetClass, lw->headBox, 
  795. X              XtNborderWidth, 0, NULL);
  796. X                 XtVaCreateManagedWidget("head2", 
  797. X              labelWidgetClass, lw->headBox, 
  798. X              XtNborderWidth, 0, NULL);
  799. X                 XtVaCreateManagedWidget("head3", 
  800. X              labelWidgetClass, lw->headBox, 
  801. X              XtNborderWidth, 0, NULL);
  802. X                 XtVaCreateManagedWidget("head4", 
  803. X              labelWidgetClass, lw->headBox, 
  804. X              XtNborderWidth, 0, NULL);
  805. X
  806. X   lw->list = XtVaCreateManagedWidget("mylist", 
  807. X           listWidgetClass, lw->vpWin,  
  808. /*           XtNnumberStrings, lw->listArgc,  */
  809. X           XtNdefaultColumns, 1,  
  810. X           XtNforceColumns, True,  
  811. X           XtNlist, lw->listArgv, NULL);
  812. X   XtAddCallback(lw->quit, XtNcallback, gulCloseListWinCmd, (XtPointer)bp);
  813. X   XtAddCallback(lw->list, XtNcallback, csrDisplayCardCmd, (XtPointer)bp);
  814. X   XtAddCallback(lw->print, XtNcallback, cprPrintListCmd, (XtPointer)lw->cardLst);
  815. X   XtAddCallback(lw->save, XtNcallback, cprSaveListCmd, (XtPointer)bp);
  816. X
  817. X   XtPopup(lw->lstShell, XtGrabNone);
  818. X   return(OK);
  819. }
  820. X
  821. X
  822. /*********************************************************************/
  823. /* gulListWinExists:                                                 */
  824. /*    TRUE, if list window exists, else FALSE                        */
  825. /*********************************************************************/
  826. Boolean
  827. gulListWinExists (BibPtr bp)
  828. {
  829. X   return(bp->lw != NULL);
  830. }
  831. X
  832. X
  833. /*********************************************************************/
  834. /* gulReplaceListData:                                               */
  835. /*    Replace cards to display in list                               */
  836. /*********************************************************************/
  837. Errcode
  838. gulReplaceListData (BibPtr bp, CardDataList cl)
  839. {
  840. LstWinPtr lw = bp->lw;
  841. Widget vsb;
  842. Errcode status;
  843. X
  844. X   if (lw == NULL) /* is list window open? */
  845. X      return(OK);
  846. X
  847. X   /* free old stuff */
  848. X   if (lw->listArgv)
  849. X      free(lw->listArgv);
  850. X   if (lw->strs)
  851. X      free(lw->strs);
  852. X
  853. /*   dbtCardListDelete(&lw->cardLst); */
  854. X     XtRemoveAllCallbacks(lw->print, XtNcallback); 
  855. X
  856. X   /* create argc and argv for list window */
  857. X   lw->cardLst = cl;
  858. X   if ((status = MakeListStrings(lw)) != OK) {
  859. X      lw->listArgv = NULL;
  860. X      lw->strs = NULL;
  861. X      return(status); 
  862. X   }
  863. X
  864. X   /* change list */
  865. X   XawPanedSetRefigureMode(lw->vpWin, False); 
  866. X   XawListChange(lw->list, lw->listArgv, lw->listArgc, 0, True);
  867. X
  868. X   /* scroll to beginning of list */
  869. X   XawListHighlight(lw->list, 0);
  870. X   XawListUnhighlight(lw->list);
  871. X   XawPanedSetRefigureMode(lw->vpWin, True);
  872. X
  873. X   /* set new client data for callbacks */
  874. X   XtAddCallback(lw->print, XtNcallback, cprPrintListCmd, (XtPointer)lw->cardLst);
  875. X
  876. X   return(OK);
  877. }
  878. X
  879. X
  880. /*********************************************************************/
  881. /* gulCloseListWinCmd:                                               */
  882. /*    Callback function for list menu entry quit                     */
  883. /*********************************************************************/
  884. void
  885. gulCloseListWinCmd (Widget w, XtPointer clientData, XtPointer callData)
  886. {
  887. BibPtr bp = (BibPtr) clientData;
  888. Errcode status;
  889. X
  890. X   if ((status = gulCloseListWin(bp)) != OK)
  891. X      guwError(status);
  892. }
  893. X
  894. X
  895. /*********************************************************************/
  896. /* gulCloseListWin:                                                  */
  897. /*    Close list window                                              */
  898. /*********************************************************************/
  899. Errcode
  900. gulCloseListWin (BibPtr bp)
  901. {
  902. X   if (bp->lw != NULL) {
  903. X      XtPopdown(bp->lw->lstShell);
  904. X      if (bp->lw->listArgv)
  905. X         free(bp->lw->listArgv);
  906. X      if (bp->lw->strs)
  907. X         free(bp->lw->strs);
  908. /*    free(bp->lw->cardLst); HOLGER  */
  909. X      bp->lw->cardLst = NULL;
  910. X      free(bp->lw->shellName);
  911. X      free(bp->lw); 
  912. X      bp->lw = NULL;
  913. X   }
  914. X   return(OK);
  915. }
  916. X
  917. X
  918. /*********************************************************************/
  919. /* gulCascade:                                                       */
  920. /*    Reposition list window                                         */
  921. /*********************************************************************/
  922. Errcode
  923. gulCascade (BibPtr bp)
  924. {
  925. X   if (bp->lw == NULL) /* is list window open? */
  926. X      return(OK);
  927. X
  928. X   gulSetWindowCoords(bp, FALSE);
  929. X   if (cotIconizeOnDesktop())
  930. X      gulSetIconCoords(bp, FALSE);
  931. X   return(OK);
  932. }
  933. X
  934. X
  935. /*********************************************************************/
  936. /* gulSetWindowCoords:                                               */
  937. /*    Set position of list window                                    */
  938. /*********************************************************************/
  939. Errcode
  940. gulSetWindowCoords (BibPtr bp, Boolean calcOnly)
  941. {
  942. Dimension dwidth, dheight;
  943. Position x, y;
  944. LstWinPtr lw = bp->lw;
  945. X
  946. X   if (lw == NULL) /* is list window open? */
  947. X      return(OK);
  948. X
  949. X   /* calculate position of window */
  950. X   XtVaGetValues(bp->bw->bibdesk,
  951. X         XtNwidth, &dwidth,
  952. X         XtNheight, &dheight, NULL);
  953. X   x = dwidth - SUBWIN_MARGIN;
  954. X   y = SUBWIN_MARGIN;
  955. X   XtTranslateCoords(bp->bw->bibdesk,
  956. X             x, y,
  957. X             &lw->winX, &lw->winY);
  958. X
  959. X   /* set values */
  960. X   if (!calcOnly) {
  961. X      XtVaSetValues(lw->lstShell,
  962. X                    XtNx, lw->winX,
  963. X            XtNy, lw->winY, NULL);
  964. X      if (XtIsRealized(lw->lstShell)) {
  965. X         XRaiseWindow(XtDisplay(lw->lstShell),
  966. X              XtWindow(lw->lstShell));
  967. X      }
  968. X   }
  969. X   return(OK);
  970. }
  971. X
  972. X
  973. /*********************************************************************/
  974. /* gulSetIconCoords:                                                 */
  975. /*    Set position of list window icon                               */
  976. /*********************************************************************/
  977. Errcode
  978. gulSetIconCoords (BibPtr bp, Boolean calcOnly)
  979. {
  980. Dimension dwidth, dheight;
  981. Position x, y;
  982. LstWinPtr lw = bp->lw;
  983. X
  984. X   if (lw == NULL) /* is list window open? */
  985. X      return(OK);
  986. X
  987. X   /* calculate position of icon */
  988. X   XtVaGetValues(bp->bw->bibdesk,
  989. X         XtNwidth, &dwidth,
  990. X         XtNheight, &dheight, NULL);
  991. X   x = dwidth - LST_ICON_WIDTH - LST_ICON_MARGIN;
  992. X   y = LST_ICON_MARGIN;
  993. X   XtTranslateCoords(bp->bw->bibdesk,
  994. X                 x, y, 
  995. X             &lw->iconX, &lw->iconY);
  996. X
  997. X   /* set values */
  998. X   if (!calcOnly) {
  999. X      XtVaSetValues(lw->lstShell,
  1000. X            XtNiconX, lw->iconX,
  1001. X            XtNiconY, lw->iconY, NULL);
  1002. X   }
  1003. X   return(OK);
  1004. }
  1005. X
  1006. X
  1007. /*********************************************************************/
  1008. /* gulUnsetIconCoords:                                               */
  1009. /*    Delete position of list window icon                            */
  1010. /*********************************************************************/
  1011. Errcode
  1012. gulUnsetIconCoords (BibPtr bp, Boolean calcOnly)
  1013. {
  1014. LstWinPtr lw = bp->lw;
  1015. X
  1016. X   if (lw == NULL) /* is list window open? */
  1017. X      return(OK);
  1018. X
  1019. X   lw->iconX = lw->iconY = -1;
  1020. X   if (!calcOnly) {
  1021. X      XtVaSetValues(lw->lstShell,
  1022. X            XtNiconX, lw->iconX,
  1023. X            XtNiconY, lw->iconY, NULL);
  1024. X   }
  1025. X   return(OK);
  1026. }
  1027. X
  1028. X
  1029. X
  1030. /*********************************************************************/
  1031. /* LOCAL FUNCTIONS                                                   */
  1032. /*********************************************************************/
  1033. X
  1034. /*********************************************************************/
  1035. /* MakeListStrings:                                                  */
  1036. /*    Build entries for list from argv of cards                      */
  1037. /*********************************************************************/
  1038. static Errcode
  1039. MakeListStrings (LstWinPtr lw)
  1040. {
  1041. CardDataList cl;
  1042. String p, *sp, help, spp;
  1043. int i, noOfCards = 0; 
  1044. X
  1045. X   /* find out how many cards there are */
  1046. X   for (cl=lw->cardLst; cl != NULL; cl=cl->next, noOfCards++)  ;
  1047. X   lw->listArgc = noOfCards;  
  1048. X
  1049. X   if (noOfCards == 0) {
  1050. X      lw->listArgv = NULL;
  1051. X      lw->strs = NULL;
  1052. X      return(OK);
  1053. X   }
  1054. X
  1055. X   /* alloc new argv for Strings */
  1056. X   if ((help = (String)calloc(1,LST_ENTRY_LEN+1)) == NULL)
  1057. X      return(ERR_NOMALLOC);
  1058. X   if ((lw->listArgv=(String *)calloc(noOfCards+1, sizeof(String))) == NULL)
  1059. X      return(ERR_NOMALLOC);
  1060. X   if ((lw->strs = (String)calloc(noOfCards,(size_t)(LST_ENTRY_LEN+1))) == NULL)
  1061. X      return(ERR_NOMALLOC); 
  1062. X   for (i=0, p=lw->strs; i < noOfCards; i++) {
  1063. X      (lw->listArgv)[i] = p;
  1064. X      p += LST_ENTRY_LEN+1; 
  1065. X   }
  1066. X   lw->listArgv[noOfCards] = NULL; /* NULL terminated list */
  1067. X   i=0; 
  1068. X   for (cl=lw->cardLst, sp=lw->listArgv; cl != NULL; cl=cl->next, sp++) {
  1069. X     sprintf(*sp, "%-*.*s",
  1070. X        LST_AUTHOR_WIDTH, LST_AUTHOR_WIDTH, 
  1071. X    ((glbIsStringEmpty(cl->data->author))? "" : cl->data->author));
  1072. X
  1073. X     sprintf(help, "%-*.*s",
  1074. X    LST_WHITESPACE, LST_WHITESPACE, "");
  1075. X
  1076. X     *sp = strcat(*sp,help);
  1077. X
  1078. X     sprintf(help, "%-*.*s",
  1079. X    LST_TITLE_WIDTH, LST_TITLE_WIDTH, 
  1080. X    ((glbIsStringEmpty(cl->data->title))? "" : cl->data->title));
  1081. X
  1082. X     *sp = strcat(*sp,help);
  1083. X
  1084. X     sprintf(help, "%-*.*s",
  1085. X    LST_WHITESPACE, LST_WHITESPACE, "");
  1086. X
  1087. X     *sp = strcat(*sp,help);
  1088. X
  1089. X     sprintf(help, "%-*.*s",
  1090. X    LST_TYPE_WIDTH, LST_TYPE_WIDTH, glbTypeToName(cl->data->cardtype));
  1091. X
  1092. X     *sp = strcat(*sp,help);
  1093. X
  1094. X     sprintf(help, "%-*.*s",
  1095. X    LST_WHITESPACE, LST_WHITESPACE, "");
  1096. X
  1097. X     *sp = strcat(*sp,help);
  1098. X
  1099. X     sprintf(help, "%-*.*s",
  1100. X    LST_YEAR_WIDTH, LST_YEAR_WIDTH, 
  1101. X    ((glbIsStringEmpty(cl->data->year)) ? ""  : cl->data->year));
  1102. X
  1103. X     *sp = strcat(*sp,help); 
  1104. X     for (spp=*sp;*spp!='\0';spp++)
  1105. X       if ((*spp=='\t')||(*spp=='\n'))
  1106. X     *spp=' ';
  1107. X   }
  1108. X   free(help);
  1109. X   return(OK);
  1110. }
  1111. SHAR_EOF
  1112. chmod 0644 gui_list.c ||
  1113. echo 'restore of gui_list.c failed'
  1114. Wc_c="`wc -c < 'gui_list.c'`"
  1115. test 14331 -eq "$Wc_c" ||
  1116.     echo 'gui_list.c: original size 14331, current size' "$Wc_c"
  1117. rm -f _shar_wnt_.tmp
  1118. fi
  1119. # ============= gui_main.c ==============
  1120. if test -f 'gui_main.c' -a X"$1" != X"-c"; then
  1121.     echo 'x - skipping gui_main.c (File already exists)'
  1122.     rm -f _shar_wnt_.tmp
  1123. else
  1124. > _shar_wnt_.tmp
  1125. echo 'x - extracting gui_main.c (Text)'
  1126. sed 's/^X//' << 'SHAR_EOF' > 'gui_main.c' &&
  1127. /*********************************************************************/
  1128. /*  bibView: Administration of bibTex-Databases                      */
  1129. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  1130. /*                                                                   */
  1131. /*  Module:  gui_main.c                                              */
  1132. /*                                                                   */
  1133. /*             - Realize main application window                     */
  1134. /*             -                                                     */
  1135. /*                                                                   */
  1136. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  1137. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  1138. /*                                                                   */
  1139. /*  History:                                                         */
  1140. /*    11.22.91  PMU  created                                         */
  1141. /*    05.26.92       Version 1.0 released                            */
  1142. /*                                                                   */
  1143. /*  Copyright 1992 TU MUENCHEN                                       */
  1144. /*    See ./Copyright for complete rights and liability information. */
  1145. /*                                                                   */
  1146. /*********************************************************************/
  1147. X
  1148. #include <stdio.h>
  1149. #include <X11/Intrinsic.h>
  1150. #include <X11/StringDefs.h>
  1151. #include <X11/Xaw/Paned.h>
  1152. #include <X11/Xaw/Form.h>
  1153. #include <X11/Xaw/Box.h>
  1154. #include <X11/Xaw/Command.h>
  1155. #include <X11/Xaw/MenuButton.h>
  1156. #include <X11/Xaw/SimpleMenu.h>
  1157. #include <X11/Xaw/SmeBSB.h>
  1158. #include <X11/Xaw/SmeLine.h>
  1159. #include <X11/bitmaps/xlogo16>
  1160. #include <X11/bitmaps/gray>
  1161. #include "bibview.h"
  1162. X
  1163. X
  1164. /* imported global variables */
  1165. /* ------------------------- */
  1166. extern Widget topLevel;
  1167. extern Pixmap chkmarkPixmap;
  1168. extern Pixmap bvIconPixmap;
  1169. X
  1170. X
  1171. /* macros and definitions */
  1172. /* ---------------------- */
  1173. X
  1174. /* structure hold a menu entry */
  1175. typedef struct {
  1176. X   String name;
  1177. X   XtCallbackProc cb;
  1178. X   Boolean *bool;
  1179. } menuEntry;
  1180. X
  1181. X
  1182. /* local function prototypes */
  1183. /* ------------------------- */
  1184. static void OptionsSelect(Widget w, XtPointer client_data, XtPointer garbage);
  1185. static void createMenu(String name, menuEntry item[], Widget *menu, Widget parent, Boolean isBool);
  1186. X
  1187. /* exported variables */
  1188. /* ------------------ */
  1189. Widget mainMenu, desktop;
  1190. X
  1191. X
  1192. /* local global variables */
  1193. /* ---------------------- */
  1194. X
  1195. /* Widgets for main window */
  1196. static Widget mwShell,
  1197. X          mwWin,
  1198. X          mwCommandBox,
  1199. X          mwFile,       mwFileMenu,
  1200. X          mwServices,   mwServicesMenu,
  1201. X          mwOptions,    mwOptionsMenu,
  1202. X          mwWindow,     mwWindowMenu,
  1203. X          mwHelp,       mwHelpMenu,
  1204. X          mwDesktop;
  1205. X
  1206. X
  1207. static menuEntry fileEntry[] = {
  1208. X   { "line1", NULL,              NULL },
  1209. X   { "item1", copNewCmd,         NULL },
  1210. X   { "item2", copOpenCmd,        NULL },
  1211. X   { "item3", csaCloseBibCmd,    NULL },
  1212. X   { "item4", csaSaveBibCmd,     NULL },
  1213. X   { "item5", csaSaveAsBibCmd,   NULL },
  1214. X   { "line2", NULL,              NULL },
  1215. X   { "quit",  csaQuitBibviewCmd, NULL },
  1216. X   { NULL,    NULL,              NULL }
  1217. };
  1218. X
  1219. static menuEntry servicesEntry[] = {
  1220. X   { "line1", NULL,             NULL },
  1221. X   { "item1", cseCheckBibCmd,   NULL },
  1222. X   { "item2", cseCollateBibCmd, NULL },
  1223. X   { "item3", cprPrintBibCmd,   NULL },
  1224. X   { "item4", cseEditMacrosCmd, NULL },
  1225. X   { "item5", cseLoadConfigCmd, NULL },
  1226. X   { NULL,    NULL,             NULL }
  1227. };
  1228. X
  1229. static menuEntry optionsEntry[] = {
  1230. X   { "line1", NULL, NULL },
  1231. X   { "item1", cotOptionsControl,
  1232. X          &optionsStatus[OPT_BEEP_ON_ERROR] },
  1233. X   { "item2", cotOptionsControl,
  1234. X          &optionsStatus[OPT_BACKUP_ON_SAVE] },
  1235. X   { "item3", cotOptionIconOnDeskCmd, 
  1236. X          &optionsStatus[OPT_ICON_ON_DESKTOP] },
  1237. X   { "item4", cotOptionsControl,
  1238. X          &optionsStatus[OPT_AUTO_CHECK_BIB] },
  1239. X   { "item5", cotOptionsControl,
  1240. X          &optionsStatus[OPT_REQUIRED_FIELDS] },
  1241. X   { NULL, NULL, NULL }
  1242. };
  1243. X
  1244. static menuEntry windowEntry[] = {
  1245. X   { "line1", NULL, NULL },
  1246. X   { "item1", gubCascadeCmd, NULL },
  1247. X   { NULL, NULL, NULL }
  1248. };
  1249. X
  1250. static menuEntry helpEntry[] = {
  1251. X   { "line1", NULL, NULL },
  1252. X   { "item1", hlpOpenHelpWinCmd, NULL },
  1253. X   { "item2", hlpOpenHelpWinCmd, NULL },
  1254. X   { "item3", hlpOpenHelpWinCmd, NULL },
  1255. X   { "item4", hlpOpenHelpWinCmd, NULL },
  1256. X   { "item5", hlpOpenHelpWinCmd, NULL },
  1257. X   { "item6", hlpOpenHelpWinCmd, NULL },
  1258. X   { "line2", NULL, NULL },
  1259. X   { "info",  guwProgInfo, NULL },
  1260. X   { NULL, NULL, NULL }
  1261. };
  1262. X
  1263. X
  1264. X
  1265. /*********************************************************************/
  1266. /* gwmMainWin:                                                       */
  1267. /*    Realize main application window                                */
  1268. /*********************************************************************/
  1269. int
  1270. gwmMainWin (void)
  1271. {
  1272. /* mwShell      = XtVaCreatePopupShell("mainShell",
  1273. X            topLevelShellWidgetClass, topLevel, 
  1274. X            XtNiconPixmap, bvIconPixmap, NULL);
  1275. */
  1276. X   mwWin        = XtVaCreateManagedWidget("mainwin", 
  1277. X            panedWidgetClass, topLevel, NULL);
  1278. X
  1279. X   /* create command buttons */
  1280. X   mainMenu =
  1281. X   mwCommandBox = XtVaCreateManagedWidget("commandBox", 
  1282. X            boxWidgetClass, mwWin, NULL);
  1283. X   mwFile       = XtVaCreateManagedWidget("file", 
  1284. X            menuButtonWidgetClass, mwCommandBox, NULL);
  1285. X   mwServices   = XtVaCreateManagedWidget("services", 
  1286. X            menuButtonWidgetClass, mwCommandBox, NULL);
  1287. X   mwOptions    = XtVaCreateManagedWidget("options", 
  1288. X            menuButtonWidgetClass, mwCommandBox, NULL);
  1289. X   mwWindow     = XtVaCreateManagedWidget("window", 
  1290. X            menuButtonWidgetClass, mwCommandBox, NULL);
  1291. X   mwHelp       = XtVaCreateManagedWidget("help", 
  1292. X            menuButtonWidgetClass, mwCommandBox, NULL);
  1293. X
  1294. X   /* make pulldownmenus for command boxes */
  1295. X   createMenu("fileMenu", fileEntry, &mwFileMenu, mwFile, FALSE);
  1296. X   createMenu("servicesMenu", servicesEntry, &mwServicesMenu, mwServices, FALSE);
  1297. X   createMenu("optionsMenu", optionsEntry, &mwOptionsMenu, mwOptions, TRUE);
  1298. X   createMenu("windowMenu", windowEntry, &mwWindowMenu, mwWindow, FALSE);
  1299. X   createMenu("helpMenu", helpEntry, &mwHelpMenu, mwHelp, FALSE);
  1300. X
  1301. X   desktop = 
  1302. X   mwDesktop    = XtVaCreateManagedWidget("desktop", 
  1303. X                    formWidgetClass, mwWin,
  1304. X            XtNresizable, TRUE, NULL);
  1305. X
  1306. X   return(OK);
  1307. }
  1308. X
  1309. X
  1310. X
  1311. /*********************************************************************/
  1312. /* createMenu:                                                       */
  1313. /*    Build a main application window pulldown menu                  */
  1314. /*********************************************************************/
  1315. static void
  1316. createMenu (String menuName, menuEntry item[], Widget *menu, Widget parent, Boolean isBool)
  1317. {
  1318. static Widget w;
  1319. int i = 0;
  1320. String iname;
  1321. X
  1322. X   *menu = XtVaCreatePopupShell(menuName, 
  1323. X                               simpleMenuWidgetClass, 
  1324. X                   parent, NULL);
  1325. X   i = 0;
  1326. X   while ((iname = item[i].name) != NULL) { 
  1327. X      if (strncmp("line", iname, 4) == 0)   /* use a line pane */
  1328. X         w = XtVaCreateManagedWidget(iname,
  1329. X               smeLineObjectClass, *menu, NULL);
  1330. X      else {
  1331. X         w = XtVaCreateManagedWidget(iname, 
  1332. X           smeBSBObjectClass, *menu, NULL);
  1333. X     if (isBool) {
  1334. X        if (*item[i].bool)
  1335. X           XtVaSetValues(w, XtNleftBitmap, chkmarkPixmap, NULL);
  1336. X     }
  1337. X         XtAddCallback(w, XtNcallback, item[i].cb, (XtPointer) i);
  1338. X      }
  1339. X      i++;
  1340. X   } /* endwhile */
  1341. }
  1342. X
  1343. X
  1344. X
  1345. X
  1346. SHAR_EOF
  1347. chmod 0644 gui_main.c ||
  1348. echo 'restore of gui_main.c failed'
  1349. Wc_c="`wc -c < 'gui_main.c'`"
  1350. test 7429 -eq "$Wc_c" ||
  1351.     echo 'gui_main.c: original size 7429, current size' "$Wc_c"
  1352. rm -f _shar_wnt_.tmp
  1353. fi
  1354. # ============= gui_widg.c ==============
  1355. if test -f 'gui_widg.c' -a X"$1" != X"-c"; then
  1356.     echo 'x - skipping gui_widg.c (File already exists)'
  1357.     rm -f _shar_wnt_.tmp
  1358. else
  1359. > _shar_wnt_.tmp
  1360. echo 'x - extracting gui_widg.c (Text)'
  1361. sed 's/^X//' << 'SHAR_EOF' > 'gui_widg.c' &&
  1362. /*********************************************************************/
  1363. /*  bibView: Administration of bibTex-Databases                      */
  1364. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  1365. /*                                                                   */
  1366. /*  Module:  gui_widg.c                                              */
  1367. /*                                                                   */
  1368. /*             GUI: Widgets and misc functions                       */
  1369. /*             - Notice/Warning/Error windows                        */
  1370. /*                                                                   */
  1371. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  1372. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  1373. /*                                                                   */
  1374. /*  History:                                                         */
  1375. /*    12.05.91  PMU  created                                         */
  1376. /*    05.26.92       Version 1.0 released                            */
  1377. /*                                                                   */
  1378. /*  Copyright 1992 TU MUENCHEN                                       */
  1379. /*    See ./Copyright for complete rights and liability information. */
  1380. /*                                                                   */
  1381. /*********************************************************************/
  1382. X
  1383. #include <stdio.h>
  1384. #include <X11/Intrinsic.h>
  1385. #include <X11/StringDefs.h>
  1386. #include <X11/Shell.h>
  1387. #include <X11/Xaw/Form.h>
  1388. #include <X11/Xaw/Paned.h>
  1389. #include <X11/Xaw/Box.h>
  1390. #include <X11/Xaw/Command.h>
  1391. #include <X11/Xaw/Dialog.h>
  1392. #include <X11/Xaw/Viewport.h>
  1393. #include <X11/Xaw/List.h>
  1394. #include "bibview.h"
  1395. X
  1396. X
  1397. /* imported global variables */
  1398. /* ------------------------- */
  1399. extern Widget topLevel, desktop, mainMenu;
  1400. extern Pixmap errorPixmap;
  1401. extern Pixmap warnPixmap;
  1402. extern Pixmap noticePixmap;
  1403. extern Pixmap confirmPixmap;
  1404. extern Pixmap progInfoPixmap;
  1405. X
  1406. X
  1407. /* exported global variables */
  1408. /* ------------------------- */
  1409. X
  1410. X
  1411. /* local global variables */
  1412. /* ---------------------- */
  1413. static Widget selShell;
  1414. static BibPtr *bibptrArgv;
  1415. static String *bibselArgv;
  1416. static int    bibselArgc;
  1417. X
  1418. X
  1419. /* local function prototypes */
  1420. /* ------------------------- */
  1421. static void selectBibOK (Widget w, XtPointer ClientData, XtPointer CallData);
  1422. static void selectBibCancel (Widget w, XtPointer ClientData, XtPointer CallData);
  1423. static void closeMsgWin (Widget w, XtPointer clientData, XtPointer callData);
  1424. static void closeProgInfoWin (Widget w, XtPointer clientData, XtPointer callData);
  1425. X
  1426. X
  1427. /*********************************************************************/
  1428. /* guwSelectBib:                                                     */
  1429. /*    Display List of opened bibs to select one                      */
  1430. /*********************************************************************/
  1431. Errcode
  1432. guwSelectBib(String head, CtlFuncPtr ctlFunc)
  1433. {
  1434. static Widget selForm, selLabel, selVport, selList, selQuit;
  1435. BibPtr bp;
  1436. Position dx, dy, x, y;
  1437. int i = 0;
  1438. X
  1439. X   /* check number of opened bibs */
  1440. X   if ((bibselArgc = gubNoOfOpenBibs()) == 0)
  1441. X      return(ERR_NOBIBOPEN);
  1442. X
  1443. X   /* create argv for list */
  1444. X   if ((bibselArgv = (String *)calloc(bibselArgc, sizeof(String))) == NULL) 
  1445. X      return(ERR_NOMALLOC);
  1446. X   if ((bibptrArgv = (BibPtr *)calloc(bibselArgc, sizeof(BibPtr))) == NULL) {
  1447. X      free(bibselArgv);
  1448. X      return(ERR_NOMALLOC);
  1449. X   }
  1450. X   bp = glbFirstBibListEl();
  1451. X   i = 0;
  1452. X   while (bp != NULL) {
  1453. X      bibptrArgv[i] = bp;
  1454. X      bibselArgv[i] = bp->filepath;
  1455. X      bp = glbNextBibListEl(bp);
  1456. X      i++;
  1457. X   }
  1458. X
  1459. X   /* display window */
  1460. X   XtVaGetValues(desktop,
  1461. X                 XtNx, &dx,
  1462. X                 XtNy, &dy, NULL);
  1463. X   XtTranslateCoords(desktop,
  1464. X                     (Position)dx + SUBWIN_MARGIN,
  1465. X                     (Position)dy + SUBWIN_MARGIN,
  1466. X                     &x, &y);
  1467. X   selShell = XtVaCreatePopupShell("bibselShell",
  1468. X            transientShellWidgetClass, topLevel, 
  1469. X        XtNx, x, XtNy, y, NULL);
  1470. X   selForm  = XtVaCreateManagedWidget("bibselWin",
  1471. X            formWidgetClass, selShell, NULL);
  1472. X   selLabel = XtVaCreateManagedWidget(head,
  1473. X            labelWidgetClass, selForm,
  1474. X        XtNborderWidth, 0,
  1475. X            XtNleft, XtChainLeft,
  1476. X            XtNtop, XtChainTop, NULL);
  1477. X   selVport = XtVaCreateManagedWidget("bibselVport",
  1478. X        viewportWidgetClass, selForm,
  1479. X        XtNallowVert, True,
  1480. X        XtNfromVert, selLabel, NULL);
  1481. X   selList  = XtVaCreateManagedWidget("bibselLst",
  1482. X        listWidgetClass, selVport,
  1483. X        XtNnumberStrings, bibselArgc,
  1484. X        XtNlist, bibselArgv, 
  1485. X        XtNforceColumns, True,
  1486. X        XtNdefaultColumns, 1, NULL);
  1487. X   selQuit  = XtVaCreateManagedWidget("cancel",
  1488. X            commandWidgetClass, selForm, 
  1489. X        XtNfromVert, selVport,
  1490. X        XtNleft, XtChainLeft, NULL);
  1491. X
  1492. X   XtAddCallback(selList, XtNcallback, selectBibOK, (XtPointer)ctlFunc);
  1493. X   XtAddCallback(selQuit, XtNcallback, selectBibCancel, NULL);
  1494. X
  1495. X   XtSetSensitive(mainMenu, FALSE);
  1496. X   gubSetSensitive(NULL, FALSE);
  1497. X   XtPopup(selShell, XtGrabNonexclusive);
  1498. X   return(OK);
  1499. }
  1500. X
  1501. X
  1502. /*********************************************************************/
  1503. /* selectBibOK:                                                      */
  1504. /*    Callback for select bib list entries                           */
  1505. /*********************************************************************/
  1506. static void
  1507. selectBibOK (Widget w, XtPointer clientData, XtPointer callData)
  1508. {
  1509. XXawListReturnStruct *item = (XawListReturnStruct*)callData;
  1510. CtlFuncPtr ctlFunc = (CtlFuncPtr)clientData;
  1511. BibPtr bp;
  1512. X
  1513. X   XtPopdown(selShell);
  1514. X   XtSetSensitive(mainMenu, TRUE);
  1515. X   gubSetSensitive(NULL, TRUE);
  1516. X
  1517. X   bp = bibptrArgv[item->list_index];
  1518. X   free(bibptrArgv);
  1519. X   free(bibselArgv);
  1520. X   (ctlFunc) (bp);
  1521. }
  1522. X
  1523. X
  1524. /*********************************************************************/
  1525. /* selectBibCancel:                                                  */
  1526. /*    Callback for Cancel button of select bib shell                 */
  1527. /*********************************************************************/
  1528. static void
  1529. selectBibCancel (Widget w, XtPointer ClientData, XtPointer CallData)
  1530. {
  1531. X
  1532. X   XtPopdown(selShell);
  1533. X   free(bibptrArgv);
  1534. X   free(bibselArgv);
  1535. X   XtSetSensitive(mainMenu, TRUE);
  1536. X   gubSetSensitive(NULL, TRUE);
  1537. }
  1538. X
  1539. X
  1540. /*********************************************************************/
  1541. /* guwNotImpl:                                                       */
  1542. /*    Display 'not implemented' message (dummy function)             */
  1543. /*********************************************************************/
  1544. void
  1545. guwNotImpl (Widget w, XtPointer clientData, XtPointer callData)
  1546. {
  1547. X   guwNotice(ERR_NOT_IMPLEMENTED);
  1548. }
  1549. X
  1550. X
  1551. /*********************************************************************/
  1552. /* guwError:                                                         */
  1553. /*    Display error message in a popup shell on desktop              */
  1554. /*********************************************************************/
  1555. void
  1556. guwError (Errcode errcode)
  1557. SHAR_EOF
  1558. true || echo 'restore of gui_widg.c failed'
  1559. fi
  1560. echo 'End of  part 17'
  1561. echo 'File gui_widg.c is continued in part 18'
  1562. echo 18 > _shar_seq_.tmp
  1563. exit 0
  1564. -- 
  1565. Senior Systems Scientist        mail: dcmartin@msi.com
  1566. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1567. 796 North Pastoria Avenue        at&t: 408/522-9236
  1568. Sunnyvale, California 94086        fax: 408/732-0831
  1569.