home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / src / amiga_menu.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  128 lines

  1. /* Amiga menu bar related stuff.
  2.    Copyright (C) 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Original Amiga version by David Gay, 
  21.  * Emacs 19 version by Carsten Heyl,
  22.  * took lot of code from xmenu.c
  23.  */
  24.  
  25. #include <exec/types.h>
  26. #include <libraries/gadtools.h>
  27. #include <intuition/intuition.h>
  28. #include <proto/exec.h>
  29. #include <proto/dos.h>
  30. #include <proto/gadtools.h>
  31. #include <proto/intuition.h>
  32. #include "config.h"
  33. #include "lisp.h"
  34. #include "frame.h"
  35. #include "amiga.h"
  36.  
  37. #ifdef USE_PROTOS
  38. #include "protos.h"
  39. #endif
  40.  
  41. #ifndef GTMN_NewLookMenus
  42. #define GTMN_NewLookMenus    GT_TagBase+67
  43. #endif
  44.  
  45. #if 0
  46. static struct Menu *emacs_menu;
  47. static char *emacs_menu_strings;
  48. static APTR win_vi;
  49. #endif
  50. struct Library *GadToolsBase;
  51.  
  52. static void Famiga_delete_menus(FRAME_PTR f);
  53.  
  54. void suspend_menus(FRAME_PTR f)
  55. {
  56.   if (EMACS_WIN(f))
  57.     {
  58.       ClearMenuStrip(EMACS_WIN(f));
  59.       if (EMACS_VI(f))
  60.     {
  61.       FreeVisualInfo(EMACS_VI(f));
  62.       EMACS_VI(f) = 0;
  63.     }
  64.     }
  65. }
  66.  
  67. int resume_menus(FRAME_PTR f)
  68. {
  69.   if (EMACS_WIN(f) && EMACS_MENU(f))
  70.     {
  71.       EMACS_VI(f) = GetVisualInfo(EMACS_WIN(f)->WScreen, TAG_END);
  72.  
  73.       if (!EMACS_VI(f) || !LayoutMenus(EMACS_MENU(f), EMACS_VI(f),
  74.                   GTMN_NewLookMenus, 1L,
  75.                   TAG_END))
  76.     {
  77.       if (EMACS_VI(f)) FreeVisualInfo(EMACS_VI(f));
  78.       Famiga_delete_menus(f);
  79.  
  80.       return FALSE;
  81.     }
  82.       SetMenuStrip(EMACS_WIN(f), EMACS_MENU(f));
  83.     }
  84.   return TRUE;
  85. }
  86.  
  87. static 
  88. void Famiga_delete_menus(FRAME_PTR f)
  89. {
  90.     check_intuition();
  91.  
  92.     suspend_menus(f);
  93.     if (EMACS_MENU(f)) FreeMenus(EMACS_MENU(f));
  94.     EMACS_MENU(f) = 0;
  95.     if (EMACS_MENU_STRINGS(f)) free(EMACS_MENU_STRINGS(f));
  96.     EMACS_MENU_STRINGS(f) = 0;
  97. }
  98.  
  99.  
  100. void syms_of_amiga_fns(void);
  101. void init_amiga_fns(void);
  102. void syms_of_amiga_xmenu(void);
  103. void init_amiga_xmenu(void);
  104.  
  105. void syms_of_amiga_menu(void)
  106. {
  107.     syms_of_amiga_fns();
  108.     syms_of_amiga_xmenu();
  109. }
  110.  
  111. void init_amiga_menu(void)
  112. {
  113.     GadToolsBase = OpenLibrary("gadtools.library", 0);
  114.     if (!GadToolsBase) _fail("gadtools.library required");
  115.     init_amiga_fns();
  116. }
  117.  
  118. void cleanup_amiga_menu(void)
  119. {
  120. #ifdef MULTI_FRAME
  121.   you lose
  122. #endif
  123.   suspend_menus(selected_frame);
  124.   if (EMACS_MENU(f)) Famiga_delete_menus(selected_frame);
  125.   if (GadToolsBase) CloseLibrary(GadToolsBase);
  126. }
  127.  
  128.