function nv_statusbar(method,ctrlEntId,param1,param2,param3,param4,param5,param6,param7) /* ---------------------------------------------------------------------------- Author : Mark Boorman Date : 18 January 2012 Version : 1.0.0.0 Purpose : A set of generic processing functions to perform on a statusbar control Modification Info: ---------------------------------------------------------------------------- Date Who Notes ---------------------------------------------------------------------------- 120711 mab Removed the slide animation from the cancel button 150210 mab Added method.setuser 150420 mab Added some more cases to getincrement 150527 mab Added method.getcaption 221215 mab replaced reference to utility_proc with nv_utility. Now wondering if this ever truly compiled correctly. Parameters: ---------------------------------------------------------------------------- method [in] The process to perform CtrlEntId [in] The name of the statusbar control, can include the window name, or if just the control name, @window is used to complete the full control id. If null then the MDI Status bar is used. param1~ [in] See individual methods for details. param7 Returns: ------------------------------------------------------------------------------------------------------------------------- Result [out] See individual methods for details use get_status to check for errors. -------------------------------------------------------------------------------------------------------------------------*/ declare function get_property, GetEnvcolours, nv_Utility, send_message, nv_Get_Image declare subroutine Check_Assignments, nv_Setup_Statusbar, set_property, nv_SRPmsg $Insert APP_COMMON_INS $insert nv_userprefs $Insert Usercommon_ins Equ ScrollPane$ to 7 Equ CapsPane$ to 6 Equ NumPane$ to 5 Equ UserPane$ to 4 Equ MarqueePane$ to 3 Equ ProgressPane$ to 2 Equ StatusPane$ to 1 Equ CancelPopup$ to MDI_Frame@:'.OLE_POPUP_CANCEL' Check_Assignments(method,ctrlEntId,param1,param2,param3,param4,param5,param6,param7) nv_version$$ = "[ver: n349]" result = null$ If CtrlEntId = '' then CtrlEntId = MDI_Status@ end Begin Case case method[1,5] _eqc "ver$$" ; RETURN nv_version$$ case method _eqc 'COLOUR' ; gosub method.colour case method _eqc 'CREATE' ; gosub method.create case method _eqc 'GETCAPTION' ; gosub method.getcaption case method _eqc 'GETINCREMENT' ; gosub method.getincrement case method _eqc 'GETPROGRESS' ; gosub method.getprogress case method _eqc 'MARQUEE' ; gosub method.marquee case method _eqc 'PROGRESS' ; gosub method.progress case method _eqc 'SETCAPTION' ; gosub method.setcaption case method _eqc 'SETIMAGE' ; gosub method.setimage case method _eqc 'SETPROGRESS' ; gosub method.setprogress case method _eqc 'SETUSER' ; gosub method.setuser case method _eqc 'STOPPROGRESS' ; gosub method.stopprogress end case return result ******************************************************************************** * internal subroutines ******************************************************************************** * method.colour: Transfer param1 to colour Transfer param2 to PaneNo If colour _eqc 'Reset' then EnvironColours = GetEnvcolours('') startgradient = EnvironColours<1> endgradient = EnvironColours<2> colour = 'SpringGreen' end If PaneNo = '' then PaneNo = 1 end Set_Property(CtrlEntId, "OLE.PaneColors[":PaneNo:"]", @fm:@fm:'Yellow':@fm:colour) Return method.display_cancel_button: /* Displays a cancel button over the username panel of the mdi statusbar No parameters because this is called from within the progress method only. */ Set_Property(MDI_Frame@, '@CANCELPROCESS', false$) sbarpos = nv_Utility('getxy', ctrlentid) SPaneWidth = Get_Property(ctrlentid, 'OLE.PaneWidth[':StatusPane$:']') PPaneWidth = Get_Property(ctrlentid, 'OLE.PaneWidth[':ProgressPane$:']') MPaneWidth = Get_Property(ctrlentid, 'OLE.PaneWidth[':MarqueePane$:']') UPaneWidth = Get_Property(ctrlentid, 'OLE.PaneWidth[':UserPane$:']') popupsize = Get_Property(CancelPopup$, 'OLE.Size') popupwidth = popupsize<3> popupheight = popupsize<4> Marqueeends = sbarpos<1> + SPaneWidth + MPaneWidth Popupx = Marqueeends + 4 ; // Add four to account for the spacing between panes. Each space defaults to 2 Popupy = sbarpos<2> + 2 Set_Property(CancelPopup$, 'OLE.Size', @fm:@fm:UPaneWidth) Set_Property(CancelPopup$, 'OLE.Item[1]', @vm:@vm:UPaneWidth) * Marqueestarts = sbarpos<1> + SPaneWidth * stat = Send_Message(CancelPopup$, "OLE.ShowAt", Marqueeends - popupwidth, sbarpos<2> - popupheight) * stat = Send_Message(CancelPopup$, "OLE.ShowAt", Popupx, Popupy) nv_SRPmsg('ShowMsg', CancelPopup$, '', '', popupx:@fm:popupy, null$, 'None') Return method.create: /* Defines the panels and appearance of the statusbar If param1 is true$ then it will be a simple statusbar without the username, caps, scroll etc */ nv_Setup_Statusbar(ctrlentid, param1) Return method.getcaption: result = Get_Property(CtrlEntId, "OLE.PaneCaption[":StatusPane$:"]") Return method.getincrement: /* result [out] Returns a value to be passed in as the increment for progressing the percentage pane. Value returned is increment value:@fm:iteration iteration is the number within your loop for when you should call the progress calculated by if mod(loopcnt, iteration) = 0 then call progress Provides for some consistency and removes the need to do the calculation in each routine you want to use the progress function*/ totalNo = param1 Begin Case Case (totalNo gt 300) and (totalno le 30000) result = null$:@fm:4 Case (totalNo gt 250) and (totalno le 300) result = 1:@fm:4 Case (totalNo gt 225) and (totalno le 250) result = 1:@fm:3 Case (totalNo gt 200) and (totalno le 225) result = 1:@fm:2 Case (totalNo gt 175) and (totalno le 200) Result = 1:@fm:2 Case (totalNo gt 150) and (totalno le 175) Result = 1:@fm:2 Case (totalNo gt 125) and (totalno le 150) Result = 2:@fm:3 Case (totalNo gt 100) and (totalno le 125) Result = 1:@fm:1 Case (totalNo gt 75) and (totalno le 100) Result = 1:@fm:1 Case (totalNo gt 50) and (totalno le 75) Result = 3:@fm:2 Case (totalNo gt 30) and (totalno le 50) Result = 2:@fm:1 Case (totalNo gt 0) and (totalno le 30) Result = 3 Case 1 Result = 1:@fm:1 End Case Return method.getprogress: /* result [out] Returns the percentage value that the progress percent bar is currently at. */ Current = get_property(CtrlEntId, "OLE.PanePercent[":ProgressPane$:"]") Result = current if current ge 99 then call Jasamja() end Return method.marquee: Return method.progress: /* Animates the various statusbar components. Firstly, it moves the marquee bar one position across. If param1 then the progress percent bar will also be displayed and updated. param1 [in] Increment value. If assigned, then the progress percent bar will be displayed and the progress bar will be increased by this amount. To set the progress percent bar at a specific value, use the 'setprogress' method. param2 [in] ShowCancelButton. - Boolean. If true then a cancel button will be displayed on the statusbar. If the cancel button is clicked, it sets a flag on the mdi (@CANCELPROCESS) that can be checked by the calling routine. */ * type = get_Property(CtrlEntId, "OLE.PaneType[":StatusPane$:"]") increment = param1 showcancel = param2 * Set_Property(CtrlEntId, "OLE.PaneVisible[":MarqueePane$:"]", True$) Set_Property(CtrlEntId, "OLE.PaneType[":MarqueePane$:"]", "Progress Marquee") ProgressVisible = Get_Property(CtrlEntId, 'OLE.PaneVisible[':ProgressPane$:']') If increment then If Not(ProgressVisible) then Set_Property(CtrlEntId, 'OLE.PaneVisible[':ProgressPane$:']', True$) end // Update the progress bar GoSub method.getprogress Progress = Current + increment If Progress GT 100 then Progress = 0 end Set_Property(CtrlEntId, "OLE.PanePercent[":ProgressPane$:"]", Progress) End // Scroll the marqueee rv = Send_Message(CtrlEntId, "OLE.UpdateMarquee", MarqueePane$) If showcancel then GoSub method.display_cancel_button end Return *---------- method.setcaption: *---------- /* Displays a caption in the first panel of the statusbar param1 [in] The string to be displayed in the statusbar. Note: This will remain in the statusbar until it is replaced by something else. To clear it, such as at the end of a process, call this method again, passing null. */ caption = param1 If caption = '' then Colour = '3DFace' end else Swap char(13):char(10) with ' ' In caption Swap @fm with ' ' In caption Swap '|' with ' ' In caption Colour = 'Yellow' end Set_Property(CtrlEntId, "OLE.PaneColors[":StatusPane$:"]", @fm:colour) Set_Property(CtrlEntId, "OLE.PaneCaption[":StatusPane$:"]", caption) Return *---------- method.setimage: *---------- /* Displays an image in the statusbar panel that also displays a caption. param1 [in] The key to the image record in wwa_sys_settings The image can be displayed alone or alongside a caption. To display a caption as well, just call setcaption method. */ image = param1 imagepath = nv_Get_Image(image, 'Tab') Set_Property(CtrlEntID, "OLE.PaneImage[":StatusPane$:"]", imagepath) Return *---------- method.setprogress: *---------- /* Sets the progress percent pane to a specific percentage as opposed to the 'progress' method which increments by a specific value. param1 [in] The percentage value to set the pane at. Eg passing 50 will set the percentage progress bar at the halfway point regardless of its current value. (Passing 50 to the 'progress' method will increment the bar by 50) */ Transfer param1 to progress ProgressVisible = Get_Property(CtrlEntId, 'OLE.PaneVisible[':ProgressPane$:']') If Not(ProgressVisible) then Set_Property(CtrlEntId, 'OLE.PaneVisible[':ProgressPane$:']', True$) end Set_Property(CtrlEntId, "OLE.PanePercent[":ProgressPane$:"]", Progress) Return method.setuser: Set_Property(ctrlentid, 'OLE.PaneCaption[':UserPane$:']', Curr_User%) Return method.stopprogress: /* Stops any statusbar animation. If the progress percent bar was visible, it hides it again. If the marquee bar was scrolling then it stops it and removes the bar. Also removes any cancel button that may have been on display. If you have called progress or setprogress at the beginning or during a process then call this method when the process is complete. Would generally be used alongside a call to the setcaption method with a parameter of null to clear any processing messages. */ GoSub method.progress Set_Property(CtrlEntId, "OLE.PanePercent[":ProgressPane$:"]", 0) Set_Property(CtrlEntId, 'OLE.PaneVisible[':ProgressPane$:']', False$) * Set_Property(CtrlEntId, 'OLE.PaneVisible[':MarqueePane$:']', False$) Set_Property(CtrlEntId, "OLE.PaneType[":MarqueePane$:"]", "Normal") stat = Send_Message(CancelPopup$, "OLE.Close") Return End