home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sources / misc / 3784 < prev    next >
Encoding:
Text File  |  1992-07-30  |  29.7 KB  |  1,080 lines

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