home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume31 / bam / part04 < prev    next >
Encoding:
Text File  |  1992-07-30  |  29.5 KB  |  1,074 lines

  1. Newsgroups: comp.sources.misc
  2. From: sbo@vlsi.polymtl.ca (Stephane Boucher)
  3. Subject:  v31i060:  bam - [OpenLook|Athena] menu system for [GNU|Epoch|Lucid] Emacs, Part04/07
  4. Message-ID: <1992Jul31.042532.23787@sparky.imd.sterling.com>
  5. X-Md4-Signature: 3790d96ad8205adbf64165f25058384f
  6. Date: Fri, 31 Jul 1992 04:25:32 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: sbo@vlsi.polymtl.ca (Stephane Boucher)
  10. Posting-number: Volume 31, Issue 60
  11. Archive-name: bam/part04
  12. Environment: Lex, Yacc, SunOS 4.x with XView or BSD Unix with Athena Widget
  13. Supersedes: bam: Volume 27, Issue 68-69
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 4 (of 7)."
  22. # Contents:  bam-2.0/panelmenu.c bam-2.0/parfaw.c bam-2.0/parfxv.c
  23. #   bam-2.0/parser.y
  24. # Wrapped by sbo@froh on Mon Jul 27 20:11:49 1992
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'bam-2.0/panelmenu.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'bam-2.0/panelmenu.c'\"
  28. else
  29. echo shar: Extracting \"'bam-2.0/panelmenu.c'\" \(6333 characters\)
  30. sed "s/^X//" >'bam-2.0/panelmenu.c' <<'END_OF_FILE'
  31. X/*   bam - the Born Again Menus for GNU Emacs.
  32. X   Copyright (C) 1992 Stephane Boucher.
  33. X
  34. X    This program is free software; you can redistribute it and/or modify
  35. X    it under the terms of the GNU General Public License as published by
  36. X    the Free Software Foundation; either version 1, or (at your option)
  37. X    any later version.
  38. X
  39. X    This program is distributed in the hope that it will be useful,
  40. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42. X    GNU General Public License for more details.
  43. X
  44. X    You should have received a copy of the GNU General Public License
  45. X    along with this program; if not, write to the Free Software
  46. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  47. X
  48. X  In other words, you are welcome to use, share and improve this program.
  49. X  You are forbidden to forbid anyone else to use, share and improve
  50. X  what you give them.   Help stamp out software-hoarding!
  51. X*/
  52. X/* $Id: panelmenu.c,v 1.3 1992/03/30 20:50:24 sbo Exp $ */
  53. X
  54. X#include "bam.h"
  55. X
  56. X#define ABOUT_THE_AUTHOR "About the Author"
  57. X#define BUG_REPORTS "Bug Reports"
  58. X#define RELOAD_MENU_STR "Reload Menu"
  59. X#define TOGGLE_RESIZE_CORNER_STR "Toggle Resize Corners"
  60. X
  61. XFrame authorFrame;
  62. XFrame bugReportsFrame;
  63. X
  64. Xstatic short authorPictureBits[] = {
  65. X  0x3E00, 0x7F00, 0xFF80, 0xFF80, 0xFF80, 0xFF80, 0xFF80, 0x7F00,
  66. X  0x3E00, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x7F00, 0x0000
  67. X  };
  68. X
  69. Xvoid panelMenuEventProc();
  70. XpanelMenuNotifyProc();
  71. X
  72. XmakePanelMenu(frame, panel)
  73. X     Frame frame;
  74. X     Panel panel;
  75. X{
  76. X  Menu panelMenu;
  77. X  Panel frameCmdPanel;
  78. X  Server_image authorPicture;
  79. X  Xv_screen screen;
  80. X  int screenNo;
  81. X  Display *dpy;
  82. X  int screenWidth, screenHeight;
  83. X  int frameWidth, frameHeight;
  84. X
  85. X  panelMenu=(Menu)
  86. X    xv_create(NULL, MENU,
  87. X          MENU_NOTIFY_PROC, panelMenuNotifyProc,
  88. X          MENU_STRINGS, ABOUT_THE_AUTHOR, BUG_REPORTS, RELOAD_MENU_STR, NULL,
  89. X          NULL);
  90. X  xv_set(panel, WIN_CLIENT_DATA, panelMenu,
  91. X     PANEL_BACKGROUND_PROC, panelMenuEventProc, NULL);
  92. X
  93. X
  94. X  dpy=(Display *)xv_get(frame, XV_DISPLAY);
  95. X  screen=(Xv_screen)xv_get(frame, XV_SCREEN);
  96. X  screenNo=(int)xv_get(screen, SCREEN_NUMBER);
  97. X  screenWidth=DisplayWidth(dpy, screenNo);
  98. X  screenHeight=DisplayHeight(dpy, screenNo);
  99. X
  100. X  /* Create the 'About the Author Frame' */
  101. X  authorFrame=(Frame)
  102. X    xv_create(frame, FRAME_CMD, FRAME_LABEL, ABOUT_THE_AUTHOR, NULL);
  103. X  frameCmdPanel=(Panel)xv_get(authorFrame, FRAME_CMD_PANEL, NULL);
  104. X  authorPicture=(Server_image)
  105. X    xv_create(NULL, SERVER_IMAGE,
  106. X          XV_WIDTH, 16, 
  107. X          XV_HEIGHT, 16, 
  108. X          SERVER_IMAGE_DEPTH, 1,
  109. X          SERVER_IMAGE_BITS, authorPictureBits,
  110. X          NULL);
  111. X  (void)
  112. X    xv_create(frameCmdPanel, PANEL_MESSAGE,
  113. X          PANEL_LABEL_IMAGE, authorPicture,
  114. X          NULL);
  115. X  (void)
  116. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  117. X          PANEL_LABEL_STRING, "Hi! I'm the author of this software.", NULL);
  118. X  (void)
  119. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  120. X          PANEL_LABEL_STRING, "sbo@vlsi.polymtl.ca", NULL);
  121. X
  122. X  window_fit(frameCmdPanel);
  123. X  window_fit(authorFrame);
  124. X
  125. X  frameWidth=(int)xv_get(authorFrame, XV_WIDTH, NULL);
  126. X  frameHeight=(int)xv_get(authorFrame, XV_HEIGHT, NULL);
  127. X
  128. X  xv_set(authorFrame, 
  129. X     XV_X, (screenWidth-frameWidth)/2,
  130. X     XV_Y, (screenHeight-frameHeight)/2,
  131. X     NULL);
  132. X
  133. X  if (noAuthorFrame) {
  134. X    /* Do not display the author frame when starting Bam */
  135. X  }
  136. X  else {
  137. X    /* Start the author frame */
  138. X    xv_set(authorFrame, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  139. X    xv_set(authorFrame, XV_SHOW, TRUE, NULL);
  140. X
  141. X    /* Disable the display, so that the frame will not
  142. X       be shown when reloading a menu */
  143. X    noAuthorFrame=TRUE;
  144. X  }
  145. X
  146. X  /* Create the 'Bug Reports' */
  147. X  bugReportsFrame=(Frame)
  148. X    xv_create(frame, FRAME_CMD, FRAME_LABEL, BUG_REPORTS, NULL);
  149. X  frameCmdPanel=(Panel)xv_get(bugReportsFrame, FRAME_CMD_PANEL, NULL);
  150. X  (void)
  151. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  152. X          PANEL_LABEL_STRING, "You think you found a bug :-( ?", NULL);
  153. X  (void)
  154. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  155. X          PANEL_LABEL_STRING, "Check first with your local administrator,", NULL);
  156. X  (void)
  157. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  158. X          PANEL_LABEL_STRING, "and if he can't help you send me a description at:", NULL);
  159. X  (void)
  160. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  161. X          PANEL_LABEL_STRING, "sbo@vlsi.polymtl.ca", NULL);
  162. X  (void)
  163. X    xv_create(frameCmdPanel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1,
  164. X          PANEL_LABEL_STRING, "I'll try to correct the problem.", NULL);
  165. X
  166. X  window_fit(frameCmdPanel);
  167. X  window_fit(bugReportsFrame);
  168. X
  169. X  frameWidth=(int)xv_get(bugReportsFrame, XV_WIDTH, NULL);
  170. X  frameHeight=(int)xv_get(bugReportsFrame, XV_HEIGHT, NULL);
  171. X
  172. X  xv_set(bugReportsFrame, 
  173. X     XV_X, (screenWidth-frameWidth)/2,
  174. X     XV_Y, (screenHeight-frameHeight)/2,
  175. X     NULL);
  176. X}
  177. X
  178. X
  179. XpanelMenuNotifyProc(menu, menuItem)
  180. X     Menu menu;
  181. X     Menu_item menuItem;
  182. X{
  183. X  char *menuString;
  184. X  int resizeCorners;
  185. X  Panel panel;
  186. X  Frame frame;
  187. X  
  188. X  menuString=(char *)xv_get(menuItem, MENU_STRING, NULL);
  189. X  if (strcmp(menuString, RELOAD_MENU_STR)==0) {
  190. X    xv_destroy_safe(baseFrame);
  191. X    
  192. X    /* The exit will not be the final one... */
  193. X    finalExit=0;
  194. X  }
  195. X/*  else if (strcmp(menuString, TOGGLE_RESIZE_CORNER_STR)==0) {
  196. X    panel=(Panel)xv_get(menu, XV_OWNER, NULL);
  197. X    printf("1\n");
  198. X    frame=(Frame)xv_get(panel, XV_OWNER, NULL);
  199. X    printf("2\n");
  200. X    resizeCorners=xv_get(baseFrame, FRAME_SHOW_RESIZE_CORNER, NULL);
  201. Xprintf("resC %d\n", resizeCorners);
  202. X    if (resizeCorners) 
  203. X      xv_set(baseFrame, FRAME_SHOW_RESIZE_CORNER, (int)0, NULL);
  204. X    else
  205. X      xv_set(baseFrame, FRAME_SHOW_RESIZE_CORNER, (int)1, NULL);
  206. X  }*/
  207. X  else if (strcmp(menuString, ABOUT_THE_AUTHOR)==0) {
  208. X    xv_set(authorFrame, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  209. X    xv_set(authorFrame, XV_SHOW, TRUE, NULL);
  210. X  }
  211. X  else if (strcmp(menuString, BUG_REPORTS)==0) {
  212. X    xv_set(bugReportsFrame, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  213. X    xv_set(bugReportsFrame, XV_SHOW, TRUE, NULL);
  214. X  }
  215. X  else {
  216. X    /* Error */
  217. X  }
  218. X}
  219. X
  220. X
  221. Xvoid  
  222. X  panelMenuEventProc(panel, event)
  223. XPanel panel;
  224. XEvent *event;
  225. X{
  226. X  if (event_action(event)==ACTION_MENU && event_is_down(event)) {
  227. X    Menu menu=(Menu)xv_get(panel, WIN_CLIENT_DATA);
  228. X    menu_show(menu, panel, event, NULL);
  229. X  }
  230. X}
  231. END_OF_FILE
  232. if test 6333 -ne `wc -c <'bam-2.0/panelmenu.c'`; then
  233.     echo shar: \"'bam-2.0/panelmenu.c'\" unpacked with wrong size!
  234. fi
  235. # end of 'bam-2.0/panelmenu.c'
  236. fi
  237. if test -f 'bam-2.0/parfaw.c' -a "${1}" != "-c" ; then 
  238.   echo shar: Will not clobber existing file \"'bam-2.0/parfaw.c'\"
  239. else
  240. echo shar: Extracting \"'bam-2.0/parfaw.c'\" \(5756 characters\)
  241. sed "s/^X//" >'bam-2.0/parfaw.c' <<'END_OF_FILE'
  242. X/*   bam - the Born Again Menus for GNU Emacs.
  243. X   Copyright (C) 1992 Hans Olsson.
  244. X
  245. X    This program is free software; you can redistribute it and/or modify
  246. X    it under the terms of the GNU General Public License as published by
  247. X    the Free Software Foundation; either version 1, or (at your option)
  248. X    any later version.
  249. X
  250. X    This program is distributed in the hope that it will be useful,
  251. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  252. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  253. X    GNU General Public License for more details.
  254. X
  255. X    You should have received a copy of the GNU General Public License
  256. X    along with this program; if not, write to the Free Software
  257. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  258. X
  259. X  In other words, you are welcome to use, share and improve this program.
  260. X  You are forbidden to forbid anyone else to use, share and improve
  261. X  what you give them.   Help stamp out software-hoarding!
  262. X*/
  263. X/* $Id: parfaw.c,v 1.2 1992/07/27 23:04:16 sbo Exp $ */
  264. X
  265. X#include "bam.h"
  266. X#include "strstore.h"
  267. X
  268. X#include "menu.icon"
  269. Xstatic int menubitmap = 0;
  270. X/* boolean grab  must come from another file */
  271. X
  272. XPixmap loadBitmap(name, w, h)
  273. X     char *name;
  274. X     Widget w;
  275. X     unsigned int *h; 
  276. X{
  277. X  int width,hot_x,hot_y;
  278. X  Pixmap bitmap;
  279. X  Drawable d;
  280. X  Display *dpy=XtDisplay(w);
  281. X  d=DefaultRootWindow(dpy);
  282. X
  283. X  if (!(BitmapSuccess
  284. X        ==XReadBitmapFile(dpy,d,
  285. X                          name,&width,h,&bitmap,&hot_x,&hot_y))) {
  286. X    return (Pixmap)NULL;
  287. X  } else return bitmap;
  288. X}
  289. X
  290. XWidget CreateBSB(name, action, parent, dobit, proc)
  291. X     char *name;
  292. X     int action;
  293. X     Widget parent;
  294. X     int dobit;
  295. X     void (*proc)();
  296. X{
  297. X  Widget m=XtCreateManagedWidget(dobit?"":name,
  298. X                                 smeBSBObjectClass,parent,NULL,ZERO);
  299. X#ifdef DEBUG
  300. X  printf("Create\n");
  301. X#endif
  302. X  if (proc) 
  303. X    XtAddCallback(m,XtNcallback,proc,(XtPointer)action);
  304. X  else {
  305. X    Arg args[1];
  306. X    XtSetArg(args[0],XtNrightBitmap,menubitmap);
  307. X    XtSetValues(m,args,1);
  308. X  }
  309. X  if (dobit) {
  310. X    Pixmap bitmap;
  311. X    unsigned int h;
  312. X    if (NULL==(bitmap=loadBitmap(name,parent,&h))) {
  313. X      sendErrorToEmacs("Can't find bitmap:%s\n",name);
  314. X    } else {
  315. X      Arg args[2];
  316. X      XtSetArg(args[0],XtNleftBitmap,bitmap);
  317. X      XtSetArg(args[1],XtNheight,(Dimension)h);
  318. X      XtSetValues(m,args,2);
  319. X    }
  320. X  }
  321. X  return m;
  322. X}
  323. X
  324. Xint createBaseFrame(frame, frameData)
  325. X     Frame *frame;
  326. X     FrameData *frameData;
  327. X{
  328. X  *frame = 
  329. X    XtCreateManagedWidget("paned",panedWidgetClass,mainFrame,
  330. X              NULL,0);
  331. X  /* Use frameData->Title ?? */
  332. X
  333. X  if (menubitmap==0) {
  334. X    menubitmap=XCreateBitmapFromData(XtDisplay(mainFrame),
  335. X                                   DefaultRootWindow(XtDisplay(mainFrame)),
  336. X                                   menu_bits,menu_width,menu_height);
  337. X  }
  338. X  return (*frame==NULL); 
  339. X  /* should make an icon from frameData->attr.iconFileName
  340. X     and frameData->attr.iconLabel */
  341. X}
  342. X
  343. Xvoid frameAdjust(frame, frameData)
  344. X     Frame frame;
  345. X     FrameData *frameData;
  346. X{
  347. X  if (grab&&windowName) {
  348. X    Arg args[1];
  349. X    XtSetArg(args[0],XtNwindowName,windowName);
  350. X    gam=
  351. X      XtCreateManagedWidget("gam",grabAndManageWidgetClass,frame,args,ONE);
  352. X  } 
  353. X  return;
  354. X}
  355. X
  356. Xvoid panelCreateInitialise(frame, panel)
  357. X     Frame *frame;
  358. X     Panel *panel;
  359. X{
  360. X  *panel=XtCreateManagedWidget("box",boxWidgetClass,*frame,NULL,ZERO);
  361. X}
  362. X
  363. Xvoid panelAdjust(panel)
  364. X     Panel panel;
  365. X{
  366. X  return;
  367. X}
  368. X
  369. Xvoid panelButtonInitialize(frame, panel, buttonNameIndex, 
  370. X               buttonActionIndex,button)
  371. X     Frame frame;
  372. X     Panel panel;
  373. X     int buttonNameIndex; 
  374. X     int buttonActionIndex;
  375. X     ButtonData *button;
  376. X{
  377. X  (*button).button=XtCreateManagedWidget(strStoreGet(buttonNameIndex),
  378. X                     menuButtonWidgetClass,
  379. X                     panel,NULL,ZERO);
  380. X  XtOverrideTranslations((*button).button,button_xt);
  381. X}
  382. X
  383. Xvoid panelButtonCreateAndAdjust(button,menuData) 
  384. X     ButtonData *button;
  385. X     MenuData *menuData;
  386. X{
  387. X  return ;
  388. X}
  389. X
  390. X
  391. Xvoid createMenuInit(button,menuData)
  392. X     ButtonData *button;
  393. X     MenuData *menuData;
  394. X{
  395. X  initMenuData((MenuData *)menuData); 
  396. X  (*menuData).prevCur=(*menuData).id;
  397. X  (*menuData).id=NULL;
  398. X  (*menuData).button=(*button).button; /* initMenuData shoulld do this ? */
  399. X}
  400. X
  401. Xvoid createMenu(menuData,subMenu)
  402. X     MenuData *menuData;
  403. X     int subMenu;
  404. X{
  405. X   Widget out;
  406. X   Arg args[1];
  407. X   XtTranslations xt;
  408. X
  409. X   XtSetArg(args[0],XtNlabel,(*menuData).attr.title);
  410. X  /* Create a new menu and make it the current menu */
  411. X  out=XtCreatePopupShell("menu",simpleMenuWidgetClass,
  412. X             (*menuData).button,args,1);
  413. X  if (subMenu) {
  414. X    xt=XtParseTranslationTable("<LeaveWindow>:popdownSubmenus()\n");
  415. X    XtOverrideTranslations(out,xt);
  416. X  }
  417. X  (*menuData).id = out;
  418. X
  419. X}
  420. X
  421. Xvoid createMenuFinalise(menuData)
  422. X     MenuData *menuData;
  423. X{
  424. X  return ;
  425. X}
  426. X
  427. Xvoid createTextMenuItem(frame, curMenu, menuItemName, 
  428. X            menuItemActionIndex, subMenu)
  429. X     Frame frame;
  430. X     MenuData *curMenu;
  431. X     char *menuItemName;
  432. X     int menuItemActionIndex;
  433. X     MenuData *subMenu;
  434. X{
  435. X  Menu menuItem;
  436. X
  437. X  menuItem=CreateBSB(menuItemName,
  438. X             menuItemActionIndex, (*curMenu).id, 0,
  439. X             (void (*)()) (subMenu? NULL:menuProc));
  440. X  if (subMenu!=NULL) {
  441. X    pops[pops_nr++]=(*subMenu).id;
  442. X    XtAddCallback(menuItem,XtNcallback,menuUp,(XtPointer)(*subMenu).id);
  443. X  }
  444. X}
  445. X
  446. Xvoid createBitmapMenuItem(frame, curMenu, bitmapFileName,
  447. X              menuItemActionIndex, subMenu)
  448. X     Frame frame; 
  449. X     MenuData *curMenu;
  450. X     char *bitmapFileName;
  451. X     int menuItemActionIndex;
  452. X     MenuData *subMenu;
  453. X{
  454. X  Menu menuItem;
  455. X  
  456. X  menuItem=CreateBSB(bitmapFileName,menuItemActionIndex,
  457. X             (*curMenu).id, 1,
  458. X             (void (*)()) (subMenu?NULL:menuProc));
  459. X  if (subMenu!=NULL) {
  460. X    pops[pops_nr++]=(*subMenu).id;
  461. X    XtAddCallback(menuItem,XtNcallback,menuUp,(XtPointer)(*subMenu).id);
  462. X  }
  463. X}
  464. X
  465. END_OF_FILE
  466. if test 5756 -ne `wc -c <'bam-2.0/parfaw.c'`; then
  467.     echo shar: \"'bam-2.0/parfaw.c'\" unpacked with wrong size!
  468. fi
  469. # end of 'bam-2.0/parfaw.c'
  470. fi
  471. if test -f 'bam-2.0/parfxv.c' -a "${1}" != "-c" ; then 
  472.   echo shar: Will not clobber existing file \"'bam-2.0/parfxv.c'\"
  473. else
  474. echo shar: Extracting \"'bam-2.0/parfxv.c'\" \(6381 characters\)
  475. sed "s/^X//" >'bam-2.0/parfxv.c' <<'END_OF_FILE'
  476. X/*   bam - the Born Again Menus for GNU Emacs.
  477. X   Copyright (C) 1992 Stephane Boucher.
  478. X
  479. X    This program is free software; you can redistribute it and/or modify
  480. X    it under the terms of the GNU General Public License as published by
  481. X    the Free Software Foundation; either version 1, or (at your option)
  482. X    any later version.
  483. X
  484. X    This program is distributed in the hope that it will be useful,
  485. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  486. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  487. X    GNU General Public License for more details.
  488. X
  489. X    You should have received a copy of the GNU General Public License
  490. X    along with this program; if not, write to the Free Software
  491. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  492. X
  493. X  In other words, you are welcome to use, share and improve this program.
  494. X  You are forbidden to forbid anyone else to use, share and improve
  495. X  what you give them.   Help stamp out software-hoarding!
  496. X*/
  497. X/* $Id: parfxv.c,v 1.2 1992/07/02 00:57:44 sbo Exp $ */
  498. X
  499. X#include "bam.h"
  500. X
  501. Xint createBaseFrame(frame, frameData)
  502. X     Frame *frame;
  503. X     FrameData *frameData;
  504. X{
  505. X  Icon icon;
  506. X  int retval=0;
  507. X  
  508. X  if ((*frameData).attr.showResizeCorner) {
  509. X    *frame = (Frame)
  510. X      xv_create(NULL, FRAME, FRAME_SHOW_RESIZE_CORNER, TRUE,
  511. X        FRAME_LABEL, (*frameData).attr.title, 
  512. X        NULL);
  513. X  } 
  514. X  else {
  515. X    *frame = (Frame)
  516. X      xv_create(NULL, FRAME, FRAME_SHOW_RESIZE_CORNER, FALSE,
  517. X        FRAME_LABEL, (*frameData).attr.title,
  518. X        NULL);
  519. X  }
  520. X
  521. X  if ((icon=makeIcon((*frameData).attr.iconFileName, 
  522. X             (*frameData).attr.iconLabel))==NULL) {
  523. X    /* An error as occured */
  524. X    return(2);
  525. X  }
  526. X  else {
  527. X    /*    Rect rect;
  528. X      
  529. X      rect.r_width=(int)xv_get(icon, XV_WIDTH);
  530. X      rect.r_height=(int)xv_get(icon, XV_HEIGHT);
  531. X      if (rect.r_width<64) rect.r_width=64;
  532. X      if (rect.r_height<64) rect.r_height=64;*/
  533. X    xv_set(*frame, 
  534. X       FRAME_ICON, icon, 
  535. X       /*       FRAME_CLOSED_RECT, &rect,*/
  536. X       NULL);
  537. X  }
  538. X  return(0);
  539. X}
  540. X
  541. Xvoid frameAdjust(frame, frameData)
  542. X     Frame frame;
  543. X     FrameData *frameData;
  544. X{
  545. X  frame_fit_all(frame);
  546. X
  547. X  if ((*frameData).attr.showResizeCorner) {
  548. X    xv_set(frame, FRAME, FRAME_SHOW_RESIZE_CORNER, TRUE,
  549. X       NULL);
  550. X  }
  551. X}
  552. X
  553. Xvoid panelCreateInitialise(frame, panel)
  554. X     Frame *frame;
  555. X     Panel *panel;
  556. X{
  557. X  *panel = (Panel) xv_create(*frame, PANEL, NULL);
  558. X  makePanelMenu(*frame, *panel);
  559. X}
  560. X
  561. Xvoid panelAdjust(panel)
  562. X     Panel panel;
  563. X{
  564. X  window_fit(panel);
  565. X}
  566. X
  567. Xvoid panelButtonInitialize(frame, panel, buttonNameIndex, 
  568. X               buttonActionIndex,button)
  569. X     Frame frame;
  570. X     Panel panel;
  571. X     int buttonNameIndex;
  572. X     int buttonActionIndex;
  573. X     ButtonData *button;
  574. X{
  575. X  (*button).frame=frame;
  576. X  (*button).panel=panel;
  577. X  (*button).buttonNameIndex=buttonNameIndex;
  578. X  (*button).buttonActionIndex=buttonActionIndex;
  579. X  (*button).button=NULL;
  580. X}
  581. X
  582. Xvoid panelButtonCreateAndAdjust(button,menuData) 
  583. X     ButtonData *button;
  584. X     MenuData *menuData;
  585. X{
  586. X  (*button).button=(Panel_item)
  587. X    xv_create((*button).panel,PANEL_BUTTON,
  588. X          PANEL_LABEL_STRING, strStoreGet((*button).buttonNameIndex),
  589. X          PANEL_NOTIFY_PROC,selected,
  590. X          PANEL_ITEM_MENU, (*menuData).id,
  591. X          XV_KEY_DATA, M_COMMAND_STRING, (*button).buttonActionIndex,
  592. X          NULL);
  593. X  setMenu((*button).frame,menuData,strStoreGet((*button).buttonNameIndex));
  594. X}
  595. X  
  596. X
  597. Xvoid createMenuInit(button,menuData)
  598. X     ButtonData *button;
  599. X     MenuData *menuData;
  600. X{
  601. X  initMenuData((MenuData *)menuData);
  602. X  (*menuData).prevCur=(*menuData).id;
  603. X  (*menuData).id=NULL;
  604. X}
  605. X
  606. Xvoid createMenu(menuData,subMenu)
  607. X     MenuData *menuData;
  608. X     int subMenu;
  609. X{
  610. X  /* Create a new menu and make it the current menu */
  611. X  (*menuData).id = (Menu) xv_create(NULL, MENU, NULL);
  612. X}
  613. X
  614. Xvoid createMenuFinalise(menuData)
  615. X     MenuData *menuData;
  616. X{
  617. X  /* Set the default of the current menu that has just been built
  618. X     before the previous menu is restored.
  619. X     NOTE: THE TITLE COUNT AS THE ITEM #1. THEREFORE ONE HAS
  620. X     TO BE ADDED TO cur.menu.defaultChoice */
  621. X  xv_set((*menuData).id, MENU_DEFAULT, (*menuData).defaultChoice+1, NULL);
  622. X}
  623. X
  624. Xvoid createTextMenuItem(frame, curMenu, menuItemName, 
  625. X            menuItemActionIndex, subMenu)
  626. X     Frame frame;
  627. X     MenuData *curMenu;
  628. X     char *menuItemName;
  629. X     int menuItemActionIndex;
  630. X     MenuData *subMenu;
  631. X{
  632. X  Menu menuItem;
  633. X
  634. X  /* Menu Item with no sub menu attached */
  635. X  if (subMenu==NULL) {
  636. X    menuItem=(Menu_item)
  637. X      xv_create(NULL, MENUITEM, MENU_RELEASE,
  638. X        MENU_STRING, menuItemName,
  639. X        MENU_NOTIFY_PROC, menuProc,
  640. X        XV_KEY_DATA, M_COMMAND_STRING, menuItemActionIndex,
  641. X        NULL);
  642. X
  643. X    xv_set((*curMenu).id, MENU_APPEND_ITEM, menuItem, NULL);
  644. X  }
  645. X
  646. X  /* Menu Item with a sub menu attached */
  647. X  else {
  648. X    menuItem=(Menu_item)
  649. X      xv_create(NULL, MENUITEM, MENU_RELEASE,
  650. X        MENU_PULLRIGHT_ITEM, menuItemName, (*subMenu).id,
  651. X        MENU_NOTIFY_PROC, menuProc,
  652. X        XV_KEY_DATA, M_COMMAND_STRING, menuItemActionIndex,
  653. X        NULL);
  654. X    xv_set((*subMenu).prevCur, MENU_APPEND_ITEM, menuItem, NULL);
  655. X
  656. X    /* manque le test d'erreur du code de retour de setMenu */
  657. X    setMenu(frame, subMenu, menuItemName);
  658. X  }
  659. X}
  660. X
  661. Xvoid createBitmapMenuItem(frame, curMenu, bitmapFileName,
  662. X              menuItemActionIndex, subMenu)
  663. X     Frame frame; 
  664. X     MenuData *curMenu;
  665. X     char *bitmapFileName;
  666. X     int menuItemActionIndex;
  667. X     MenuData *subMenu;
  668. X{
  669. X  Server_image serverImage;
  670. X  Menu_item menuItem;
  671. X  int index;
  672. X
  673. X  /* Bitmap menu item with no sub menu */
  674. X  if (subMenu==NULL) {
  675. X    serverImage=(Server_image)
  676. X      xv_create(NULL, SERVER_IMAGE, 
  677. X        SERVER_IMAGE_BITMAP_FILE, bitmapFileName,
  678. X        NULL);
  679. X
  680. X    menuItem=(Menu_item)
  681. X      xv_create(NULL, MENUITEM, MENU_RELEASE,
  682. X        MENU_IMAGE, serverImage,
  683. X        MENU_RELEASE_IMAGE,
  684. X        MENU_NOTIFY_PROC, menuProc,
  685. X        XV_KEY_DATA, M_COMMAND_STRING, menuItemActionIndex,
  686. X        NULL);
  687. X
  688. X    xv_set((*curMenu).id, MENU_APPEND_ITEM, menuItem, NULL);
  689. X  }        
  690. X
  691. X  /* Bitmap Menu item with a sub menu */
  692. X  else {
  693. X    serverImage=(Server_image)
  694. X      xv_create(NULL, SERVER_IMAGE,
  695. X        SERVER_IMAGE_BITMAP_FILE, bitmapFileName,
  696. X        NULL);
  697. X    
  698. X    menuItem=(Menu_item)
  699. X      xv_create(NULL, MENUITEM,
  700. X        MENU_RELEASE,
  701. X        MENU_PULLRIGHT_IMAGE, serverImage, (*subMenu).id,
  702. X        MENU_RELEASE_IMAGE,
  703. X        MENU_NOTIFY_PROC, menuProc,
  704. X        XV_KEY_DATA, M_COMMAND_STRING, menuItemActionIndex,
  705. X        NULL);
  706. X    xv_set((*subMenu).prevCur, MENU_APPEND_ITEM, menuItem, NULL);
  707. X    
  708. X    /* manque le test d'erreur du code de retour de setMenu */
  709. X    setMenu(frame, subMenu, "");
  710. X  }
  711. X}
  712. END_OF_FILE
  713. if test 6381 -ne `wc -c <'bam-2.0/parfxv.c'`; then
  714.     echo shar: \"'bam-2.0/parfxv.c'\" unpacked with wrong size!
  715. fi
  716. # end of 'bam-2.0/parfxv.c'
  717. fi
  718. if test -f 'bam-2.0/parser.y' -a "${1}" != "-c" ; then 
  719.   echo shar: Will not clobber existing file \"'bam-2.0/parser.y'\"
  720. else
  721. echo shar: Extracting \"'bam-2.0/parser.y'\" \(7558 characters\)
  722. sed "s/^X//" >'bam-2.0/parser.y' <<'END_OF_FILE'
  723. X/*   bam - the Born Again Menus for GNU Emacs.
  724. X   Copyright (C) 1992 Stephane Boucher.
  725. X
  726. X    This program is free software; you can redistribute it and/or modify
  727. X    it under the terms of the GNU General Public License as published by
  728. X    the Free Software Foundation; either version 1, or (at your option)
  729. X    any later version.
  730. X
  731. X    This program is distributed in the hope that it will be useful,
  732. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  733. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  734. X    GNU General Public License for more details.
  735. X
  736. X    You should have received a copy of the GNU General Public License
  737. X    along with this program; if not, write to the Free Software
  738. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  739. X
  740. X  In other words, you are welcome to use, share and improve this program.
  741. X  You are forbidden to forbid anyone else to use, share and improve
  742. X  what you give them.   Help stamp out software-hoarding!
  743. X*/
  744. X%{
  745. X
  746. X/* @(#)parser.y    1.12 92/03/31 */
  747. X
  748. X#include <unistd.h>
  749. X
  750. X#include "bam.h"
  751. X
  752. Xstruct {
  753. X  Frame frame;
  754. X  FrameData frameData;
  755. X  MenuData menu;
  756. X  Menu_item menuItem;
  757. X  Panel panel;
  758. X  ButtonData button; /* Athena only */
  759. X  int menuLevel;     /* Athena only */
  760. X} cur;
  761. X
  762. X/*search menu, vertical buttons, TITLE a l'Interieur de BEGIN
  763. X  traiter les exit en erreurs voir buttons.el*/
  764. X
  765. X%}    
  766. X%union {
  767. X  MenuData menu;
  768. X  char *str;
  769. X  int boolean;
  770. X}
  771. X
  772. X%token TITLE_TOK BUTTON_TOK
  773. X%token END_TOK
  774. X%token FRAME_TOK LABEL_TOK PANEL_TOK MENU_TOK
  775. X%token PUSHPIN_TOK
  776. X%token RESIZE_CORNER_TOK
  777. X%token ICON_FILE_NAME
  778. X%token ICON_LABEL_TOK
  779. X%token TRUE_TOK FALSE_TOK
  780. X%token TEXT_TOK BITMAP_TOK
  781. X%token DEFAULT_TOK
  782. X
  783. X%token ERROR_TOK
  784. X
  785. X%token <str> STRING
  786. X%type <menu> menu
  787. X%type <boolean> boolean
  788. X%%
  789. X
  790. Xfile:       /* empty */
  791. X{
  792. X  cur.frame=NULL;
  793. X  cur.frameData=defaultFrameDataValue;
  794. X  cur.menu=defaultMenuDataValue;
  795. X  cur.menuItem=NULL;
  796. X  cur.panel=NULL;
  797. X  cur.menuLevel=0;
  798. X}
  799. X  | FRAME_TOK
  800. X{
  801. X   /* Init frameData */
  802. X   cur.frameData=defaultFrameDataValue;
  803. X}
  804. X   lst_frame_attributes_or_empty 
  805. X{ 
  806. X  int retval;
  807. X  retval=createBaseFrame(&(cur.frame), &(cur.frameData)); 
  808. X  if (retval!=0)
  809. X    return(retval);
  810. X}
  811. X   lst_panels END_TOK
  812. X{
  813. X  frameAdjust(cur.frame, &(cur.frameData));
  814. X  baseFrame=cur.frame;
  815. X}
  816. X;
  817. X
  818. Xlst_frame_attributes_or_empty: /* empty */
  819. X  | lst_frame_attributes
  820. X;
  821. X
  822. Xlst_frame_attributes: frame_attributes
  823. X  | lst_frame_attributes frame_attributes
  824. X;
  825. X
  826. Xframe_attributes: TITLE_TOK STRING{strStorePut($2);
  827. X                   cur.frameData.attr.title=$2;}
  828. X  | RESIZE_CORNER_TOK boolean     {cur.frameData.attr.showResizeCorner=$2;}
  829. X  | ICON_FILE_NAME STRING         {strStorePut($2);
  830. X                   cur.frameData.attr.iconFileName=$2;}
  831. X  | ICON_LABEL_TOK STRING    {strStorePut($2);
  832. X                 cur.frameData.attr.iconLabel=$2;}
  833. X;  
  834. X
  835. Xlst_panels:    panel
  836. X    | lst_panels panel
  837. X;
  838. X
  839. Xpanel: PANEL_TOK { panelCreateInitialise( &(cur.frame), &(cur.panel)); }
  840. X  lst_panel_items END_TOK { panelAdjust(cur.panel); }
  841. X;
  842. X
  843. Xlst_panel_items: panel_item
  844. X    | lst_panel_items panel_item
  845. X;
  846. X
  847. Xpanel_item:  panel_button
  848. X;
  849. X
  850. Xpanel_button: BUTTON_TOK STRING STRING
  851. X{
  852. X  int buttonActionIndex;
  853. X  int buttonNameIndex;
  854. X
  855. X  buttonNameIndex=strStorePut($2); /* buttonName */
  856. X  buttonActionIndex=strStorePut($3); /* buttonAction */
  857. X
  858. X
  859. X  panelButtonInitialize(cur.frame, cur.panel, 
  860. X            buttonNameIndex, 
  861. X            buttonActionIndex,
  862. X            &(cur.button));
  863. X} menu {
  864. X  panelButtonCreateAndAdjust(&(cur.button),&($5));
  865. X}
  866. X;
  867. X
  868. Xmenu: MENU_TOK 
  869. X{
  870. X  /* Save the cur.menu */
  871. X  $<menu>$=cur.menu;
  872. X
  873. X  if (menuDebug) 
  874. X    printMenuDataStruct("Pushed Menu\n---------", &(cur.menu), "");
  875. X
  876. X  cur.menuLevel++;
  877. X  createMenuInit(&(cur.button),&(cur.menu));
  878. X}
  879. X  lst_menu_attributes_or_empty 
  880. X{ 
  881. X  createMenu(&(cur.menu),cur.menuLevel>1);  /* SubMenu if Level>1 */
  882. X}
  883. X  lst_menu_items END_TOK       
  884. X{
  885. X  if (menuDebug) printMenuDataStruct("New Menu\n--------", &(cur.menu), "");
  886. X
  887. X  createMenuFinalise(&(cur.menu)); 
  888. X
  889. X  /* Returned value for the resulting token (menu) */
  890. X  $$=cur.menu;
  891. X
  892. X  /* Restore (pop) the data for the previous menu */
  893. X  cur.menu=$<menu>2;
  894. X  cur.menuLevel--;
  895. X
  896. X  if (menuDebug) printMenuDataStruct("Poped Menu\n--------", &(cur.menu), "");
  897. X}
  898. X;
  899. X
  900. Xlst_menu_attributes_or_empty: /* empty */
  901. X  | lst_menu_attributes
  902. X;
  903. X
  904. Xlst_menu_attributes: menu_attributes
  905. X  | lst_menu_attributes menu_attributes
  906. X;
  907. X
  908. Xmenu_attributes: 
  909. X    TITLE_TOK STRING    {strStorePut($2); cur.menu.attr.title=$2;}
  910. X  | PUSHPIN_TOK boolean {cur.menu.attr.pushpin=$2;}
  911. X;  
  912. X
  913. Xlst_menu_items: menu_item        
  914. X        | lst_menu_items menu_item
  915. X;
  916. X
  917. Xmenu_item: TEXT_TOK lst_text_attributes_or_empty STRING STRING
  918. X{
  919. X  int menuItemActionIndex;
  920. X
  921. X  strStorePut($3); /* menuItemName */
  922. X  menuItemActionIndex=strStorePut($4); /* menuItemAction */
  923. X
  924. X  createTextMenuItem(cur.frame, &(cur.menu),
  925. X             $3,
  926. X             menuItemActionIndex, 
  927. X             NULL);
  928. X             
  929. X  if (menuDebug>=2) fprintf(debugFp, "TEXT \"%s\" \"%s\"\n", $3, $4);
  930. X
  931. X  cur.menu.curItem++;
  932. X}
  933. X         | TEXT_TOK lst_text_attributes_or_empty STRING STRING menu
  934. X{
  935. X  int menuItemActionIndex;
  936. X
  937. X  strStorePut($3); /* menuItemName */
  938. X  menuItemActionIndex=strStorePut($4); /* menuItemAction */
  939. X
  940. X  createTextMenuItem(cur.frame, &(cur.menu),
  941. X             $3, 
  942. X             menuItemActionIndex, 
  943. X             &($5));
  944. X
  945. X  if (menuDebug>=2) {
  946. X    fprintf(debugFp, "TEXT \"%s\" \"%s\"\n", $3, $4);
  947. X    printMenuDataStruct("MENU", &($5), "");
  948. X  }
  949. X
  950. X  cur.menu.curItem++;
  951. X}
  952. X    | BITMAP_TOK lst_bitmap_attributes_or_empty STRING STRING
  953. X{
  954. X  int menuItemActionIndex;
  955. X  char *bitmapFileName;
  956. X  
  957. X  strStorePut($3);
  958. X  strStorePut(bitmapFileName=getFileName($3, R_OK, 
  959. X                     bitmapsPath, 
  960. X                     DEFAULT_BITMAPS_PATH));
  961. X  menuItemActionIndex=strStorePut($4);
  962. X
  963. X  if (bitmapFileName==NULL) {
  964. X    /* Internal error */
  965. X    sendErrorToEmacs("Internal Error While Trying to Find the Bitmap File: %s", $3);
  966. X    return(2);
  967. X  }
  968. X  else if (strcmp(bitmapFileName, "")==0) {
  969. X    /* No file was found */
  970. X    sendErrorToEmacs("Unable to Find the Bitmap File: %s", $3);
  971. X    return(2);
  972. X  }
  973. X  else {
  974. X    createBitmapMenuItem(cur.frame, &(cur.menu),
  975. X             bitmapFileName,
  976. X             menuItemActionIndex,
  977. X             NULL);
  978. X
  979. X    if (menuDebug>=2) fprintf(debugFp, "BITMAP \"%s\" \"%s\"\n", $3, $4);
  980. X
  981. X    cur.menu.curItem++;
  982. X  }
  983. X}        
  984. X    | BITMAP_TOK lst_bitmap_attributes_or_empty STRING STRING menu
  985. X{
  986. X  int menuItemActionIndex;
  987. X  char *bitmapFileName;
  988. X  
  989. X  strStorePut($3);
  990. X  strStorePut(bitmapFileName=getFileName($3, R_OK, 
  991. X                     bitmapsPath, 
  992. X                     DEFAULT_BITMAPS_PATH));
  993. X  menuItemActionIndex=strStorePut($4);
  994. X
  995. X  if (bitmapFileName==NULL) {
  996. X    /* Internal error */
  997. X    sendErrorToEmacs("Internal Error While Trying to Find the File: %s", $3);
  998. X    return(2);
  999. X  }
  1000. X  else if (strcmp(bitmapFileName, "")==0) {
  1001. X    /* No file was found */
  1002. X    sendErrorToEmacs("Unable to Find the Bitmap File: %s", $3);
  1003. X    return(2);
  1004. X  }
  1005. X  else {
  1006. X    createBitmapMenuItem(cur.frame, &(cur.menu),
  1007. X             bitmapFileName,
  1008. X             menuItemActionIndex,
  1009. X             &($5));
  1010. X
  1011. X    if (menuDebug>=2) {
  1012. X      fprintf(debugFp, "BITMAP \"%s\" \"%s\"\n", $3, $4);
  1013. X      printMenuDataStruct("MENU\n", &($5), "");
  1014. X    }
  1015. X
  1016. X    cur.menu.curItem++;
  1017. X  }
  1018. X}        
  1019. X;
  1020. X
  1021. Xlst_text_attributes_or_empty: /* empty */
  1022. X  | lst_text_attributes
  1023. X;
  1024. X
  1025. Xlst_text_attributes: text_attributes
  1026. X  | lst_text_attributes text_attributes
  1027. X;
  1028. X
  1029. Xtext_attributes: DEFAULT_TOK  {cur.menu.defaultChoice=cur.menu.curItem;}
  1030. X;  
  1031. X
  1032. Xlst_bitmap_attributes_or_empty: /* empty */
  1033. X  | lst_bitmap_attributes
  1034. X;
  1035. X
  1036. Xlst_bitmap_attributes: bitmap_attributes
  1037. X  | lst_bitmap_attributes bitmap_attributes
  1038. X;
  1039. X
  1040. Xbitmap_attributes: DEFAULT_TOK   {cur.menu.defaultChoice=cur.menu.curItem;}
  1041. X;  
  1042. X
  1043. Xboolean: TRUE_TOK       {$$=TRUE;} 
  1044. X       | FALSE_TOK      {$$=FALSE;}
  1045. X;
  1046. X
  1047. X%%
  1048. END_OF_FILE
  1049. if test 7558 -ne `wc -c <'bam-2.0/parser.y'`; then
  1050.     echo shar: \"'bam-2.0/parser.y'\" unpacked with wrong size!
  1051. fi
  1052. # end of 'bam-2.0/parser.y'
  1053. fi
  1054. echo shar: End of archive 4 \(of 7\).
  1055. cp /dev/null ark4isdone
  1056. MISSING=""
  1057. for I in 1 2 3 4 5 6 7 ; do
  1058.     if test ! -f ark${I}isdone ; then
  1059.     MISSING="${MISSING} ${I}"
  1060.     fi
  1061. done
  1062. if test "${MISSING}" = "" ; then
  1063.     echo You have unpacked all 7 archives.
  1064.     rm -f ark[1-9]isdone
  1065. else
  1066.     echo You still need to unpack the following archives:
  1067.     echo "        " ${MISSING}
  1068. fi
  1069. ##  End of shell archive.
  1070. exit 0
  1071.  
  1072. exit 0 # Just in case...
  1073.