% % A HyperNeWS Menu % % NOTE: altough ClassMenuCanvas is a subclass of ClassTrackingCanvas it % does NOT use any of the tracking functionality. It could also be a subclass % of ClassCanvas. % /ClassMenuCanvas ClassTrackingCanvas [] classbegin /menuprocess null def /Menuable? true def /onmenu nullproc def /MenuStart { % posname event -- posname event menu? boolean { currentprocess /ProcessName (HyperNeWS menu handler) put currentprocess /track_evt 3 -1 roll put currentprocess /menuok true put clear {onmenu} stopped pop currentprocess /track_evt undef currentprocess /menuok undef } fork { pause dup /State get dup /breakpoint eq { pop /menuprocess 1 index promote /OperandStack get dup length 2 copy 1 sub get 3 1 roll 2 sub get 4 -1 roll pop 3 1 roll true exit } if /runnable ne {pop false exit} if } loop } def /MenuStop { % menu -- pop menuprocess null ne { menuprocess /State get /breakpoint eq { menuprocess continueprocess } if /menuprocess unpromote } if } def classend def % % HyperNeWS menu class % /ClassHNMenu ClassMenu [] classbegin /ExecuteNotifier { % value notifier -- dup null ne { % make sure this gets executed in the hypernews context dup type /nametype eq { exch [exch] exch [3 1 roll /self cvx /Send cvx] cvx /target self send send } { [3 1 roll] [exch /doit /self cvx /Send cvx] cvx /target self send send } ifelse } {pop pop} ifelse } def classend def % % Utillities % /menuable { % -- boolean currentprocess /track_evt known currentprocess /menuok known and } def /doshowmenu { % posname menu -- self soften /settarget 2 index send soften breakpoint null /settarget 2 index send null /setinvoker 2 index send currentprocess /track_evt undef currentprocess /menuok undef pop pop } def /showmenu { % menu -- dup null ne menuable and { /Default exch //doshowmenu exec } {pop} ifelse } def /showxymenu { % menu x y -- 2 index null ne menuable and { mouseevent begin /YLocation exch def /XLocation exch def end /NorthWest exch //doshowmenu exec } {pop pop pop} ifelse } def currentdict /doshowmenu undef