[comp.sources.amiga] v90i135: PopUpMenu 3.2 - make intuition menus into pop up menus, Part01/03

Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (04/14/90)

Submitted-by: d5adria@dtek.chalmers.se (Martin Adrian)
Posting-number: Volume 90, Issue 135
Archive-name: util/popupmenu-3.2/part01

[ uuencoded executables and icon enclosed.  ...tad ]

Finally I'm back with a new version (3.2) of my PopUpMenu program.

The previus version (2.42) caused a lot of gurus, specially
#81000005.  The solution to this was to write my own
SwapBitsRastPortClipRect() and almost all bugs disappeared.

There are also some new features in this version, check out
the PopUpMenu.doc file.

Martin Adrian

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 3)."
# Contents:  PopUpMenu.doc PopUpMenu.info.uu Source Source/AltStartup.a
#   Source/CheckItemSize.a Source/Convert.c Source/Globals.c
#   Source/Highlight.a Source/Highlight.c Source/InputHandler.a
#   Source/InputHandler.c Source/MakeFile Source/MyFunctions.a
#   Source/MySwapBits.a Source/PopUpMenu.h Source/PopUpMenu.i
#   Source/PortStuff.c Source/SendMessage.c Source/Source.doc
#   Source/Startup.a Source/Tags Source/Version.h
# Wrapped by tadguy@xanth on Fri Apr 13 19:45:15 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'PopUpMenu.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PopUpMenu.doc'\"
else
echo shar: Extracting \"'PopUpMenu.doc'\" \(4512 characters\)
sed "s/^X//" >'PopUpMenu.doc' <<'END_OF_FILE'
X    PopUpMenu V3.2 by Martin Adrian	       90-04-11
X    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X
X    Introduction
X    ~~~~~~~~~~~~
X    Are you using QMose, DMouse, or HeliosMouse and "always" get the wrong
X     menues when you press the mousebutton?
X    Have you ever needed pop-up menues for your Amiga?
X
X    The solution: PopUpMenu
X
X    What is it ?
X    ~~~~~~~~~~~~
X    This small program makes it possible for You to use popupmenues with
X     every program that uses standard intuition menues.
X     ~~~~~
X    The popupmenues works just like the standard pull-down menues for both
X     the user (multiple selections, checkmarks, commandkeys) and the
X     programmer (MENUPICK and MENUVERIFY).
X     All intuition menu-flags (COMMSEQ, HIGHBOX, MENUTOGGLE ...)
X     are fully supported.
X
X    Features:
X    ~~~~~~~~~
X    * The Pop-up menues will not show up when you press the menubutton
X       if any of the following conditions are true:
X
X       1) No window is active.
X       2) The active window has no menues.
X       3) The active window has the flag RMBTRAP set.
X       4) The active window has a requester open.
X       5) The mousepointer is in the screens menubar.
X	  (standard pull-down menues will appear)
X       6) You are pressing any qualifier key.
X	  (shift, alt, ctrl, left or right Amiga, left (or middle) mousebutton)
X
X    * If a menuitem has subitems this is marked with a small arrow.
X
X    * The program remembers the last menu selected.
X       (Works only with items selected with PopUpMenues and does not remember
X	different windows).
X
X   Differences from Intuition:
X   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
X   Bad:
X     Drag-select is not supported (i never use it), Use Multiple selcet.
X     If a Menu is disabled the menuitems will not show up.
X     PopUpMenu does not sort the menues after their LeftValue (they may
X      show up in the wrong order).
X
X   Good:
X     Mousepointer don't stop while menuwindows are opened or closed.
X
X   Installation:
X   ~~~~~~~~~~~~
X   To use the program put the file `PopUpMenu' and 'PopUpMenu.info'
X     in your current directory.
X
X   To turn on the pop-up menues just type:
X
X     1> PopUpMenu
X
X   (If You (or maybe Kickstart 1.4) don't like selfdetaching programs,
X     RUN the PopUpMenu.run program)
X
X   To turn them off, just type:
X
X     1> PopUpMenu
X
X   Workbench users can click the PopUpMenu-icon.
X
X   The program will take up < 10K. (including stack)
X
X   Distribution
X   ~~~~~~~~~~~~
X
X   This version of the PopUpMenu program is released as Public Domain.
X							~~~~~~~~~~~~~~
X     This program can be used, copied, included in a library or commercial
X     product as long as You don't do it for profit.
X
X     You may also use the source for your own programs, but if You intend
X     to do a similar popupmenu-program with it please let me know.
X
X   Warnings:
X   ~~~~~~~~~
X   * A bug in intuition will sometimes lock the inputhandler (Mousepointer
X       and keyboard will freeze).  This happens when intuition tries to change
X       the screen (i.e draw something) while menues are displayed.
X     The PopUpMenu program will detect this, fix it, and then resume the
X       menuoperation. (The menues flashes once).
X
X   * It is not possible to remove older versions (2.42 and lower) with
X       this program.
X
X   FUTURE:
X   ~~~~~~~
X    Size is to big.
X
X    The program only remembers the last menu (not menuitem or subitem) selected.
X
X
X   Author:
X   ~~~~~~~
X     Martin Adrian							  o
X     Motgangen 305		    (the a is an 'a' with a ring above -> a)
X     S-412 80  Gothenburg
X     Sweden
X
XUSENET d5adria@dtek.chalmers.se  (not sure if this works anymore)
X
X   Thanks to:
X	Derek Zahn	      for the PopUpMenu program on FishDisk 96
X	Commodore	      for the Amiga
X	Arp - people	      for Arp 1.3 & AShell
X	Lattice 	      for the C compiler (5.0)
X	My English teatcher
X	Anna		      my girlfriend
X	You		      for using this program.
X
X
X   Differences from version 2.42
X   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X   For speed:
X   * Some code optimizations (C -> Assembler).
X
X   For safety:
X   * MENUVERIFY is now fully supported.
X   * Forbid() and LockIBase() is now used where needed. (I hope.)
X   * Made my own SwapBitsRastPortClipRect.   (No more guru #81000005)
X
X   For use:
X   * Shows if an item has subitems.
X   * Now always shows items & subitems (even if they cover other menuwindows).
X   * Now resumes after the intuition lock-up.
X
X   For compability:
X   * Fixed Fontbug.
X
X   New Distrbution:
X   * Public Domain.  (i'm not a poor student anymore 8-) )
X
END_OF_FILE
if test 4512 -ne `wc -c <'PopUpMenu.doc'`; then
    echo shar: \"'PopUpMenu.doc'\" unpacked with wrong size!
fi
# end of 'PopUpMenu.doc'
fi
if test -f 'PopUpMenu.info.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PopUpMenu.info.uu'\"
else
echo shar: Extracting \"'PopUpMenu.info.uu'\" \(1041 characters\)
sed "s/^X//" >'PopUpMenu.info.uu' <<'END_OF_FILE'
Xbegin 664 PopUpMenu.info
XMXQ```0``````/0`4`#(`$P`&``,``0#`TS``P-B`````````````````````O
XM`````_X`P%)@`,!G:````!<```````````````````?0```````R`!(``@``V
XMHV@#```````/______P``#```````P``8`````%!@`!``````<"``$``````K
XM`(``0```````@`!```````"``$```````(``0```````@`!```````"``$```
XM`````(``0```````@`!@``````&``&```````8``/_______```?______X`5
XM``______^````(````"```````````````````````````````"`````````#
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````<```````````````````````````````#(`$@`"``"DB`,`````V
XM``_______```,``````#``!@`!_``4&``$``$,`!P(``0``?P```@`!``!``[
XM``"``$``'W^``(``0``00(``@`!``!]_@`"``$``$$.``(``0``??X``@`!`]
XM`!````"``&``'\```8``8``````!@``_______\``!_______@``#______X'
XM````@````(```````````````````````````````(``````#P``````````/
XM``````````\`````````'P`````````?/P```````!\`````````#SP`````V
XM``````````````\````````````````````````````````````````````!0
XFP`````````````````````````````$`````#`````$``````0``/
X``
Xend
Xsize 713
END_OF_FILE
if test 1041 -ne `wc -c <'PopUpMenu.info.uu'`; then
    echo shar: \"'PopUpMenu.info.uu'\" unpacked with wrong size!
fi
# end of 'PopUpMenu.info.uu'
fi
if test ! -d 'Source' ; then
    echo shar: Creating directory \"'Source'\"
    mkdir 'Source'
fi
if test -f 'Source/AltStartup.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/AltStartup.a'\"
else
echo shar: Extracting \"'Source/AltStartup.a'\" \(2393 characters\)
sed "s/^X//" >'Source/AltStartup.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "libraries/dos.i"
X	       INCLUDE	  "libraries/dosextens.i"
X	       INCLUDE	  "exec/execbase.i"
X	       INCLUDE	  "exec/funcdef.i"
X	       INCLUDE	  "exec/exec_lib.i"
X	       INCLUDE	  "libraries/dos_lib.i"
X
XAbsExecBase    EQU	  4
XPOPUPPRI       EQU	  5
XPOPUPSTACK     EQU	  2000
X* Must use Kickstart 1.2 or higher
XLIBVERSION     EQU	  33
X
X	       xref	  _LinkerDB
X	       xref	  @InitPopUpMenu
X	       xref	  _PopUpTaskName
X
X	       section	  text,code
X
XStartup        MOVEM.L	  D2-D4/A2-A4/A6,-(A7)
X	       LEA	  _LinkerDB,A4
X
X* ------------ Open dos.
X	       LEA	  DosName(PC),A1
X	       MOVEQ.L	  #LIBVERSION,D0
X	       MOVEA.L	  AbsExecBase.W,A6
X	       JSR	  _LVOOpenLibrary(A6)
X	       MOVE.L	  D0,_DOSBase(A4)
X
X	       TST.L	  D0
X	       BEQ.W	  NoDos
X
X* ------------ Get pointer to our Process.
X	       MOVEA.L	  ThisTask(A6),A3
X
X* ------------ Find current output window.
X	       MOVE.L	  #CurrWindow,D1
X	       MOVE.L	  #MODE_OLDFILE,D2
X
X* ------------ Run from Workbench ?
X	       TST.L	  pr_CLI(A3)
X	       BNE.B	  FromCLI
X
X* ------------ Wait for Workbench startup-message.
X	       LEA	  pr_MsgPort(A3),A0
X	       JSR	  _LVOWaitPort(A6)
X	       LEA	  pr_MsgPort(A3),A0
X	       JSR	  _LVOGetMsg(A6)
X	       MOVE.L	  D0,D3
X
X* ------------ Open window on Workbench screen.
X	       MOVE.L	  #WbWindow,D1
X	       MOVE.L	  #MODE_NEWFILE,D2
XFromCLI        MOVEA.L	  _DOSBase(A4),A6
X	       JSR	  _LVOOpen(A6)
X	       MOVE.L	  D0,_StdOut(A4)
X
X	       MOVEA.L	  AbsExecBase.W,A6
X	       TST.L	  D0
X	       BEQ.B	  NoStdOut
X
X* ------------ Don't unload segments.
X	       CLR.L	  _PopUpSeg(A4)
X
X* ------------ Set task priority.
X	       MOVEA.L	  A3,A1
X	       MOVEQ	  #POPUPPRI,D0
X	       JSR	  _LVOSetTaskPri(A6)
X
X* ------------ Start PopUpMenu-program.
X	       JSR	  @InitPopUpMenu
X
X* ------------ Must reply if started from workbench.
XNoStdOut       TST.L	  pr_CLI(A3)
X	       BNE.B	  Done
X	       JSR	  _LVOForbid(A6)
X	       MOVEA.L	  D3,A1
X	       JSR	  _LVOReplyMsg(A6)
XDone
XNoDos	       MOVEQ	  #00,D0
X	       MOVEM.L	  (A7)+,D2-D4/A2-A4/A6
X	       RTS
X* Put these data in our code-segment.
XCurrWindow     dc.b	  '*',0
XDosName        dc.b	  'dos.library',0
XWbWindow       dc.b	  'CON:100/75/400/45/PopUpMenu',0
X
X	       section	  __MERGED,bss
X
X	       xref	  _DOSBase
X	       xref	  _StdOut
X	       xref	  _PopUpSeg
X
X	       END
X
END_OF_FILE
if test 2393 -ne `wc -c <'Source/AltStartup.a'`; then
    echo shar: \"'Source/AltStartup.a'\" unpacked with wrong size!
fi
# end of 'Source/AltStartup.a'
fi
if test -f 'Source/CheckItemSize.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/CheckItemSize.a'\"
else
echo shar: Extracting \"'Source/CheckItemSize.a'\" \(4465 characters\)
sed "s/^X//" >'Source/CheckItemSize.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "graphics/rastport.i"
X	       INCLUDE	  "graphics/text.i"
X	       INCLUDE	  "intuition/intuition.i"
X	       INCLUDE	  "PopUpMenu.i"
X
X	       xdef	  @CheckItemSize
X
X	       xref	  @Mystrlen
X
X_LVOIntuiTextLength EQU   -$14a
X_LVOTextLength	    EQU   -$36
X
X	       section	  text,code
X*********************************************************
X* CheckItemSize(SizeSoFar,Item,Contents) -              *
X*  find the size needed to include Item in window.	*
X*							*
X* Input:						*
X*   SizeSoFar (A0)  Current size of window.             *
X*   Item      (A1)  Item to check.                      *
X*   Contents  (D0)  What to fill (ItemFill/SelectFill). *
X* Output:						*
X*   SizeSoFar	    New size of window			*
X*********************************************************
X@CheckItemSize:
X	       MOVEM.L	  D2-D7/A2-A3/A5-A6,-(SP)
X
X	       MOVEA.L	  A0,A3 	      * A3 = SizeSoFar
X	       MOVEA.L	  A1,A2 	      * A2 = Item to check
X	       MOVEA.L	  D0,A5 	      * D0 = What to check
X
X* ------------ Anything to check ?
XCheck:	       MOVE.L	  A5,D0
X	       BEQ.W	  Done
X
X	       MOVE.W	  mi_LeftEdge(A2),D3  * D3 = LeftEdge
X	       MOVE.W	  mi_TopEdge(A2),D2   * D2 = TopEdge
X	       MOVE.W	  D3,D7 	      * D7 = Left
X	       MOVE.W	  D2,D6 	      * D6 = Top
X	       MOVE.W	  D3,D5
X	       MOVE.W	  D2,D4
X
X* ------------ ITEMTEXT or ITEMIMAGE ?
X	       MOVEQ.L	  #ITEMTEXT,D0
X	       AND.W	  mi_Flags(A2),D0
X	       BEQ.B	  ItemImage
X
X* ------------ Add IText position to left and top.
X	       ADD.W	  it_LeftEdge(A5),D7
X	       ADD.W	  it_TopEdge(A5),D6
X
X* ------------ What font to use ?
X	       TST.L	  it_ITextFont(A5)
X	       BEQ.B	  DefaultFont
X
X* ------------ Find length of string in pixels.
X	       MOVEA.L	  A5,A0
X	       MOVEA.L	  _IntuitionBase(A4),A6
X	       JSR	  _LVOIntuiTextLength(A6)
X
X* ------------ Add to LeftEdge.
X	       ADD.W	  D0,D5 	      * D5 = Right
X
X* ------------ Find hight of string in pixels and add to top.
X	       MOVEA.L	  it_ITextFont(A5),A1
X	       ADD.W	  ta_YSize(A1),D4     * D4 = Bottom
X	       BRA.B	  NextText
X
X* ------------ Find length of string with default font.
XDefaultFont:   MOVEA.L	  it_IText(A5),A0
X	       JSR	  @Mystrlen(PC)
X	       LEA	  _Rp(A4),A1
X	       MOVEA.L	  it_IText(A5),A0
X	       MOVEA.L	  _GfxBase(A4),A6
X	       JSR	  _LVOTextLength(A6)
X
X* ------------ Add to LeftEdge to get rightedge.
X	       ADD.W	  D0,D5
X
X* ------------ Find hight of string in pixels and add to top to get bottom.
X	       MOVE.W	  _Rp+rp_TxHeight(A4),D4
X	       ADD.W	  D6,D4
X
X* ------------ Move to next text.
XNextText:      MOVEA.L	  it_NextText(A5),A5
X	       BRA.B	  CheckLeft
X
X* ------------ Add Image position to left and top.
XItemImage:     ADD.W	  (A5),D7
X	       ADD.W	  ig_TopEdge(A5),D6
X
X* ------------ Add Imgage width and height to right and bottom.
X	       ADD.W	  ig_Width(A5),D5
X	       ADD.W	  ig_Height(A5),D4
X
X* ------------ Move to next image
X	       MOVE.L	  ig_NextImage(A5),A5
X
X* ------------ Find lowest leftedge.
XCheckLeft:     CMP.W	  D7,D3 	      * D3 = LeftEdge
X	       BGE.B	  1$
X	       MOVE.L	  D3,D7
X1$:	       CMP.W	  (A3),D7
X	       BGE.B	  CheckRight
X	       MOVE.W	  D7,(A3)
X
X* ------------ Find Biggest RightEdge
XCheckRight:    ADD.W	  mi_Width(A2),D3     * D3 = RightEdge
X	       CMP.W	  D5,D3
X	       BLE.B	  1$
X	       MOVE.L	  D3,D5
X* ------------ If item has subitem make room for pointer.
X1$:	       TST.L	  mi_SubItem(A2)
X	       BEQ.B	  2$
X	       ADDQ.W	  #6,D5
X* ------------ If screentype is HIRESSCREEN make pointer bigger.
X	       TST.W	  _ScreenType(A4)
X	       BNE.B	  2$
X	       ADDQ.W	  #4,D5
X2$:	       CMP.W	  ws_Right(A3),D5
X	       BLE.B	  CheckTop
X	       MOVE.W	  D5,ws_Right(A3)
X
X* ------------ Find lowest Topedge.
XCheckTop:      CMP.W	  D6,D2 	      * D2 = TopEdge
X	       BGE.B	  1$
X	       MOVE.L	  D2,D6
X1$:	       CMP.W	  ws_Top(A3),D6
X	       BGE.B	  CheckBottom
X	       MOVE.W	  D6,ws_Top(A3)
X
X* ------------ Find biggest bottompos.
XCheckBottom:   ADD.W	  mi_Height(A2),D2    * D2 = BottomEdge
X	       CMP.W	  D4,D2
X	       BLE.B	  1$
X	       MOVE.L	  D2,D4
X1$:	       CMP.W	  ws_Bottom(A3),D4
X	       BLE.B	  2$		      * Size comes before speed.
X	       MOVE.W	  D4,ws_Bottom(A3)
X2$	       BRA.W	  Check
X
XDone:	       MOVEM.L	  (SP)+,D2-D7/A2-A3/A5-A6
X	       RTS
X
X	       section	  __MERGED,bss
X
X	       xref	  _Rp
X	       xref	  _ScreenType
X	       xref	  _IntuitionBase
X	       xref	  _GfxBase
X
X	       END
X
END_OF_FILE
if test 4465 -ne `wc -c <'Source/CheckItemSize.a'`; then
    echo shar: \"'Source/CheckItemSize.a'\" unpacked with wrong size!
fi
# end of 'Source/CheckItemSize.a'
fi
if test -f 'Source/Convert.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Convert.c'\"
else
echo shar: Extracting \"'Source/Convert.c'\" \(3682 characters\)
sed "s/^X//" >'Source/Convert.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X/****************************************************************
X * FinalSelect()  Do checkmarking and calculate Menupick value. *
X *								*
X * Input:							*
X *   none							*
X * Output:							*
X *   return  - MenuPick-value or MENUNULL.			*
X ****************************************************************/
XWORDBITS FinalSelect()
X{
X  IMPORT const UWORD  CurrentMenuNr;
X  IMPORT struct MenuItem *const CurrentItem, *const CurrentSubItem;
X  IMPORT struct WindowData ItemWindow, SubWindow;
X  IMPORT struct RastPort Rp;
X
X  UWORD  SubItemNr = 31;
X  UWORD  ItemNr;
X
X  if ((CurrentSubItem) AND (CurrentSubItem->Flags & ITEMENABLED)) {
X
X    /* subitem selected -> checkmark and draw all subitems again */
X
X    CheckMark(CurrentSubItem,SubWindow.Items);
X    DrawAllItems(&SubWindow);
X    HighLightItem(CurrentSubItem,&SubWindow,HIGHLIGHTON);
X
X    /* clear nextselect field */
X    CurrentSubItem->NextSelect = MENUNULL;
X
X    /* find the number of the selected subitem */
X
X    SubItemNr = FindItemNr(CurrentSubItem,SubWindow.Items);
X
X    /* remove the subitem-window so we can checkmark the items */
X    SwapBits(&SubWindow);
X  }
X  else
X    if ((CurrentItem) AND (CurrentItem->Flags & ITEMENABLED) AND
X	!(CurrentItem->SubItem))
X      CurrentItem->NextSelect = MENUNULL;
X    else
X      /* nothing is selected -> exit */
X      return (MENUNULL);
X
X  CheckMark(CurrentItem,ItemWindow.Items);
X
X  /* find number of selected item */
X  ItemNr = FindItemNr(CurrentItem,ItemWindow.Items);
X
X  DrawAllItems(&ItemWindow);
X  HighLightItem(CurrentItem,&ItemWindow,HIGHLIGHTON);
X
X  /* restore subwindow */
X  SwapBits(&SubWindow);
X
X  return (SHIFTMENU((CurrentMenuNr - 1)) |
X	  SHIFTITEM(ItemNr) |
X	  SHIFTSUB(SubItemNr));
X}
X
X/********************************************************
X * CheckMark(Selected,Items) - Checkmark selected item. *
X *							*
X * Input:						*
X *   Selected - The selected item.			*
X *   Items    - All items on the same level.		*
X * Output:						*
X *   none						*
X ********************************************************/
XVOID CheckMark(Selected,Items)
X  struct MenuItem *const Selected;
X  struct MenuItem *Items;
X{
X  if (Selected->Flags & CHECKIT) {
X    if (Selected->Flags & CHECKED) {
X      if (Selected->Flags & MENUTOGGLE)
X	Selected->Flags &= ~CHECKED;
X    }
X    else {
X      LONGBITS	Exclude = Selected->MutualExclude;
X
X      Selected->Flags |= CHECKED;
X
X      /* Handle mutual exclusion */
X
X      if (Exclude)
X	do {
X	  if (Exclude & 1)
X	    Items->Flags &= ~CHECKED;
X	  Exclude >>= 1;
X	}
X	while ((Items = Items->NextItem) != NULL);
X    } /* if CHECKED */
X  } /* if CHECKIT */
X}
X
X/**********************************************
X * FindMenuPtr(Number) - Find Menu structure. *
X *					      *
X * INPUT				      *
X *   Number - Number of the menu to look for. *
X * OUTPUT				      *
X *   return - Ptr to the Menu structure.      *
X **********************************************/
Xstruct Menu *FindMenuPtr(Number)
X  UWORD  Number;
X{
X  IMPORT struct Menu *const Menues;
X
X  struct Menu *MenuPtr = Menues;
X
X  while ((MenuPtr) AND (--Number))
X    MenuPtr = MenuPtr->NextMenu;
X
X  return (MenuPtr);
X}
X
X/************************************************
X * FindItemNr(Item,ItemList) - Find nr of item. *
X *  WARNING: The item MUST exist		*
X *						*
X * Input:					*
X *   Item - Item to look for.			*
X *   ItemList - all items on same level.	*
X * OUTPUT					*
X *   return - Nr of Item.			*
X ************************************************/
XUWORD  FindItemNr(Item,ItemList)
X  struct MenuItem *const Item;
X  struct MenuItem *ItemList;
X{
X  UWORD Count = 0;
X
X  while (ItemList != Item) {
X    Count++;
X    ItemList = ItemList->NextItem;
X  }
X  return (Count);
X}
X
END_OF_FILE
if test 3682 -ne `wc -c <'Source/Convert.c'`; then
    echo shar: \"'Source/Convert.c'\" unpacked with wrong size!
fi
# end of 'Source/Convert.c'
fi
if test -f 'Source/Globals.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Globals.c'\"
else
echo shar: Extracting \"'Source/Globals.c'\" \(2342 characters\)
sed "s/^X//" >'Source/Globals.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X/* Library base pointers */
Xstruct DosLibrary    *DOSBase;
Xstruct IntuitionBase *IntuitionBase;
Xstruct GfxBase	     *GfxBase;
Xstruct LayersBase    *LayersBase;
X
X/* Our semaphore */
Xstruct SignalSemaphore PopUpSemaphore;
X
X/* Pointers to intuition functions */
X__fptr OldSetMenuStrip, OldClearMenuStrip, OldOnMenu, OldOffMenu;
X
X/* The menuwindows */
Xstruct WindowData MenuWindow, ItemWindow, SubWindow;
X
X/* The currently select items */
Xstruct MenuItem   *CurrentSubItem, *CurrentItem, *TempItem;
Xstruct Menu	  *CurrentMenuPtr;
XUWORD		  CurrentMenuNr;
X
X/* Size of the font used to draw the menues */
XUWORD		  MenuFontSize;
X
X/* Mouse position on screen */
XUWORD		  MouseX,MouseY;
X
X/* device request blocks */
Xstruct IOStdReq *InputReqBlock;
Xstruct timerequest *TimerReqBlock;
X
X/* Pointer to the menus to use */
Xstruct Menu	*Menues;
X
X/* Variables to hold the last selection */
Xstruct Window	*LastWindow;
XWORDBITS LastSelected;
X
X/* Screen to draw on */
Xstruct Screen	*Screen;
X
XBOOL		ScreenType;
X
X/* A copy (almost) of the screens rastport */
Xstruct RastPort Rp;
X
X/* Window with menues to use */
Xstruct Window	*ActiveWindow;
XBPTR		StdOut;
XBPTR		PopUpSeg;
X
X
XUWORD chip AmigaKeyHighRes[] = {
X  0xc000, 0x0600,
X  0x0003, 0xc000,
X  0x000f, 0xc000,
X  0x0039, 0xc000,
X  0x00e1, 0xc000,
X  0x03ff, 0xc000,
X  0x1f83, 0xf000,
X  0xc000, 0x0600
X};
X
XUWORD chip AmigaKeyLoRes[] = {
X  0x8004,
X  0x00e0,
X  0x01e0,
X  0x0360,
X  0x0660,
X  0x0fe0,
X  0x3cf0,
X  0x8004
X};
X
XUWORD chip SubItemPointerL[] = {
X  0x7000,
X  0x3000,
X  0x1000,
X  0x0000,
X  0x1000,
X  0x3000,
X  0x7000
X};
X
XUWORD chip SubItemPointerH[] = {
X  0x3f00,
X  0x0f00,
X  0x0300,
X  0x0000,
X  0x0300,
X  0x0f00,
X  0x3f00
X};
X
X/* these doesn't need to be in chip-ram but it's the easiest way to
X   get Blink to create a BSS hunk */
X
Xstruct Image chip MyAmigaKeyImage[2] = {
X  /*  Pos   Size Depth	  Data		Pick OnOff  Next */
X  {-25, 0, 23, 8,  1,	AmigaKeyHighRes,  1,   0,   NULL},
X  {-16, 0, 14, 8,  1,	AmigaKeyLoRes,	  1,   0,   NULL}
X};
X
Xstruct Image chip MySubItemImage[2] = {
X  /*  Pos   Size Depth	  Data		Pick OnOff  Next */
X  {  2, 0,  8, 7,  1,	SubItemPointerH,  1,  0,   NULL},
X  {  1, 0,  4, 7,  1,	SubItemPointerL,  1,  0,   NULL}
X};
X
XUWORD chip GhostPattern[]  = { 0x1111, 0x4444 };
XUWORD chip NormalPattern[] = { 0xffff, 0xffff };
X
XSTRPTR chip PopUpTaskName = "PopUpMenu";
X
END_OF_FILE
if test 2342 -ne `wc -c <'Source/Globals.c'`; then
    echo shar: \"'Source/Globals.c'\" unpacked with wrong size!
fi
# end of 'Source/Globals.c'
fi
if test -f 'Source/Highlight.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Highlight.a'\"
else
echo shar: Extracting \"'Source/Highlight.a'\" \(4959 characters\)
sed "s/^X//" >'Source/Highlight.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "graphics/rastport.i"
X	       INCLUDE	  "intuition/intuition.i"
X	       INCLUDE	  "PopUpMenu.i"
X
X_LVOSetDrMd    EQU	  -$162
X_LVODraw       EQU	  -$f6
X_LVOMove       EQU	  -$f0
X_LVORectFill   EQU	  -$132
X
XBORDERSIZE     EQU	  2
X
X	       xdef	  @HighLightItem
X	       xdef	  @ToggleMenu
X
X	       xref	  @DrawMenuItem
X
X	       section	  text,code
X
X***************************************************
X* HighLightItem(Item, ItemWindow, Mode)           *
X*						  *
X* Input:					  *
X*   Item  -	  Item to highlight.		  *
X*   ItemWindow -  Data for the window to draw in. *
X*   Mode   -	  HIGHLIGHTON or HIGHLIGHTOFF.	  *
X* Output:					  *
X*   none					  *
X***************************************************
X@HighLightItem:
X	       MOVEM.L	 D2-D7/A2-A3/A5-A6,-(SP)
X	       MOVEA.L	 A0,A3
X	       MOVEA.L	 A1,A2
X
X* ------------ Possible to highlight item ?
X	       MOVEQ.L	 #ITEMENABLED,D1
X	       AND.W	 mi_Flags(A3),D1
X	       BEQ.B	 HighlightDone
X
X* ------------ Start highlighting.
X	       LEA	 _Rp(A4),A5
X	       MOVEA.L	 _GfxBase(A4),A6
X
X	       MOVE.W	 #HIGHFLAGS,D7
X	       AND.W	 mi_Flags(A3),D7
X	       BNE.B	 NotHighImage
X
X* ------------ Invert Mode and call DrawMenuItem.
X* ------------ DrawMenuItem(Item, ItemWindow, !Mode,CLEAROLD);
XHighImage:     MOVEQ.L	 #1,D1		  * CLEAROLD
X	       ADDQ.W	 #1,D0
X	       AND.W	 D1,D0
X	       JSR	 @DrawMenuItem(PC)
X	       BRA.B	 HighlightDone
X
X* ------------ Left   = Item->LeftEdge - ItemWindow->LeftValue
XNotHighImage:  MOVE.W	 mi_LeftEdge(A3),D6
X	       SUB.W	 wd_LeftValue(A2),D6
X	       EXT.L	 D6
X
X* ------------ Right  = Left + Item->Width
X	       MOVE.W	 mi_Width(A3),D5
X	       EXT.L	 D5
X	       ADD.L	 D6,D5
X
X* ------------ Top    = Item->TopEdge - ItemWindow->TopValue
X	       MOVE.W	 mi_TopEdge(A3),D4
X	       SUB.W	 wd_TopValue(A2),D4
X	       EXT.L	 D4
X
X* ------------ Bottom = Top + Item->Height
X	       MOVE.W	 mi_Height(A3),D3
X	       EXT.L	 D3
X	       ADD.L	 D4,D3
X
X* ------------ Set drawmode = COMPLEMENT.
X	       MOVEQ.L	 #RP_COMPLEMENT,D0
X	       MOVEA.L	 A5,A1
X	       JSR	 _LVOSetDrMd(A6)
X
X* ------------ Check out kind of highlighting.
XHighType:      CMPI.W	 #HIGHBOX,D7
X	       BEQ.B	 HighBox
X	       CMPI.W	 #HIGHCOMP,D7
X	       BNE.B	 HighlightDone
X
X* ------------ RectFill(Left, Top, Right - 1, Bottom - 1)
XHighComp:      MOVE.L	 D6,D0
X	       MOVE.L	 D4,D1
X	       MOVEA.L	 A5,A1
X	       MOVE.L	 D5,D2
X	       SUBQ.L	 #1,D2
X	       SUBQ.L	 #1,D3
X	       JSR	 _LVORectFill(A6)
X	       BRA.B	 HighlightDone
X
X* ------------ DrawRect(Left, Top, Right, Bottom)
XHighBox:       BSR.B	 DrawRect
X
X* ------------ DrawRect(Left - 1, Top - 1, Right + 1, Bottom + 1)
X	       ADDQ.L	 #1,D5
X	       ADDQ.L	 #1,D3
X	       BSR.B	 DrawRect
X
XHighlightDone: MOVEM.L	 (SP)+,D2-D7/A2-A3/A5-A6
X	       RTS
X
X* ------------ Draw a rectangle.
X* ------------ Move(--Left,Top).
XDrawRect:      SUBQ.L	 #1,D6
X	       MOVE.L	 D6,D0
X	       MOVE.L	 D4,D1
X	       MOVEA.L	 A5,A1
X	       JSR	 _LVOMove(A6)
X
X* ------------ Draw(Left,Bottom).
X	       MOVE.L	 D6,D0
X	       MOVE.L	 D3,D1
X	       BSR.B	 Draw
X
X* ------------ Draw(Right,Bottom).
X	       MOVE.L	 D5,D0
X	       MOVE.L	 D3,D1
X	       BSR.B	 Draw
X
X* ------------ Draw(Right,--Top).
X	       SUBQ.L	 #1,D4
X	       MOVE.L	 D5,D0
X	       MOVE.L	 D4,D1
X	       BSR.B	 Draw
X
X* ------------ Draw(Left,Top).
X	       MOVE.L	 D6,D0
X	       MOVE.L	 D4,D1
X
XDraw:	       MOVEA.L	 A5,A1	       * Get RastPort
X	       JMP	 _LVODraw(A6)
X
X*********************************************
X* ToggleMenu(Number,Menu)                   *
X*					    *
X* Input:				    *
X*   Number - Menu to highlight. 	    *
X*   Menu   - Pointer to the Menu structure. *
X* Output:				    *
X*   none				    *
X*********************************************
X@ToggleMenu    MOVEM.L	 D2-D3/A6,-(A7)
X
X* ------------ Menu enabled ?
X	       MOVEQ.L	 #MENUENABLED,D2
X	       AND.W	 mu_Flags(A0),D2
X	       BEQ.B	 ToggleDone
X
X	       MOVE.W	 D0,D3
X
X* ------------ Set drawmode = COMPLEMENT.
X	       LEA	 _Rp(A4),A1
X	       MOVEQ	 #RP_COMPLEMENT,D0
X	       MOVEA.L	 _GfxBase(A4),A6
X	       JSR	 _LVOSetDrMd(A6)
X
X* ------------ Invert menu.
X* ------------ Bottom = Number * MenuFontSize + MenuWindow.TopEdge.
X	       MOVE.W	 _MenuFontSize(A4),D2
X	       MULU.W	 D2,D3
X	       ADD.W	 _MenuWindow+wd_TopEdge(A4),D3
X
X* ------------ Top = Bottom - MenuFontSize + BORDERSIZE.
X	       MOVE.L	 D3,D1
X	       SUB.L	 D2,D1
X	       ADDQ.L	 #BORDERSIZE,D1
X
X* ------------ Left = MenuWindow.LeftEdge + BORDERSIZE.
X	       MOVEQ.L	 #BORDERSIZE,D0
X	       ADD.W	 _MenuWindow+wd_LeftEdge(A4),D0
X
X* ------------ Right = MenuWindow.RightEdge - BORDERSIZE.
X	       MOVE.W	 _MenuWindow+wd_RightEdge(A4),D2
X	       SUBQ.L	 #BORDERSIZE,D2
X
X	       LEA	 _Rp(A4),A1
X	       JSR	 _LVORectFill(A6)
X
XToggleDone     MOVEM.L	 (A7)+,D2-D3/A6
X	       RTS
X
X
X	       section	 __MERGED,bss
X
X	       xref	 _Rp
X	       xref	 _GfxBase
X	       xref	 _MenuFontSize
X	       xref	 _MenuWindow
X
X	       END
X
END_OF_FILE
if test 4959 -ne `wc -c <'Source/Highlight.a'`; then
    echo shar: \"'Source/Highlight.a'\" unpacked with wrong size!
fi
# end of 'Source/Highlight.a'
fi
if test -f 'Source/Highlight.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Highlight.c'\"
else
echo shar: Extracting \"'Source/Highlight.c'\" \(2208 characters\)
sed "s/^X//" >'Source/Highlight.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X/**************************************************
X * HighLightItem(Item, ItemWindow, Mode)          *
X *						  *
X * Input:					  *
X *   Item  -	  Item to highlight.		  *
X *   ItemWindow - Data for the window to draw in. *
X *   Mode   -	  HIGHLIGHTON or HIGHLIGHTOFF.	  *
X * Output:					  *
X *   none					  *
X **************************************************/
XVOID HighLightItem(Item, ItemWindow, Mode)
X  struct MenuItem *const Item;
X  struct WindowData  *const ItemWindow;
X  const UWORD Mode;
X{
X  IMPORT struct RastPort Rp;
X
X  /* possible to highlight item ? */
X  if (Item->Flags & ITEMENABLED) {
X    const LONG Left   = Item->LeftEdge - ItemWindow->LeftValue;
X    const LONG Right  = Left + Item->Width;
X    const LONG Top    = Item->TopEdge - ItemWindow->TopValue;
X    const LONG Bottom = Top + Item->Height;
X
X    SetDrMd(&Rp, COMPLEMENT);
X
X    switch (Item->Flags & HIGHFLAGS) {
X      case HIGHCOMP:
X	RectFill(&Rp, Left, Top, Right - 1, Bottom - 1);
X	break;
X      case HIGHBOX:
X	Move(&Rp, Left  - 1, Top - 2);
X	Draw(&Rp, Right + 1, Top - 2);
X	Draw(&Rp, Right + 1, Bottom + 1);
X	Draw(&Rp, Left  - 1, Bottom + 1);
X	Draw(&Rp, Left  - 1, Top - 1);
X	Draw(&Rp, Right    , Top - 1);
X	Draw(&Rp, Right    , Bottom);
X	Draw(&Rp, Left     , Bottom);
X	Draw(&Rp, Left     , Top);
X	break;
X      case HIGHIMAGE:
X	DrawMenuItem(Item, ItemWindow, (UWORD)(!Mode),CLEAROLD);
X    }
X  }
X}
X
X/*********************************************
X * ToggleMenu(Number,Menu)                   *
X *					     *
X * Input:				     *
X *   Number - Menu to highlight.	     *
X *   Menu   - Pointer to the Menu structure. *
X * Output:				     *
X *   none				     *
X *********************************************/
XVOID ToggleMenu(Number,Menu)
X  const UWORD Number;
X  struct Menu *const Menu;
X{
X  IMPORT struct WindowData  MenuWindow;
X  IMPORT struct RastPort Rp;
X  IMPORT const UWORD  MenuFontSize;
X
X  if (Menu->Flags & MENUENABLED) {
X    const LONG Bottom = MenuWindow.TopEdge + Number * MenuFontSize;
X    const LONG Top    = Bottom - MenuFontSize + BORDERSIZE;
X
X    SetDrMd(&Rp, COMPLEMENT);
X    RectFill(&Rp, (LONG)MenuWindow.LeftEdge  + BORDERSIZE, Top,
X		  (LONG)MenuWindow.RightEdge - BORDERSIZE, Bottom);
X  }
X}
X
END_OF_FILE
if test 2208 -ne `wc -c <'Source/Highlight.c'`; then
    echo shar: \"'Source/Highlight.c'\" unpacked with wrong size!
fi
# end of 'Source/Highlight.c'
fi
if test -f 'Source/InputHandler.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/InputHandler.a'\"
else
echo shar: Extracting \"'Source/InputHandler.a'\" \(3865 characters\)
sed "s/^X//" >'Source/InputHandler.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "intuition/intuition.i"
X	       INCLUDE	  "intuition/screens.i"
X	       INCLUDE	  "devices/inputevent.i"
X	       INCLUDE	  "PopUpMenu.i"
X
XQUALIFIERS     EQU  IEQUALIFIER_LSHIFT+IEQUALIFIER_RSHIFT+IEQUALIFIER_CONTROL+IEQUALIFIER_LALT+IEQUALIFIER_RALT+IEQUALIFIER_LCOMMAND+IEQUALIFIER_RCOMMAND+IEQUALIFIER_MIDBUTTON+IEQUALIFIER_LEFTBUTTON
X_LVOSignal     EQU	 -$144
XAbsExecBase    EQU	 4
XFALSE	       EQU	 0
XTRUE	       EQU	 1
X
X	       xdef	 @PopUpHandler
X
X	       xref	 _IntuitionBase
X
X	       section	 text,code
X
X@PopUpHandler: MOVEM.L	 D2/A2-A6,-(A7)
X	       MOVEA.L	 A0,A3		  *A3 = Events
X	       MOVEA.L	 A1,A2		  *A2 = MySignals
X	       MOVEA.L	 A3,A4		  *A4 = Event
X	       SUB.L	 A5,A5		  *A5 = LastEvent
X	       MOVEA.L	 AbsExecBase.W,A6
X
X	       MOVE.W	 sd_Down(A2),D2
X	       BEQ.B	 NoMoveSignal
X
X* ------------ Tell the task we are living.
X	       MOVEA.L	 (A2),A1          *sd_PopUpMenuTask
X	       MOVE.L	 sd_MouseMovedSig(A2),D0
X	       JSR	 _LVOSignal(A6)
X
X* ------------ No more events ?
XNoMoveSignal:
XMoreEvents:    MOVE.L	 A4,D0
X	       BEQ.W	 Done
X
X* ------------ Mouseevent ?
X	       MOVEQ.L	 #IECLASS_RAWMOUSE,D0
X	       CMP.B	 ie_Class(A4),D0
X	       BNE.W	 KeepEvent	  * Don't care about this message.
X
X	       MOVE.W	 ie_Code(A4),D1
X
X* ------------ Is menubutton already pressed.
X	       TST.W	 D2
X	       BNE.B	 MouseIsDown	  * Yes
X
X* ------------ Menubutton pressed ?
X	       MOVEQ.L	 #MENUDOWN,D0
X	       CMP.W	 D1,D0
X	       BNE.B	 KeepEvent	  * No
X
X* ------------ Is any qualifierkey also pressed ?
X	       MOVE.W	 #QUALIFIERS,D0
X	       AND.W	 ie_Qualifier(A4),D0
X	       BNE.B	 KeepEvent	  * Yes
X
X* ------------ Is any screen active ?
X	       MOVEA.L	 _IntuitionBase,A1
X	       MOVEA.L	 ib_ActiveScreen(A1),A0
X	       MOVE.L	 A0,D0
X	       BEQ.B	 KeepEvent	  * No
X
X* ------------ Is the mouse in the titlebar ?
X	       MOVE.B	 sc_BarHeight(A0),D0
X	       EXT.W	 D0
X	       CMP.W	 sc_MouseY(A0),D0
X	       BGT.B	 KeepEvent	  * Yes
X
X* ------------ Is any window active ?
X	       MOVEA.L	 ib_ActiveWindow(A1),A0
X	       MOVE.L	 A0,D0
X	       BEQ.B	 KeepEvent	  * No
X
X* ------------ Is any requester blocking the window ?
X	       TST.W	 wd_ReqCount(A0)
X	       BNE.B	 KeepEvent	  * Yes
X
X* ------------ Does the window have menues ?
X	       TST.L	 wd_MenuStrip(A0)
X	       BEQ.B	 KeepEvent	  * No
X
X* ------------ Is the RMBTRAP flag set ?
X	       MOVEQ.L	 #1,D0
X	       AND.W	 wd_Flags(A0),D0
X	       BNE.B	 KeepEvent	  * Yes
X
X	       MOVEQ.L	 #TRUE,D2
X
X* ------------ Tell task to popup the menues.
X	       MOVE.L	 sd_MenuDownSig(A2),D0
X	       BRA.B	 SigAndRemove
X
X* ------------ Check out if the user has selected something.
XMouseIsDown:   CMPI.W	 #MENUUP,D1	  *Is menubutton released ?
X	       BNE.B	 1$
X
X	       MOVEQ.L	 #FALSE,D2
X	       MOVE.L	 sd_MenuUpSig(A2),D0
X	       BRA.B	 SigAndRemove
X
X* ------------ Multiple select ?
X1$:	       CMPI.W	 #SELECTDOWN,D1
X	       BNE.B	 CheckSelUp
X
X	       MOVE.L	 sd_SelectDownSig(A2),D0
X
XSigAndRemove:  MOVEA.L	 (A2),A1          *sd_PopUpMenuTask(A2)
X	       JSR	 _LVOSignal(A6)
X	       BRA.B	 RemoveEvent
X
X* ------------ SELECTUP isn't used but remove the event anyway.
XCheckSelUp:    CMPI.W	 #SELECTUP,D1
X	       BNE.B	 KeepEvent
X
X* ------------ Remove the event from the list.
XRemoveEvent:   MOVE.L	 A5,D0		  * First event in list ?
X	       BNE.B	 1$		  * No
X	       MOVEA.L	 (A4),A3          *ie_NextEvent(A4)
X	       BRA.B	 NextEvent
X1$:	       MOVE.L	 (A4),(A5)        *ie_NextEvent(A4),ie_NextEvent(A5)
X	       BRA.B	 NextEvent
X
X* ------------ Keep this message.
XKeepEvent:     MOVE.L	 A4,A5
X
X* ------------ Check out the next event.
XNextEvent:     MOVE.L	 (A4),A4          *ie_NextEvent(A4)
X	       BRA.W	 MoreEvents
X
XDone	       MOVE.W	 D2,sd_Down(A2)
X	       MOVE.L	 A3,D0
X
X	       MOVEM.L	 (A7)+,D2/A2-A6
X	       RTS
X
X	       END
X
END_OF_FILE
if test 3865 -ne `wc -c <'Source/InputHandler.a'`; then
    echo shar: \"'Source/InputHandler.a'\" unpacked with wrong size!
fi
# end of 'Source/InputHandler.a'
fi
if test -f 'Source/InputHandler.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/InputHandler.c'\"
else
echo shar: Extracting \"'Source/InputHandler.c'\" \(2633 characters\)
sed "s/^X//" >'Source/InputHandler.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X#define QUALIFIERS (IEQUALIFIER_LSHIFT   | IEQUALIFIER_RSHIFT    | \
X		    IEQUALIFIER_CONTROL  | IEQUALIFIER_LALT	 | \
X		    IEQUALIFIER_RALT	 | IEQUALIFIER_LCOMMAND  | \
X		    IEQUALIFIER_RCOMMAND | IEQUALIFIER_MIDBUTTON | \
X		    IEQUALIFIER_LEFTBUTTON)
XIMPORT struct IntuitionBase *IntuitionBase;
X
X/*++++++++++++++++++++++++++++++++++++++++++++++++
X+  MyHandler(Events, MySignals)
X+    Look for MenuDown & MenuUp events and signal our task
X+
X+  INPUTS
X+    Events    - List of events (from input.device)
X+    MySignals - PopUpMenuTask & MenuUp, MenuDown Signals
X+
X+  OUTPUT
X+    Eventlist without MenuDown messgaes
X+++++++++++++++++++++++++++++++++++++++++++++++++++*/
Xstruct InputEvent *PopUpHandler(Events, MySignals)
X  struct InputEvent *Events;
X  struct SignalData *MySignals;
X{
X
X  struct InputEvent *Event;
X  struct InputEvent *LastEvent;
X
X  if (MySignals->Down)
X    /* tell the task we are living */
X    Signal(MySignals->PopUpMenuTask, MySignals->MouseMovedSig);
X
X  for (Event = Events, LastEvent = NULL; Event != NULL; Event = Event->ie_NextEvent) {
X    if (Event->ie_Class == IECLASS_RAWMOUSE) {
X      if (NOT(MySignals->Down)) {
X	union {
X	  struct Window *ActiveWindow;
X	  struct Screen *ActiveScreen;
X	} Temp;
X	/* Do not signal my task if
X	   1) Any qualifierkey is pressed.
X	   2) Mouse in menubar
X	   3) No window is active.
X	   4) A requester is blocking the window.
X	   5) Window has no menues
X	   6) Window has RMBTRAP set */
X
X	if ((Event->ie_Code == MENUDOWN) AND
X	    !(Event->ie_Qualifier & QUALIFIERS) AND
X	    (Temp.ActiveScreen = IntuitionBase->ActiveScreen) AND
X	    (Temp.ActiveScreen->MouseY >= Temp.ActiveScreen->BarHeight) AND
X	    (Temp.ActiveWindow = IntuitionBase->ActiveWindow) AND
X	    (Temp.ActiveWindow->ReqCount == 0) AND
X	    (Temp.ActiveWindow->MenuStrip) AND
X	    !(Temp.ActiveWindow->Flags & RMBTRAP)) {
X	  Signal (MySignals->PopUpMenuTask, MySignals->MenuDownSig);
X	  MySignals->Down = TRUE;
X	}
X	else
X	  goto GetOutOfHere;  /* oops! */
X      } /* if NOT Down */
X      else  /* Down */
X	switch (Event->ie_Code) {
X	  case SELECTDOWN:
X	    Signal(MySignals->PopUpMenuTask, MySignals->SelectDownSig);
X	  case SELECTUP:
X	    break;
X	  case MENUUP:
X	    Signal (MySignals->PopUpMenuTask, MySignals->MenuUpSig);
X	    MySignals->Down = FALSE;
X	    break;
X	  default:
X	    goto GetOutOfHere;	/* oops! */
X	} /* case */
X      /* Take event from chain */
X      if (LastEvent == NULL)
X	Events = Event->ie_NextEvent;
X      else
X	LastEvent->ie_NextEvent = Event->ie_NextEvent;
X      continue;
X    } /* if RAWMOUSE */
X
XGetOutOfHere:
X    LastEvent = Event;
X  }
X  return(Events);
X}
X
END_OF_FILE
if test 2633 -ne `wc -c <'Source/InputHandler.c'`; then
    echo shar: \"'Source/InputHandler.c'\" unpacked with wrong size!
fi
# end of 'Source/InputHandler.c'
fi
if test -f 'Source/MakeFile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/MakeFile'\"
else
echo shar: Extracting \"'Source/MakeFile'\" \(3060 characters\)
sed "s/^X//" >'Source/MakeFile' <<'END_OF_FILE'
XCINCLUDES  = INCLUDE:all.sym
XASMINCLUDE = Asm/Include/
XOBJ = obj/
X
XLC1FLAGS  =  -. -fl -b1 -r1r -crs -w -oQUAD: -h$(CINCLUDES)
XLC2FLAGS  =  -. -v -o$(OBJ)
XASMFLAGS  =  -i$(ASMINCLUDE) -o$(OBJ)
X
XPopUpMenu: $(OBJ)AltStartUp.o $(OBJ)StartUp.o $(OBJ)Main.o $(OBJ)MyFunctions.o
XPopUpMenu: $(OBJ)InputHandler.o $(OBJ)PopUpMenu.o $(OBJ)OpenWindows.o
XPopUpMenu: $(OBJ)Select.o $(OBJ)HighLight.o $(OBJ)MySwapBits.o $(OBJ)Convert.o
XPopUpMenu: $(OBJ)PortStuff.o $(OBJ)Globals.o $(OBJ)SendMessage.o
XPopUpMenu: $(OBJ)CheckItemSize.o
X  @Echo "Linking PopUpMenu"
X  @BLINK FROM \
X	  $(OBJ)StartUp.o $(OBJ)Main.o $(OBJ)MyFunctions.o $(OBJ)InputHandler.o \
X	  $(OBJ)PopUpMenu.o $(OBJ)OpenWindows.o $(OBJ)Select.o $(OBJ)SendMessage.o \
X	  $(OBJ)HighLight.o $(OBJ)Convert.o $(OBJ)PortStuff.o $(OBJ)MySwapBits.o \
X	  $(OBJ)CheckItemSize.o $(OBJ)Globals.o \
X	TO \
X	  PopUpMenu \
X	MAP \
X	  PopUpMenu.Map h,x,s,o \
X	NODEBUG
X  @Echo "Linking PopUpMenu.run"
X  @BLINK FROM \
X	  $(OBJ)AltStartUp.o $(OBJ)Main.o $(OBJ)MyFunctions.o $(OBJ)InputHandler.o \
X	  $(OBJ)PopUpMenu.o $(OBJ)OpenWindows.o $(OBJ)Select.o $(OBJ)SendMessage.o \
X	  $(OBJ)HighLight.o $(OBJ)Convert.o $(OBJ)PortStuff.o $(OBJ)MySwapBits.o\
X	  $(OBJ)CheckItemSize.o $(OBJ)Globals.o \
X	TO \
X	  PopUpMenu.run \
X	MAP \
X	  PopUpMenu.run.Map h,x,s,o \
X	NODEBUG
X
X$(OBJ)StartUp.o: StartUp.a
X   @Echo "Assembling StartUp"
X   @Asm $(ASMFLAGS) StartUp.a
X
X$(OBJ)AltStartUp.o: AltStartUp.a
X   @Echo "Assembling AltStartUp"
X   @Asm $(ASMFLAGS) AltStartUp.a
X
X$(OBJ)Main.o: Main.c Version.h
X   @Echo "Compiling Main"
X   @LC1 -d -j121 $(LC1FLAGS) Main.c
X   @LC2 $(LC2FLAGS) QUAD:Main.q
X
X$(OBJ)SendMessage.o: SendMessage.c
X   @Echo "Compiling SendMessage"
X   @LC1 -d $(LC1FLAGS) SendMessage.c
X   @LC2 $(LC2FLAGS) QUAD:SendMessage.q
X
X$(OBJ)MySwapBits.o: MySwapBits.a
X   @Echo "Assembling MySwapBits"
X   @Asm $(ASMFLAGS) MySwapBits.a
X
X$(OBJ)InputHandler.o: InputHandler.a
X   @Echo "Assembling InputHandler"
X   @Asm $(ASMFLAGS) InputHandler.a
X
X$(OBJ)PopUpMenu.o: PopUpMenu.c
X   @Echo "Compiling PopUpMenu"
X   @LC1 -d $(LC1FLAGS) PopUpMenu.c
X   @LC2 $(LC2FLAGS) QUAD:PopUpMenu.q
X
X$(OBJ)OpenWindows.o: OpenWindows.c
X   @Echo "Compiling OpenWindows"
X   @LC1 -d $(LC1FLAGS) OpenWindows.c
X   @LC2 $(LC2FLAGS) QUAD:OpenWindows.q
X
X$(OBJ)Select.o: Select.c
X   @Echo "Compiling Select"
X   @LC1 -d $(LC1FLAGS) Select.c
X   @LC2 $(LC2FLAGS) QUAD:Select.q
X
X$(OBJ)HighLight.o: HighLight.a
X   @Echo "Assembling HighLight"
X   @Asm $(ASMFLAGS) HighLight.a
X
X$(OBJ)Convert.o: Convert.c
X   @Echo "Compiling Convert"
X   @LC1 -d $(LC1FLAGS) Convert.c
X   @LC2 $(LC2FLAGS) QUAD:Convert.q
X
X$(OBJ)PortStuff.o: PortStuff.c
X   @Echo "Compiling PortStuff"
X   @LC1 -d $(LC1FLAGS) PortStuff.c
X   @LC2 $(LC2FLAGS) QUAD:PortStuff.q
X
X$(OBJ)CheckItemSize.o: CheckItemSize.a
X   @Echo "Assembling CheckItemSize"
X   @Asm $(ASMFLAGS) CheckItemSize.a
X
X$(OBJ)Globals.o: Globals.c
X   @Echo "Compiling Globals"
X   @LC1 -d $(LC1FLAGS) Globals.c
X   @LC2 $(LC2FLAGS) QUAD:Globals.q
X
X$(OBJ)MyFunctions.o: MyFunctions.a
X   @Echo "Assembling MyFunctions"
X   @Asm $(ASMFLAGS) MyFunctions.a
X
X
END_OF_FILE
if test 3060 -ne `wc -c <'Source/MakeFile'`; then
    echo shar: \"'Source/MakeFile'\" unpacked with wrong size!
fi
# end of 'Source/MakeFile'
fi
if test -f 'Source/MyFunctions.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/MyFunctions.a'\"
else
echo shar: Extracting \"'Source/MyFunctions.a'\" \(1436 characters\)
sed "s/^X//" >'Source/MyFunctions.a' <<'END_OF_FILE'
X	       xdef	  @MySetMenuStrip
X	       xdef	  @MyClearMenuStrip
X	       xdef	  @MyOnMenu
X	       xdef	  @MyOffMenu
X	       xdef	  @Mystrlen
X
X	       xref	  _OldSetMenuStrip
X	       xref	  _OldClearMenuStrip
X	       xref	  _OldOffMenu
X	       xref	  _OldOnMenu
X	       xref	  _PopUpSemaphore
X
X_LVOObtainSemaphore  EQU  -$0234
X_LVOReleaseSemaphore EQU  -$023a
XAbsExecBase    EQU	  4
X
X	       section	  text,code
X
X@MySetMenuStrip:
X	       MOVEM.L	  A2/A6,-(SP)
X	       MOVEA.L	  _OldSetMenuStrip,A2
X	       BRA.B	  CallOldFunction
X
X@MyClearMenuStrip:
X	       MOVEM.L	  A2/A6,-(SP)
X	       MOVEA.L	  _OldClearMenuStrip,A2
X	       BRA.B	  CallOldFunction
X
X@MyOnMenu:     MOVEM.L	  A2/A6,-(SP)
X	       MOVEA.L	  _OldOnMenu,A2
X	       BRA.B	  CallOldFunction
X
X@MyOffMenu:    MOVEM.L	  A2/A6,-(SP)
X	       MOVEA.L	  _OldOffMenu,A2
X
X* ------------ Obtain semaphore and then call the intuition function.
XCallOldFunction:
X	       MOVEM.L	  D0/A0-A1/A6,-(SP)
X	       LEA	  _PopUpSemaphore,A0
X	       MOVE.L	  AbsExecBase.W,A6
X	       JSR	  _LVOObtainSemaphore(A6)
X	       MOVEM.L	  (SP)+,D0/A0-A1/A6
X	       JSR	  (A2)
X	       LEA	  _PopUpSemaphore,A0
X	       MOVE.L	  AbsExecBase.W,A6
X	       JSR	  _LVOReleaseSemaphore(A6)
X	       MOVEM.L	  (SP)+,A2/A6
X	       RTS
X
X* ------------ This is the shortest strlen (I think).
X@Mystrlen:     MOVEQ.L	  #-1,D0
X1$:	       ADDQ.L	  #1,D0
X	       TST.B	  (A0)+
X	       BNE.B	  1$
X	       RTS
X
X	       END
X
X
END_OF_FILE
if test 1436 -ne `wc -c <'Source/MyFunctions.a'`; then
    echo shar: \"'Source/MyFunctions.a'\" unpacked with wrong size!
fi
# end of 'Source/MyFunctions.a'
fi
if test -f 'Source/MySwapBits.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/MySwapBits.a'\"
else
echo shar: Extracting \"'Source/MySwapBits.a'\" \(2010 characters\)
sed "s/^X//" >'Source/MySwapBits.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "graphics/clip.i"
X	       INCLUDE	  "graphics/rastport.i"
X	       INCLUDE	  "hardware/blit.i"
X	       INCLUDE	  "PopUpMenu.i"
X
X_LVOBltBitMap  EQU	  -$1e
XALLPLANES      EQU	  -1
XB_XOR_C        EQU	  ABNC+ANBC
X
X	       xdef	  @SwapBits
X
X	       section	  text,code
X*****************************************************************************
X* SwapBits(Window) - Works like SwapBitsRastPortClipRect() without bugs :-) *
X*									    *
X*****************************************************************************
X
X* ------------ Check to see that window is open
X@SwapBits:     TST.W	  (A0)
X	       BEQ.S	  NoWindow
X
X	       MOVEM.L	  D2-D7/A2/A6,-(SP)
X
X* ------------ SrcX
X	       MOVEQ.L	  #0,D0
X	       MOVE.W	  wd_LeftEdge(A0),D0
X
X* ------------ SrcY
X	       MOVEQ.L	  #0,D1
X	       MOVE.W	  wd_TopEdge(A0),D1
X
X* ------------ SizeX
X	       MOVEQ.L	  #0,D4
X	       MOVE.W	  wd_Width(A0),D4
X
X* ------------ SizeY
X	       MOVEQ.L	  #0,D5
X	       MOVE.W	  wd_Height(A0),D5
X
X* ------------ MinTerm
X	       MOVEQ.L	  #B_XOR_C,D6
X
X* ------------ Mask
X	       MOVEQ.L	  #ALLPLANES,D7
X
X* ------------ TempA
X	       SUB.L	  A2,A2
X
X	       MOVE.L	  _GfxBase(A4),A6
X
X* ------------ Off-screen bitmap
X	       LEA	  wd_Bm(A0),A1
X
X* ------------ On-screen bitmap
X	       MOVE.L	  _Rp+rp_BitMap(A4),A0
X
X* ------------ DestX
X	       MOVEQ.L	  #0,D2
X* ------------ DestY
X	       MOVEQ.L	  #0,D3
X
X* ------------ OffScreen = OffScreen XOR OnScreen
X	       BSR.S	  Swap
X* ------------ OnScreen = OnScreen XOR OffScreen  (= OffScreen)
X	       BSR.S	  Swap
X* ------------ OffScreen = OffScreen XOR OnScreen  (= OnScreen)
X	       BSR.S	  Swap
X
X	       MOVEM.L	  (SP)+,D2-D7/A2/A6
XNoWindow:      RTS
X
X
XSwap:	       MOVEM.L	  D0/D1/A0/A1,-(SP)
X	       JSR	  _LVOBltBitMap(A6)
X	       MOVEM.L	  (SP)+,D0/D1/A0/A1
X
X	       EXG.L	  A0,A1
X	       EXG.L	  D0,D2
X	       EXG.L	  D1,D3
X
X	       RTS
X
X	       section	  __MERGED,bss
X
X	       xref	  _GfxBase
X	       xref	  _Rp
X
X	       END
X
END_OF_FILE
if test 2010 -ne `wc -c <'Source/MySwapBits.a'`; then
    echo shar: \"'Source/MySwapBits.a'\" unpacked with wrong size!
fi
# end of 'Source/MySwapBits.a'
fi
if test -f 'Source/PopUpMenu.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/PopUpMenu.h'\"
else
echo shar: Extracting \"'Source/PopUpMenu.h'\" \(2954 characters\)
sed "s/^X//" >'Source/PopUpMenu.h' <<'END_OF_FILE'
X#define ABSEXECBASE ((struct ExecBase **)4L)
X
X/* this is for lattice bug with 16-bit ints */
X#undef	RMBTRAP
X#define RMBTRAP 0x00010000L
X
X/* this is for missing limits */
X#define WORD_MIN   SHRT_MIN
X#define WORD_MAX   SHRT_MAX
X#define UWORD_MIN  USHRT_MIN
X#define UWORD_MAX  USHRT_MAX
X
X/* this is for bug in AddSemaphore */
X#undef AddSemaphore
X#define AddSemaphore(SS) InitSemaphore(SS),\
X			 Enqueue(&((*ABSEXECBASE)->SemaphoreList),\
X				 &((SS)->ss_Link))
X
X/* this is a fake intuimessage-class used to quit the popupmenu program */
X#define QUITPOPUPMENU	   0
X
X#define HIGHLIGHTON	   0
X#define HIGHLIGHTOFF	   1
X
X#define BORDERSIZE	   2
X
X#define AND		  &&
X#define OR		  ||
X
X#define ITEMWINDOW 0
X#define SUBWINDOW  SHRT_MAX
X/* used for drawing commandkeys */
X#define LORESSCREEN	  TRUE
X#define HIRESSCREEN	  FALSE
X
X/* used by DrawMenuItem */
X#define SELECTFILL   1
X#define ITEMFILL     0
X#define CLEAROLD     TRUE
X#define DONTCLEAROLD FALSE
X
Xstruct WindowSize {
X  WORD Left, Top, Right, Bottom;
X};
X
Xunion FillTypes {
X  APTR		    APTR;
X  struct IntuiText *IText;
X  struct Image	   *Image;
X};
X
Xstruct WindowData {
X  BOOL	BitMapOk;
X  WORD	LeftEdge, TopEdge;
X  WORD	RightEdge, Bottom;
X  WORD	Width, Height;
X  WORD	TopValue, LeftValue;
X  struct MenuItem *Items;
X  struct BitMap Bm;
X};
X
Xstruct SignalData {
X  struct Task *PopUpMenuTask;
X  LONGBITS MenuUpSig;
X  LONGBITS MenuDownSig;
X  LONGBITS MouseMovedSig;
X  LONGBITS SelectDownSig;
X  BOOL	Down;
X};
X
X/* My functioms */
X
XVOID		   WriteAndClose(STRPTR,ULONG);
XVOID		   PopUpMainLoop(struct SignalData *, struct MsgPort *);
XVOID		   PopUpMenu(struct SignalData *);
XVOID		   QueueTimer(VOID);
XVOID		   InitGlobals(VOID);
XBOOL		   OpenMenuWindow(WORD);
XVOID		   HighLightItem(struct MenuItem *, struct WindowData *, UWORD);
XVOID		   HighLightCurrItemBehind(UWORD);
Xstruct MenuItem   *FindMouseItem(struct WindowData *);
XVOID		   SelectItem(VOID);
XVOID		   OpenItemWindow(struct WindowData *, struct WindowData *, WORD, UWORD);
XVOID		   CheckItemSize(struct WindowSize *,struct MenuItem *,LONG);
XVOID		   CloseItemWindow(struct WindowData *);
XVOID		   ToggleMenu(UWORD,struct Menu *);
XVOID		   DrawAllItems(struct WindowData *);
XVOID		   DrawMenuItem(struct MenuItem *, struct WindowData *, UWORD, BOOL);
Xstruct Menu	  *FindMenuPtr(UWORD);
XWORDBITS	   FinalSelect(VOID);
XVOID		   CheckMark(struct MenuItem *,struct MenuItem *);
XUWORD		   FindItemNr(struct MenuItem *, struct MenuItem *);
XVOID		   TellWindow(WORDBITS);
XBOOL		   BuildBitMap(struct WindowData *);
XVOID		   ClearWindow(struct WindowData *);
XVOID		   RemoveBitMap(struct WindowData *);
XBOOL		   MouseInWindow(struct WindowData *);
XWORD		   SendMessage(struct MsgPort *);
Xstruct IntuiMessage *BuildIntuiMsg(struct MsgPort *, ULONG, UWORD);
Xstruct InputEvent *PopUpHandler(struct InputEvent *,struct SignalData *);
XULONG		   Mystrlen(STRPTR);
XVOID		   SwapBits(struct WindowData *);
X
X#define DeleteStdIO(IOReq) FreeMem((IOReq),sizeof(struct IOStdReq))
X
END_OF_FILE
if test 2954 -ne `wc -c <'Source/PopUpMenu.h'`; then
    echo shar: \"'Source/PopUpMenu.h'\" unpacked with wrong size!
fi
# end of 'Source/PopUpMenu.h'
fi
if test -f 'Source/PopUpMenu.i' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/PopUpMenu.i'\"
else
echo shar: Extracting \"'Source/PopUpMenu.i'\" \(746 characters\)
sed "s/^X//" >'Source/PopUpMenu.i' <<'END_OF_FILE'
X	       STRUCTURE  WindowData,0
X	       BOOL	  wd_BitMapOk
X	       WORD	  wd_LeftEdge
X	       WORD	  wd_TopEdge
X	       WORD	  wd_RightEdge
X	       WORD	  wd_Bottom
X	       WORD	  wd_Width
X	       WORD	  wd_Height
X	       WORD	  wd_TopValue
X	       WORD	  wd_LeftValue
X	       APTR	  wd_Items
X	       STRUCT	  wd_Bm,bm_SIZEOF
X	       LABEL	  wd_SIZEOF
X
X	       STRUCTURE  WindowSize,0
X	       WORD	  ws_Left
X	       WORD	  ws_Top
X	       WORD	  ws_Right
X	       WORD	  ws_Bottom
X	       LABEL	  ws_SIZEOF
X
X	       STRUCTURE  SignalData,0
X	       APTR	  sd_PopUpMenuTask
X	       ULONG	  sd_MenuUpSig
X	       ULONG	  sd_MenuDownSig
X	       ULONG	  sd_MouseMovedSig
X	       ULONG	  sd_SelectDownSig
X	       BOOL	  sd_Down
X	       LABEL	  sd_SIZEOF
X
END_OF_FILE
if test 746 -ne `wc -c <'Source/PopUpMenu.i'`; then
    echo shar: \"'Source/PopUpMenu.i'\" unpacked with wrong size!
fi
# end of 'Source/PopUpMenu.i'
fi
if test -f 'Source/PortStuff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/PortStuff.c'\"
else
echo shar: Extracting \"'Source/PortStuff.c'\" \(952 characters\)
sed "s/^X//" >'Source/PortStuff.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X/*+++++++++++++++++++++++++++++++++++++++++++++
X+  CreatePort(Name, Pri)
X+  DeletePort(Port)
X+
X+     Replacements for amiga.lib
X+++++++++++++++++++++++++++++++++++++++++++++++*/
Xstruct MsgPort *CreatePort(Name, Pri)
X  char	*Name;
X  LONG	Pri;
X{
X  UBYTE  SigBit;
X
X  if ((SigBit = AllocSignal(-1)) != -1) {
X    struct MsgPort  *const Port = AllocMem(sizeof(struct MsgPort),
X					   MEMF_CLEAR | MEMF_PUBLIC);
X    if (Port) {
X      Port->mp_Node.ln_Name = Name;
X      Port->mp_Node.ln_Pri  = Pri;
X      Port->mp_Node.ln_Type = NT_MSGPORT;
X      Port->mp_Flags	    = PA_SIGNAL;
X      Port->mp_SigBit	    = SigBit;
X      Port->mp_SigTask	    = (struct Task *)FindTask(0);
X
X      AddPort(Port);
X      return(Port);
X    }
X    else
X      FreeSignal((LONG)SigBit);
X  }
X  return(NULL);
X}
X
XVOID DeletePort(Port)
X  struct MsgPort *const Port;
X{
X  RemPort(Port);
X  FreeSignal((LONG)Port->mp_SigBit);
X  FreeMem(Port,sizeof(struct MsgPort));
X}
END_OF_FILE
if test 952 -ne `wc -c <'Source/PortStuff.c'`; then
    echo shar: \"'Source/PortStuff.c'\" unpacked with wrong size!
fi
# end of 'Source/PortStuff.c'
fi
if test -f 'Source/SendMessage.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/SendMessage.c'\"
else
echo shar: Extracting \"'Source/SendMessage.c'\" \(1967 characters\)
sed "s/^X//" >'Source/SendMessage.c' <<'END_OF_FILE'
X#include "PopUpMenu.h"
X
X/*******************************************************
X * SendMessage(ReplyPort) - Send MENUVERIFY message    *
X *  to all windows on screen with MENUVERIFY flag set. *
X * Input:					       *
X *   ReplyPort - PopUpMenu replyport.		       *
X * Output:					       *
X *   return    - Messages sent. 		       *
X *******************************************************/
XSHORT SendMessage(ReplyPort)
X  struct MsgPort  *const ReplyPort;
X{
X  IMPORT struct Window	*const ActiveWindow;
X
X  struct Window  *Window;
X  WORD	 NrOfMessages = 0;
X
X  Forbid(); /* To be sure that the windowlist doesn't change */
X
X  Window = ActiveWindow->WScreen->FirstWindow;
X  do {
X    if (Window->IDCMPFlags & MENUVERIFY) {
X      struct IntuiMessage *const Message =
X			  BuildIntuiMsg(ReplyPort, MENUVERIFY,
X			     (Window == ActiveWindow) ? MENUHOT : MENUWAITING);
X      if (Message) {
X	CurrentTime(&Message->Seconds,&Message->Micros);
X	Message->IDCMPWindow = Window;
X
X	PutMsg(Window->UserPort,(struct Message *)Message);
X	NrOfMessages++;
X      }
X    }
X  }
X  while (Window = Window->NextWindow);
X
X  Permit();
X
X  return (NrOfMessages);
X}
X
X/***************************************
X * BuildIntuiMsg(ReplyMsg,Class,Code)  *
X *				       *
X * Input:			       *
X *   ReplyPort			       *
X *   Class			       *
X *   Code			       *
X * Output:			       *
X *   return    -  IntuiMessage	       *
X ***************************************/
Xstruct IntuiMessage *BuildIntuiMsg(ReplyPort,Class,Code)
X  struct MsgPort  *const ReplyPort;
X  ULONG   Class;
X  UWORD   Code;
X{
X  struct IntuiMessage *const Message =
X		AllocMem(sizeof(struct IntuiMessage),MEMF_PUBLIC | MEMF_CLEAR);
X
X  if (Message) {
X    Message->ExecMessage.mn_Node.ln_Type = NT_MESSAGE;
X    Message->ExecMessage.mn_ReplyPort	 = ReplyPort;
X    Message->ExecMessage.mn_Length	 = sizeof(struct IntuiMessage) -
X					   sizeof(struct Message);
X    Message->Class = Class;
X    Message->Code  = Code;
X  }
X  return (Message);
X}
X
X
END_OF_FILE
if test 1967 -ne `wc -c <'Source/SendMessage.c'`; then
    echo shar: \"'Source/SendMessage.c'\" unpacked with wrong size!
fi
# end of 'Source/SendMessage.c'
fi
if test -f 'Source/Source.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Source.doc'\"
else
echo shar: Extracting \"'Source/Source.doc'\" \(747 characters\)
sed "s/^X//" >'Source/Source.doc' <<'END_OF_FILE'
XComments to the source:
X  * I am using a pre-compiled headerfile including all the amiga includefiles.
X     This means that the .c files don't have any includes.
X
X  * Lattice C 5.0 is used. Lattice 5.02 makes the program ~300 bytes bigger.
X
X  * No optimizing is used (program gets bigger ??? (both 5.0 & 5.02))
X
X  * All my function prototypes and structures is in PopUpMenu.h
X
X  * All global variable declarations is made in Globals.c
X
X  * There are comments in the source.
X
X  * I have rewritten part of the code in assembler. Both versions included.
X
X  * I'm not good at assembler.
X
X  * Tags file included for dme users.
X
X  * Makefile for lattice Lmk included. (must be modified to fit your system)
X      Uses Lc1 & Lc2 to save memory.
X
XMartin.
X
END_OF_FILE
if test 747 -ne `wc -c <'Source/Source.doc'`; then
    echo shar: \"'Source/Source.doc'\" unpacked with wrong size!
fi
# end of 'Source/Source.doc'
fi
if test -f 'Source/Startup.a' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Startup.a'\"
else
echo shar: Extracting \"'Source/Startup.a'\" \(3107 characters\)
sed "s/^X//" >'Source/Startup.a' <<'END_OF_FILE'
X	       INCLUDE	  "exec/types.i"
X	       INCLUDE	  "libraries/dos.i"
X	       INCLUDE	  "libraries/dosextens.i"
X	       INCLUDE	  "exec/execbase.i"
X	       INCLUDE	  "exec/funcdef.i"
X	       INCLUDE	  "exec/exec_lib.i"
X	       INCLUDE	  "libraries/dos_lib.i"
X
XAbsExecBase    EQU	  4
XPOPUPPRI       EQU	  5
XPOPUPSTACK     EQU	  2000
X* Must use Kickstart 1.2 or higher
XLIBVERSION     EQU	  33
X
X	       xref	  _LinkerDB
X	       xref	  @InitPopUpMenu
X	       xref	  _PopUpTaskName
X
X	       section	  Startup,code
X
XStartup        MOVEM.L	  D2-D4/A2-A4/A6,-(A7)
X	       LEA	  _LinkerDB,A4
X
X* ------------ Open dos.
X	       LEA	  DosName(PC),A1
X	       MOVEQ.L	  #LIBVERSION,D0
X	       MOVEA.L	  AbsExecBase.W,A6
X	       JSR	  _LVOOpenLibrary(A6)
X	       MOVE.L	  D0,_DOSBase(A4)
X
X	       TST.L	  D0
X	       BEQ.W	  NoDos
X
X* ------------ Get pointer to our Process.
X	       MOVEA.L	  ThisTask(A6),A3
X
X* ------------ Run from Workbench ?
X	       TST.L	  pr_CLI(A3)
X	       BEQ.B	  FromWorkbench
X
X* ------------ Get address to this segment.
X	       LEA	  Startup-4(PC),A2
X
X* ------------ Get address to PopUpMenu code segment.
X	       MOVE.L	  #@InitPopUpMenu-4,D3
X
X* ------------ Convert to BCPL.
X	       ASR.L	  #2,D3
X
X* ------------ Find current output window.
X	       MOVE.L	  #CurrWindow,D1
X	       MOVE.L	  #MODE_OLDFILE,D2
X	       MOVEA.L	  _DOSBase(A4),A6
X	       JSR	  _LVOOpen(A6)
X	       MOVE.L	  D0,_StdOut(A4)
X
X	       TST.L	  D0
X	       BEQ.B	  NoStdOut
X
X* ------------ Save start of segments.
X	       MOVE.L	  (A2),_PopUpSeg(A4)
X
X* ------------ Remove this segment.
X	       CLR.L	  (A2)
X
X* ------------ Create PopUpMenu process.
X	       MOVE.L	  _PopUpTaskName,D1
X	       MOVEQ	  #POPUPPRI,D2
X	       MOVE.L	  #POPUPSTACK,D4
X	       JSR	  _LVOCreateProc(A6)
X	       BRA.B	  Done
X
X* ------------ Wait for Workbench startup-message.
XFromWorkbench  LEA	  pr_MsgPort(A3),A0
X	       JSR	  _LVOWaitPort(A6)
X	       LEA	  pr_MsgPort(A3),A0
X	       JSR	  _LVOGetMsg(A6)
X	       MOVE.L	  D0,D3
X
X* ------------ Open window on Workbench screen.
X	       MOVE.L	  #WbWindow,D1
X	       MOVE.L	  #MODE_NEWFILE,D2
X	       MOVEA.L	  _DOSBase(A4),A6
X	       JSR	  _LVOOpen(A6)
X	       MOVE.L	  D0,_StdOut(A4)
X
X	       MOVEA.L	  AbsExecBase.W,A6
X	       TST.L	  D0
X	       BEQ.B	  NoWbStdOut
X
X* ------------ No need to unload segments (Workbench takes care of that).
X	       CLR.L	  _PopUpSeg(A4)
X
X* ------------ Set task priority.
X	       MOVEA.L	  A3,A1
X	       MOVEQ	  #POPUPPRI,D0
X	       JSR	  _LVOSetTaskPri(A6)
X
X* ------------ Start PopUpMenu-program.
X	       JSR	  @InitPopUpMenu
X
X* ------------ Forbid so Workbench can't unload us before we are done.
XNoWbStdOut     JSR	  _LVOForbid(A6)
X	       MOVEA.L	  D3,A1
X	       JSR	  _LVOReplyMsg(A6)
XDone
XNoStdOut
XNoDos	       MOVEQ	  #00,D0
X	       MOVEM.L	  (A7)+,D2-D4/A2-A4/A6
X	       RTS
X* Put these data in our code-segment.
XCurrWindow     dc.b	  '*',0
XDosName        dc.b	  'dos.library',0
XWbWindow       dc.b	  'CON:100/75/400/45/PopUpMenu',0
X
X	       section	  __MERGED,bss
X
X	       xref	  _DOSBase
X	       xref	  _StdOut
X	       xref	  _PopUpSeg
X
X	       END
X
END_OF_FILE
if test 3107 -ne `wc -c <'Source/Startup.a'`; then
    echo shar: \"'Source/Startup.a'\" unpacked with wrong size!
fi
# end of 'Source/Startup.a'
fi
if test -f 'Source/Tags' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Tags'\"
else
echo shar: Extracting \"'Source/Tags'\" \(1636 characters\)
sed "s/^X//" >'Source/Tags' <<'END_OF_FILE'
XInitPopUpMenu		Main.c		/^VOID InitPopUpMenu(
XWriteAndClose		Main.c		/^VOID WriteAndClose(
XPopUpMainLoop		Main.c		/^VOID PopUpMainLoop(
XPopUpMenu		PopUpMenu.c	/^VOID PopUpMenu(
XQueueTimer		PopUpMenu.c	/^VOID QueueTimer(
XInitGlobals		PopUpMenu.c	/^VOID InitGlobals(
XOpenMenuWindow		OpenWindows.c	/^BOOL OpenMenuWindow(
XHighLightItem		HighLight.a	/^@HighLightItem:
XHighLightCurrItemBehind Select.c	/^VOID HighLightCurrItemBehind(
XFindMouseItem		Select.c	/^struct MenuItem *FindMouseItem(
XSelectItem		Select.c	/^VOID SelectItem(
XOpenItemWindow		OpenWindows.c	/^VOID OpenItemWindow(
XCloseItemWindow 	OpenWindows.c	/^VOID CloseItemWindow(
XToggleMenu		HighLight.a	/^@ToggleMenu:
XDrawAllItems		OpenWindows.c	/^VOID DrawAllItems(
XDrawMenuItem		OpenWindows.c	/^VOID DrawMenuItem(
XFindMenuPtr		Convert.c	/^struct Menu *FindMenuPtr(
XFinalSelect		Convert.c	/^LONG FinalSelect(
XCheckMark		Convert.c	/^VOID CheckMark(
XFindItemNr		Convert.c	/^UWORD FindItemNr(
XTellWindow		PopUpMenu.c	/^VOID TellWindow(
XBuildBitMap		OpenWindows.c	/^BOOL BuildBitMap(
XClearWindow		OpenWindows.c	/^VOID ClearWindow(
XRemoveBitMap		OpenWindows.c	/^VOID RemoveBitMap(
XMouseInWindow		Select.c	/^BOOL MouseInWindow(
XSendMessage		SendMessage.c	/^WORD SendMessage(
XBuildIntuiMsg		SendMessage.c	/^struct IntuiMessage *BuildIntuiMsg(
XPopUpHandler		InputHandler.a	/^@PopUpHandler:
XMystrlen		MyFunctions.a	/^@Mystrlen:
XMySetMenuStrip		MyFunctions.a	/^@MySetMenuStrip:
XMyClearMenuStrip	MyFunctions.a	/^@MyClearMenuStrip:
XMyOnMenu		MyFunctions.a	/^@MyOnMenu
XMyOffMenu		MyFunctions.a	/^@MyOffMenu
XCheckItemSize		CheckItemSize.a /^@CheckItemSize:
XSwapBits		MySwapBits.a	/^@SwapBits:
X
X
END_OF_FILE
if test 1636 -ne `wc -c <'Source/Tags'`; then
    echo shar: \"'Source/Tags'\" unpacked with wrong size!
fi
# end of 'Source/Tags'
fi
if test -f 'Source/Version.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Source/Version.h'\"
else
echo shar: Extracting \"'Source/Version.h'\" \(35 characters\)
sed "s/^X//" >'Source/Version.h' <<'END_OF_FILE'
X#define VERSION        "Ver 3.2 "
X
END_OF_FILE
if test 35 -ne `wc -c <'Source/Version.h'`; then
    echo shar: \"'Source/Version.h'\" unpacked with wrong size!
fi
# end of 'Source/Version.h'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.