/button superclass /str null def %begin postscript section /str persist %end postscript section /value false def %begin postscript section /value persist %end postscript section /minwidth { % -- float preferredwidth } def /minheight { % -- float preferredheight } def /preferredwidth { % -- float gsave textfont setfont str DISize pop 16 add grestore dup /preferredwidth exch promote } def /preferredheight { % -- float textfont fontheight 8 add } def /action { % -- preview /value value not softpromote [str DIString value] /Action self Send } def /preview { % -- [value] /Preview self Send } def /PaintLabel { % any -- textfont setfont FG setcolor justification /Centered eq { 8 2 w 16 sub //OLButtonH 4 sub DIPaintCentered } { 8 2 w 16 sub //OLButtonH 4 sub DIPaintLeft } ifelse } def /PaintButton { % boolean -- { value not } {value} ifelse {FG} {BG} ifelse setcolor 0 0 w h rectpath fill FG setcolor 0 [0 0 w h] insetstroke aload pop rectpath stroke str PaintLabel } def /setlabel { % any -- /preferredwidth unpromote /str exch promote /Paint gexec } def /setvalue { % boolean -- dup value ne { /value exch softpromote /Paint gexec preview } {pop} ifelse } def /flipvalue { % -- /value value not softpromote /Paint gexec preview } def