[q-lang-cvs] qcalc calclib.q,1.29,1.30
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-16 06:52:55
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18939 Modified Files: calclib.q Log Message: add support for action button elements Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** calclib.q 15 Nov 2007 09:54:05 -0000 1.29 --- calclib.q 16 Nov 2007 06:52:52 -0000 1.30 *************** *** 140,143 **** --- 140,152 ---- hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; + /* The action button is a special push button which has an associated Q + expression (special argument) to be evaluated in the inferior Q process + whenever the button is clicked. The ARGS parameter has the same format as + for toggle buttons (the INIT parameter specifies the initial value of the + button, 0 by default). The result returned by the action expression (which + can be any Q value) becomes the value of the button when it is clicked. */ + + public special actionbutton ~ARGS X; + /* The task button is a special toggle button with a slightly different visual appearance and an associated background task (Q thread) to be executed in *************** *** 246,250 **** var YYDATA = ref emptyhdict, YYKEY = ref (); ! public yymain, yyval KEY, yyset KEY VAL, yyclear KEY, yytask KEY MSG; public special yyeval ~KEY VAL; private yyloop, yyout X, yyerror X; --- 255,260 ---- var YYDATA = ref emptyhdict, YYKEY = ref (); ! public yymain, yyval KEY, yyset KEY VAL, yyclear KEY, yytask KEY MSG, ! yyaction KEY, yyclearaction KEY; public special yyeval ~KEY VAL; private yyloop, yyout X, yyerror X; *************** *** 437,440 **** --- 447,465 ---- where (I,J) = get YYKEY; + /* The action button. */ + + var YYACT = ref emptyhdict; + + actionbutton S:String X + = actionbutton (S,"",0) X; + actionbutton (S:String,ICON:String) X + = actionbutton (S,ICON,0) X; + actionbutton (S:String,ICON:String,INIT) X + = YYACT := insert (get YYACT) ((I,J),'X) || + printf "\f+++ Actionbutton: %s %s\n" + (str (I,J),str (S,ICON,str INIT)) || + yyset (I,J) INIT || INIT + where (I,J) = get YYKEY; + /* The task button. */ *************** *** 542,545 **** --- 567,579 ---- YYDATA := delete (get YYDATA) KEY; + /* Handle activation and deletion of action buttons. */ + + yyaction (I:Int,J:Int) + = setval (I,J) Y + where 'X = get YYACT!(I,J), Y = catch fail X; + + yyclearaction (I:Int,J:Int) + = YYACT := delete (get YYACT) (I,J) || yyclear (I,J); + /* Substitute cell values into task expressions. */ *************** *** 591,595 **** where (H,SEM,'X) = get YYTASKS!(I,J): = cancel H || YYTASKS := delete (get YYTASKS) (I,J) || ! YYSEM := delete (get YYSEM) (thread_no H) if isthread H; ! = YYTASKS := delete (get YYTASKS) (I,J); --- 625,629 ---- where (H,SEM,'X) = get YYTASKS!(I,J): = cancel H || YYTASKS := delete (get YYTASKS) (I,J) || ! YYSEM := delete (get YYSEM) (thread_no H) || yyclear (I,J) if isthread H; ! = YYTASKS := delete (get YYTASKS) (I,J) || yyclear (I,J); |