q-lang-cvs Mailing List for Q - Equational Programming Language (Page 16)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(106) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(219) |
Feb
(152) |
Mar
|
Apr
(92) |
May
(45) |
Jun
(3) |
Jul
|
Aug
(3) |
Sep
(111) |
Oct
(52) |
Nov
|
Dec
|
2005 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(23) |
Jun
(46) |
Jul
(158) |
Aug
(22) |
Sep
|
Oct
(26) |
Nov
(11) |
Dec
(49) |
2006 |
Jan
(57) |
Feb
(196) |
Mar
(10) |
Apr
(41) |
May
(149) |
Jun
(308) |
Jul
(11) |
Aug
(25) |
Sep
(15) |
Oct
|
Nov
|
Dec
(15) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
(204) |
Jun
(112) |
Jul
(7) |
Aug
(16) |
Sep
(134) |
Oct
(313) |
Nov
(262) |
Dec
(83) |
2008 |
Jan
(81) |
Feb
(83) |
Mar
(21) |
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Albert G. <ag...@us...> - 2007-11-16 10:42:59
|
Update of /cvsroot/q-lang/qcalc/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6989/examples Modified Files: guiexamples.qcalc Log Message: update task button example, add action button example Index: guiexamples.qcalc =================================================================== RCS file: /cvsroot/q-lang/qcalc/examples/guiexamples.qcalc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** guiexamples.qcalc 15 Nov 2007 10:30:14 -0000 1.7 --- guiexamples.qcalc 16 Nov 2007 10:42:55 -0000 1.8 *************** *** 1,61 **** ! // qcalc 1.0, created Thu Nov 15 11:33:22 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31"),((32,0),("Task button example (cool stuff!). Shows how to operate a Q thread using a toggle button. See the script tab for the Q code implementing this example.",1,4)),((33,0),""),((33,1),""),((33,2),""),((33,3),""),((34,0),"Seconds for countdown:"),((34,1),"= spinbox (1,60,1,10)"),((34,2),""),((34,3),""),((35,0),"Push here to start counting:"),((35,1),"= taskbutton \"Start me!\" (timer_task B35)"),((35,2),"= spinbox (0,999999)"),((35,3),""),((36,0),""),((36,1),""),((36,2),""),((36,3),""),((37,0),""),((37,1),""),((37,2),""),((37,3),"")] ! // [(14,55),(32,44)] // [(0,162),(1,116),(2,139),(3,125)] // Start of script. Please do not remove this line. ! /* Countdown example for the task button (see the bottom of the ! spreadsheet). */ import calclib; ! /* Main entry point, invoke this with N = number to count from. */ ! ! timer_task N = waiting N $ get task_input; ! ! /* Extract the counter data from the quoted thread expression. Note that ! this needs to be a special form to prevent premature evaluation of the ! timer_task function. */ ! ! special data X; ! data (_,_,'(timer_task N)) ! = N where N:Int = N; ! ! /* Wait for the timer to be started. */ ! waiting N B:Bool = running N N if B; ! waiting N X = waiting N $ get task_input where N:Int = data X; ! waiting N _ = waiting N $ get task_input otherwise; ! /* Timer is running, count it down. */ ! running N I ! /* Check whether there are any messages waiting for us: */ ! where X = get task_input if #task_input > 0: ! /* Uncomment this to have the task restart itself (in waiting mode) ! if a new countdown is set: */ ! // = taskbutton (S,INIT) X where (S,INIT,'X) = X; ! /* Otherwise we just update our state and restart the countdown at ! the new value: */ ! = running N N where N:Int = data X; /* User stopped the countdown: */ ! = fini N if not B where B:Bool = X; ! /* Check for more messages: */ ! = running N I otherwise; ! otherwise: ! /* Done processing messages from the user, count! */ ! = setval task_index $ sprintf "Counting... %d" I || ! // update the cell to the right with the current value ! setval (task_row,task_column+1) I || ! sleep 1 || running N (I-1) if I>0; /* Reaching zero. Sleep for another second so that the user has a chance to ! see our takeoff message on the button. */ ! = setval task_index "** Takeoff! **" || ! setval (task_row,task_column+1) I || ! sleep 1 || running N (I-1) if I=0; ! /* Tell qcalc that we're stopped, and prepare for the next run. */ ! = setval task_index false || fini N otherwise; ! /* Clean it up after we're done counting. */ ! fini N = setval task_index "Run me again!" || timer_task N; --- 1,45 ---- ! // qcalc 1.0, created Fri Nov 16 11:15:41 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31"),((32,0),("Task button example. Shows how to operate a Q thread using a toggle button. See the script tab for the Q code implementing this example.",1,4)),((33,0),""),((33,1),""),((33,2),""),((33,3),""),((34,0),"Seconds for countdown:"),((34,1),"= spinbox (1,60,1,10)"),((34,2),""),((34,3),""),((35,0),"Push here to start counting:"),((35,1),"= taskbutton \"&Run me!\" (task B35)"),((35,2),"= spinbox (0,999999)"),((35,3),""),((36,0),""),((36,1),""),((36,2),""),((36,3),""),((37,0),"Action button example"),((37,1),"= actionbutton \"Random &number\" random"),((37,2),"= B38"),((37,3),"")] ! // [(14,55),(32,35)] // [(0,162),(1,116),(2,139),(3,125)] // Start of script. Please do not remove this line. ! /* Countdown task for the task button example. */ import calclib; ! /* Main entry point, invoke this with N = the number to count from. ! Note that we start out by reading the first message to see whether ! we're actually started or not. */ ! task N = if B then countdown N N where B:Bool = get task_input; ! /* We're up and running, do the countdown. */ ! countdown N I ! /* Process pending messages: */ ! where X = try task_input: /* User stopped the countdown: */ ! = fini if not B where B:Bool = X; ! /* Uncomment this to have the task restart itself (in waiting mode) if a ! new countdown is set: */ ! // = Y where 'Y = X; ! /* If the above line is commented out then we just update our state and ! restart the countdown at the new value: */ ! = countdown N N where 'Y = X, (_,_,N:Int) = task_params X; ! /* We're finally done processing messages from the user, count down now: */ ! = setval task_index $ sprintf "Counting... %d" I || ! // update the cell to the right with the current value ! setval (task_row,task_column+1) I || ! sleep 1 || countdown N (I-1) if I>0; /* Reaching zero. Sleep for another second so that the user has a chance to ! see our takeoff message on the button: */ ! = setval task_index "** Takeoff! **" || ! setval (task_row,task_column+1) I || ! sleep 1 || countdown N (I-1) if I=0; ! /* We're done, bail out: */ ! = fini otherwise; ! /* Clean up and exit. */ ! fini = setval task_index "&Run me!"; |
From: Albert G. <ag...@us...> - 2007-11-16 10:41:45
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6784 Modified Files: qcalc.q Log Message: make the Return key do something appropriate with chekboxes and buttons Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** qcalc.q 16 Nov 2007 08:59:23 -0000 1.154 --- qcalc.q 16 Nov 2007 10:41:36 -0000 1.155 *************** *** 2720,2723 **** --- 2720,2726 ---- gui_enter (I,J) X where C:String = gui_class X: + = // toggle a checkbox item + qt X "setChecked" $ not qt X "isChecked" () + if C = "MyCheckBox"; = // enter a new item in an editable combobox if all (<>S) L then *************** *** 2738,2741 **** --- 2741,2747 ---- Y = min MAX $ (Y0-MIN) div STEP*STEP+MIN if C = "MySpinBox"; + where "QPushButton" = class_name X: // press a GUI button + = qt X "toggle" () if qt X "isToggleButton" (); + = qt X "animateClick" () otherwise; /* Special actions on GUI elements. */ |
From: Albert G. <ag...@us...> - 2007-11-16 10:14:54
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32569 Modified Files: calclib.q Log Message: bugfixes Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** calclib.q 16 Nov 2007 08:08:31 -0000 1.32 --- calclib.q 16 Nov 2007 10:14:50 -0000 1.33 *************** *** 616,620 **** = post SEM B if isthread H and then active H; // thread has terminated and is activated again, restart it ! = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) where SEM:Semaphore = semaphore, H:Thread = --- 616,621 ---- = post SEM B if isthread H and then active H; // thread has terminated and is activated again, restart it ! = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) || ! post SEM B where SEM:Semaphore = semaphore, H:Thread = |
From: Albert G. <ag...@us...> - 2007-11-16 09:10:14
|
Update of /cvsroot/q-lang/qcalc/pixmaps In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18050/pixmaps Modified Files: 1rightarrow-green.png Log Message: make task arrow look brighter Index: 1rightarrow-green.png =================================================================== RCS file: /cvsroot/q-lang/qcalc/pixmaps/1rightarrow-green.png,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsFXhmoz and /tmp/cvs0fBgEc differ |
From: Albert G. <ag...@us...> - 2007-11-16 08:59:43
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14457 Modified Files: qcalc.q Log Message: disable word wrap on computed cells Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** qcalc.q 16 Nov 2007 07:25:34 -0000 1.153 --- qcalc.q 16 Nov 2007 08:59:23 -0000 1.154 *************** *** 936,940 **** = qt TABLE "setItem" (I,J,IT) || qt IT "setSpan" (N,M) || ! qt IT "setWordWrap" true || insert_cells ((I,J),IT) || IT if not is_nil IT --- 936,940 ---- = qt TABLE "setItem" (I,J,IT) || qt IT "setSpan" (N,M) || ! qt IT "setWordWrap" $ not member (get EVAL) (I,J) || insert_cells ((I,J),IT) || IT if not is_nil IT *************** *** 1087,1092 **** otherwise; set_cell (I,J) S ! = qt TABLE "setText" (I,J,S) if (I,J) = real_index (I,J); set_pixmap (I,J) PM --- 1087,1100 ---- otherwise; + init_wrap (I,J) = qt IT "setWordWrap" $ not member (get EVAL) (I,J) + if not is_nil IT + where IT:QtObject = qt TABLE "item" (I,J); + + init_cell (I,J,S) + = qt TABLE "setText" (I,J,S) || init_wrap (I,J); + set_cell (I,J) S ! = qt TABLE "setText" (I,J,S) || init_wrap (I,J) ! if (I,J) = real_index (I,J); set_pixmap (I,J) PM *************** *** 2003,2007 **** EVAL := hdict (zip KEYS2 (zip3 VALS2 XVALS2 DEPS)) || make_xref || ! do (qt TABLE "setText") L1 || do (\I.qt TABLE "setRowHeight" (I,DEF_HT)) ROWS || do (\J.qt TABLE "setColumnWidth" (J,DEF_WD)) COLS || --- 2011,2015 ---- EVAL := hdict (zip KEYS2 (zip3 VALS2 XVALS2 DEPS)) || make_xref || ! do init_cell L1 || do (\I.qt TABLE "setRowHeight" (I,DEF_HT)) ROWS || do (\J.qt TABLE "setColumnWidth" (J,DEF_WD)) COLS || |
From: Albert G. <ag...@us...> - 2007-11-16 08:08:41
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7204 Modified Files: calclib.q Log Message: pass task button update as a quoted taskbutton call instead of a triple; add task_params convenience function to extract the parameters from a quoted taskbutton call Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** calclib.q 16 Nov 2007 07:08:12 -0000 1.31 --- calclib.q 16 Nov 2007 08:08:31 -0000 1.32 *************** *** 183,200 **** started, false otherwise) when the tread is kicked off. ! The task_input semaphore may also yield a triple (S,INIT,'X) to indicate ! that the task button itself was updated while the task is still running. ! This happens when a triggered update of the button is caused by some ! requisite cells of the task button formula changing values. In such a case, ! rather than reexecuting the taskbutton function and restarting the task ! from scratch, the button's new parameters are sent via the semaphore, ! including the new thread expression which is transmitted in quoted form to ! prevent premature evaluation. Again, it is completely up to the task how it ! handles such a message; it may completely ignore it, or it may just ! reexecute the taskbutton function with the new parameters (unquoting the ! thread expression) to replace itself with the new task (to support this, ! the taskbutton function, unlike the other GUI elements, may also be ! executed asynchronously). Alternatively, the task may also cannibalize the ! given data and update its own internal state accordingly. At any time, the background task can also send values back to the hosting --- 183,202 ---- started, false otherwise) when the tread is kicked off. ! The task_input semaphore may also yield a quoted taskbutton call of the ! form '(taskbutton (S,INIT) X) to indicate that the task button itself was ! updated while the task is still running. This happens when a triggered ! update of the button is caused by some requisite cells of the task button ! formula changing values. In such a case, rather than reexecuting the ! taskbutton function and restarting the task from scratch, the taskbutton ! expression with the new parameters are sent via the semaphore. Again, it is ! completely up to the task how it handles such a message; it may completely ! ignore it, or it may just evaluate the (unquoted) taskbutton call to ! replace itself with the new task (to support this, the taskbutton function, ! unlike the other GUI elements, may also be executed asynchronously). ! Alternatively, the task may also extract the needed data from the quoted ! taskbutton call and update its own internal state accordingly. To help with ! this, we provide the task_params special form which, when applied to the ! quoted expression '(taskbutton (S,INIT) (F X1 ... Xn)), where F X1 ... Xn ! is the new task expression, returns the parameter tuple (S,INIT,X1,...,Xn). At any time, the background task can also send values back to the hosting *************** *** 214,223 **** button is, the user can always check whether the task associated with the button is currently up and running by taking a look at the arrow symbol ! shown on the button. If the task is still executing, the arrow symbol will ! be "lit" in green, otherwise it will be greyed out. Also note that in the latter case, if the thread has exited when the user starts it by pressing the button, the task will be restarted automatically. */ ! public special taskbutton ~ARGS X; public task_input, task_index, task_row, task_column; --- 216,226 ---- button is, the user can always check whether the task associated with the button is currently up and running by taking a look at the arrow symbol ! shown on the button. If the task is currently executing (even if it hasn't ! been "started" by pushing the button down yet), the arrow symbol will be ! "lit" in green, otherwise it will be greyed out. Also note that in the latter case, if the thread has exited when the user starts it by pressing the button, the task will be restarted automatically. */ ! public special taskbutton ~ARGS X, task_params X; public task_input, task_index, task_row, task_column; *************** *** 467,470 **** --- 470,485 ---- var YYTASKS = ref emptyhdict, YYSEM = ref emptyhdict; + special task_expr_params ~Xs X; + + task_params '(taskbutton (S,INIT) X) + = (S,INIT|tuple ARGS) + where (S,INIT) = catch () (S,INIT), + ARGS:List = catch () (task_expr_params [] 'X); + + task_expr_params Xs '(F X) + = task_expr_params [X|Xs] 'F; + task_expr_params Xs _ + = Xs otherwise; + task_input = SEM where (I,J,SEM) = get YYSEM!thread_no this_thread; *************** *** 616,620 **** where (H,SEM,'_) = get YYTASKS!(I,J): // task is alive and kicking, update it with the new data ! = post SEM (S,INIT,subst 'X) || INIT if isthread H and then active H; // zombie: kill it, then restart --- 631,636 ---- where (H,SEM,'_) = get YYTASKS!(I,J): // task is alive and kicking, update it with the new data ! = post SEM '(taskbutton (S,INIT) X) || INIT ! where 'X = subst 'X if isthread H and then active H; // zombie: kill it, then restart |
From: Albert G. <ag...@us...> - 2007-11-16 07:25:40
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24641 Modified Files: qcalc.q Log Message: bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -d -r1.152 -r1.153 *** qcalc.q 16 Nov 2007 07:08:12 -0000 1.152 --- qcalc.q 16 Nov 2007 07:25:34 -0000 1.153 *************** *** 2449,2453 **** = qt X "setFlat" true || qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || - gui_set_actionbutton X INIT || qt TABLE "setCellWidget" (I,J,X) || IT if not is_nil IT and then not is_nil X --- 2449,2452 ---- *************** *** 2465,2470 **** actionbutton_gui (I,J) X:QtObject (TEXT,ICON,INIT) ! = qt X "setText" TEXT || qt X "setIconSet" ICONSET || ! gui_set_actionbutton X INIT where PM = if null ICON then NULLPM --- 2464,2468 ---- actionbutton_gui (I,J) X:QtObject (TEXT,ICON,INIT) ! = qt X "setText" TEXT || qt X "setIconSet" ICONSET where PM = if null ICON then NULLPM *************** *** 2603,2608 **** "MyTaskButton", (taskbutton_gui,gui_get_togglebutton, gui_set_taskbutton); ! "MyActionButton", (actionbutton_gui,gui_get_actionbutton, ! gui_set_actionbutton);]; /* Get our class name for a GUI element. Note that the checkbox and combobox --- 2601,2605 ---- "MyTaskButton", (taskbutton_gui,gui_get_togglebutton, gui_set_taskbutton); ! "MyActionButton", (actionbutton_gui,(),());]; /* Get our class name for a GUI element. Note that the checkbox and combobox *************** *** 2635,2641 **** = qt X "isDown" (); - gui_get_actionbutton X - = cell_getval (I,J) where (I,J) = qt_data X; - gui_get_togglebutton X = qt X "isOn" (); --- 2632,2635 ---- *************** *** 2675,2682 **** otherwise; - gui_set_actionbutton X S - = cell_setval (I,J) S0 - where (I,J) = qt_data X, (S0,S1) = unquote S; - gui_set_togglebutton X S = qt X "setOn" Y --- 2669,2672 ---- *************** *** 3352,3357 **** (reg 1,reg 2), (I1,J1) = val K1, (TEXT,ICON,INIT) = val S1, ! IT:QtObject = make_gui actionbutton_gui (I1,J1,INIT) ! (TEXT,ICON); = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" --- 3342,3347 ---- (reg 1,reg 2), (I1,J1) = val K1, (TEXT,ICON,INIT) = val S1, ! IT:QtObject = make_gui actionbutton_gui (I1,J1) ! (TEXT,ICON,INIT); = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" |
From: Albert G. <ag...@us...> - 2007-11-16 07:08:16
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20846 Modified Files: calclib.q qcalc.q Log Message: make action buttons flat Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** qcalc.q 16 Nov 2007 07:03:28 -0000 1.151 --- qcalc.q 16 Nov 2007 07:08:12 -0000 1.152 *************** *** 2447,2451 **** actionbutton_gui (I,J) () (TEXT,ICON,INIT) ! = qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || gui_set_actionbutton X INIT || qt TABLE "setCellWidget" (I,J,X) || IT --- 2447,2452 ---- actionbutton_gui (I,J) () (TEXT,ICON,INIT) ! = qt X "setFlat" true || ! qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || gui_set_actionbutton X INIT || qt TABLE "setCellWidget" (I,J,X) || IT Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** calclib.q 16 Nov 2007 06:52:52 -0000 1.30 --- calclib.q 16 Nov 2007 07:08:12 -0000 1.31 *************** *** 140,149 **** 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; --- 140,150 ---- hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; ! /* The action button is a special push button with a slightly different visual ! appearance, 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; |
From: Albert G. <ag...@us...> - 2007-11-16 07:03:32
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20327 Modified Files: qcalc.q Log Message: revert change concerning cell alignment (looked awful) Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.150 retrieving revision 1.151 diff -C2 -d -r1.150 -r1.151 *** qcalc.q 16 Nov 2007 06:45:42 -0000 1.150 --- qcalc.q 16 Nov 2007 07:03:28 -0000 1.151 *************** *** 49,54 **** // maximum entries in the recent files menu MAXFILES = 8, - // alignment of custom table items - ALIGNMENT = qt_val "Qt" "AlignAuto" or qt_val "Qt" "AlignTop", // create a connector object implementing the custom slots SLOTS = --- 49,52 ---- *************** *** 946,956 **** (if null DATA then [("createEditor",create_editor), ! ("setContentFromEditor",content_from_editor), ! ("alignment",alignment)] else []) [] []; - alignment _ _ _ = ALIGNMENT; - make_check_table_item (I,J,S|DATA) = qt TABLE "setItem" (I,J,IT) || --- 944,951 ---- (if null DATA then [("createEditor",create_editor), ! ("setContentFromEditor",content_from_editor)] else []) [] []; make_check_table_item (I,J,S|DATA) = qt TABLE "setItem" (I,J,IT) || |
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); |
From: Albert G. <ag...@us...> - 2007-11-16 06:45:45
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18183 Modified Files: qcalc.q Log Message: code cleanup, bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** qcalc.q 16 Nov 2007 03:59:44 -0000 1.149 --- qcalc.q 16 Nov 2007 06:45:42 -0000 1.150 *************** *** 1047,1054 **** = IT if eq () X; - gui_data (I,J) = DATA - where IT:QtObject = get CELLS!(I,J), - (_,_,_,_|DATA) = qt_data IT; - has_table_item (I,J) = true --- 1047,1050 ---- *************** *** 1216,1222 **** where (I,J) = real_index (I,J) if is_global and then not is_recursive and then not is_nil X: ! = if (I,J)<>real_current_cell then ! set_current_cell (I,J) || ! gui_action X (I,J) || process_gui2 (I,J) X || digest_loop; --- 1212,1216 ---- where (I,J) = real_index (I,J) if is_global and then not is_recursive and then not is_nil X: ! = if (I,J)<>real_current_cell then set_current_cell (I,J) || process_gui2 (I,J) X || digest_loop; *************** *** 2457,2462 **** ICONSET = qt_new "QIconSet" PM; ! actionbutton_gui (I,J) () (TEXT,ICON) = qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || qt TABLE "setCellWidget" (I,J,X) || IT if not is_nil IT and then not is_nil X --- 2451,2457 ---- ICONSET = qt_new "QIconSet" PM; ! actionbutton_gui (I,J) () (TEXT,ICON,INIT) = qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || + gui_set_actionbutton X INIT || qt TABLE "setCellWidget" (I,J,X) || IT if not is_nil IT and then not is_nil X *************** *** 2470,2478 **** // slots [("guiUpdate()",gui_update)] [], ! IT:QtObject = make_table_item (I,J,X,ref ()) (qt_val "QTableItem" "Never"); ! actionbutton_gui (I,J) X:QtObject (TEXT,ICON) ! = qt X "setText" TEXT || qt X "setIconSet" ICONSET where PM = if null ICON then NULLPM --- 2465,2474 ---- // slots [("guiUpdate()",gui_update)] [], ! IT:QtObject = make_table_item (I,J,X) (qt_val "QTableItem" "Never"); ! actionbutton_gui (I,J) X:QtObject (TEXT,ICON,INIT) ! = qt X "setText" TEXT || qt X "setIconSet" ICONSET || ! gui_set_actionbutton X INIT where PM = if null ICON then NULLPM *************** *** 2644,2648 **** gui_get_actionbutton X ! = get Y where (I,J) = qt_data X, (Y,) = gui_data (I,J); gui_get_togglebutton X --- 2640,2644 ---- gui_get_actionbutton X ! = cell_getval (I,J) where (I,J) = qt_data X; gui_get_togglebutton X *************** *** 2684,2690 **** gui_set_actionbutton X S ! = Y := Z ! where (I,J) = qt_data X, (Y,) = gui_data (I,J), ! 'Z = valq S, Z = catch fail Z; gui_set_togglebutton X S --- 2680,2685 ---- gui_set_actionbutton X S ! = cell_setval (I,J) S0 ! where (I,J) = qt_data X, (S0,S1) = unquote S; gui_set_togglebutton X S *************** *** 2761,2764 **** --- 2756,2764 ---- = send_expr '(yyaction (I,J)) if C = "MyActionButton"; + = // make sure that the new value is set in the inferior + // process (also check that the value is transferable) + submit_val (I,J) Y || process_gui (I,J) X + if checkval Y + where Y = gui_getval X; gui_clear X (I,J) *************** *** 2766,2770 **** = send_expr '(yytask (I,J) ()) if C = "MyTaskButton"; ! = send_expr '(yyclearaction (I,J)) if C = "MyActionButton"; --- 2766,2770 ---- = send_expr '(yytask (I,J) ()) if C = "MyTaskButton"; ! = send_expr '(yyclearaction (I,J)) || cell_setval (I,J) () if C = "MyActionButton"; *************** *** 3355,3360 **** "^\\+\\+\\+ Actionbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), ! (I1,J1) = val K1, (TEXT,ICON) = val S1, ! IT:QtObject = make_gui actionbutton_gui (I1,J1) (TEXT,ICON); = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] --- 3355,3360 ---- "^\\+\\+\\+ Actionbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), ! (I1,J1) = val K1, (TEXT,ICON,INIT) = val S1, ! IT:QtObject = make_gui actionbutton_gui (I1,J1,INIT) (TEXT,ICON); = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] *************** *** 3482,3490 **** process_gui2 (I,J) X ! = // make sure that the new value is set in the inferior ! // process (also check that the value is transferable) ! if checkval Y then submit_val (I,J) Y || ! process_gui (I,J) X ! where Y = gui_getval X; process1 (I,J,S) --- 3482,3486 ---- process_gui2 (I,J) X ! = gui_action X (I,J) || process_gui (I,J) X otherwise; process1 (I,J,S) |
From: Albert G. <ag...@us...> - 2007-11-16 03:59:49
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3185 Modified Files: qcalc.q Log Message: code cleanup, add support for action button elements Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** qcalc.q 15 Nov 2007 13:20:01 -0000 1.148 --- qcalc.q 16 Nov 2007 03:59:44 -0000 1.149 *************** *** 960,964 **** where (N,M) = cell_span (I,J), IT:QtObject = qt_object "QCheckTableItem" ! (TABLE,S) "MyCheckTableItem" (ref (),ref (),ref (),()|DATA) [] [] []; --- 960,964 ---- where (N,M) = cell_span (I,J), IT:QtObject = qt_object "QCheckTableItem" ! (TABLE,S) "MyCheckBox" (ref (),ref (),ref (),()|DATA) [] [] []; *************** *** 971,975 **** where (N,M) = cell_span (I,J), IT:QtObject = qt_object "QComboTableItem" ! (TABLE,SL,E) "MyComboTableItem" (ref (),ref (),ref (),()|DATA) [] [] []; --- 971,976 ---- where (N,M) = cell_span (I,J), IT:QtObject = qt_object "QComboTableItem" ! (TABLE,SL,E) ! (if E then "MyComboEdit" else "MyComboBox") (ref (),ref (),ref (),()|DATA) [] [] []; *************** *** 1046,1049 **** --- 1047,1054 ---- = IT if eq () X; + gui_data (I,J) = DATA + where IT:QtObject = get CELLS!(I,J), + (_,_,_,_|DATA) = qt_data IT; + has_table_item (I,J) = true *************** *** 1071,1082 **** qt TABLE "clearSelection" (); - private yytask KEY MSG; - clear_cell (I,J) ! where X:QtObject = gui_elem (I,J), ("MyTaskButton"|_) = qt_mob_data X: ! = // nuke an existing background thread ! send_expr '(yytask (I,J) ()) || ! fail; // falls through to below ! if (I,J) = real_index (I,J): = qt TABLE "clearCell" (I,J) if not has_table_item (I,J); = cell_setval (I,J) Y --- 1076,1086 ---- qt TABLE "clearSelection" (); clear_cell (I,J) ! if (I,J) <> real_index (I,J): ! = _FAIL_; ! where X:QtObject = gui_elem (I,J): ! = // clean up GUI element in the inferior process ! gui_clear (I,J) || fail; // falls through to below ! otherwise: = qt TABLE "clearCell" (I,J) if not has_table_item (I,J); = cell_setval (I,J) Y *************** *** 1210,1219 **** gui_update X (I,J) _ ! where (I,J) = real_index (I,J), (CC|_) = qt_mob_data X if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then set_current_cell (I,J) || ! if CC = "MyTaskButton" then ! send_expr '(yytask (I,J) ~(qt X "isOn" ())) || process_gui2 (I,J) X || digest_loop; --- 1214,1222 ---- gui_update X (I,J) _ ! where (I,J) = real_index (I,J) if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then set_current_cell (I,J) || ! gui_action X (I,J) || process_gui2 (I,J) X || digest_loop; *************** *** 2454,2457 **** --- 2457,2483 ---- ICONSET = qt_new "QIconSet" PM; + actionbutton_gui (I,J) () (TEXT,ICON) + = qt_connect X (SIGNAL "clicked()") X (SLOT "guiUpdate()") || + qt TABLE "setCellWidget" (I,J,X) || IT + if not is_nil IT and then not is_nil X + where ICONSET = + if null ICON then () + else qt_new "QIconSet" $ qt_new "QPixmap" ICON, + X:QtObject = qt_object "QPushButton" + (if is_qt_object ICONSET then (ICONSET,TEXT,TABLE) + else (TEXT,TABLE)) + "MyActionButton" (I,J) [] + // slots + [("guiUpdate()",gui_update)] [], + IT:QtObject = make_table_item (I,J,X,ref ()) + (qt_val "QTableItem" "Never"); + + actionbutton_gui (I,J) X:QtObject (TEXT,ICON) + = qt X "setText" TEXT || qt X "setIconSet" ICONSET + where PM = + if null ICON then NULLPM + else qt_new "QPixmap" ICON, + ICONSET = qt_new "QIconSet" PM; + togglebutton_gui (I,J) () (TEXT,ICON,INIT) = qt X "setToggleButton" true || *************** *** 2571,2613 **** fval MIN STEP S = round ((V-MIN)/STEP) where V:Num = val S; ! /* Get the "type" (denoted by the creation/update function) of a GUI ! element. */ ! gui_gettype X ! where C:String = class_name X: ! = checkbox_gui ! if C = "QCheckTableItem"; ! = if qt X "isEditable" () then comboedit_gui ! else combobox_gui ! if C = "QComboTableItem"; ! = spinbox_gui ! if C = "QSpinBox"; ! = slider_gui ! if C = "QSlider"; ! = if CC = "MyTaskButton" then taskbutton_gui ! else if qt X "isToggleButton" () then togglebutton_gui ! else pushbutton_gui ! where (CC|_) = qt_mob_data X ! if C = "QPushButton"; ! // = printf "unknown GUI element %s\n" C || fail otherwise; /* Get the value of a GUI element. */ ! gui_getval X ! where C:String = class_name X: ! = qt X "isChecked" () ! if C = "QCheckTableItem"; ! = qt X "currentText" () ! if C = "QComboTableItem"; ! = spinbox_value $ qt X "cleanText" () ! if C = "QSpinBox"; ! = qt X "value" () ! if C = "QSlider"; ! = qt X "isOn" () ! if (C = "QPushButton") and then qt X "isToggleButton" (); ! = qt X "isDown" () ! if C = "QPushButton"; ! = //printf "unknown GUI element %s\n" C || ! 0 otherwise; // default value spinbox_value S = X if checknum 'X where 'X = valq S; --- 2597,2657 ---- fval MIN STEP S = round ((V-MIN)/STEP) where V:Num = val S; ! /* Table of GUI elements with the corresponding creation/update, getter and ! setter functions. */ ! def GUI_TYPES = dict ! ["MyCheckBox", (checkbox_gui,gui_get_checkbox,gui_set_checkbox); ! "MyComboBox", (combobox_gui,gui_get_combobox,gui_set_combobox); ! "MyComboEdit", (comboedit_gui,gui_get_combobox,gui_set_combobox); ! "MySpinBox", (spinbox_gui,gui_get_spinbox,gui_set_spinbox); ! "MySlider", (slider_gui,gui_get_slider,gui_set_slider); ! "MyPushButton", (pushbutton_gui,gui_get_pushbutton,()); ! "MyToggleButton", (togglebutton_gui,gui_get_togglebutton, ! gui_set_togglebutton); ! "MyTaskButton", (taskbutton_gui,gui_get_togglebutton, ! gui_set_taskbutton); ! "MyActionButton", (actionbutton_gui,gui_get_actionbutton, ! gui_set_actionbutton);]; ! ! /* Get our class name for a GUI element. Note that the checkbox and combobox ! elements are actually implemented as special QTableItems which are *not* ! widgets (not even QObjects) and so the meta object is not available; we ! handle those cases manually. */ ! ! gui_class X = C where (C|_) = qt_mob_data X; ! = "MyCheckBox" if class_name X = "QCheckTableItem"; ! = if qt X "isEditable" () then "MyComboEdit" ! else "MyComboBox" ! if class_name X = "QComboTableItem"; ! ! gui_gettype X = F where C:String = gui_class X, (F|_) = GUI_TYPES!C; ! // = printf "unknown GUI element %s\n" (class_name X) || fail otherwise; /* Get the value of a GUI element. */ ! gui_getval X = GV X where C:String = gui_class X, (_,GV,_) = GUI_TYPES!C; ! // = printf "unknown GUI element %s\n" (class_name X) || 0; ! = 0 otherwise; // default value ! ! gui_get_checkbox X ! = qt X "isChecked" (); ! ! gui_get_combobox X ! = qt X "currentText" (); ! ! gui_get_pushbutton X ! = qt X "isDown" (); ! ! gui_get_actionbutton X ! = get Y where (I,J) = qt_data X, (Y,) = gui_data (I,J); ! ! gui_get_togglebutton X ! = qt X "isOn" (); ! ! gui_get_spinbox X ! = spinbox_value $ qt X "cleanText" (); ! ! gui_get_slider X ! = qt X "value" (); spinbox_value S = X if checknum 'X where 'X = valq S; *************** *** 2616,2624 **** /* Set the value of a GUI element from a string. */ ! gui_setval X S ! where C:String = class_name X: = qt X "setChecked" Y ! if checkbool 'Y where 'Y = valq S ! if C = "QCheckTableItem"; = if all (<>S) L then (qt X "setStringList" $ append L S || --- 2660,2670 ---- /* Set the value of a GUI element from a string. */ ! gui_setval X S = SV X S where C:String = gui_class X, (_,_,SV) = GUI_TYPES!C; ! ! gui_set_checkbox X S = qt X "setChecked" Y ! if checkbool 'Y where 'Y = valq S; ! ! gui_set_combobox X S = if all (<>S) L then (qt X "setStringList" $ append L S || *************** *** 2626,2640 **** else qt X "setCurrentItem" S ! where S = Y, ! N = qt X "count" (), L = map (qt X "text") [0..N-1] if checkstr 'Y where 'Y = valq S ! if (C = "QComboTableItem") and then ! qt X "isEditable" (); = qt X "setCurrentItem" S if any (=S) L ! where S = Y, ! N = qt X "count" (), L = map (qt X "text") [0..N-1] if checkstr 'Y where 'Y = valq S ! if C = "QComboTableItem"; = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), --- 2672,2704 ---- else qt X "setCurrentItem" S ! where S = Y, N = qt X "count" (), ! L = map (qt X "text") [0..N-1] if checkstr 'Y where 'Y = valq S ! if qt X "isEditable" (); = qt X "setCurrentItem" S if any (=S) L ! where S = Y, N = qt X "count" (), ! L = map (qt X "text") [0..N-1] if checkstr 'Y where 'Y = valq S ! otherwise; ! ! gui_set_actionbutton X S ! = Y := Z ! where (I,J) = qt_data X, (Y,) = gui_data (I,J), ! 'Z = valq S, Z = catch fail Z; ! ! gui_set_togglebutton X S ! = qt X "setOn" Y ! if checkbool 'Y where 'Y = valq S; ! ! gui_set_taskbutton X S ! = if checkstr 'Y then ! qt X "setText" Y ! else if checkbool 'Y then ! qt X "setOn" Y ! else fail ! where 'Y = valq S; ! ! gui_set_spinbox X S = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), *************** *** 2643,2648 **** STEP = qt X "lineStep" (), Y = min MAX $ (Y-MIN) div STEP*STEP+MIN ! where Y:Int = make_spinbox_value X S ! if C = "QSpinBox"; = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), --- 2707,2713 ---- STEP = qt X "lineStep" (), Y = min MAX $ (Y-MIN) div STEP*STEP+MIN ! where Y:Int = make_spinbox_value X S; ! ! gui_set_slider X S = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), *************** *** 2650,2668 **** MAX = qt X "maxValue" (), Y = (min MAX.max MIN) (round Y) ! if checknum 'Y where 'Y = valq S ! if C = "QSlider"; ! = if checkstr 'Y then ! qt X "setText" Y ! else if checkbool 'Y then ! qt X "setOn" Y ! // else printf "bad value %s for GUI element %s\n" (str S,C) ! where ("MyTaskButton"|_) = qt_mob_data X, 'Y = valq S ! if (C = "QPushButton") and then qt X "isToggleButton" (); ! = qt X "setOn" Y ! if checkbool 'Y where 'Y = valq S ! if (C = "QPushButton") and then qt X "isToggleButton" (); ! = () if C = "QPushButton"; ! // = printf "bad value %s for GUI element %s\n" (str S,C); ! = () otherwise; // Convert a spinbox value; use the special value text and the text->value --- 2715,2719 ---- MAX = qt X "maxValue" (), Y = (min MAX.max MIN) (round Y) ! if checknum 'Y where 'Y = valq S; // Convert a spinbox value; use the special value text and the text->value *************** *** 2679,2683 **** gui_enter (I,J) X ! where C:String = class_name X: = // enter a new item in an editable combobox if all (<>S) L then --- 2730,2734 ---- gui_enter (I,J) X ! where C:String = gui_class X: = // enter a new item in an editable combobox if all (<>S) L then *************** *** 2688,2693 **** where S = qt X "currentText" (), N = qt X "count" (), L = map (qt X "text") [0..N-1] ! if (C = "QComboTableItem") and then ! qt X "isEditable" (); = // confine the value to the given range and step size if Y<>Y0 then recursive (qt X "setValue" Y) || --- 2739,2743 ---- where S = qt X "currentText" (), N = qt X "count" (), L = map (qt X "text") [0..N-1] ! if C = "MyComboEdit"; = // confine the value to the given range and step size if Y<>Y0 then recursive (qt X "setValue" Y) || *************** *** 2698,2702 **** STEP = qt X "lineStep" (), Y = min MAX $ (Y0-MIN) div STEP*STEP+MIN ! if C = "QSpinBox"; /* Undo/redo. **************************************************************/ --- 2748,2771 ---- STEP = qt X "lineStep" (), Y = min MAX $ (Y0-MIN) div STEP*STEP+MIN ! if C = "MySpinBox"; ! ! /* Special actions on GUI elements. */ ! ! private yyeval KEY X, yyset KEY X, yyclear X, yyval KEY, yytask KEY MSG, ! yyaction KEY, yyclearaction KEY; ! ! gui_action X (I,J) ! where C:String = gui_class X: ! = send_expr '(yytask (I,J) ~(qt X "isOn" ())) ! if C = "MyTaskButton"; ! = send_expr '(yyaction (I,J)) ! if C = "MyActionButton"; ! ! gui_clear X (I,J) ! where C:String = gui_class X: ! = send_expr '(yytask (I,J) ()) ! if C = "MyTaskButton"; ! = send_expr '(yyclearaction (I,J)) ! if C = "MyActionButton"; /* Undo/redo. **************************************************************/ *************** *** 3109,3114 **** and the executing script). */ - private yyeval KEY X, yyset KEY X, yyclear X, yyval KEY, yytask KEY MSG; - parse S = 'X where --- 3178,3181 ---- *************** *** 3286,3289 **** --- 3353,3363 ---- = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" + "^\\+\\+\\+ Actionbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S + (reg 1,reg 2), + (I1,J1) = val K1, (TEXT,ICON) = val S1, + IT:QtObject = make_gui actionbutton_gui (I1,J1) + (TEXT,ICON); + = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] + where [(K1,S1)] = regex "" "^\\+\\+\\+ Togglebutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), |
From: Albert G. <ag...@us...> - 2007-11-15 13:20:05
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26583 Modified Files: qcalc.q Log Message: fix vertical alignment in custom table items Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** qcalc.q 15 Nov 2007 10:22:52 -0000 1.147 --- qcalc.q 15 Nov 2007 13:20:01 -0000 1.148 *************** *** 49,52 **** --- 49,54 ---- // maximum entries in the recent files menu MAXFILES = 8, + // alignment of custom table items + ALIGNMENT = qt_val "Qt" "AlignAuto" or qt_val "Qt" "AlignTop", // create a connector object implementing the custom slots SLOTS = *************** *** 944,951 **** (if null DATA then [("createEditor",create_editor), ! ("setContentFromEditor",content_from_editor)] else []) [] []; make_check_table_item (I,J,S|DATA) = qt TABLE "setItem" (I,J,IT) || --- 946,956 ---- (if null DATA then [("createEditor",create_editor), ! ("setContentFromEditor",content_from_editor), ! ("alignment",alignment)] else []) [] []; + alignment _ _ _ = ALIGNMENT; + make_check_table_item (I,J,S|DATA) = qt TABLE "setItem" (I,J,IT) || |
From: Albert G. <ag...@us...> - 2007-11-15 10:30:21
|
Update of /cvsroot/q-lang/qcalc/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13108/examples Modified Files: guiexamples.qcalc Log Message: bugfixes Index: guiexamples.qcalc =================================================================== RCS file: /cvsroot/q-lang/qcalc/examples/guiexamples.qcalc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** guiexamples.qcalc 15 Nov 2007 10:23:43 -0000 1.6 --- guiexamples.qcalc 15 Nov 2007 10:30:14 -0000 1.7 *************** *** 1,4 **** ! // qcalc 1.0, created Thu Nov 15 11:18:06 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31"),((32,0),("Task button example (cool stuff!). Shows how to operate a Q thread using a toggle button. See the script tab for the Q code implementing this example.",1,4)),((33,0),""),((33,1),""),((33,2),""),((33,3),""),((34,0),"Seconds for countdown:"),((34,1),"= spinbox (1,60,1,10)"),((34,2),""),((34,3),""),((35,0),"Push here to start counting:"),((35,1),"= taskbutton \"Start me!\" (timer_task B34)"),((35,2),"= spinbox (0,999999)"),((35,3),""),((36,0),""),((36,1),""),((36,2),""),((36,3),""),((37,0),""),((37,1),""),((37,2),""),((37,3),"")] // [(14,55),(32,44)] // [(0,162),(1,116),(2,139),(3,125)] --- 1,4 ---- ! // qcalc 1.0, created Thu Nov 15 11:33:22 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31"),((32,0),("Task button example (cool stuff!). Shows how to operate a Q thread using a toggle button. See the script tab for the Q code implementing this example.",1,4)),((33,0),""),((33,1),""),((33,2),""),((33,3),""),((34,0),"Seconds for countdown:"),((34,1),"= spinbox (1,60,1,10)"),((34,2),""),((34,3),""),((35,0),"Push here to start counting:"),((35,1),"= taskbutton \"Start me!\" (timer_task B35)"),((35,2),"= spinbox (0,999999)"),((35,3),""),((36,0),""),((36,1),""),((36,2),""),((36,3),""),((37,0),""),((37,1),""),((37,2),""),((37,3),"")] // [(14,55),(32,44)] // [(0,162),(1,116),(2,139),(3,125)] |
From: Albert G. <ag...@us...> - 2007-11-15 10:28:54
|
Update of /cvsroot/q-lang/qcalc/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12642/examples Modified Files: clock.qcalc Log Message: cosmetic changes Index: clock.qcalc =================================================================== RCS file: /cvsroot/q-lang/qcalc/examples/clock.qcalc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** clock.qcalc 4 Nov 2007 21:35:52 -0000 1.2 --- clock.qcalc 15 Nov 2007 10:28:49 -0000 1.3 *************** *** 1,6 **** ! // qcalc 1.0, created Sun Nov 4 22:32:52 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,0),"Sun Nov 4 22:32:51 2007")] // [] ! // [(0,141)] // Start of script. Please do not remove this line. --- 1,6 ---- ! // qcalc 1.0, created Thu Nov 15 11:28:43 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,0),"Thu Nov 15 11:28:42 2007")] // [] ! // [(0,172)] // Start of script. Please do not remove this line. |
From: Albert G. <ag...@us...> - 2007-11-15 10:23:47
|
Update of /cvsroot/q-lang/qcalc/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12419/examples Modified Files: guiexamples.qcalc Log Message: added task button example Index: guiexamples.qcalc =================================================================== RCS file: /cvsroot/q-lang/qcalc/examples/guiexamples.qcalc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** guiexamples.qcalc 12 Nov 2007 20:29:35 -0000 1.5 --- guiexamples.qcalc 15 Nov 2007 10:23:43 -0000 1.6 *************** *** 1,5 **** ! // qcalc 1.0, created Mon Nov 12 21:31:39 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31")] ! // [(14,55)] ! // [(0,162),(2,139)] // Start of script. Please do not remove this line. --- 1,61 ---- ! // qcalc 1.0, created Thu Nov 15 11:18:06 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"GUI element"),((0,2),"Value"),((0,3),"Display"),((2,0),"Checkbox"),((2,1),"= checkbox (\"test\",true)"),((2,2),"= B3"),((2,3),"= checkbox (\"test\",B3)"),((4,0),"Combobox"),((4,1),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((4,2),"= B5"),((4,3),"= combobox ([\"apples\",\"bananas\",\"oranges\"],B5)"),((5,0),"Comboedit"),((5,1),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],\"bananas\")"),((5,2),"= B6"),((5,3),"= comboedit ([\"apples\",\"bananas\",\"oranges\"],B6)"),((6,0),"Int Spinbox"),((6,1),"= spinbox (0,100,5,40)"),((6,2),"= B7"),((6,3),"= spinbox (0,100,5,B7)"),((7,0),"Float Spinbox"),((7,1),"= spinbox (0.0,10.0,0.5,4.0)"),((7,2),"= B8"),((7,3),"= spinbox (0.0,10.0,0.5,B8)"),((9,0),"Spinbox with special value"),((9,1),"= spinbox (-1,10,1,0,\"Any\")"),((9,2),"= B10"),((9,3),"= spinbox (-1,10,1,B10,\"Any\")"),((10,0),"Spinbox with prefix"),((10,1),"= spinbox (-0.1,10,0.1,0,\"Any\",\"$ \")"),((10,2),"= B11"),((10,3),"= spinbox (-0.1,10,0.1,B11,\"Any\",\"$ \")"),((11,0),"Spinbox with suffix"),((11,1),"= spinbox (-1,72,1,10,\"Any\",\"\",\"pt\")"),((11,2),"= B12"),((11,3),"= spinbox (-1,72,1,B12,\"Any\",\"\",\"pt\")"),((13,0),"Horizontal slider"),((13,1),"= hslider (0,100,1,50)"),((13,2),"= B14"),((13,3),"= hslider (0,100,1,B14)"),((14,0),"Vertical slider"),((14,1),"= vslider (0,100,1,50)"),((14,2),"= B15"),((14,3),"= vslider (0,100,1,B15)"),((16,0),"Pushbutton"),((16,1),"= pushbutton \"Push me!\""),((16,2),"= B17"),((16,3),"N/A"),((17,0),"Pushbutton with icon"),((17,1),"= pushbutton (\"Push me!\",which \"pixmaps/1rightarrow.png\")"),((17,2),"= B18"),((17,3),"N/A"),((18,0),"Togglebutton with icon"),((18,1),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((18,2),"= B19"),((18,3),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\",B19)"),((20,0),"\"Buddies\" (linked elements)"),((20,1),"= hslider (0,100,1,D21)"),((20,2),"= B21"),((20,3),"= spinbox (0,100,1,B21)"),((22,0),("Alternative \"remote control\" of GUI elements using setval",1,4)),((24,0),"GUI element A (click here)"),((24,1),"Transfer A -> B"),((24,2),"GUI element B (display)"),((24,3),"Value of B"),((26,0),"= checkbox \"A\""),((26,1),"= setval 'C27 A27"),((26,2),"= checkbox \"B\""),((26,3),"= C27"),((27,0),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,1),"= setval 'C28 A28"),((27,2),"= spinbox (-0.1,10,0.1,0,\"Any\")"),((27,3),"= C28"),((28,0),"= spinbox (-5,100,5,40,\"Any\")"),((28,1),"= setval 'C29 A29"),((28,2),"= spinbox (-1,100,1,40,\"Any\")"),((28,3),"= C29"),((29,0),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,1),"= setval 'C30 A30"),((29,2),"= combobox ([\"apples\",\"bananas\",\"oranges\"],\"oranges\")"),((29,3),"= C30"),((30,0),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,1),"= setval 'C31 A31"),((30,2),"= togglebutton (\"Toggle me!\",which \"pixmaps/flag.png\")"),((30,3),"= C31"),((32,0),("Task button example (cool stuff!). Shows how to operate a Q thread using a toggle button. See the script tab for the Q code implementing this example.",1,4)),((33,0),""),((33,1),""),((33,2),""),((33,3),""),((34,0),"Seconds for countdown:"),((34,1),"= spinbox (1,60,1,10)"),((34,2),""),((34,3),""),((35,0),"Push here to start counting:"),((35,1),"= taskbutton \"Start me!\" (timer_task B34)"),((35,2),"= spinbox (0,999999)"),((35,3),""),((36,0),""),((36,1),""),((36,2),""),((36,3),""),((37,0),""),((37,1),""),((37,2),""),((37,3),"")] ! // [(14,55),(32,44)] ! // [(0,162),(1,116),(2,139),(3,125)] // Start of script. Please do not remove this line. + + /* Countdown example for the task button (see the bottom of the + spreadsheet). */ + + import calclib; + + /* Main entry point, invoke this with N = number to count from. */ + + timer_task N = waiting N $ get task_input; + + /* Extract the counter data from the quoted thread expression. Note that + this needs to be a special form to prevent premature evaluation of the + timer_task function. */ + + special data X; + data (_,_,'(timer_task N)) + = N where N:Int = N; + + /* Wait for the timer to be started. */ + + waiting N B:Bool = running N N if B; + waiting N X = waiting N $ get task_input where N:Int = data X; + waiting N _ = waiting N $ get task_input otherwise; + + /* Timer is running, count it down. */ + + running N I + /* Check whether there are any messages waiting for us: */ + where X = get task_input if #task_input > 0: + /* Uncomment this to have the task restart itself (in waiting mode) + if a new countdown is set: */ + // = taskbutton (S,INIT) X where (S,INIT,'X) = X; + /* Otherwise we just update our state and restart the countdown at + the new value: */ + = running N N where N:Int = data X; + /* User stopped the countdown: */ + = fini N if not B where B:Bool = X; + /* Check for more messages: */ + = running N I otherwise; + otherwise: + /* Done processing messages from the user, count! */ + = setval task_index $ sprintf "Counting... %d" I || + // update the cell to the right with the current value + setval (task_row,task_column+1) I || + sleep 1 || running N (I-1) if I>0; + /* Reaching zero. Sleep for another second so that the user has a chance to + see our takeoff message on the button. */ + = setval task_index "** Takeoff! **" || + setval (task_row,task_column+1) I || + sleep 1 || running N (I-1) if I=0; + /* Tell qcalc that we're stopped, and prepare for the next run. */ + = setval task_index false || fini N otherwise; + + /* Clean it up after we're done counting. */ + + fini N = setval task_index "Run me again!" || timer_task N; |
From: Albert G. <ag...@us...> - 2007-11-15 10:22:57
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12319 Modified Files: qcalc.q Log Message: bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** qcalc.q 15 Nov 2007 10:15:48 -0000 1.146 --- qcalc.q 15 Nov 2007 10:22:52 -0000 1.147 *************** *** 1385,1389 **** merge_cells _ _ _ if is_global: ! = save_undo (I,J;N,M) where (I,J) = real_index (I,J), (N,M) = cell_span (I,J) where IT:QtObject = set_current_cell (I,J) || --- 1385,1389 ---- merge_cells _ _ _ if is_global: ! = EDITED := true || update_title || save_undo (I,J;N,M) where (I,J) = real_index (I,J), (N,M) = cell_span (I,J) where IT:QtObject = set_current_cell (I,J) || *************** *** 1402,1406 **** dissociate_cell (I,J) = set_current_cell (I,J) || qt IT "setSpan" (1,1) || ! save_undo (I,J;1,1) where IT = get_table_item (I,J); --- 1402,1406 ---- dissociate_cell (I,J) = set_current_cell (I,J) || qt IT "setSpan" (1,1) || ! EDITED := true || update_title || save_undo (I,J;1,1) where IT = get_table_item (I,J); |
From: Albert G. <ag...@us...> - 2007-11-15 10:18:13
|
Update of /cvsroot/q-lang/qcalc/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12010/examples Modified Files: example.qcalc Log Message: cosmetic changes Index: example.qcalc =================================================================== RCS file: /cvsroot/q-lang/qcalc/examples/example.qcalc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** example.qcalc 12 Nov 2007 20:33:13 -0000 1.4 --- example.qcalc 15 Nov 2007 10:18:09 -0000 1.5 *************** *** 1,5 **** ! // qcalc 1.0, created Mon Nov 12 21:36:00 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"*** Erathosthenes' prime sieve ***"),((2,0),"Q stream of *all* primes"),((2,1),"= primes"),((3,0),"The first 50 primes"),((3,1),"= list $ take 50 B3"),((4,0),"The 111th prime"),((4,1),"= B3!111"),((5,0),"Product of the first 50"),((5,1),"= prd B4"),((6,1),("(This is a HUGE number, make the column bigger to see it all.)",1,2)),((8,1),"*** Linear Regression (Eddie Rucker) ***"),((9,0),"1"),((9,1),"3"),((10,0),"2"),((10,1),"5"),((11,0),"3"),((11,1),"7"),((12,0),"4"),((12,1),"9"),((13,0),"5"),((13,1),"10"),((14,0),"6"),((14,1),"13"),((15,0),"Least squares:"),((15,1),"= regress A10:A15 B10:B15"),((16,0),"Enter X:"),((16,1),"7"),((17,0),"Value at X:"),((17,1),"= B16 B17"),((19,1),"*** Normal Distribution (Eddie Rucker) ***"),((20,0),"Enter A:"),((20,1),"-1"),((21,0),"Enter B:"),((21,1),"1"),((22,0),"P(X>=A):"),((22,1),"= normal_above B21"),((23,0),"P(X<=B):"),((23,1),"= normal_below B22"),((24,0),"P(A<=X<=B):"),((24,1),"= normal B21 B22"),((26,1),"*** Playing with sums etc. ***"),((26,2),"Squares"),((26,3),"Cubes"),((27,1),"1"),((27,2),"= square B28"),((27,3),"= cube B28"),((28,1),"2"),((28,2),"= square B29"),((28,3),"= cube B29"),((29,1),"3"),((29,2),"= square B30"),((29,3),"= cube B30"),((30,1),"4"),((30,2),"= square B31"),((30,3),"= cube B31"),((31,1),"5"),((31,2),"= square B32"),((31,3),"= cube B32"),((32,1),"6"),((32,2),"= square B33"),((32,3),"= cube B33"),((33,1),"7"),((33,2),"= square B34"),((33,3),"= cube B34"),((34,1),"8"),((34,2),"= square B35"),((34,3),"= cube B35"),((35,1),"9"),((35,2),"= square B36"),((35,3),"= cube B36"),((36,1),"10"),((36,2),"= square B37"),((36,3),"= cube B37"),((38,0),"Sum"),((38,1),"= sum B28:B37"),((38,2),"= sum C28:C37"),((38,3),"= sum D28:D37"),((39,0),"Product"),((39,1),"= prd B28:B37"),((39,2),"= prd C28:C37"),((39,3),"= prd D28:D37"),((40,1),"Note that the range B28:B37 becomes a Q list:"),((41,1),"= B28:B37"),((44,1),"*** Geometric series ***"),((45,0),"Enter Q:"),((45,1),"= 1/3"),((46,0),"Series:"),((46,1),"= geom_series B46"),((47,0),"1"),((47,1),"= B$47!A48"),((48,0),"2"),((48,1),"= B$47!A49"),((49,0),"3"),((49,1),"= B$47!A50"),((50,0),"4"),((50,1),"= B$47!A51"),((51,0),"5"),((51,1),"= B$47!A52"),((52,0),"6"),((52,1),"= B$47!A53"),((53,0),"7"),((53,1),"= B$47!A54"),((54,0),"8"),((54,1),"= B$47!A55"),((55,0),"9"),((55,1),"= B$47!A56"),((56,0),"10"),((56,1),"= B$47!A57"),((57,0),"11"),((57,1),"= B$47!A58"),((58,0),"12"),((58,1),"= B$47!A59"),((59,0),"13"),((59,1),"= B$47!A60"),((60,0),"14"),((60,1),"= B$47!A61"),((61,0),"15"),((61,1),"= B$47!A62"),((63,1),"Some calculations with rationals:"),((64,0),"Op1"),((64,1),"= 5%3"),((65,0),"Op2"),((65,1),"= 81%53"),((66,0),"Sum"),((66,1),"= B65+B66"),((67,0),"Product"),((67,1),"= B65*B66"),((68,0),"Quotient"),((68,1),"= B65 % B66"),((70,1),"Complex numbers:"),((71,0),"2^(1/i)"),((71,1),"= 2^(1/i)"),((72,0),"log2 of that"),((72,1),"= lg B72"),((73,0),"abs, arg of the log2"),((73,1),"= (abs B73,arg B73)"),((75,1),"Complex rationals:"),((76,1),"= (1+:2)%(3+:4)"),((77,1),"= square (5+:-5%18)")] ! // [] // [(0,139),(1,308),(2,120),(3,163),(4,188)] // Start of script. Please do not remove this line. --- 1,5 ---- ! // qcalc 1.0, created Thu Nov 15 11:21:15 2007 -*-Q-*- -*- coding: UTF-8 -*- ! // [((0,1),"*** Erathosthenes' prime sieve ***"),((2,0),"Q stream of *all* primes"),((2,1),"= primes"),((3,0),"The first 50 primes"),((3,1),"= list $ take 50 B3"),((4,0),"The 111th prime"),((4,1),"= B3!111"),((5,0),"Product of the first 50"),((5,1),"= prd B4"),((6,1),"(This is a HUGE number, make the column bigger to see it all.)"),((8,1),"*** Linear Regression (Eddie Rucker) ***"),((9,0),"1"),((9,1),"3"),((10,0),"2"),((10,1),"5"),((11,0),"3"),((11,1),"7"),((12,0),"4"),((12,1),"9"),((13,0),"5"),((13,1),"10"),((14,0),"6"),((14,1),"13"),((15,0),"Least squares:"),((15,1),"= regress A10:A15 B10:B15"),((16,0),"Enter X:"),((16,1),"7"),((17,0),"Value at X:"),((17,1),"= B16 B17"),((19,1),"*** Normal Distribution (Eddie Rucker) ***"),((20,0),"Enter A:"),((20,1),"-1"),((21,0),"Enter B:"),((21,1),"1"),((22,0),"P(X>=A):"),((22,1),"= normal_above B21"),((23,0),"P(X<=B):"),((23,1),"= normal_below B22"),((24,0),"P(A<=X<=B):"),((24,1),"= normal B21 B22"),((26,1),"*** Playing with sums etc. ***"),((26,2),"Squares"),((26,3),"Cubes"),((27,1),"1"),((27,2),"= square B28"),((27,3),"= cube B28"),((28,1),"2"),((28,2),"= square B29"),((28,3),"= cube B29"),((29,1),"3"),((29,2),"= square B30"),((29,3),"= cube B30"),((30,1),"4"),((30,2),"= square B31"),((30,3),"= cube B31"),((31,1),"5"),((31,2),"= square B32"),((31,3),"= cube B32"),((32,1),"6"),((32,2),"= square B33"),((32,3),"= cube B33"),((33,1),"7"),((33,2),"= square B34"),((33,3),"= cube B34"),((34,1),"8"),((34,2),"= square B35"),((34,3),"= cube B35"),((35,1),"9"),((35,2),"= square B36"),((35,3),"= cube B36"),((36,1),"10"),((36,2),"= square B37"),((36,3),"= cube B37"),((38,0),"Sum"),((38,1),"= sum B28:B37"),((38,2),"= sum C28:C37"),((38,3),"= sum D28:D37"),((39,0),"Product"),((39,1),"= prd B28:B37"),((39,2),"= prd C28:C37"),((39,3),"= prd D28:D37"),((40,1),"Note that the range B28:B37 becomes a Q list:"),((41,1),"= B28:B37"),((44,1),"*** Geometric series ***"),((45,0),"Enter Q:"),((45,1),"= 1/3"),((46,0),"Series:"),((46,1),"= geom_series B46"),((47,0),"1"),((47,1),"= B$47!A48"),((48,0),"2"),((48,1),"= B$47!A49"),((49,0),"3"),((49,1),"= B$47!A50"),((50,0),"4"),((50,1),"= B$47!A51"),((51,0),"5"),((51,1),"= B$47!A52"),((52,0),"6"),((52,1),"= B$47!A53"),((53,0),"7"),((53,1),"= B$47!A54"),((54,0),"8"),((54,1),"= B$47!A55"),((55,0),"9"),((55,1),"= B$47!A56"),((56,0),"10"),((56,1),"= B$47!A57"),((57,0),"11"),((57,1),"= B$47!A58"),((58,0),"12"),((58,1),"= B$47!A59"),((59,0),"13"),((59,1),"= B$47!A60"),((60,0),"14"),((60,1),"= B$47!A61"),((61,0),"15"),((61,1),"= B$47!A62"),((63,1),"Some calculations with rationals:"),((64,0),"Op1"),((64,1),"= 5%3"),((65,0),"Op2"),((65,1),"= 81%53"),((66,0),"Sum"),((66,1),"= B65+B66"),((67,0),"Product"),((67,1),"= B65*B66"),((68,0),"Quotient"),((68,1),"= B65 % B66"),((70,1),"Complex numbers:"),((71,0),"2^(1/i)"),((71,1),"= 2^(1/i)"),((72,0),"log2 of that"),((72,1),"= lg B72"),((73,0),"abs, arg of the log2"),((73,1),"= (abs B73,arg B73)"),((75,1),"Complex rationals:"),((76,1),"= (1+:2)%(3+:4)"),((77,1),"= square (5+:-5%18)")] ! // [(6,37)] // [(0,139),(1,308),(2,120),(3,163),(4,188)] // Start of script. Please do not remove this line. |
From: Albert G. <ag...@us...> - 2007-11-15 10:15:57
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10599 Modified Files: qcalc.q Log Message: set word wrap on all custom table items Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** qcalc.q 15 Nov 2007 09:54:05 -0000 1.145 --- qcalc.q 15 Nov 2007 10:15:48 -0000 1.146 *************** *** 927,932 **** spanned_table_item (I,J) (N,M) ! = qt IT "setSpan" (N,M) || ! qt IT "setWordWrap" (N>1) || IT if not is_nil IT where (I0,J0) = real_index (I,J), --- 927,931 ---- spanned_table_item (I,J) (N,M) ! = qt IT "setSpan" (N,M) || IT if not is_nil IT where (I0,J0) = real_index (I,J), *************** *** 937,940 **** --- 936,940 ---- = qt TABLE "setItem" (I,J,IT) || qt IT "setSpan" (N,M) || + qt IT "setWordWrap" true || insert_cells ((I,J),IT) || IT if not is_nil IT |
From: Albert G. <ag...@us...> - 2007-11-15 09:54:10
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8352 Modified Files: calclib.q qcalc.q Log Message: make task buttons flat so that they can be distinguished from ordinary toggle buttons Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** qcalc.q 15 Nov 2007 00:08:33 -0000 1.144 --- qcalc.q 15 Nov 2007 09:54:05 -0000 1.145 *************** *** 2478,2481 **** --- 2478,2482 ---- taskbutton_gui (I,J) () (TEXT,INIT) = qt X "setToggleButton" true || + qt X "setFlat" true || qt X "setOn" INIT || qt_connect X (SIGNAL "toggled(bool)") Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** calclib.q 15 Nov 2007 09:26:36 -0000 1.28 --- calclib.q 15 Nov 2007 09:54:05 -0000 1.29 *************** *** 140,149 **** hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; ! /* The task button is a special toggle button with an associated background ! task (Q thread) to be executed in the inferior Q process. The ARGS ! parameter is the same as for togglebutton, without the ICON parameter ! (instead, the icon on the button is set and animated automatically in ! response to the current activation status of the thread). The special X ! parameter is the Q expression to be evaluated by the task. Inside the background task, the task_input, task_index, task_row and --- 140,150 ---- hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; ! /* 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 ! the inferior Q process. The ARGS parameter is the same as for togglebutton, ! without the ICON parameter (instead, the icon on the button is set and ! animated automatically in response to the current activation status of the ! thread). The special X parameter is the Q expression to be evaluated by the ! task. Inside the background task, the task_input, task_index, task_row and |
From: Albert G. <ag...@us...> - 2007-11-15 09:26:40
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv821 Modified Files: calclib.q Log Message: allow a task to reexecute itself by a recursive invocation of the taskbutton function, bugfixes Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** calclib.q 15 Nov 2007 00:36:41 -0000 1.27 --- calclib.q 15 Nov 2007 09:26:36 -0000 1.28 *************** *** 168,187 **** if at all. However, it is a good idea to have the task at least empty the semaphore in regular time intervals to prevent the semaphore from being ! flooded with useless messages. (In any case the semaphore queue will be ! initially empty when the tread is started.) ! The task_input semaphore may also yield a quoted expression value to ! indicate that the task button itself was updated while the task is still ! running. This happens when a triggered update of the button is caused by ! some requisite cells of the task button formula changing values. In such a ! case, rather than reexecuting the taskbutton function and restarting the ! task from scratch, the button's X parameter is send via the semaphore as a ! quoted expression. Again, it is completely up to the task how it handles ! such messages. It may completely ignore the message, but a more appropriate ! response would be to just replace itself with the sent expression. ! Alternatively, the task may update its own internal state accordingly and ! continue processing. In the latter case, it is often convenient to employ ! the standard library special form 'case' to extract the needed values from ! the quoted expression. At any time, the background task can also send values back to the hosting --- 168,189 ---- if at all. However, it is a good idea to have the task at least empty the semaphore in regular time intervals to prevent the semaphore from being ! flooded with useless messages. In any case the semaphore queue will ! initially contain just the "startup" message (true if the task is initially ! started, false otherwise) when the tread is kicked off. ! The task_input semaphore may also yield a triple (S,INIT,'X) to indicate ! that the task button itself was updated while the task is still running. ! This happens when a triggered update of the button is caused by some ! requisite cells of the task button formula changing values. In such a case, ! rather than reexecuting the taskbutton function and restarting the task ! from scratch, the button's new parameters are sent via the semaphore, ! including the new thread expression which is transmitted in quoted form to ! prevent premature evaluation. Again, it is completely up to the task how it ! handles such a message; it may completely ignore it, or it may just ! reexecute the taskbutton function with the new parameters (unquoting the ! thread expression) to replace itself with the new task (to support this, ! the taskbutton function, unlike the other GUI elements, may also be ! executed asynchronously). Alternatively, the task may also cannibalize the ! given data and update its own internal state accordingly. At any time, the background task can also send values back to the hosting *************** *** 451,467 **** taskbutton (S:String,INIT:Bool) X where (I,J) = get YYKEY: ! // update an old task if still present ! = do (yytask (I,J)) ['X,INIT] || ! printf "\f+++ Taskbutton: %s %s\n" ! (str (I,J),str (S,INIT)) || yyset (I,J) INIT || INIT ! where (H,_,'_) = get YYTASKS!(I,J); // start up a new task = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) || post SEM INIT || ! printf "\f+++ Taskbutton: %s %s\n" ! (str (I,J),str (S,INIT)) || yyset (I,J) INIT || INIT where SEM:Semaphore = semaphore, H:Thread = thread (begin_task (I,J,SEM) || catch id X || end_task); /* Watchdogs for the beginning and end of a task. */ --- 453,476 ---- taskbutton (S:String,INIT:Bool) X where (I,J) = get YYKEY: ! // update existing task ! = yytask (I,J) (S,INIT,'X) if member (get YYTASKS) (I,J); // start up a new task = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) || post SEM INIT || ! yyset (I,J) INIT || INIT where SEM:Semaphore = semaphore, H:Thread = + printf "\f+++ Taskbutton: %s %s\n" + (str (I,J),str (S,INIT)) || thread (begin_task (I,J,SEM) || catch id X || end_task); + if active H where (I,J,_) = get YYSEM!thread_no this_thread, + (H:Thread,SEM,'_) = get YYTASKS!(I,J): + // request by a task to replace itself with a new task + = // update the button + do (setval (I,J)) [S,INIT] || + // update the task data + YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) || + // send the startup message and tail-execute the new thread + post SEM INIT || yyset (I,J) INIT || X; /* Watchdogs for the beginning and end of a task. */ *************** *** 566,575 **** if isthread H; ! /* Update a task with a new thread expression. */ ! yytask (I:Int,J:Int) 'X where (H,SEM,'_) = get YYTASKS!(I,J): ! = post SEM (subst 'X) if isthread H and then active H; ! = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,subst 'X); /* Kill a task. */ --- 575,587 ---- if isthread H; ! /* Update a task with new data. */ ! yytask (I:Int,J:Int) (S,INIT,'X) where (H,SEM,'_) = get YYTASKS!(I,J): ! // task is alive and kicking, update it with the new data ! = post SEM (S,INIT,subst 'X) || INIT ! if isthread H and then active H; ! // zombie: kill it, then restart ! = yytask (I,J) () || taskbutton (S,INIT) X; /* Kill a task. */ |
From: Albert G. <ag...@us...> - 2007-11-15 00:36:45
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27694 Modified Files: calclib.q Log Message: remove debugging code Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** calclib.q 15 Nov 2007 00:08:33 -0000 1.26 --- calclib.q 15 Nov 2007 00:36:41 -0000 1.27 *************** *** 570,574 **** yytask (I:Int,J:Int) 'X where (H,SEM,'_) = get YYTASKS!(I,J): - = puts "Task updated\n" || fail; = post SEM (subst 'X) if isthread H and then active H; = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,subst 'X); --- 570,573 ---- *************** *** 578,582 **** yytask (I:Int,J:Int) () where (H,SEM,'X) = get YYTASKS!(I,J): - = puts "Task killed\n" || fail; = cancel H || YYTASKS := delete (get YYTASKS) (I,J) || YYSEM := delete (get YYSEM) (thread_no H) --- 577,580 ---- |
From: Albert G. <ag...@us...> - 2007-11-15 00:10:42
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16972 Modified Files: Makefile Log Message: added 'task button' GUI element Index: Makefile =================================================================== RCS file: /cvsroot/q-lang/qcalc/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile 4 Nov 2007 20:34:12 -0000 1.11 --- Makefile 15 Nov 2007 00:10:35 -0000 1.12 *************** *** 15,19 **** appdir = $(pkgdatadir)/apps/$(app) ! PIXMAPS = pixmaps/qcalc.png pixmaps/flag.png pixmaps/1rightarrow.png DISTFILES = Makefile COPYING README calclib.q $(app).desktop $(app).q *.ui $(PIXMAPS) doc/Makefile doc/*.html doc/*.png doc/*.xml doc/*.texi doc/texinfo.tex examples/*.qcalc examples/*.q --- 15,19 ---- appdir = $(pkgdatadir)/apps/$(app) ! PIXMAPS = pixmaps/qcalc.png pixmaps/flag.png pixmaps/1rightarrow.png pixmaps/1rightarrow-green.png DISTFILES = Makefile COPYING README calclib.q $(app).desktop $(app).q *.ui $(PIXMAPS) doc/Makefile doc/*.html doc/*.png doc/*.xml doc/*.texi doc/texinfo.tex examples/*.qcalc examples/*.q |
From: Albert G. <ag...@us...> - 2007-11-15 00:10:41
|
Update of /cvsroot/q-lang/qcalc/pixmaps In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16972/pixmaps Added Files: 1rightarrow-green.png Log Message: added 'task button' GUI element --- NEW FILE: 1rightarrow-green.png --- (This appears to be a binary file; contents omitted.) |
From: Albert G. <ag...@us...> - 2007-11-15 00:08:37
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16041 Modified Files: calclib.q qcalc.q Log Message: added 'task button' GUI element, minor bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.143 retrieving revision 1.144 diff -C2 -d -r1.143 -r1.144 *** qcalc.q 13 Nov 2007 11:52:27 -0000 1.143 --- qcalc.q 15 Nov 2007 00:08:33 -0000 1.144 *************** *** 178,183 **** qt TIMER "start" 300, // some pixmaps ! [FLAG, RES, NULLPM] = map (qt_new "QPixmap") ! [which "pixmaps/flag.png", which "pixmaps/1rightarrow.png", ()], // dictionary of edited and computed cells CELLS = ref emptyhdict, EVAL = ref emptyhdict, XREF = ref emptyhdict, --- 178,188 ---- qt TIMER "start" 300, // some pixmaps ! [FLAG, RES, TASKB, TASKA, NULLPM] = map (qt_new "QPixmap") ! [which "pixmaps/flag.png", ! which "pixmaps/1rightarrow.png", ! which "pixmaps/1rightarrow.png", ! which "pixmaps/1rightarrow-green.png", ! ()], ! TASKPM = [TASKB,TASKA], // dictionary of edited and computed cells CELLS = ref emptyhdict, EVAL = ref emptyhdict, XREF = ref emptyhdict, *************** *** 776,779 **** --- 781,790 ---- (reg 1,reg 2), (I,J) = val K; + = qt X "setIconSet" ICONSET + where [(K,S)] = regex "" + "^\\+\\+\\+ Taskstate: (\\([0-9]+,[0-9]+\\)) ([0-9]+)$" S + (reg 1,reg 2), + (I,J) = val K, Y = val S, X = gui_elem (I,J), + ICONSET = qt_new "QIconSet" (TASKPM!Y); = qt LOG "append" S || qt LOG "scrollToBottom" () otherwise; *************** *** 1055,1059 **** --- 1066,1076 ---- qt TABLE "clearSelection" (); + private yytask KEY MSG; + clear_cell (I,J) + where X:QtObject = gui_elem (I,J), ("MyTaskButton"|_) = qt_mob_data X: + = // nuke an existing background thread + send_expr '(yytask (I,J) ()) || + fail; // falls through to below if (I,J) = real_index (I,J): = qt TABLE "clearCell" (I,J) if not has_table_item (I,J); *************** *** 1101,1105 **** where (I,J) = real_index (I,J) if is_global and then not is_recursive: ! = process_gui (I,J) X || digest_loop where X:QtObject = gui_elem (I,J); = post MSGS '(check_last_gui (I,J,X)) --- 1118,1122 ---- where (I,J) = real_index (I,J) if is_global and then not is_recursive: ! = process_gui2 (I,J) X || digest_loop where X:QtObject = gui_elem (I,J); = post MSGS '(check_last_gui (I,J,X)) *************** *** 1188,1196 **** gui_update X (I,J) _ ! where (I,J) = real_index (I,J) if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then set_current_cell (I,J) || ! process_gui (I,J) X || digest_loop; check_editing = EDITED := true || --- 1205,1215 ---- gui_update X (I,J) _ ! where (I,J) = real_index (I,J), (CC|_) = qt_mob_data X if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then set_current_cell (I,J) || ! if CC = "MyTaskButton" then ! send_expr '(yytask (I,J) ~(qt X "isOn" ())) || ! process_gui2 (I,J) X || digest_loop; check_editing = EDITED := true || *************** *** 2457,2460 **** --- 2476,2499 ---- ICONSET = qt_new "QIconSet" PM; + taskbutton_gui (I,J) () (TEXT,INIT) + = qt X "setToggleButton" true || + qt X "setOn" INIT || + qt_connect X (SIGNAL "toggled(bool)") + X (SLOT "guiUpdate()") || + qt TABLE "setCellWidget" (I,J,X) || IT + if not is_nil IT and then not is_nil X + where ICONSET = qt_new "QIconSet" TASKB, + X:QtObject = qt_object "QPushButton" + (if is_qt_object ICONSET then (ICONSET,TEXT,TABLE) + else (TEXT,TABLE)) + "MyTaskButton" (I,J) [] + // slots + [("guiUpdate()",gui_update)] [], + IT:QtObject = make_table_item (I,J,X) + (qt_val "QTableItem" "Never"); + + taskbutton_gui (I,J) X:QtObject (TEXT,INIT) + = qt X "setText" TEXT || qt X "setOn" INIT; + spinbox_gui (I,J) () (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V) = // FIXME: implement more appropriate validation here *************** *** 2540,2545 **** = slider_gui if C = "QSlider"; ! = if qt X "isToggleButton" () then togglebutton_gui else pushbutton_gui if C = "QPushButton"; // = printf "unknown GUI element %s\n" C || fail otherwise; --- 2579,2586 ---- = slider_gui if C = "QSlider"; ! = if CC = "MyTaskButton" then taskbutton_gui ! else if qt X "isToggleButton" () then togglebutton_gui else pushbutton_gui + where (CC|_) = qt_mob_data X if C = "QPushButton"; // = printf "unknown GUI element %s\n" C || fail otherwise; *************** *** 2605,2614 **** if checknum 'Y where 'Y = valq S if C = "QSlider"; = qt X "setOn" Y if checkbool 'Y where 'Y = valq S if (C = "QPushButton") and then qt X "isToggleButton" (); = () if C = "QPushButton"; ! = //printf "bad value %s for GUI element %s\n" (str S,C) || ! () otherwise; // Convert a spinbox value; use the special value text and the text->value --- 2646,2662 ---- if checknum 'Y where 'Y = valq S if C = "QSlider"; + = if checkstr 'Y then + qt X "setText" Y + else if checkbool 'Y then + qt X "setOn" Y + // else printf "bad value %s for GUI element %s\n" (str S,C) + where ("MyTaskButton"|_) = qt_mob_data X, 'Y = valq S + if (C = "QPushButton") and then qt X "isToggleButton" (); = qt X "setOn" Y if checkbool 'Y where 'Y = valq S if (C = "QPushButton") and then qt X "isToggleButton" (); = () if C = "QPushButton"; ! // = printf "bad value %s for GUI element %s\n" (str S,C); ! = () otherwise; // Convert a spinbox value; use the special value text and the text->value *************** *** 2631,2635 **** (qt X "setStringList" $ append L S || qt X "setCurrentItem" N) || ! process_gui (I,J) X || digest_loop where S = qt X "currentText" (), N = qt X "count" (), L = map (qt X "text") [0..N-1] --- 2679,2683 ---- (qt X "setStringList" $ append L S || qt X "setCurrentItem" N) || ! process_gui2 (I,J) X || digest_loop where S = qt X "currentText" (), N = qt X "count" (), L = map (qt X "text") [0..N-1] *************** *** 2638,2642 **** = // confine the value to the given range and step size if Y<>Y0 then recursive (qt X "setValue" Y) || ! process_gui (I,J) X || digest_loop where Y0 = qt X "value" (), MIN = qt X "minValue" (), --- 2686,2690 ---- = // confine the value to the given range and step size if Y<>Y0 then recursive (qt X "setValue" Y) || ! process_gui2 (I,J) X || digest_loop where Y0 = qt X "value" (), MIN = qt X "minValue" (), *************** *** 3055,3059 **** and the executing script). */ ! private yyeval KEY X, yyset KEY X, yyclear X, yyval KEY; parse S = 'X --- 3103,3107 ---- and the executing script). */ ! private yyeval KEY X, yyset KEY X, yyclear X, yyval KEY, yytask KEY MSG; parse S = 'X *************** *** 3239,3242 **** --- 3287,3297 ---- = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" + "^\\+\\+\\+ Taskbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S + (reg 1,reg 2), + (I1,J1) = val K1, (TEXT,INIT) = val S1, + IT:QtObject = make_gui taskbutton_gui (I1,J1) + (TEXT,INIT); + = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] + where [(K1,S1)] = regex "" "^\\+\\+\\+ Combobox: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), *************** *** 3343,3353 **** process_gui (I,J) X ! = // set the new value in the inferior process ! // (check whether the value is actually transferable) ! if checkval X then submit_val (I,J) X || ! // do the necessary reevaluations ! if check_interp then compute V ! where V = eval_list (cst false) (I,J), ! X = gui_getval X; process1 (I,J,S) --- 3398,3410 ---- process_gui (I,J) X ! = if check_interp then compute V ! where V = eval_list (cst false) (I,J); ! ! process_gui2 (I,J) X ! = // make sure that the new value is set in the inferior ! // process (also check that the value is transferable) ! if checkval Y then submit_val (I,J) Y || ! process_gui (I,J) X ! where Y = gui_getval X; process1 (I,J,S) Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** calclib.q 10 Nov 2007 13:42:12 -0000 1.25 --- calclib.q 15 Nov 2007 00:08:33 -0000 1.26 *************** *** 6,16 **** operations of this module in your spreadsheet script. ! However, for QCalc to work properly, this script needs to be on the QPATH, therefore it is recommended that you install QCalc under the prefix where your Q installation lives. Otherwise you will have to set your QPATH accordingly. */ - /* Public access operations for use in spreadsheets. */ - /* Access the row and column indices of the cell currently being computed. The index function returns both indices as a pair (I,J) where I and J are --- 6,14 ---- operations of this module in your spreadsheet script. ! Note that for QCalc to work properly, this script needs to be on the QPATH, therefore it is recommended that you install QCalc under the prefix where your Q installation lives. Otherwise you will have to set your QPATH accordingly. */ /* Access the row and column indices of the cell currently being computed. The index function returns both indices as a pair (I,J) where I and J are *************** *** 35,42 **** The most useful routine is the cellindex function which can be used with a ! quoted cell symbol to embed symbolic cell names used as parameters to ! functions like setval into formulas, where they are adjusted automatically ! when copied or filled (actually, this conversion is done by setval et al ! automagically). */ public cellindex X, cellstr KEY, cellname KEY; --- 33,40 ---- The most useful routine is the cellindex function which can be used with a ! quoted cell symbol to embed symbolic cell names into formulas, where they ! are adjusted automatically when copied or filled (this conversion is ! already built into setval et al, so you do not have to use cellindex ! explicitly for these). */ public cellindex X, cellstr KEY, cellname KEY; *************** *** 49,53 **** /* Definition of GUI elements in table cells. Currently supported are checkboxes, comboboxes (both non-editable and editable), spinboxes, ! horizontal and vertical sliders, push and toggle buttons. The argument tuple ARGS depends on the specific kind of widget: --- 47,51 ---- /* Definition of GUI elements in table cells. Currently supported are checkboxes, comboboxes (both non-editable and editable), spinboxes, ! horizontal and vertical sliders, push buttons and toggle buttons. The argument tuple ARGS depends on the specific kind of widget: *************** *** 142,149 **** hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; /* Set a cell value (and return that value). The given cell index KEY can either be in the numeric format as returned by the index function or in any of the symbolic formats supported by the cellindex routine (see above), and ! X may be any Q expression. If the given cell is an ordinary cell (no GUI element), then the current cell value is overwritten, so you should make sure that you do not have important data there. For GUI elements, the value --- 140,216 ---- hslider ARGS, vslider ARGS, pushbutton ARGS, togglebutton ARGS; + /* The task button is a special toggle button with an associated background + task (Q thread) to be executed in the inferior Q process. The ARGS + parameter is the same as for togglebutton, without the ICON parameter + (instead, the icon on the button is set and animated automatically in + response to the current activation status of the thread). The special X + parameter is the Q expression to be evaluated by the task. + + Inside the background task, the task_input, task_index, task_row and + task_column functions are available to provide the input semaphore and the + cell index of the task, respectively. (Note that the index, row and column + functions don't work in background tasks, they can only be used inside + formulas, so you have to use task_index, task_row and task_column instead. + Also note that these values are only available in the original background + task started by the taskbutton function; if your task in turn creates other + threads which need to access these values, you have to pass them on to the + secondary threads.) + + The task_input semaphore is a Q semaphore queue used to communicate values + to the executing task in response to GUI actions inside QCalc. Usually + these are either 'true' or 'false', and are sent when the button state + changes (true = button is switched on, i.e. the task was "started" by the + user; false = button is off, the task was "stopped" or "paused"). The + background task can respond to these by taking some appropriate action, + e.g., pause operation (or terminate altogether) if the 'false' value is + sent, or resume operation (if still active) when 'true' is sent. Note that + it is completely up to the task how it actually responds to these messages, + if at all. However, it is a good idea to have the task at least empty the + semaphore in regular time intervals to prevent the semaphore from being + flooded with useless messages. (In any case the semaphore queue will be + initially empty when the tread is started.) + + The task_input semaphore may also yield a quoted expression value to + indicate that the task button itself was updated while the task is still + running. This happens when a triggered update of the button is caused by + some requisite cells of the task button formula changing values. In such a + case, rather than reexecuting the taskbutton function and restarting the + task from scratch, the button's X parameter is send via the semaphore as a + quoted expression. Again, it is completely up to the task how it handles + such messages. It may completely ignore the message, but a more appropriate + response would be to just replace itself with the sent expression. + Alternatively, the task may update its own internal state accordingly and + continue processing. In the latter case, it is often convenient to employ + the standard library special form 'case' to extract the needed values from + the quoted expression. + + At any time, the background task can also send values back to the hosting + QCalc process, using the setval function (see below) with task_index as the + KEY argument. For instance, you can do a 'setval task_index false' to + indicate that processing has finished and the task is stopped (this is also + done automatically when the thread terminates). Currently, the recognized + values to be sent back are 'false' (the task is stopped), 'true' (the task + has been started, maybe in response to an asynchronous event), and + arbitrary string values (which change the text label shown on the task + button). QCalc will update the button in response to these messages and + also change the cell value of the task button accordingly, which may + trigger updates in other, dependent cells, see the description of the + setval function below for further details. + + Note that, no matter what the purported "start/stopped" status of the + button is, the user can always check whether the task associated with the + button is currently up and running by taking a look at the arrow symbol + shown on the button. If the task is still executing, the arrow symbol will + be "lit" in green, otherwise it will be greyed out. Also note that in the + latter case, if the thread has exited when the user starts it by pressing + the button, the task will be restarted automatically. */ + + public special taskbutton ~ARGS X; + public task_input, task_index, task_row, task_column; + /* Set a cell value (and return that value). The given cell index KEY can either be in the numeric format as returned by the index function or in any of the symbolic formats supported by the cellindex routine (see above), and ! X may be any Q expression. If the given cell is an ordinary cell (no GUI element), then the current cell value is overwritten, so you should make sure that you do not have important data there. For GUI elements, the value *************** *** 159,166 **** the given list value. For the matrix function, Xs must be a list of lists which are all of the same size; the component lists become the rows of the ! matrix. rowvect and colvect are convenience functions to create matrices ! with just one row or column for a given list of values, respectively. In ! any case the matrix or vector is inserted into the table starting at the ! given index KEY (given in any of the formats supported by setval). */ public matrix KEY Xs, rowvect KEY Xs, colvect KEY Xs; --- 226,234 ---- the given list value. For the matrix function, Xs must be a list of lists which are all of the same size; the component lists become the rows of the ! matrix. The rowvect and colvect routines are convenience functions to ! create matrices with just one row or column for a given list of values, ! respectively. In any case the matrix or vector is inserted into the table ! starting at the given index KEY (given in any of the formats supported by ! setval). */ public matrix KEY Xs, rowvect KEY Xs, colvect KEY Xs; *************** *** 175,179 **** var YYDATA = ref emptyhdict, YYKEY = ref (); ! public yymain, yyval KEY, yyset KEY VAL, yyclear KEY; public special yyeval ~KEY VAL; private yyloop, yyout X, yyerror X; --- 243,247 ---- 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; *************** *** 366,369 **** --- 434,479 ---- where (I,J) = get YYKEY; + /* The task button. */ + + var YYTASKS = ref emptyhdict, YYSEM = ref emptyhdict; + + task_input = SEM + where (I,J,SEM) = get YYSEM!thread_no this_thread; + task_index = (I,J) + where (I,J,SEM) = get YYSEM!thread_no this_thread; + task_row = I where (I,J) = task_index; + task_column = J where (I,J) = task_index; + + private begin_task ARGS, end_task; + + taskbutton S:String X + = taskbutton (S,false) X; + taskbutton (S:String,INIT:Bool) X + where (I,J) = get YYKEY: + // update an old task if still present + = do (yytask (I,J)) ['X,INIT] || + printf "\f+++ Taskbutton: %s %s\n" + (str (I,J),str (S,INIT)) || yyset (I,J) INIT || INIT + where (H,_,'_) = get YYTASKS!(I,J); + // start up a new task + = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) || + post SEM INIT || + printf "\f+++ Taskbutton: %s %s\n" + (str (I,J),str (S,INIT)) || yyset (I,J) INIT || INIT + where SEM:Semaphore = semaphore, + H:Thread = + thread (begin_task (I,J,SEM) || catch id X || end_task); + + /* Watchdogs for the beginning and end of a task. */ + + begin_task (I,J,SEM) + = YYSEM := insert (get YYSEM) + (thread_no this_thread,(I,J,SEM)) || + printf "\f+++ Taskstate: %s 1\n" (str (I,J)); + + end_task = setval (I,J) false || + printf "\f+++ Taskstate: %s 0\n" (str (I,J)) + where (I,J) = task_index; + /* setval and friends. */ *************** *** 416,422 **** yyset KEY VAL = //printf "INTERP: SET %s := %s\n" (cellstr KEY,str VAL) || flush || ! YYDATA := insert (get YYDATA) (KEY,VAL) || VAL where VAL = YYKEY := KEY || VAL; yyclear KEY = //printf "INTERP: CLEAR %s\n" (cellstr KEY) || flush || YYDATA := delete (get YYDATA) KEY; --- 526,584 ---- yyset KEY VAL = //printf "INTERP: SET %s := %s\n" (cellstr KEY,str VAL) || flush || ! YYDATA := insert (get YYDATA) (KEY,VAL) || YYKEY := () || VAL where VAL = YYKEY := KEY || VAL; yyclear KEY = //printf "INTERP: CLEAR %s\n" (cellstr KEY) || flush || YYDATA := delete (get YYDATA) KEY; + + /* Substitute cell values into task expressions. */ + + special subst X; + + subst ''X = ''X; + subst '(yyval (I,J)) + = 'X where X = yyval (I,J); + + subst '(X Y) = '(`(subst 'X) `(subst 'Y)); + subst '(X|Y) = '(`(subst 'X)|`(subst 'Y)); + subst '[X|Y] = '[`(subst 'X)|`(subst 'Y)]; + subst '{X|Y} = '{`(subst 'X)|`(subst 'Y)}; + + subst 'X = 'X otherwise; + + /* These are sent by the parent process to update and abolish a task. */ + + /* Update a task with a new started/stopped status. */ + + yytask (I:Int,J:Int) B:Bool + where (H,SEM,'X) = get YYTASKS!(I,J): + // thread is still alive and kicking; pass the message + = post SEM B if isthread H and then active H; + // thread has terminated and is activated again, restart it + = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,'X) + where SEM:Semaphore = semaphore, + H:Thread = + thread (begin_task (I,J,SEM) || catch id X || end_task) + if B; + // thread has terminated and is deactivated, put it in limbo + = YYTASKS := insert (get YYTASKS) (I,J;(),(),'X) || + YYSEM := delete (get YYSEM) (thread_no H) + if isthread H; + + /* Update a task with a new thread expression. */ + + yytask (I:Int,J:Int) 'X + where (H,SEM,'_) = get YYTASKS!(I,J): + = puts "Task updated\n" || fail; + = post SEM (subst 'X) if isthread H and then active H; + = YYTASKS := insert (get YYTASKS) (I,J;H,SEM,subst 'X); + + /* Kill a task. */ + + yytask (I:Int,J:Int) () + where (H,SEM,'X) = get YYTASKS!(I,J): + = puts "Task killed\n" || fail; + = cancel H || YYTASKS := delete (get YYTASKS) (I,J) || + YYSEM := delete (get YYSEM) (thread_no H) + if isthread H; + = YYTASKS := delete (get YYTASKS) (I,J); |