%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% liteChoice.ps %%% ------------- %%% %%% Version 1.0 %%% %%% A psuedo-implementation of SunView choice item %%% %%% Date: Sept. 25 1989 %%% Author: %%% David C. Mak %%% Argonne National Laboratory %%% Visual Interfaces Section %%% mak@athens.ees.anl.gov %%% %%% %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% This file contains the class definition for a ChoiceItem. It is similar %%% to the SunView Choice item, except it does not have a menu associated %%% with it. There is an area to click to select all items and on to %%% deselect all items. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% Example: %%% %%% /items 10 dict dup begin %%% /features (Options) [(Sort)(List)(Erase)(Modify)] {} %%% ClientCanvas 0 0 /new ChoiceItem send %%% 0 0 /move 3 index send def %%% end def %%% items forkitems pop %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% systemdict begin /ChoiceItem Item dictbegin /TempChoiceStates null def /tempjunk null def /ChoiceOnMark /panel_check_on def /ChoiceOffMark /panel_check_off def /ChoiceLabels [] def /ChoiceStates [] def /ItemLabel null def /ItemLabelColor 0 0 0 rgbcolor def /ItemLabelFont /Times-Roman findfont 18 scalefont def /ChoiceColor 0 0 0 rgbcolor def /ChoiceFont ItemLabelFont def /ChoiceMarkOffset 5 def /ChoiceLabelOffset ChoiceMarkOffset 25 add def /LabelGap 5 def /ControlSize ItemLabelFont fontheight def /NotifyUser nullproc def dictend classbegin /new % label [choice_label] Notifyproc canvas => instance { /new super send begin /NotifyUser exch store /ChoiceLabels exch store /ItemLabel exch store /ChoiceStates [ ChoiceLabels length { false } repeat ] store ItemHeight null eq { /ItemHeight 0 store /ItemWidth 0 store } if AutoSize currentdict end } def /setdata % [choice_label] [Choice values] => - { /TempChoiceStates exch store /ChoiceLabels exch store /ChoiceStates [ TempChoiceStates { 1 eq {true}{false} ifelse } forall ] store ItemHeight null eq { /ItemHeight 0 store /ItemWidth 0 store } if AutoSize } def /getalltruestring % - => (string with #s) { /tempjunk ( ) store 0 1 ChoiceLabels length 1 sub { dup ChoiceStates 1 index get not {pop pop} { 5 string cvs /tempjunk tempjunk ( ) 4 -1 roll append append store } ifelse } for tempjunk } def /reshape % x y w h => - { /reshape super send /ControlSize ItemLabelFont fontheight store } def /SelectAllControlDetail % - => - { ItemWidth ControlSize LabelGap add dup add sub ItemHeight ItemLabelFont fontheight LabelGap add sub moveto ControlSize dup rlineto ControlSize neg 0 rmoveto ControlSize dup neg rlineto } def /SelectAllControlBB % - => - { ItemWidth ControlSize LabelGap add dup add sub ItemHeight ItemLabelFont fontheight LabelGap add sub ControlSize dup rectpath } def /ClearAllControlBB % - => - { ItemWidth ControlSize LabelGap add sub ItemHeight ItemLabelFont fontheight LabelGap add sub ControlSize dup rectpath } def /PaintControls % - => - { 0 setgray % Paint the Select All Control SelectAllControlBB stroke SelectAllControlDetail stroke % Paint the Clear All Control ClearAllControlBB stroke } def /PaintLabel % - => - { gsave LabelGap ItemHeight currentfont fontheight LabelGap add sub moveto ItemLabelFont setfont ItemLabelColor setcolor ItemLabel show grestore } def /PaintBorder % - => - { gsave 0 strokecanvas 0 ItemHeight currentfont fontheight LabelGap 2 mul add sub ItemWidth -3 rectpath stroke grestore } def /PaintChoices % - => - { gsave 0 ItemHeight ChoiceFont fontheight LabelGap 2 mul add sub translate 0 1 ChoiceStates length 1 sub { ChoiceLabels 1 index get 0 1 index ChoiceFont ThingSize exch pop LabelGap add neg translate ChoiceColor ChoiceLabelOffset -2 ChoiceFont ShowThing ChoiceStates exch get { ChoiceOnMark } { ChoiceOffMark } ifelse ChoiceColor ChoiceMarkOffset 2 ChoiceFont ShowThing } for grestore } def /PaintItem % - => - { gsave ItemFillColor setcolor clippath fill /PaintBorder self send /PaintLabel self send /PaintControls self send /PaintChoices self send /PaintBorder self send grestore } def /AutoSize % - => - { gsave ItemLabelFont setfont /ItemWidth ItemWidth ItemLabel ItemLabelFont ThingSize pop LabelGap dup add add ControlSize LabelGap add dup add add max store ChoiceFont setfont ChoiceLabels { ChoiceFont ThingSize pop ChoiceLabelOffset add LabelGap add 10 add /ItemWidth exch ItemWidth max store } forall grestore /ItemHeight ItemHeight ItemLabelFont fontheight LabelGap dup add add ChoiceLabels { ChoiceFont ThingSize exch pop LabelGap add add } forall LabelGap add max store 0 0 ItemWidth ItemHeight /reshape self send } def /ClientUp % - => - { NotifyUser cvx exec } def /ClientDown % - => - { newpath SelectAllControlBB currentcursorlocation pointinpath { /SelectAll self send } if newpath ClearAllControlBB currentcursorlocation pointinpath { /ClearAll self send } if ItemHeight ItemLabelFont fontheight LabelGap dup add add sub currentcursorlocation exch pop sub dup 0 ge { 0 1 ChoiceLabels length 1 sub { ChoiceLabels 1 index get ChoiceFont ThingSize LabelGap add exch pop 3 -1 roll exch sub exch 1 index 0 le { /FlipState self send exit } { pop } ifelse } for pop } { pop } ifelse } def /getvalue % - => [ ] { [ 0 1 ChoiceLabels length 1 sub { ChoiceStates 1 index get not { pop } if } for ] } def /ClientDrag % - => - { } def /ClientEnter % - => - { } def /ClientExit % - => - { } def /FlipState % index => - { ItemHeight ItemLabelFont fontheight LabelGap dup add add sub 0 1 3 index { ChoiceLabels exch get ChoiceFont ThingSize LabelGap add exch pop sub } for exch ChoiceStates 1 index get { ChoiceStates exch false put ChoiceOffMark ChoiceOnMark } { ChoiceStates exch true put ChoiceOnMark ChoiceOffMark } ifelse ItemFillColor ChoiceMarkOffset 4 index 2 add ChoiceFont ShowThing ChoiceColor ChoiceMarkOffset 4 -1 roll 2 add ChoiceFont ShowThing } def /SelectAll { /ChoiceStates [ ChoiceLabels length { true } repeat ] store /paint self send } def /ClearAll { /ChoiceStates [ ChoiceLabels length { false } repeat ] store /paint self send } def classend def end