|
|||||||
Version 3 Technical Highlights - Add_ButtonsThe program on the following pages uses this extended functionality to put buttons on the screen in an AREV window as in the illustration below. When the buttons are pointed at and clicked with the mouse the buttons give the illusion of being pressed into the screen and provide an audible click. Setting up the buttons is simple a case of putting five parameters per button into Register(5) of the window (see below), the parameters being Label, X, Y, Code Command as shown below. Then add a call to ADD_BNS passing PRE_INIT on the pre init hook. The program works by adding "pseudo" prompts for each button into the window at pre init. It then checks on a perpetual process to see if these prompts are in WC_Wi_Next%. If they are they can be there by either arrowing to the prompt or clicking on the prompt. Arrowing (or returning) to the prompt should ignore the prompts and continue on in the direction of travel. Clicking on the prompt with a mouse should action the code and command. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍTESTÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º º º Customer Id 1 º º Company Name FIRST BANK OF NEW YORK º º Contact Name Rick Garber º º Jim Lovell º º ÚÄÄÄÄ· ÚÄÄÄÄÄÄÄÄÄÄ· ÚÄÄÄ· º º ³Saveº ³Table Modeº ³TCLº º º ÔÍÍÍͼ ÔÍÍÍÍÍÍÍÍÍͼ ÔÍÍͼ º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Example Parameters in Register(5) For Above Screen Save|2|5|K|{F9} Table Mode|10|5|K|{CTRL-F5} Print|24|5|K|{ALT-P} To determine whether the prompt was clicked on, @PROG.CHAR is checked. If it is four characters long a mouse click was used. (See above). Note that WC_Wi_Next% is not reliable when exiting an associated MVed prompt. Essentially when an AMV group is exited by pressing return, WC_Wi_Next% is not set. Rather WC_Mv_Next% is set to two more than the count of MVs in the group! This behaviour is not new, but large thanks to Alan Humphrey/Bob Madden of Revelation Technologies for helping to pinpoint it. The only remaining point of interest is that the window processor obviously uses the length of the prompt label and entry to work out whether a prompt has been clicked on using InRect. Originally the program following made the prompt label equal to the complete button string but this led to false alarms when clicking ANYWHERE on the prompt line. Hence the use of a pre-key process to actually draw the button. 0001 Subroutine Add_BNS(Branch) 0002 /* 0003 Author AMcA 0004 Date Sept 1992 0005 Notes Note for BP@ read ButtonPrompts@, for Bn read Button 0006 */ 0007 GoTo Main 0008 Declare Subroutine Catalyst, VSpace, Delay, Msg 0009 $Insert SysInclude, Window_Common% 0010 $Insert SysInclude, LcPositions 0011 $Insert SysInclude, Virtual.Params 0012 $Insert SysInclude, Logical 0013 $Insert SysInclude, Window.Constants 0014 Equ RegisterToUse$ To 49 ; * Window Register 5 0015 Equ BnLabel$ To 1 0016 Equ BnX$ To 2 0017 Equ BnY$ To 3 0018 Equ BnCode$ To 4 0019 Equ BnCommand$ To 5 0020 Equ Dm$ To Char(247) 0021 0022 Main: 0023 Common /WindowBns/ BP@, BnLabelPrePress@, 0024 BnLabelPress@ 0025 Begin Case 0026 Case Branch = "PRE_KEY" ; GoSub SetUpBns 0027 Case Branch = "PRE_INIT" ;GoSub PreInit 0028 Case Branch = "PERP" ; GoSub Perpetual 0029 End Case 0030 Return 0031 0032 Perpetual: 0033 CAG = WC_Curr_Amv_Group% 0034 If CAG Then 0035 If WC_Mv_Next%>(WC_Amv_Vars%<CAG,Amv.Depth$>+1) Then 0036 * Moving out of an AMV group downwards so the next prompt will be 0037 * equal to the start pos + count of prompts + 1 0038 WC_Wi_Next%=WC_Amv%<CAG,1>+ WC_Amv_Vars%<CAG, Amv.Width$> 0039 End 0040 End 0041 Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Then 0042 If Len(@Prog.Char) = 4 Then 0043 * Asked to mouse to Bn prompt so get options code and command and 0044 * execute it 0045 Old_Wi_Next% = WC_Wi_Next% 0046 GoSub BnPress 0047 Catalyst(WC_W%(BP@<Pos>)<Options.Code>, WC_W% (BP@<Pos>) 0048 <Options.Command>) 0049 If WC_Wi_Next% # Old_Wi_Next% Then 0050 * Do nothing, user must have changed it in catalyst 0051 End Else 0052 * Return whence one came 0053 WC_Wi_Next% = WC_Wi% 0054 End 0055 @Prog.Char = "" 0056 End Else 0057 * Normal attempt to move into the Bn prompt so just increment Wi_Next% 0058 Exit = False$ 0059 Begin Case 0060 Case WC_Wi% = 1 And WC_Wi_Next% = WC_W_Cnt% 0061 Loop 0062 Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else 0063 Exit = True$ 0064 End 0065 Until Exit 0066 Wi_Next% -= 1 0067 Repeat 0068 Case WC_Wi_Next% > WC_Wi% 0069 Loop 0070 WC_Wi_Next% += 1 0071 Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else 0072 Exit = True$ 0073 End 0074 If WC_Wi_Next% > WC_W_Cnt% Then 0075 WC_Wi_Next% = 1 0076 End 0077 Until Exit Repeat 0078 Case WC_Wi_Next% < WC_Wi% 0079 Loop 0080 WC_Wi_Next% -= 1 0081 Locate WC_Wi_Next% In BP@ Using @Fm Setting Pos Else 0082 Exit = True$ 0083 End 0084 If WC_Wi_Next% < 1 Then 0085 WC_Wi_Next% = WC_W_Cnt% 0086 End 0087 Until Exit Repeat 0088 End Case 0089 End 0090 End 0091 Return 0092 0093 PreInit: 0094 BnDetails = Field(@Record, Dm$, RegisterToUse$) 0095 If BnDetails Then 0096 * For each Bn defined, add into prompt array and into labelled common 0097 Convert "|" : @Vm To @Vm : @Fm In BnDetails 0098 BnCtr = Count(BnDetails, @Fm) + 1 0099 PromptArray = @Record[1,Char(247)] 0100 PromptCount = PromptArray<1> 0101 For X = 1 To BnCtr 0102 PromptCount += 1 0103 Bn = BnDetails<X> 0104 Prompt = "" 0105 Prompt<0,Type> = "F" 0106 GoSub ConstructBnLabel 0107 Prompt<0,D> = BnText 0108 Prompt<0,DA> = "^PL^" 0109 Prompt<0,DX> = BnX + 1 0110 Prompt<0,DY> = BnY 0111 Prompt<0,VX> = BnX + 1 ; Prompt<0,VY> = BnY 0112 Prompt<0,VLen> = 0 ; Prompt<0,VA> = "^PE^" 0113 Prompt<0,Options.Code> = Bn<0, BnCode$> 0114 Prompt<0,Options.Command> = Bn<0, BnCommand$> 0115 PromptArray = Insert(PromptArray,PromptCount+1,0,0,Prompt) 0116 Next 0117 PromptArray<1> = PromptCount 0118 @Record = FieldStore(@Record, Dm$, 1, -1, PromptArray) 0119 @Record = FieldStore(@Record, Dm$, 9, 1, "") 0120 BP@ = "" 0121 Top = PromptCount 0122 Bottom = Top - BnCtr + 1 0123 For X = Bottom To Top 0124 BP@<-1> = X 0125 Next 0126 End 0127 * Finally add Perpetual and Pre Key call in if not there 0128 PerpetualCall = Field(@Record, Dm$, 45) 0129 Begin Case 0130 Case PerpetualCall<1> = "" 0131 PerpetualCall = "S" : @Vm : "ADD_BNS,PERP" 0132 Case Index(PerpetualCall<1>, "ADD_BNS,PERP", 1) 0133 Null 0134 Case 1 0135 PerpetualCall<1,1> = PerpetualCall<1,1> : ";S" 0136 PerpetualCall<1,2> = PerpetualCall<1,2> : ";ADD_BNS,PERP" 0137 End Case 0138 @Record = FieldStore(@Record, Dm$, 45, 1, PerpetualCall) 0139 PreCode = @Record<2, Pre.Code> 0140 PostCode = @Record<2, Post.Command> 0141 Begin Case 0142 Case Index(@Record<2, Pre.Command>, "ADD_BNS,PRE_KEY", 1) 0143 Null 0144 Case 1 0145 @Record<2, Pre.Code> = "S;" : @Record<2, Pre.Code> 0146 @Record<2,Pre.Command>="ADD_BNS,PRE_KEY":";":@Record<2, Pre.Command> 0147 End Case 0148 Delay(0) 0149 Return 0150 0151 ConstructBnLabel: 0152 BnText = Bn<0, BnLabel$> 0153 BnX = Bn<0, BnX$> 0154 BnY = Bn<0, BnY$> 0155 BnLabelLength = Len(BnText) 0156 BnLabelTemp = @(BnX,BnY- 1):"Ú":Str("Ä",BnLabelLength):"·" 0157 BnLabelTemp := @(BnX,BnY):"³":BnText:"º" 0158 BnLabelTemp := @(BnX,BnY+1):"Ô":Str("Í",BnLabelLength):"¼" 0159 BnLabelPrePress@<X> = BnLabelTemp 0160 BnLabelTemp = @(BnX,BnY- 1):"Ú":Str("Ä",BnLabelLength):"¿" 0161 BnLabelTemp := @(BnX, BnY) : "³" : BnText : "³" 0162 BnLabelTemp := @(BnX,BnY+1):"À":Str("Ä",BnLabelLength):"Ù" 0163 BnLabelPress@<X> = BnLabelTemp 0164 Return 0165 0166 BnPress: 0167 X = WC_W%(WC_Wi_Next%)<DX> 0168 Y = WC_W%(WC_Wi_Next%)<DY> 0169 ReleaseColour = WC_W%(WC_Wi_Next%)<DA> 0170 ReleaseBn = ReleaseColour : BnLabelPrePress@<Pos> 0171 If Branch = "PERP" Then 0172 PressColour = WC_W%(WC_Wi_Next%)<VA> 0173 PressBn = PressColour : BnLabelPress@<Pos> 0174 Vspace(VPrnt, Flag, VWindow%, X, Y, PressBn) 0175 Out 67, 182 ; Out 66, 21 ; Out 66, 0 0176 OldValue = Inp(97) ; NewValue = BitOr(OldValue, 03) 0177 Out 97,NewValue 0178 Delay(.2) 0179 NewValue = BitAnd(OldValue,252) 0180 Out 97,NewValue 0181 End 0182 Vspace(VPrnt, Flag, WC_VWindow%, X, Y, ReleaseBn) 0183 Return 0184 0185 SetUpBns: 0186 BnCtr = Count(BP@, @Fm) + 1 0187 For Ctr = 1 To BnCtr 0188 X = WC_W%(BP@<Ctr>)<DX> 0189 Y = WC_W%(BP@<Ctr>)<DY> 0190 ReleaseColour = WC_W%(BP@<Ctr>)<DA> 0191 ReleaseBn = ReleaseColour : BnLabelPrePress@<Ctr> 0192 Vspace(VPrnt, Flag, WC_VWindow%, X, Y, ReleaseBn) 0193 Next 0194 Return (Volume 4, Issue 5, Pages 12-15) |
|||||||
| |||||||