VERSION "2.00.WC1" BEGIN ixWindow pickListWN windowStyle = ixWindow::normalTop containingWindow *= NULL derivedFrom *= "ixWindow" rulersOn *= TRUE fontItalic *= FALSE title = "Pick List" fontUnderline *= FALSE enabled *= TRUE backgroundColor *= NULL foregroundColor *= NULL fontName = "Courier New" fontSize = 8 fontBold *= TRUE database = "STORES6" snapToGrid *= FALSE height = 4935 width = 3600 left = 3000 top = 0 helpFile *= NULL classname = "pickListWCL" name = "pickListWN" helpNum *= 0 source *= TRUE shown = FALSE rofID *= 0 @rofFileName *= NULL topicName *= NULL icon *= NULL theStartup *= FALSE characterMode *= FALSE gridOn *= FALSE BEGIN ixListBox pickListLB fontItalic *= NULL fontUnderline *= NULL enabled *= TRUE tabIndex *= NULL tabEnabled *= TRUE backgroundColor *= NULL foregroundColor *= NULL fontName = "Arial" fontSize *= NULL fontBold *= NULL height = 4215 width = 2910 left = 60 top = 75 style *= ixListBox::singleSelect classname *= "ixListBox" name = "pickListLB" helpNum *= 0 itemList = NULL shown *= TRUE sorted = FALSE rofID *= 0 @rofFileName *= NULL handler activate() # pick the highlighted row and return CALL selPickItem(TRUE) CALL mPickListWN.hide() end handler handler select() # turn on the paging keys as required CALL pickAbleMoveBNs(mPickListWN,"EN") end handler END BEGIN ixPictureButton gfFirstRowBN enabled = FALSE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 3075 top = 75 disablePic = ".\gffrd.bmp" pressPic = ".\gffrp.bmp" enablePic = ".\gffre.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "gfFirstRowBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() CALL locatePickList(self) # set buttons as required CALL pickAbleMoveBNs(getWindow(), "EN") end handler END BEGIN ixPictureButton gfPrevPageBN enabled = FALSE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 3075 top = 610 disablePic = ".\gfppd.bmp" pressPic = ".\gfppp.bmp" enablePic = ".\gfppe.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "gfPrevPageBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() CALL locatePickList(self) # set buttons as required CALL pickAbleMoveBNs(getWindow(), "EN") end handler END BEGIN ixPictureButton gfNextPageBN enabled = FALSE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 3075 top = 1145 disablePic = ".\gfnpd.bmp" pressPic = ".\gfnpp.bmp" enablePic = ".\gfnpe.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "gfNextPageBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() CALL locatePickList(self) # set buttons as required CALL pickAbleMoveBNs(getWindow(), "EN") end handler END BEGIN ixPictureButton gfLastRowBN enabled = FALSE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 3075 top = 1680 disablePic = ".\gflrd.bmp" pressPic = ".\gflrp.bmp" enablePic = ".\gflre.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "gfLastRowBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() CALL locatePickList(self) # set buttons as required CALL pickAbleMoveBNs(getWindow(), "EN") end handler END BEGIN ixPictureButton applyBN enabled = TRUE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 2510 top = 4395 disablePic = ".\applyd.bmp" pressPic = ".\applyp.bmp" enablePic = ".\applye.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "applyBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() # pick the highlighted row and return CALL selPickItem(TRUE) CALL mPickListWN.hide() end handler END BEGIN ixPictureButton revertBN enabled = TRUE tabIndex *= NULL tabEnabled *= TRUE height *= 450 width *= 450 left = 3050 top = 4395 disablePic = ".\revertd.bmp" pressPic = ".\revertp.bmp" enablePic = ".\reverte.bmp" theDefault *= FALSE dynamicMode *= FALSE classname *= "ixPictureButton" name = "revertBN" helpNum *= 0 shown *= TRUE rofID *= 0 @rofFileName *= NULL handler activate() # close without picking anything CALL selPickItem(FALSE) CALL mPickListWN.hide() end handler END BEGIN ixListBox PKLB fontItalic *= NULL fontUnderline *= NULL enabled *= TRUE tabIndex *= NULL tabEnabled *= TRUE backgroundColor *= NULL foregroundColor *= NULL fontName *= NULL fontSize *= NULL fontBold *= NULL height = 1950 width = 360 left = 3105 top = 2310 style *= ixListBox::singleSelect classname *= "ixListBox" name = "PKLB" helpNum *= 0 itemList = NULL shown = FALSE sorted = FALSE rofID *= 0 @rofFileName *= NULL END BEGIN ixTextBox messageTB fontItalic *= NULL fontUnderline *= NULL enabled = TRUE tabIndex *= NULL tabEnabled = FALSE backgroundColor *= NULL foregroundColor *= NULL fontName *= NULL fontSize *= NULL fontBold = FALSE height = 450 width = 2355 left = 90 top = 4380 maxChars *= 255 classname *= "ixTextBox" name = "messageTB" helpNum *= 0 shown *= TRUE rofID *= 0 text = "Please wait..." @rofFileName *= NULL multiLine = TRUE END handler pre_body() VARIABLE mPickListWN pickListWCL VARIABLE mPickListLB ixListBox # the PKLB holds the PK values of the contents of mPickListLB. # It is hidden VARIABLE mPKLB ixListBox # variables to return the PK and item in the LB VARIABLE rtnPK CHAR(*) = NULL VARIABLE rtnItem CHAR(*) = NULL # name of the table that's currently in the list VARIABLE mTabName CHAR(*) = NULL VARIABLE mSqlStmt CHAR(*) = NULL VARIABLE mMaxRows CHAR(*) = NULL FUNCTION pickAbleBN(myVC ixVisualContainer, BNname CHAR(*), whatWay CHAR(*)) RETURNING VOID # dis or enable the button designated VARIABLE myBN ixButton LET myBN = myVC.getContainedObjByName(BNname) IF whatWay = "DIS" THEN CALL myBN.disable() ELSE CALL myBN.enable() END IF END FUNCTION # pickAbleBN(myVC ixVisualContainer, BNname CHAR(*), whatWay CHAR(*)) FUNCTION pickAbleMoveBNs(myVC ixVisualContainer, whichWay CHAR(*)) RETURNING VOID IF whichWay = "DIS" THEN # if we want to disable, just go ahead and disable CALL pickAbleBN(myVC,"gfFirstRowBN","DIS") CALL pickAbleBN(myVC,"gfPrevPageBN","DIS") CALL pickAbleBN(myVC,"gfNextPageBN","DIS") CALL pickAbleBN(myVC,"gfLastRowBN","DIS") ELSE # enable only if there's a current row and other details IF mPickListLB.getNumItems() > 0 THEN IF mPickListLB.getSelectedItem() > 1 THEN IF mPickListLB.getNumItems() > 20 THEN CALL pickAbleBN(myVC,"gfFirstRowBN","EN") CALL pickAbleBN(myVC,"gfPrevPageBN","EN") END IF ELSE CALL pickAbleBN(myVC,"gfFirstRowBN","DIS") CALL pickAbleBN(myVC,"gfPrevPageBN","DIS") END IF IF mPickListLB.getSelectedItem() < mPickListLB.getNumItems() - 19 THEN CALL pickAbleBN(myVC,"gfLastRowBN","EN") CALL pickAbleBN(myVC,"gfNextPageBN","EN") ELSE CALL pickAbleBN(myVC,"gfLastRowBN","DIS") CALL pickAbleBN(myVC,"gfNextPageBN","DIS") END IF ELSE # recursively call to disable CALL pickAbleMoveBNs(myVC, "DIS") END IF # mPickListLB.getNumItems() > 0 END IF END FUNCTION # pickAbleMoveBNs(myVC ixVisualContainer, whichWay CHAR(*)) FUNCTION locatePickList(myBN ixButton) RETURNING VOID VARIABLE myString ixString VARIABLE BNname CHAR(*) VARIABLE itemNum SMALLINT LET myString = NEW ixString("") CALL myString.concat(myBN.name) LET BNname = myString.getValueStr() CASE WHEN BNname MATCHES "*irstRowBN" LET itemNum = 1 WHEN BNname MATCHES "*extPageBN" # select down to the bottom of the next page the subsequent select # will locate us at the top of the next page. LET itemNum = mPickListLB.getSelectedItem() + 39 WHEN BNname MATCHES "*revPageBN" LET itemNum = mPickListLB.getSelectedItem() - 20 WHEN BNname MATCHES "*astRowBN" # locate at the very bottom, then we'll page back 19 columns LET itemNum = mPickListLB.getNumItems() END CASE IF itemNum > mPickListLB.getNumItems() THEN LET itemNum = mPickListLB.getNumItems() END IF IF itemNum < 1 THEN LET itemNum = 1 END IF CALL mPickListLB.selectItem(itemNum) IF BNname MATCHES "*extPageBN" OR BNname MATCHES "*astRowBN" THEN # we're at the bottom of the displayed LB, so get to the top LET itemNum = itemNum - 19 IF itemNum < 1 THEN LET itemNum = 1 END IF CALL mPickListLB.selectItem(itemNum) END IF CALL mPickListLB.focus() END FUNCTION # locatePickList(myBN ixButton) FUNCTION selPickItem(pickFlag BOOLEAN) RETURNING VOID # called from pickListLB.activate(), applyBN.activate(), and revertBN.activate() # to set the modular values as required LET rtnPK = NULL LET rtnItem = NULL IF pickFlag THEN # do fill in the modulars LET rtnItem = mPickListLB.getItemByNumber(mPickListLB.getSelectedItem()) LET rtnPK = mPKLB.getItemByNumber(mPickListLB.getSelectedItem()) END IF END FUNCTION # selPickItem(pickFlag BOOLEAN) FUNCTION pickListWCL::fillPickList (tabName CHAR(*), sqlStmt CHAR(*), maxRows INTEGER) RETURNING INTEGER VARIABLE ct SMALLINT VARIABLE myItem CHAR(*) VARIABLE myPK CHAR(*) VARIABLE myStatus INTEGER VARIABLE myRow ixRow VARIABLE myValue ixValue VARIABLE myTB ixTextBox VARIABLE msgTxt CHAR(*) IF mTabName IS NULL OR mTabName != tabName OR mSqlStmt IS NULL OR mSqlStmt != sqlStmt OR mMaxRows IS NULL OR mMaxRows != maxRows THEN # either first time in, # or not the same stuff as before; fill the LB IF ixApp::setCursor(ixApp::busyCur) THEN END IF LET mTabName = tabName LET mSqlStmt = sqlStmt LET mMaxRows = maxRows # empty anything in the pick boxes IF mPickListLB.getNumItems() > 0 THEN FOR ct = mPickListLB.getNumItems() TO 1 STEP -1 LET myItem = mPickListLB.delete(ct) LET myPK = mPKLB.delete(ct) END FOR # ct = mPickListLB.getNumItems() TO 1 END IF # mPickListLB.getNumItems() > 0 LET myStatus = prepPick(sqlStmt) WHILE myStatus = 0 LET myRow = fetchPick() IF myRow IS NULL THEN # error on the fetch EXIT WHILE END IF # myRow IS NULL LET myValue = myRow.getVal(1) IF myValue IS NULL THEN LET myStatus = 100 EXIT WHILE END IF LET ct = mPKLB.insert(itemVal: myValue, itemNum: mPKLB.getNumItems() + 1) LET myValue = myRow.getVal(2) LET ct = mPickListLB.insert(itemVal: myValue, itemNum: mPickListLB.getNumItems() + 1) IF ct = maxRows THEN # that's all; # if maxRows is 0 we'll never match it and get all rows LET myStatus = 100 END IF END WHILE # myStatus = 0 # select the 1st one CALL mPickListLB.selectItem(1) # turn on the paging keys as required CALL pickAbleMoveBNs(mPickListWN,"EN") # display a count LET myTB = mPickListWN.getContainedObjByName("messageTB") LET msgTxt = mPickListLB.getNumItems() USING "<<<<<<<<&", " Items" CALL myTB.replaceText(0,NULL,msgTxt) CALL myTB.setCursorPos(0) IF ixApp::setCursor(ixApp::standardCur) THEN END IF END IF # mTabName IS NULL OR mTabName != tabName ... RETURN mPickListLB.getNumItems() END FUNCTION # pickListWCL::fillPickList(tabName CHAR(*), sqlStmt CHAR(*), maxRows) FUNCTION pickListWCL::getPickList() RETURNING CHAR(*), CHAR(*) RETURN rtnPK, rtnItem END FUNCTION # pickListWCL::getPickList() end handler handler start() # start LET mPickListWN = getWindow() LET mPickListLB = getContainedObjByName("pickListLB") LET mPKLB = getContainedObjByName("PKLB") end handler handler pre_header() INCLUDE SYSTEM "ixapp.4gh" INCLUDE SYSTEM "ix4gl.4gh" INCLUDE SYSTEM "ixrow.4gh" INCLUDE SYSTEM "ixtxtbox.4gh" end handler handler finish(byWhom smallint) # don't allow them to finish from a child window IF byWhom = ixWindow::closedBySysMenu THEN RETURN FALSE ELSE RETURN TRUE END IF end handler handler class_extension() PUBLIC FUNCTION fillPickList(tabName CHAR(*), sqlStmt CHAR(*), maxRows INTEGER) RETURNING INTEGER PUBLIC FUNCTION getPickList() RETURNING CHAR(*), CHAR(*) end handler END