/drawable superclass /list [null 0] def %begin postscript section /list persist %end postscript section /tntmn null def /menutarget null def %begin postscript section /ClassHNCommandMenu ClassCommandMenu [] classbegin /ExecuteNotifier { % value notifier -- self /notify /target self send send } def /itemstring { % i -- str|null /item self send { dup isarray? not {exit} if 0 get } loop dup type /stringtype ne { pop null } if } def /width { /size self send pop } def /height { /size self send exch pop } def classend def /ClassHNSettingsMenu ClassSettingsMenu [] classbegin /ExecuteNotifier { % value notifier -- dup null ne { self /notify /target self send } { /ExecuteNotifier super } ifelse send } def /itemstring { % i -- str|null /item self send { dup isarray? not {exit} if 0 get } loop dup type /stringtype ne { pop null } if } def /width { /size self send pop } def /height { /size self send exch pop } def classend def /ClassHNMenu ClassMenu [] classbegin /ClassCommandMenu ClassHNCommandMenu def /ClassSettingsMenu ClassHNSettingsMenu def /qvalidate { /?validate super send } def /width { /size self send pop } def /height { /size self send exch pop } def /open_pinned { % canvas -- dup /setinvoker self send PinnedCopy null ne { /map PinnedCopy send /totop PinnedCopy send } if 0 1 /itemcount self send 1 sub { /item self send dup isarray? { dup length 2 eq { 1 get dup type /canvastype eq { 2 copy /open_pinned exch send } if } if } if pop } for pop } def /close_pinned { PinnedCopy null ne { /unmap PinnedCopy send } if 0 1 /itemcount self send 1 sub { /item self send dup isarray? { dup length 2 eq { 1 get dup type /canvastype eq { dup /close_pinned exch send } if } if } if pop } for } def /setallcolors { % c1 c2 c3 c4 c5 c6 c7 -- 7 copy /setallcolors super send 0 1 /itemcount self send 1 sub { /item self send dup isarray? { dup length 2 eq { 1 get dup type /canvastype eq { 8 copy /setallcolors exch send } if } if } if pop } for pop pop pop pop pop pop pop } def /stealallcolors { % object {2DFG 2DBG FG BG0 BG BG2 BG3} exch send /setallcolors self send } def classend def currentdict /ClassHNCommandMenu undef currentdict /ClassHNSettingsMenu undef %end postscript section /nritems { % any * -- int length 2 sub 3 div cvi } def /getheader { % any * -- any * 0 2 getinterval } def /getitem { % any * int -- any * 3 mul 2 add 3 getinterval } def /createtntmenu { % any * -- TNTmenu gsave framebuffer setcanvas dup getheader /Grid framebuffer /new ClassHNMenu send 1 index 1 get 1 and 0 ne { /Exclusive /setchoicemode 2 index send } { 1 index 1 get 2 and 0 ne { /NonExclusive /setchoicemode 2 index send } if } ifelse 1 index 1 get 64 and 0 ne { true /setpinnable 2 index send } if exch 0 get /setlabel 2 index send self soften /settarget 2 index send /MenuAction /setnotifier 2 index send -1 exch 0 { dup 4 index nritems ge { pop 3 -1 roll pop exit } if 3 index 1 index getitem 3 1 roll 2 index 2 get truedicttype createtntmenu$SwiTch0 exch 2 copy known { get exec } { pop pop } ifelse 2 index 1 get 1 and 0 ne { dup /InActive /setvisualstate 4 index send } if 3 -1 roll 1 get 2 and 0 ne { 3 -1 roll pop dup 3 1 roll } if 1 add } loop 1 index 0 ge { exch /setdefault 2 index send } { exch pop } ifelse dup /qvalidate exch send grestore } def /createtntmenu$SwiTch0 4 dict dup begin /nulltype { [3 index 0 get] /appenditem 3 index send } def /nametype { [3 index 0 get 4 index 2 get] /appenditem 3 index send } def /arraytype { [3 index 0 get 4 index 2 get createtntmenu] /appenditem 3 index send } def /packedarraytype currentdict /arraytype get def end def /validate { % -- any tntmn null ne {tntmn} { list createtntmenu dup /tntmn exch promote } ifelse } def /setmenu { % any * -- /list exch promote /tntmn unpromote } def %begin postscript section /DIString /DIString load def %end postscript section /itemstring { % int -- string list exch 3 mul 2 add get DIString } def /defaultindex { % any * -- int pop /default tntmn send dup null eq { pop -1 } if } def /defaultactive { % -- boolean list defaultindex dup 0 ge { list exch 3 mul 3 add get 1 and 0 eq } { pop false } ifelse } def /defaultitem { % -- any list defaultindex dup 0 lt { pop null } { list exch 3 mul 2 add get } ifelse } def /track_evt null def /notify { % any name TNTmenu -- 2 index type notify$SwiTch1 exch 2 copy known { get exec } { pop pop } ifelse } def /notify$SwiTch1 3 dict dup begin /integertype { [true 5 -1 roll dup /itemstring 6 -1 roll send ] exch menutarget Send } def /packedarraytype { 2 index dup [exch 1 get 5 index 4 -1 roll 0 get /itemstring 5 index send ] 2 index menutarget Send notify$SwiTch1 /integertype get exec pop pop pop } def /arraytype currentdict /packedarraytype get def end def /execdefault0 { % any * object -- 1 index defaultindex dup 0 ge { 3 -1 roll 1 index getitem dup 2 get truedicttype execdefault0$SwiTch2 exch 2 copy known not { pop /$deFaUlT } if get exec } { pop pop pop } ifelse } def /execdefault0$SwiTch2 4 dict dup begin /$deFaUlT { [true 4 -2 roll 0 get DIString] /MenuAction 3 -1 roll Send } def /nametype { [true 4 -1 roll 3 index 0 get DIString] exch 2 get 3 -1 roll Send } def /arraytype { exch pop 2 get exch execdefault0 } def /packedarraytype currentdict /arraytype get def end def /execdefault { % object -- list exch execdefault0 } def /show_menu_pos { % object name -- 1 index soften /menutarget exch promote currentprocess /track_evt get /track_evt exch promote exch /stealallcolors tntmn send currentprocess /menumenu tntmn put currentprocess /menuposname 3 -1 roll put breakpoint currentprocess /menumenu undef currentprocess /menuposname undef currentprocess /menuok undef currentprocess /track_evt undef } def /showmenu { % object -- currentprocess /menuok known { validate pop /Default show_menu_pos } {pop} ifelse } def /showmenuS { % object float float -- currentprocess /menuok known { validate pop mouseevent /XLocation 4 -1 roll /width tntmn send neg 2 div add put mouseevent /YLocation 3 -1 roll put /NorthWest show_menu_pos } { pop pop pop } ifelse } def /showmenuE { % object float float -- currentprocess /menuok known { validate pop mouseevent /XLocation 3 index put mouseevent /YLocation 2 index put setcursorlocation /NorthWest show_menu_pos } { pop pop pop } ifelse } def /showmenuSE { % object float float -- currentprocess /menuok known { validate pop mouseevent /XLocation 4 -1 roll put mouseevent /YLocation 3 -1 roll put /NorthWest show_menu_pos } { pop pop pop } ifelse } def /owner_close { % -- /tntmn promoted { /close_pinned tntmn send } if } def /owner_open { % -- /tntmn promoted { cv /open_pinned tntmn send } if } def