;   System constants
AbsExecBase	    equ     4
TRUE		    equ     1
FALSE		    equ     0
WORD_MAX	    equ     $7fff
WORD_MIN	    equ     $8000
NULL		    equ     0

;   We need kickstart 2.04 (Not sure if V36 is OK)
KICK204 	    equ     37

;   Macros to call functions
;   Call a library function (Library base in A6)
libcall 	    macro
		    jsr     _LVO\1(A6)
		    endm

;   Call a standard C function
call		    macro
		    bsr     @\1
		    endm

MAXREMEMBER	    equ     10	; Remember last 10 selected menus
DEFAULT_TIMEOUT     equ     50	; == 1s
INPUT_DEVICE_WAIT   equ     12	; ~0,25 s
;   Don't know if this exists as a system constant
HOTKEYBUFLENGTH     equ     40

;   Qualifiers that may be used to cancel PopUpMenu
QUALIFIERS	    set     IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT!IEQUALIFIER_CONTROL
QUALIFIERS	    set     QUALIFIERS!IEQUALIFIER_LALT!IEQUALIFIER_RALT
QUALIFIERS	    set     QUALIFIERS!IEQUALIFIER_LCOMMAND!IEQUALIFIER_RCOMMAND


;   My versions of the flag bits
;   Name_B*   (* = no of bytes into flag field)
;   ex. bset WFLG_MENUSTATE_B2,wd_Flags+2(A?)

WFLG_MENUSTATE_B2   equ     7
WFLG_RMBTRAP_B1     equ     0
IDCMP_REFRESHWINDOW_B3 equ  2
IDCMP_GADGETUP_B3   equ     6
IDCMP_CLOSEWINDOW_B2 equ    1
IDCMP_VANILLAKEY_B1 equ     5
IDCMP_MENUVERIFY_B2 equ     5
IDCMP_DELTAMOVE_B1  equ     4

MENUTOGGLED_B0	    equ     6
ISDRAWN_B0	    equ     4
HIGHITEM_B0	    equ     5
MENUTOGGLE_B1	    equ     3
MENUENABLED_B1	    equ     0
MIDRAWN_B0	    equ     0
ITEMENABLED_B1	    equ     4
CHECKIT_B1	    equ     0
CHECKED_B0	    equ     0
V_HIRES_B0	    equ     7

;    Our options
CLICKMENUS	    equ     %00000001
SHOWSINGLEMENU	    equ     %00000010
ITEMSCENTERED	    equ     %00000100
POPUPWITHQUAL	    equ     %00001000
POPUPNOQUAL	    equ     %00010000
OPENOPTWINDOW	    equ     %00100000

CLICKMENUS_B0	    equ     0
SHOWSINGLEMENU_B0   equ     1
ITEMSCENTERED_B0    equ     2
POPUPWITHQUAL_B0    equ     3
POPUPNOQUAL_B0	    equ     4
OPENOPTWINDOW_B0    equ     5

;   Handler flags
MENUS_ON_B	    equ     0
M_DOWN_B	    equ     1
S_DOWN_B	    equ     2
CLICKON_B	    equ     3
NO_POPUP_B	    equ     4


;   Data about the "Windows" used to display menus,items & subitems.

		STRUCTURE   WindowData,0
		BOOL	    wwd_BitMapOk	   ; TRUE => window has bitmap
		BOOL	    wwd_ItemsEnabled	   ; >0 if items are enabled
		WORD	    wwd_LeftEdge	   ; On screen position
		WORD	    wwd_TopEdge
		WORD	    wwd_RightEdge
		WORD	    wwd_Bottom
		WORD	    wwd_Width		   ; Size of window
		WORD	    wwd_Height
		WORD	    wwd_TopValue	   ; Values to add to items position
		WORD	    wwd_LeftValue	   ; to create screen coordinates
		WORD	    wwd_CommKeySize	   ; Largest CommKey in this window
		APTR	    wwd_Items		   ; List of items
		APTR	    wwd_Current 	   ; Currently selected item
		STRUCT	    wwd_Bm,bm_SIZEOF	   ; Offscreen bitmap
		LABEL	    wwd_SIZEOF

;   This structure is used to calculate the size of a window.
		STRUCTURE   WindowSize,0
		WORD	    wws_Left
		WORD	    wws_Top
		WORD	    wws_Right
		WORD	    wws_Bottom
		WORD	    wws_CommKey
		LABEL	    wws_SIZEOF

;   Used to remember selections between menu operations.
;   Notice that it is the menus (not the window) that is saved
		STRUCTURE   LastMenus,0
		APTR	    llm_Menus	    ; the menus
		WORD	    llm_Num	    ; last selected menu
		LABEL	    llm_SIZEOF

;   Used to keep data about allocated signals.
		STRUCTURE   Signal,0
		UWORD	    ssi_Num
		ULONG	    ssi_Mask
		LABEL	    ssi_SIZEOF

;   Data passed to our custom commodity handler.
		STRUCTURE   SignalData,0
		APTR	    ssd_PopUpMenuTask	; Where signals will go
		UBYTE	    ssd_Flags		; internal to the handler
		UBYTE	    ssd_Options 	; Global options
		UWORD	    ssd_EndQualifier	; Qualifiers pressed when signal sent

		LABEL	    ssd_FirstSignal
		STRUCT	    ssd_MenuUpSig,ssi_SIZEOF	 ; Menu button released
		STRUCT	    ssd_MenuDownSig,ssi_SIZEOF	 ; Menu button pressed
		STRUCT	    ssd_SelectUpSig,ssi_SIZEOF	 ; Select button released
		STRUCT	    ssd_SelectDownSig,ssi_SIZEOF ; Select button pressed
		STRUCT	    ssd_MouseMovedSig,ssi_SIZEOF ; Input device is still running

		LABEL	    ssd_LastSignal
		STRUCT	    ssd_NotifySig,ssi_SIZEOF	 ; Not used in our handler
							 ; but is allocated in the same time
		LABEL	    ssd_SIZEOF

NO_OF_SIGNALS	EQU	    (ssd_LastSignal-ssd_FirstSignal)/ssi_SIZEOF+1

;   This is our expanded IntuiMessage that is sent to MENUVERIFY windows
;   ---> We are not increasing the size parameter in the ExecMessage! <---
		STRUCTURE   MyMsg,im_SIZEOF
		ULONG	    mmn_Session
		LABEL	    mmn_SIZEOF

;   All these global data are cleared at startup.
		STRUCTURE   Globals,0
;   Library bases  (Always open)
		APTR	    _ExecBase		; Placed first for speed
		APTR	    _DOSBase
		APTR	    _IntuitionBase
		APTR	    _GfxBase
		APTR	    _LayersBase
		APTR	    _CxBase

;   Data used by the OptWindow routines [only valid when OptWindow open]
		APTR	    _GadToolsBase
		APTR	    _OptWindow
		APTR	    _GadgetList 	; all gadgets in window
		APTR	    _VisualInfo
		STRUCT	    _Gadgets,6*4	; pointers to first six gadgets

;   Following data is cleared before each menu popup
		LABEL	    _ClearStart

;   MenuWindows (cleared)
		STRUCT	    _SubWindow,wwd_SIZEOF
		STRUCT	    _ItemWindow,wwd_SIZEOF
		STRUCT	    _MenuWindow,wwd_SIZEOF

;   Selection data (cleared)
		WORD	    _CurrentMenuNr	; Currently selected menu
		WORD	    _FirstSelected	; First item selected MENUNUMBER
		APTR	    _LastSelected	; Previus selection
		APTR	    _FirstDrag		; First item to dragselect
		WORD	    _LastSelectedNum

;   Some global data for selection (cleared)
		APTR	    _Menus		; Menus we are using
		WORD	    _MenuTextHeight	; Size of the menu strip
		WORD	    _CommKeyWidth	; Default with of command key
		BOOL	    _ScreenType 	; TRUE = HIRES (for Amiga symbol)
		STRUCT	    _Rp,rp_SIZEOF	; Copy of screens rastport
		UBYTE	    _DetailPen		; Pens to use when drawing menus
		UBYTE	    _BlockPen		; from window

		WORD	    _MouseX		; Mouse position
		WORD	    _MouseY

		STRUCT	    _MenuSorted,32*4	; sorted menus array
		STRUCT	    _Size,wws_SIZEOF	; Used to determine size of windows

		LABEL	    _ClearEnd

;   not cleared
		APTR	    _ActiveWindow	; Window and screen to use
		APTR	    _Screen

;   startup data
		APTR	    _WBenchMsg		; Startup message from WorkBench

;   timer device stuff
		APTR	    _TimerReqBlock
		APTR	    _TimerPort
		ULONG	    _TimerSigMask
		APTR	    _ReplyPort

;   broker data
		APTR	    _PopUpBroker	; Our broker
		APTR	    _HotKeyFilterCxObj	; translator object (needed to change hotkey)

		STRUCT	    _HotKeyString,HOTKEYBUFLENGTH+1
		ALIGNWORD

* ------------ Previus menus (array)
		STRUCT	    _LastMenus,(llm_SIZEOF*MAXREMEMBER)

* ------------ Data for the input handler
		STRUCT	    _CxHandlerData,ssd_SIZEOF

* ------------ that's all folks
		LABEL	    Globals_SIZEOF

;  For some reason are all prefs includes missing in version 2.04.
	      IFND	  IControlPrefs
		STRUCTURE   IControlPrefs,0
		STRUCT	    ic_Reserved,4*4
		UWORD	    ic_TimeOut
		WORD	    ic_MetaDrag
		ULONG	    ic_Flags
		UBYTE	    ic_WBtoFront
		UBYTE	    ic_FrontToBack
		UBYTE	    ic_ReqTrue
		UBYTE	    ic_ReqFalse
		LABEL	    ic_SIZEOF
	      ENDC




