// Text of project protoTable written on 5/13/95 at 11:20 PM // Beginning of file protoTable.t tableApp := {title: "protoTable example", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, viewScrollUpScript: func() begin theTable:viewScrollUpScript(); end, viewScrollDownScript: func() begin theTable:viewScrollDownScript(); end, viewSetupFormScript: func() begin local a := GetAppParams(); self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight); end, debug: "tableApp", _proto: @157 }; theTable := {def: protoTableDef, viewSetupFormScript: func() begin // clone the table definition first to avoid read only errors def := Clone(def); def.tabProtos := protoTableEntry; // protoTableEntry // For full-width text, the tabWidths MUST fit inside the table or nothing will appear, // so this calculation accomplishes that. It's bogus and redundant and you should, if at // all possible, precalculate and put in a constant here. The 2 at the end leaves space // for the table border on either side. (Sigh) def.tabWidths := viewBounds.right - viewBounds.left - 2 ; def.tabDown := 10; def.tabValueSlot := 'text; def.tabValues := ["foo", "bar", "baz", "qux", "4", "5", "6", "7", "8", "9"]; end, viewBounds: {left: 10, top: 26, right: 201, bottom: 104}, scrollAmount: 1, currentSelection: nil, selectThisCell: func(which) begin // skanky hack to get informed when cells are selected // make sure to call the inherited function, otherwise things // do not get updated properly! inherited:selectThisCell(which); // currentSelection contains the item from the table // definition tabValues array that is selected.... // so use that to set the text slot of theText SetValue(theText, 'text, currentSelection); end, debug: "theTable", viewScrollDownScript: func() begin local biggestTop; local temp := ((viewBounds.bottom - viewBounds.top) / def.tabHeights); temp := if (temp - Floor(temp)) < 0.5 then Floor(temp) else Floor(temp) + 1 ; // biggestTop is the cell index of the topmost cell when // the table is maximally scrolled biggestTop := Max(0, def.tabDown - temp) ; if vOrg < biggestTop then begin vOrg := vOrg + scrollAmount; if vOrg > biggestTop then vOrg := biggestTop ; tabbase:RedoChildren(); :updateSelection(); end; end, _proto: @223 }; AddStepForm(tableApp, theTable); StepDeclare(tableApp, theTable, 'theTable); _view000 := {text: "You Picked:", viewBounds: {left: 10, top: 114, right: 74, bottom: 138}, _proto: @218 }; AddStepForm(tableApp, _view000); theText := {text: "", viewBounds: {left: 74, top: 114, right: 162, bottom: 130}, debug: "theText" , _proto: @218 }; AddStepForm(tableApp, theText); StepDeclare(tableApp, theText, 'theText); _view001 := {viewBounds: {left: 206, top: 41, right: 225, bottom: 64}, viewFormat: 1, buttonPressedScript: func() begin theTable:viewScrollUpScript(); theTable:Dirty(); RefreshViews(); end, _proto: @198 }; AddStepForm(tableApp, _view001); // After Script for "_view001" thisView := _view001; begin // skanky hack to get ROM version of up arrow into // the icon slot. // see the Documentation (interrim or otherwise) // for further explantion of afterScript and beforeScript thisView.icon := ROM_uparrowbitmap ; end _view002 := {viewBounds: {left: 206, top: 68, right: 225, bottom: 88}, viewFormat: 1, buttonPressedScript: func() begin theTable:viewScrollDownScript() ; theTable:Dirty(); RefreshViews(); end, _proto: @198 }; AddStepForm(tableApp, _view002); // After Script for "_view002" thisView := _view002; begin // skanky hack to get ROM version of up arrow into // the icon slot. // see the Documentation (interrim or otherwise) // for further explantion of afterScript and beforeScript thisView.icon := ROM_downarrowbitmap ; end constant |layout_protoTable.t| := tableApp; // End of file protoTable.t