[q-lang-cvs] qcalc calclib.q,1.18,1.19 qcalc.q,1.113,1.114
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-09 10:41:27
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6968 Modified Files: calclib.q qcalc.q Log Message: perform incremental updates of GUI elements, so that they can also be used to display other values Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** qcalc.q 8 Nov 2007 21:42:57 -0000 1.113 --- qcalc.q 9 Nov 2007 10:41:22 -0000 1.114 *************** *** 555,559 **** special local X; ! local X = begin_local || X || end_local; /* Similarly, evaluations triggered by updates of cell and GUI elements are --- 555,559 ---- special local X; ! local X = end_local || Y where Y = begin_local || X; /* Similarly, evaluations triggered by updates of cell and GUI elements are *************** *** 568,572 **** special recursive X; ! recursive X = begin_recursive || X || end_recursive; @1 --- 568,572 ---- special recursive X; ! recursive X = end_recursive || Y where Y = begin_recursive || X; @1 *************** *** 691,695 **** else (process_sel2 [(I,J,X)] || merge_undo (I,J)) ! where X = process_update (I,J) S if get STATE = 4 where [(K,S)] = regex "" --- 691,695 ---- else (process_sel2 [(I,J,X)] || merge_undo (I,J)) ! where X = recursive (process_update (I,J) S) if get STATE = 4 where [(K,S)] = regex "" *************** *** 2044,2049 **** /* GUI elements. ***********************************************************/ ! /* Note that the creation of the GUI elements is handled by the ! collect_results routine below. */ /* Get the value of a GUI element. */ --- 2044,2228 ---- /* GUI elements. ***********************************************************/ ! /* Create a new or update an existing GUI element. */ ! ! checkbox_gui (I,J) () (S,INIT) ! = qt IT "setChecked" INIT || ! qt TABLE "setItem" (I,J,IT) || IT ! if not is_nil IT ! where IT:QtObject = qt_new "QCheckTableItem" (TABLE,S); ! ! checkbox_gui (I,J) X:QtObject (S,INIT) ! = qt X "setText" S || qt X "setChecked" INIT; ! ! combobox_gui (I,J) () (SL,INIT) ! = qt IT "setCurrentItem" INIT || ! qt TABLE "setItem" (I,J,IT) || IT ! if not is_nil IT ! where IT:QtObject = qt_new "QComboTableItem" ! (TABLE,SL,false); ! ! combobox_gui (I,J) X:QtObject (SL,INIT) ! = qt X "setStringList" SL || qt X "setCurrentItem" INIT; ! ! comboedit_gui (I,J) () (SL,INIT) ! = qt IT "setCurrentItem" INIT || ! qt TABLE "setItem" (I,J,IT) || IT ! if not is_nil IT ! where IT:QtObject = qt_new "QComboTableItem" ! (TABLE,SL,true); ! ! comboedit_gui (I,J) X:QtObject (SL,INIT) ! = qt X "setStringList" SL || gui_setval X $ str INIT; ! ! pushbutton_gui (I,J) () (TEXT,ICON) ! = qt_connect X (SIGNAL "pressed()") X (SLOT "guiUpdate()") || ! qt_connect X (SIGNAL "released()") X (SLOT "guiUpdate()") || ! qt TABLE "setItem" (I,J,IT) || ! qt TABLE "setCellWidget" (I,J,X) || ! qt IT "setReplaceable" false || 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)) ! "MyPushButton" (I,J) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT:QtObject = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] []; ! ! pushbutton_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 || ! qt X "setOn" INIT || ! qt_connect X (SIGNAL "toggled(bool)") ! X (SLOT "guiUpdate()") || ! qt TABLE "setItem" (I,J,IT) || ! qt TABLE "setCellWidget" (I,J,X) || ! qt IT "setReplaceable" false || 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)) ! "MyToggleButton" (I,J) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT:QtObject = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] []; ! ! togglebutton_gui (I,J) X:QtObject (TEXT,ICON,INIT) ! = qt X "setText" TEXT || qt X "setIconSet" ICONSET || ! qt X "setOn" INIT ! where PM = ! if null ICON then NULLPM ! else qt_new "QPixmap" ICON, ! ICONSET = qt_new "QIconSet" PM; ! ! spinbox_gui (I,J) () (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V) ! = // FIXME: implement more appropriate validation here ! // currently we just switch it off ! qt X "setValidator" nil || ! qt X "setValue" INIT || ! if not null SPECIAL then ! qt X "setSpecialValueText" SPECIAL || ! if not null PREF then qt X "setPrefix" PREF || ! if not null SUFF then qt X "setSuffix" SUFF || ! qt_connect X (SIGNAL "valueChanged(int)") ! X (SLOT "guiUpdate()") || ! qt TABLE "setItem" (I,J,IT) || ! qt TABLE "setCellWidget" (I,J,X) || ! qt IT "setReplaceable" false || IT ! if not is_nil IT and then not is_nil X ! where X:QtObject = qt_object "QSpinBox" ! (MIN,MAX,STEP,TABLE) ! "MySpinBox" (I,J) ! // override mapValueToText and mapTextToValue methods ! [("mapValueToText",v2t V2T),("mapTextToValue",t2v T2V)] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT:QtObject = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] []; ! ! spinbox_gui (I,J) X:QtObject (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V) ! = qt_set_cb X "mapValueToText" (v2t V2T) || ! qt_set_cb X "mapTextToValue" (t2v T2V) || ! qt X "setMinValue" MIN || qt X "setMaxValue" MAX || ! qt X "setLineStep" STEP || ! qt X "setSpecialValueText" SPECIAL || ! qt X "setPrefix" PREF || qt X "setSuffix" SUFF || ! qt X "setValue" INIT; ! ! slider_gui (I,J) () (MIN,MAX,STEP,INIT,VERT) ! = qt X "setLineStep" STEP || ! qt_connect X (SIGNAL "valueChanged(int)") ! X (SLOT "guiUpdate()") || ! qt TABLE "setItem" (I,J,IT) || ! qt TABLE "setCellWidget" (I,J,X) || ! qt IT "setReplaceable" false || IT ! if not is_nil IT and then not is_nil X ! where X:QtObject = qt_object "QSlider" ! (MIN,MAX,STEP,INIT, ! qt_val "Qt" (if VERT then "Vertical" else "Horizontal"), ! TABLE) ! "MySlider" (I,J) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT:QtObject = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] []; ! ! slider_gui (I,J) X:QtObject (MIN,MAX,STEP,INIT,VERT) ! = qt X "setMinValue" MIN || qt X "setMaxValue" MAX || ! qt X "setPageStep" STEP || qt X "setValue" INIT; ! ! /* Text<->value conversion routines for spinboxes. */ ! ! v2t V2T X _ V = S if not null S and then (V=MIN) ! where S:String = qt X "specialValueText" (), ! MIN = qt X "minValue" (); ! = S where S:String = V2T V; ! = str V otherwise; ! t2v T2V X _ _ where S:String = qt X "cleanText" (): ! = MIN if not null S and then (S=S1) ! where S1:String = qt X "specialValueText" (), ! MIN = qt X "minValue" (); ! = V where V:Int = T2V S; ! = val S otherwise; ! ! fstr MIN STEP V = sprintf (get FFORMAT) $ MIN+V*STEP; ! 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 qt X "isToggleButton" () then togglebutton_gui ! else pushbutton_gui ! if C = "QPushButton"; ! // = printf "unknown GUI element %s\n" C || fail otherwise; /* Get the value of a GUI element. */ *************** *** 2073,2083 **** gui_setval X S where C:String = class_name X: ! = recursive (qt X "setChecked" Y) if checkbool 'Y where 'Y = valq S if C = "QCheckTableItem"; = if all (<>S) L then - recursive (qt X "setStringList" $ append L S || qt X "setCurrentItem" N) where S = Y, N = qt X "count" (), L = map (qt X "text") [0..N-1] --- 2252,2263 ---- 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 || qt X "setCurrentItem" N) + else + qt X "setCurrentItem" S where S = Y, N = qt X "count" (), L = map (qt X "text") [0..N-1] *************** *** 2085,2089 **** if (C = "QComboTableItem") and then qt X "isEditable" (); ! = recursive (qt X "setCurrentItem" S) if any (=S) L where S = Y, --- 2265,2269 ---- if (C = "QComboTableItem") and then qt X "isEditable" (); ! = qt X "setCurrentItem" S if any (=S) L where S = Y, *************** *** 2091,2095 **** if checkstr 'Y where 'Y = valq S if C = "QComboTableItem"; ! = if Y<>Y0 then recursive (qt X "setValue" Y) where Y0 = qt X "value" (), MIN = qt X "minValue" (), --- 2271,2275 ---- if checkstr 'Y where 'Y = valq S if C = "QComboTableItem"; ! = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), MIN = qt X "minValue" (), *************** *** 2099,2103 **** where Y:Int = make_spinbox_value X S if C = "QSpinBox"; ! = if Y<>Y0 then recursive (qt X "setValue" Y) where Y0 = qt X "value" (), MIN = qt X "minValue" (), --- 2279,2283 ---- where Y:Int = make_spinbox_value X S if C = "QSpinBox"; ! = if Y<>Y0 then qt X "setValue" Y where Y0 = qt X "value" (), MIN = qt X "minValue" (), *************** *** 2106,2110 **** if checknum 'Y where 'Y = valq S if C = "QSlider"; ! = recursive (qt X "setOn" Y) if checkbool 'Y where 'Y = valq S if (C = "QPushButton") and then qt X "isToggleButton" (); --- 2286,2290 ---- 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" (); *************** *** 2618,2623 **** if (S = "+++ Syntax error.") or else not null (regex "" "^\\+\\+\\+ Exception: (.*)$" S ()); ! /* Asynchronous message to change a cell. We update the cell right now, but ! defer triggering of dependent cells until we have finished processing. */ = results_loop (insert U ((I1,J1),X)) [(I,J)|V] where X = process_update2 (I1,J1) S1 --- 2798,2802 ---- if (S = "+++ Syntax error.") or else not null (regex "" "^\\+\\+\\+ Exception: (.*)$" S ()); ! /* Message to change a cell (calclib::setval). */ = results_loop (insert U ((I1,J1),X)) [(I,J)|V] where X = process_update2 (I1,J1) S1 *************** *** 2626,2719 **** (reg 1,reg 2), (I1,J1) = val K1; ! /* Messages to create GUI elements in cells. */ ! = qt IT "setChecked" INIT || ! qt TABLE "setItem" (I1,J1,IT) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Checkbox: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (S1,INIT) = val S1, ! IT = qt_new "QCheckTableItem" (TABLE,S1); ! = qt TABLE "setItem" (I1,J1,IT) || ! qt TABLE "setCellWidget" (I1,J1,X) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Pushbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (TEXT,ICON) = val S1, ! ICONSET = ! if null ICON then () ! else qt_new "QIconSet" $ qt_new "QPixmap" ICON, ! X = qt_object "QPushButton" ! (if is_qt_object ICONSET ! then (ICONSET,TEXT,TABLE) ! else (TEXT,TABLE)) ! "MyPushButton" (I1,J1) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] [], ! _ = qt_connect X (SIGNAL "pressed()") ! X (SLOT "guiUpdate()") || ! qt_connect X (SIGNAL "released()") ! X (SLOT "guiUpdate()") || ! qt IT "setReplaceable" false; ! = qt X "setToggleButton" true || ! qt TABLE "setItem" (I1,J1,IT) || ! qt TABLE "setCellWidget" (I1,J1,X) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Togglebutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), ! (I1,J1) = val K1, (TEXT,ICON) = val S1, ! ICONSET = ! if null ICON then () ! else qt_new "QIconSet" $ qt_new "QPixmap" ICON, ! X = qt_object "QPushButton" ! (if is_qt_object ICONSET ! then (ICONSET,TEXT,TABLE) ! else (TEXT,TABLE)) ! "MyToggleButton" (I1,J1) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] [], ! _ = qt_connect X (SIGNAL "toggled(bool)") ! X (SLOT "guiUpdate()") || ! qt IT "setReplaceable" false; ! = qt IT "setCurrentItem" INIT || ! qt TABLE "setItem" (I1,J1,IT) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Combobox: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (SL,INIT) = val S1, ! IT = qt_new "QComboTableItem" (TABLE,SL,false); ! = qt IT "setCurrentItem" INIT || ! qt TABLE "setItem" (I1,J1,IT) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Comboedit: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (SL,INIT) = val S1, ! IT = qt_new "QComboTableItem" (TABLE,SL,true); ! = qt X "setValue" INIT || ! if not null SPECIAL then ! qt X "setSpecialValueText" SPECIAL || ! if not null PREF then ! qt X "setPrefix" PREF || ! if not null SUFF then ! qt X "setSuffix" SUFF || ! qt TABLE "setItem" (I1,J1,IT) || ! qt TABLE "setCellWidget" (I1,J1,X) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Spinbox: (\\([0-9]+,[0-9]+\\)) (.*)$" S --- 2805,2842 ---- (reg 1,reg 2), (I1,J1) = val K1; ! /* Messages to create GUI elements in cells (calclib::combobox et al). */ ! = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Checkbox: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (S1,INIT) = val S1, ! IT:QtObject = make_gui checkbox_gui (I1,J1) (S1,INIT); ! = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Pushbutton: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (TEXT,ICON) = val S1, ! IT:QtObject = make_gui pushbutton_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), ! (I1,J1) = val K1, (TEXT,ICON,INIT) = val S1, ! IT:QtObject = make_gui togglebutton_gui (I1,J1) ! (TEXT,ICON,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), (I1,J1) = val K1, (SL,INIT) = val S1, ! IT:QtObject = make_gui combobox_gui (I1,J1) (SL,INIT); ! = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Comboedit: (\\([0-9]+,[0-9]+\\)) (.*)$" S (reg 1,reg 2), (I1,J1) = val K1, (SL,INIT) = val S1, ! IT:QtObject = make_gui comboedit_gui (I1,J1) (SL,INIT); ! = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Spinbox: (\\([0-9]+,[0-9]+\\)) (.*)$" S *************** *** 2721,2744 **** (I1,J1) = val K1, (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V) = val S1, ! X = qt_object "QSpinBox" (MIN,MAX,STEP,TABLE) ! "MySpinBox" (I1,J1) ! // override mapValueToText and mapTextToValue methods ! [("mapValueToText",v2t V2T),("mapTextToValue",t2v T2V)] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] [], ! _ = qt_connect X (SIGNAL "valueChanged(int)") ! X (SLOT "guiUpdate()") || ! // FIXME: implement more appropriate validation here ! // currently we just switch it off ! qt X "setValidator" nil || ! qt IT "setReplaceable" false; ! = qt X "setLineStep" LSTEP || ! qt TABLE "setItem" (I1,J1,IT) || ! qt TABLE "setCellWidget" (I1,J1,X) || ! insert_cells ((I1,J1),IT) || ! results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Slider: (\\([0-9]+,[0-9]+\\)) (.*)$" S --- 2844,2850 ---- (I1,J1) = val K1, (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V) = val S1, ! IT:QtObject = make_gui spinbox_gui (I1,J1) ! (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF,V2T,T2V); ! = results_loop (insert U ((I1,J1),IT)) [(I,J)|V] where [(K1,S1)] = regex "" "^\\+\\+\\+ Slider: (\\([0-9]+,[0-9]+\\)) (.*)$" S *************** *** 2746,2762 **** (I1,J1) = val K1, (MIN,MAX,STEP,INIT,VERT) = val S1, ! X = qt_object "QSlider" ! (MIN,MAX,STEP,INIT, ! qt_val "Qt" (if VERT then "Vertical" else "Horizontal"), ! TABLE) ! "MySlider" (I1,J1) [] ! // slots ! [("guiUpdate()",gui_update)] [], ! IT = qt_object "QTableItem" ! (TABLE,qt_val "QTableItem" "Never") ! "MyTableItem" X [] [] [], ! _ = qt_connect X (SIGNAL "valueChanged(int)") ! X (SLOT "guiUpdate()") || ! qt IT "setReplaceable" false; // anything else just gets passed to the digest function, and we try again = local (digest S) || results_loop U [(I,J)|V]; --- 2852,2857 ---- (I1,J1) = val K1, (MIN,MAX,STEP,INIT,VERT) = val S1, ! IT:QtObject = make_gui slider_gui (I1,J1) ! (MIN,MAX,STEP,INIT,VERT); // anything else just gets passed to the digest function, and we try again = local (digest S) || results_loop U [(I,J)|V]; *************** *** 2784,2803 **** set_pixmap (I,J) RES; ! /* Text<->value conversion routines for spinboxes. */ ! ! v2t V2T X _ V = S if not null S and then (V=MIN) ! where S:String = qt X "specialValueText" (), ! MIN = qt X "minValue" (); ! = S where S:String = V2T V; ! = str V otherwise; ! t2v T2V X _ _ where S:String = qt X "cleanText" (): ! = MIN if not null S and then (S=S1) ! where S1:String = qt X "specialValueText" (), ! MIN = qt X "minValue" (); ! = V where V:Int = T2V S; ! = val S otherwise; ! fstr MIN STEP V = sprintf (get FFORMAT) $ MIN+V*STEP; ! fval MIN STEP S = round ((V-MIN)/STEP) where V:Num = val S; /* Recompute a single cell, or a collection of cells, and all cells depending --- 2879,2892 ---- set_pixmap (I,J) RES; ! /* Create a new or update an existing GUI element (the actual work is done by ! the creation/update functions under "GUI elements" above). */ ! make_gui TYPE (I,J) ARGS ! = TYPE (I,J) X ARGS || get CELLS!(I,J) ! if eq TYPE TYPE1 ! where X:QtObject = gui_elem (I,J), TYPE1 = gui_gettype X; ! = insert_cells ((I,J),IT) || IT ! where IT:QtObject = TYPE (I,J) () ARGS ! otherwise; /* Recompute a single cell, or a collection of cells, and all cells depending Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** calclib.q 8 Nov 2007 22:15:14 -0000 1.18 --- calclib.q 9 Nov 2007 10:41:22 -0000 1.19 *************** *** 4,11 **** /* This module provides some useful support functions for use in QCalc spreadsheets. You only need to import this if you want to use any of the ! operations of this module in your spreadsheet. 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. */ from hdict import emptyhdict; --- 4,13 ---- /* This module provides some useful support functions for use in QCalc spreadsheets. You only need to import this if you want to use any of the ! 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. */ from hdict import emptyhdict; *************** *** 54,60 **** /* Definition of GUI elements in table cells. Currently supported are checkboxes, comboboxes (both non-editable and editable), spinboxes, ! hoirzontal and vertical sliders, push and toggle buttons. You can find ! examples for all of these in the guiexamples.qcalc spreadsheet included in ! the QCalc distribution. The argument tuple ARGS depends on the specific kind of widget: --- 56,60 ---- /* 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: *************** *** 73,78 **** false otherwise. ! - togglebutton S or togglebutton (S,ICON): Analogous to push buttons, but ! toggle buttons are switched on and off by clicking them. The value of a toggle button is true if it is currently on and false --- 73,80 ---- false otherwise. ! - togglebutton S, togglebutton (S,ICON) or togglebutton (S,ICON,INIT): ! Analogous to push buttons, but toggle buttons are switched on and off by ! clicking them, and have an optional INIT argument which indicates the ! initial state (true or false, the default is false). The value of a toggle button is true if it is currently on and false *************** *** 124,130 **** as if you typed the corresponding value directly into the cell. ! NOTE: These functions will not work if they are executed asynchronously. ! They *must* be executed, either directly or indirectly, from a formula in a ! spreadsheet cell. */ public checkbox ARGS, combobox ARGS, comboedit ARGS, spinbox ARGS, --- 126,147 ---- as if you typed the corresponding value directly into the cell. ! NOTE: These functions will *not* work if they are run asynchronously (i.e., ! in a secondary Q thread of the user script). They *must* be executed, ! either directly or indirectly, from a formula in a spreadsheet cell. ! ! The parameters of all GUI elements can be computed values which may also ! depend on other cell values (including other GUI elements). In this case ! the GUI element will be updated automatically whenever any of the requisite ! cells changes. In particular, you can also use GUI elements to *display* ! values from other cells by specifying the corresponding cell as the INIT ! parameter of the widget. ! ! Moreover, the values of all GUI elements except the push button (which is a ! read-only element) can also be set with setval (see below). This is useful, ! in particular, if the GUI element displays some value which is updated ! asynchronously. ! ! You can find examples for all types of widgets in the guiexamples.qcalc ! spreadsheet included in the QCalc distribution. */ public checkbox ARGS, combobox ARGS, comboedit ARGS, spinbox ARGS, *************** *** 230,237 **** togglebutton S:String ! = togglebutton (S,""); togglebutton (S:String,ICON:String) = printf "\f+++ Togglebutton: %s %s\n" ! (str (I,J),str (S,ICON)) || false where (I,J) = get YYKEY; --- 247,256 ---- togglebutton S:String ! = togglebutton (S,"",false); togglebutton (S:String,ICON:String) + = togglebutton (S,ICON,false); + togglebutton (S:String,ICON:String,INIT:Bool) = printf "\f+++ Togglebutton: %s %s\n" ! (str (I,J),str (S,ICON,INIT)) || false where (I,J) = get YYKEY; *************** *** 286,295 **** --- 305,326 ---- SPECIAL:String) = (MIN,MAX,STEP,INIT,SPECIAL,"",""); + spinbox_args (MIN:Real,MAX:Real,STEP:Real,SPECIAL:String, + SPECIAL) + = (MIN,MAX,STEP,MIN,SPECIAL,"","") + if not null SPECIAL; spinbox_args (MIN:Real,MAX:Real,STEP:Real,INIT:Real, SPECIAL:String,PREF:String) = (MIN,MAX,STEP,INIT,SPECIAL,PREF,""); + spinbox_args (MIN:Real,MAX:Real,STEP:Real,SPECIAL:String, + SPECIAL,PREF:String) + = (MIN,MAX,STEP,MIN,SPECIAL,PREF,"") + if not null SPECIAL; spinbox_args (MIN:Real,MAX:Real,STEP:Real,INIT:Real, SPECIAL:String,PREF:String,SUFF:String) = (MIN,MAX,STEP,INIT,SPECIAL,PREF,SUFF); + spinbox_args (MIN:Real,MAX:Real,STEP:Real,SPECIAL:String, + SPECIAL,PREF:String,SUFF:String) + = (MIN,MAX,STEP,MIN,SPECIAL,PREF,SUFF) + if not null SPECIAL; spinbox ARGS = myspinbox ARGS where ARGS:Tuple = spinbox_args ARGS; |