* * * used for reference to the ::getlist:cargo array * * from sys.ch (data dictionary data driven systems only) * #DEFINE GC_SAY_ROW 1 #DEFINE GC_SAY_COL 2 #DEFINE GC_SAY_TEXT 3 #DEFINE GC_SAY_PICT 4 #DEFINE GC_SAY_COLOR 5 #DEFINE GC_FLD_GSB 6 #DEFINE GC_FLD_VALUE 7 #DEFINE GC_FLD_TYP 8 #DEFINE GC_FLD_NO 9 #DEFINE GC_ADMISSION 10 #DEFINE GC_FILE 11 #DEFINE GC_FIELD 12 #DEFINE GC_VFUNC 13 #DEFINE GC_NUM_ITEMS 13 * * * function getScreenParameters(; cChoice,; aValues,; nArrayPtr,; aLits,; abLookup,; oParent,; aPictures,; aPostBlocks,; aPreBlocks) * local aObjs := {} local aParentSize local aPX := { { XBP_PP_COMPOUNDNAME, FONT_TIMES_SMALL } } local aTheseValues local cPicture local cText local cVarType local drawingarea local lRetVal := FALSE local mp1 local mp2 local nBottom local nBoxWidth local nCharWidth local nColorDrawing local nEvent local nHeight local nLenArray local nLenChoice local nLenObjs local nLength local nMaxCharacters local nMaxChoice local nMaxValWidth local nMultiplier local nPosUp local nPtr local nXbpCol local nXbpRow local oCtrl local oDialog local oGet local oPushOk local oStatic local oXbp * nColorDrawing := graMakeRgbColor({153,202,242}) * DEFAULT nArrayPtr TO 1 /* data dictionary data driven systems only DEFAULT aValues TO syslist():oPageGets:aOtherArray DEFAULT oParent TO syslist():oPageGets:oDlg */ aParentSize := oParent:currentSize() * aTheseValues := aValues[nArrayPtr] * nMaxCharacters := maxSingleArray(aLits) nCharWidth := nMaxCharacters * 8.0 nLenChoice := len(cChoice) + 4 nMaxChoice := nLenChoice * 8.0 nMaxValWidth := maxSingleArray(aTheseValues) * nLenArray := len(aTheseValues) * DEFAULT abLookup TO array(nLenArray) * if aPostBlocks == nil aPostBlocks := array(nLenArray) aFill(aPostBlocks,{||.T.}) endif * if aPreBlocks == nil aPreBlocks := array(nLenArray) aFill(aPreBlocks,{||.T.}) endif * nHeight := (20 * nLenArray) + 60 nBottom := nHeight / 4 * nBoxWidth := ; max(nCharWidth,nMaxChoice) + (nMaxValWidth*9) + 20 * * laterlaterlaterlater * should use parent currentsize mcarew /* oDialog := ; GuiStdDialog(; "Details of " + cChoice,; {(800-nBoxWidth)/2,(560-nHeight)/2},; {nBoxWidth,nHeight},; oParent,; setappwindow()) */ * oDialog := ; GuiStdDialog(; "Details of " + cChoice,; {(800-nBoxWidth)/2,(560-nHeight)/2},; {nBoxWidth,nHeight},; oParent) * drawingArea := oDialog:drawingArea drawingArea:setFontCompoundName( "11.Terminal" ) drawingArea:SetColorBG(nColorDrawing) * oDialog:show() * FOR nPtr := 1 to nLenArray * * position * nXbpRow := 30 + ((nLenArray - nPtr) * 20) nXbpCol := 05 * * text * cText := aLits[nPtr] * oStatic := ; XbpStatic():new(; oDialog, , ; {nXbpCol,nXbpRow},; {0,0}) * oStatic:caption := cText oStatic:clipSiblings := .T. oStatic:options := XBPSTATIC_TEXT_VCENTER+XBPSTATIC_TEXT_RIGHT oStatic:autosize := .T. oStatic:SetColorBG(nColorDrawing) oStatic:setFontCompoundName( "11.Terminal" ) * oStatic:create() * aadd(aObjs,oStatic) * * data field * nXbpCol := nCharWidth + 10 * cVarType := "C" * nMultiplier := 9.7 * cVarType := valtype(aTheseValues[nPtr]) * if cVarType == "D" * nLength := 75 cPicture := "@D" * else * do case case cVarType == "C" * nLength := len(aTheseValues[nPtr]) * cPicture := "@!" * do case case nLength == 1 nMultiplier := 17 case nLength < 5 nMultiplier := 12 end case * nLength := nLength * nMulTiplier * case cVarType == "N" * * expects "@K ######" hence -3 * nLength := (len(aPictures[nPtr]) - 3) * 9.7 * end case * endif * oGet := ; XbpGet():new( ; oDialog:drawingArea, , ; {nXbpCol,nXbpRow}, ; {nLength,20}, ; aPX) * oGet:clipSiblings := .T. * oGet:picture := cPicture * oGet:postblock := aPostBlocks[nPtr] oGet:preblock := aPreBlocks[nPtr] * oGet:cargo := array(13) * oGet:cargo[GC_SAY_ROW] := nXbpRow oGet:cargo[GC_SAY_COL] := nXbpCol oGet:cargo[GC_FLD_TYP] := cVarType oGet:cargo[GC_FLD_VALUE] := aTheseValues[nPtr] oGet:cargo[GC_FLD_NO] := nPtr * IF empty(abLookup[nPtr]) else oGet:cargo[GC_VFUNC] := abLookup[nPtr] ENDIF * oGet:datalink := oBlk(oGet) * oGet:create() * oGet:setdata() * aadd(aObjs,oGet) * NEXT * oPushOk := XbpPushButton():new( oDialog:drawingarea, , {10,05}, {84,20} ) oPushOk:caption := "Ok" oPushOk:clipSiblings := .T. oPushOk:tabStop := .T. oPushOk:create() oPushOk:activate := {||lRetVal:=TRUE,PostAppEvent(xbeP_Close,,,oDialog) } * oCtrl := XbpGetController():new(oDialog):create() * setappfocus(oCtrl:window()) * setappfocus(aObjs[2]) * oCtrl:read( , .F. ) * DO WHILE nEvent <> xbeP_Close * nEvent := AppEvent( @mp1, @mp2, @oXbp ) * IF nEvent = xbeP_Keyboard * do case case mp1 == xbeK_ESC * PostAppEvent(xbeP_Close,,,oDialog) * * F2 executes the ablookup code block if any * case mp1 == xbeK_F2 * IF empty(oXbp:cargo[GC_VFUNC]) ELSE EVAL(oXbp:cargo[GC_VFUNC],oXbp) ENDIF * end case * ENDIF * oXbp:handleEvent( nEvent, mp1, mp2 ) * enddo * for nPtr := 1 to nLenArray * * objects are loaded * oGet := aObjs[nPtr*2] * aTheseValues[nPtr] := oGet:getdata() * NEXT * nLenObjs := len(aObjs) * for nPtr := 1 to nLenObjs * aObjs[nPtr]:destroy() * next * oDialog:hide() oDialog:destroy() * return lRetVal * function getValue(oGet) return oGet:cargo[GC_FLD_VALUE] /* * * very complicated example showing use of all parameters * */ FUNCTION autoPayGeneration() * local aBLookup local aDue local aLits local aPictures local aPostBlocks local aPreBlocks local aValues local cChoice local cChequeOrDirect local cFromSupplr local cToSupplr local lRetVal local lRetVal1 local nAns local nAns1 local nBalance local nEndCheque local nPayments local nStartCheque local nThisCheque local nTotalToPay local oSupplr * cChoice := "Choose Range Of Suppliers (Blank All)" cToSupplr := space(12) cFromSupplr := space(12) cChequeOrDirect := "D" aValues := {{cFromSupplr,cToSupplr,cChequeOrDirect},{}} aPictures := {"@!","@!","@!"} aLits := {"From Supplier","To Supplier","Cheque/Direct"} aPostBlocks := ; {; {||.T.},; {||.T.},; {|g|IIF(getValue(g)=="D",.T.,iif(getvalue(g)=="C",.T.,.F.))}; } * aBLookup := ; {; {|g|selectionlookup(g,"SUPPLR")},; {|g|selectionlookup(g,"SUPPLR")},; nil} * lRetVal := ; getscreenparameters(; cChoice,; aValues,; 1,; aLits,; aBLookup,; setappwindow(),; aPictures,; aPostBlocks) * IF lRetVal == TRUE * cFromSupplr := aValues[1][1] cToSupplr := aValues[1][2] cChequeOrDirect := aValues[1][3] * oSupplr := context():new(db():table("SUPPLR")) * do case case !(empty(cFromSupplr)) .AND. empty(cToSupplr) cToSupplr := cFromSupplr case empty(cFromSupplr) .AND. empty(cToSupplr) cFromSupplr := oSupplr:flds:supplr:value oSupplr:bottom() cToSupplr := oSupplr:flds:supplr:value end case * oSupplr:setScope({cFromSupplr},{cToSupplr}) oSupplr:top() * nAns1 := 1 nEndCheque := 0 nStartCheque := 0 * nBalance := 0.00 nPayments := 0 nTotalToPay := 0.00 * do while TRUE * IF oSupplr:atBot exit ENDIF * nBalance := DueToSupplier(oSupplr) * IF nBalance > 0 * nPayments ++ nTotalToPay += nBalance * ENDIF * oSupplr:skip() * enddo * * * IF nPayments > 0 * nAns := ; sysalert(; "Total To Be Paid is " + ; transform(nTotalToPay,"#######.##") + ; "; Paying " + ; alltrim(str(nPayments)) + ; " Creditors " + ; IIF(cChequeOrDirect=="C","Cheques","Direct Credits"),; {"Proceed","Quit"},; setappwindow()) * if nAns == 0 .OR. nAns == 2 * else * lRetVal1 := TRUE * if nAns == 1 * IF cChequeOrDirect == "C" * nStartCheque := 0 * aValues := {{nStartCheque,nEndCheque},{}} * aLits := ; {"Start Cheque No","End Cheque No"} * aPictures := {"@K ######","@K ######"} * aPostBlocks := ; {; {|g|nStartCheque:=getValue(g),.T.},; {||.T.}; } * aPreBlocks := ; {; {|g|.T.},; {|g|; setappfocus(g),; g:cargo[GC_FLD_VALUE]:=nStartCheque+nPayments-1,; g:setdata(g:cargo[GC_FLD_VALUE]),; g:show(),.T.}; } * lRetVal1 := ; getscreenparameters(; "Choose Start / End Cheque Number",; aValues,; 1,; aLits,; ,; setappwindow(),; aPictures,; aPostBlocks,; aPreBlocks) * IF lRetVal1 == TRUE * nStartCheque := aValues[1][1] nEndCheque := aValues[1][2] * ENDIF * ENDIF * endif * ENDIF * ENDIF * oSupplr:destroy() * ENDIF * return nil /* very simple example get date ranges */ * function dateFromTo(dFrom,dTo,cText) * local aPictures local aLits local aRecKey local aValues local cChoice * cChoice := "Select From and To Dates for " + cText aLits := {"Date From","Date To"} aValues := {{dFrom,dTo},{}} aPictures := {"@D","@D"} * getScreenParameters(; cChoice,; aValues,; 1,; aLits,; ,; setappwindow(),; aPictures) * return aValues[1] /* * a get screen parameters for printing routine */ function truckDiary() * local aBLookup local aLits local aPictures local aValues local cChoice local cDest local cShowDetails local cShowTruckByMonth local dEndDate local dStartDate local lRetVal local nTruck local oStatMessage * cShowDetails := "N" cShowTruckByMonth := "Y" dEndDate := date() dStartDate := date()-90 nTruck := 0 * cChoice := "Truck Diary Report selection screen" * aLits := ; {; "Truck No ",; "From Date",; "To Date",; "Show Details Y/N",; "Truck Months Summary Y/N"; } aValues := ; {; {nTruck,; dStartDate,; dEndDate,; cShowDetails,; cShowTruckByMonth; },; {}; } aPictures := ; {; "@K ######",; "@D",; "@D",; "@!",; "@!"; } aBLookup := {{|g|selectionLookup(g,"TRUCK")},,,,} * lRetval := ; getscreenparameters(; cChoice,; aValues,; 1,; aLits,; aBLookup,; setappwindow(),; aPictures) * IF lRetval == TRUE * cDest := setOutPutDevice() * IF cDest == nil else * nTruck := aValues[1][1] dStartDate := aValues[1][2] dEndDate := aValues[1][3] cShowDetails := aValues[1][4] cShowTruckByMonth := aValues[1][5] /* oStatMessage := ; Pleasewait('Truck Diary Report Creation') */ if prntTruckDiary(; nTruck,; dStartDate,; dEndDate,; cShowDetails,; cShowTruckByMonth) * do case case cDest == "PRINTER" * printUserTextFile() * case cDest == "SCREEN" * BrowText(cDest) * end case * endif * ENDIF * ENDIF * return nil /* * * data dictionary data driven systems only * you'll have to write your own as this one use my * db(),table(),column(),field(),index(),trigger(),rule() classes * function selectionLookup(oGet,cFileName,cIndex,cReturnFieldName) * local aPrimeKey local nFieldPos local oLookContext local xRetVal local oOldFocus := setappfocus() * aPrimeKey := generalDetailsBrows(cFileName,TRUE,,"Q",,cIndex) * IF aPrimeKey == nil ELSE * do case case cReturnFieldname == nil * oGet:setdata(aPrimeKey[1]) * otherwise * oLookContext := context():new(db():table(cFilename)) * if oLookContext:seek(aPrimeKey) * nFieldPos := oLookContext:oTable:colpos(cReturnFieldName) * xRetVal := oLookContext:fldget(nFieldPos) * oGet:setdata(xRetVal) * endif * oLookContext:destroy("C") * end case * ENDIF * setappfocus(oOldFocus) * return nil */