% % An event manager that clears the graphics state % /ClassHNEventMgr ClassEventMgr [] classbegin /DefaultProcessName (HyperNeWS event Manager) def /ClearContext { /ClearContext super send countdictstack 1 sub {end} repeat grestoreall framebuffer setcanvas initgraphics } def classend def { systemdict /MenuTrackService known not { systemdict /MenuTrackService growabledict /Default [MenuButton] /new ClassTrackInterest send put [MenuTrackService] /addclients GlobalEventMgr send } if } pop /ClassHNCanvas ClassMenuCanvas [] classbegin { /activate { self /addclient MenuTrackService send /activate super send } def /deactivate { /deactivate super send self /removeclient MenuTrackService send } def } pop % % canvas utillities % /target null def /target_send { % method -- target dup null ne { dup /ParentDictArray known {send} {pop pop} ifelse } {pop pop} ifelse } def /onkey {/handle_key target_send} def /onfunction {/handle_function target_send} def /onselect {/handle_select_click target_send} def /onadjust {/handle_adjust_click target_send} def /onmenu {/handle_menu_click target_send} def /Paint {/handle_damage target_send} def /onenter {/handle_enter target_send} def /onexit {/handle_exit target_send} def /path { % x y w h -- pop pop pop pop } def /destroy { % -- /target unpromote /tracker unpromote /menuprocess unpromote /deactivate self send /destroy super send } def % % typing % /Keyable? true def /KeyStart { % event -- .. true onenter pop [/StandardKey /NumPadKey /MetaKey /ArrowKey] true } def /KeyStop { % event -- pop onexit } def /StandardKey {/Name get onkey} def /NumPadKey {/Name get onkey} def /ArrowKey {/Name get onfunction} def /FunctionKey {/Name get onfunction} def classend def /CursorFocus /setmode ClassFocus send % % canvas utillities % /nullcanvas framebuffer newcanvas def /new_canvas { % parent-canvas -- canvas /new //ClassHNCanvas send } def /reshape_canvas { % canvas -- 0 0 0 0 /reshape 6 -1 roll send } def /move_canvas { % x y canvas -- gsave dup /Parent get setcanvas /move exch send grestore } def /map_canvas { % canvas -- true /setdamageable 2 index send /new ClassHNEventMgr send /activate 2 index send dup /target self soften put /map exch send } def /unmap_canvas { % canvas -- /unmap 1 index send /deactivate exch send } def /move_canvas { % canvas x y canvas -- /move 4 -1 roll send } def /totop_canvas { % canvas -- /totop exch send } def /tobottom_canvas { % canvas -- /tobottom exch send } def currentdict /ClassHNCanvas undef currentdict /ClassTrackingCanvas undef