Listing: 1 IMPLEMENTATION MODULE FrameManager; 2 (* 3 * REPERTOIRE 4 * Release 1.6 5 * By Charles Bradford and Cole Brecheen 6 * (c) Copyright 1985-1992 PMI 7 * Green Bay, Wisconsin 8 * All rights reserved 9 * (414) 468-6040 10 * 11 * $Header: D:/logfiles/mods/frameman.mov 1.5 10 Mar 1991 15:27:50 coleb $ 12 * 13 *) 14 15 16 (* 17 IMPORT Diagnostics; 18 *) 19 20 IMPORT ErrorManager; 21 IMPORT FramePainter; 22 IMPORT GenLists; 23 IMPORT Hash; 24 IMPORT ListUtils; 25 IMPORT Rectangles; 26 IMPORT ScrnTypes; 27 IMPORT SYSTEM; 28 IMPORT VWindows; 29 30 VAR 31 Initialized : BOOLEAN; 32 33 34 (* The idea here is that we have a list of windows, each of 35 which has a list of active DisplayFrames (pointers to 36 DisplayFrameRecs) in the position immediately following it. 37 A DisplayFrame's position in the window list indicates how 38 it is stacked --position 1 means it is in the foreground, 39 and each position after that means it is farther into the 40 background *) 41 42 CONST 43 FrameCode = 65529; 44 WindowCode = 65528; 45 (* arbitrary *) 46 47 VAR 48 WindowListInitialized : BOOLEAN; 49 WindowList: GenLists.GenList; ***** ^ not supported yet 50 51 52 PROCEDURE CleanUp(); 53 BEGIN 54 (* 55 Diagnostics.diagS( 'About to DisposeList', '' ); 56 *) 57 GenLists.DisposeList( WindowList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 58 END CleanUp; ***** ^ not supported yet 59 60 61 PROCEDURE AddWindow( TheWindow: VWindows.AWindowHandle ); ***** ^ not supported yet 62 VAR 63 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 64 BEGIN 65 IF NOT WindowListInitialized THEN 66 GenLists.NewList( WindowList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 67 WindowListInitialized := TRUE; 68 ErrorManager.AddTermProc( CleanUp ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 69 END; 70 IF ListUtils.ObjectSpot( TheWindow, WindowList, 1, 65535 ) > 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 71 (*TheWindow is already in WindowList. We don't complain 72 about redundant adds because most frames will be 73 associated with the same window, and we don't want 74 InitDisplayFrame to have to worry about whether a 75 window has already been added. *) 76 RETURN; 77 END; 78 GenLists.NewList( ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 79 GenLists.ListInsert( ActiveFrameList, GenLists.ListCode, WindowList, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 80 GenLists.ListInsert( TheWindow, WindowCode, WindowList, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 81 END AddWindow; ***** ^ not supported yet 82 83 84 PROCEDURE DeleteWindow( TheWindow: VWindows.AWindowHandle ); ***** ^ not supported yet 85 VAR 86 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 87 spot : CARDINAL; 88 BEGIN 89 spot := ListUtils.ObjectSpot( TheWindow, WindowList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 90 IF spot > 0 THEN 91 GenLists.ListDelete( WindowList, spot, 2 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 92 END; 93 END DeleteWindow; ***** ^ not supported yet 94 95 96 PROCEDURE GetAssociatedFrames( TheWindow: 97 VWindows.AWindowHandle; VAR FrameList: GenLists.GenList ); ***** ^ not supported yet ***** ^ not supported yet 98 VAR 99 spot: CARDINAL; 100 BEGIN 101 spot := ListUtils.ObjectSpot( TheWindow, WindowList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 102 IF spot > 0 THEN 103 GenLists.GetChildList( WindowList, spot + 1, FrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 104 IF GenLists.Initialized( FrameList ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 105 RETURN; 106 END; 107 END; 108 ErrorManager.WARN( "You're missing a call to AddWindow somewhere" ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 109 END GetAssociatedFrames; ***** ^ not supported yet 110 111 112 PROCEDURE FrameIsInForeGround( TheFrame: ScrnTypes.DisplayFrame ); ***** ^ not supported yet 113 VAR 114 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 115 spot: CARDINAL; 116 BEGIN 117 GetAssociatedFrames( TheFrame^.WindowHandle, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 118 spot := ListUtils.ObjectSpot( TheFrame, ActiveFrameList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 119 IF spot = 0 THEN 120 ErrorManager.WARN( 'Frame not active' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 121 END; 122 (* Now move TheFrame to the front of ActiveFrameList. *) 123 IF spot # 1 THEN 124 GenLists.ListDelete( ActiveFrameList, spot, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 125 GenLists.ListInsert( TheFrame, FrameCode, ActiveFrameList, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 126 END; 127 END FrameIsInForeGround; ***** ^ not supported yet 128 129 130 PROCEDURE GetFrameFromList( list: GenLists.GenList; spot: ***** ^ not supported yet 131 CARDINAL; VAR frame: ScrnTypes.DisplayFrame ); ***** ^ not supported yet 132 VAR 133 TypeCode: CARDINAL; 134 BEGIN 135 GenLists.GetElmt( list, spot, frame, TypeCode ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 136 IF TypeCode # FrameCode THEN 137 ErrorManager.WARN( 'Error in frame list' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 138 END; 139 END GetFrameFromList; ***** ^ not supported yet 140 141 142 PROCEDURE FrameActivated( TheFrame: ScrnTypes.DisplayFrame ); ***** ^ not supported yet 143 VAR 144 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 145 spot : CARDINAL; 146 BEGIN 147 GetAssociatedFrames( TheFrame^.WindowHandle, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 148 spot := ListUtils.ObjectSpot( TheFrame, ActiveFrameList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 149 IF spot > 0 THEN 150 (* TheFrame is already in the list. *) 151 RETURN; 152 END; 153 GenLists.ListInsert( TheFrame, FrameCode, ActiveFrameList, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 154 END FrameActivated; ***** ^ not supported yet 155 156 PROCEDURE FrameDeactivated( TheFrame: ScrnTypes.DisplayFrame ); ***** ^ not supported yet 157 VAR 158 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 159 spot : CARDINAL; 160 BEGIN 161 GetAssociatedFrames( TheFrame^.WindowHandle, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 162 spot := ListUtils.ObjectSpot( TheFrame, ActiveFrameList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 163 IF spot = 0 THEN 164 (* TheFrame is not in the list. *) 165 RETURN; 166 END; 167 GenLists.ListDelete( ActiveFrameList, spot, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 168 END FrameDeactivated; ***** ^ not supported yet 169 170 171 PROCEDURE GetFrameCoords( TheFrame: ScrnTypes.DisplayFrame; VAR ***** ^ not supported yet 172 rect: Rectangles.ARectangle ); ***** ^ not supported yet 173 BEGIN 174 Rectangles.DefineRectangle( rect, TheFrame^.startcol + ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 175 1, TheFrame^.startrow + 1, TheFrame^.endcol + 1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 176 TheFrame^.endrow + 1 ) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 177 END GetFrameCoords; ***** ^ not supported yet 178 179 180 PROCEDURE IsFrameObscured( TheFrame: ScrnTypes.DisplayFrame ): ***** ^ not supported yet 181 BOOLEAN; 182 VAR 183 FrameRect, tmprect, intersection : Rectangles.ARectangle; ***** ^ not supported yet 184 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 185 ListEnd, cnt, spot : CARDINAL; 186 TmpFrame : ScrnTypes.DisplayFrame; ***** ^ not supported yet 187 BEGIN 188 GetAssociatedFrames( TheFrame^.WindowHandle, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 189 spot := ListUtils.ObjectSpot( TheFrame, ActiveFrameList, 1, 65535 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 190 IF spot = 0 THEN 191 (* The frame itself has got to be in the list. *) 192 ErrorManager.WARN( 'Error in frame list' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 193 RETURN FALSE; 194 ELSIF spot = 1 THEN 195 (* We return if it's 1 because, if the system is working, 196 a frame that's at the top of the list will never be 197 obscured *) 198 RETURN FALSE; 199 END; 200 GetFrameCoords( TheFrame, FrameRect ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 201 ListEnd := GenLists.ListLength( ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 202 FOR cnt := 1 TO (spot - 1) DO 203 GetFrameFromList( ActiveFrameList, cnt, TmpFrame ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 204 GetFrameCoords( TmpFrame, tmprect ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 205 IF Rectangles.RectsIntersect( FrameRect, tmprect, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 206 intersection ) THEN ***** ^ not supported yet 207 RETURN TRUE; 208 END; 209 END; 210 RETURN FALSE; 211 END IsFrameObscured; ***** ^ not supported yet 212 213 214 PROCEDURE EraseFrame( TheFrame: ScrnTypes.DisplayFrame ); ***** ^ not supported yet 215 VAR 216 FrameRect, tmprect, intersection : Rectangles.ARectangle; ***** ^ not supported yet 217 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 218 ListEnd, cnt, spot : CARDINAL; 219 TmpFrame : ScrnTypes.DisplayFrame; ***** ^ not supported yet 220 BEGIN 221 FrameIsInForeGround( TheFrame ); ***** ^ not supported yet ***** ^ not supported yet 222 FrameDeactivated( TheFrame ); ***** ^ not supported yet ***** ^ not supported yet 223 GetFrameCoords( TheFrame, FrameRect ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 224 GetAssociatedFrames( TheFrame^.WindowHandle, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 225 ListEnd := GenLists.ListLength( ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 226 (* If FrameRect is wholly within an unobscured frame, 227 redraw that frame. *) 228 FOR cnt := 1 TO ListEnd DO 229 GetFrameFromList( ActiveFrameList, cnt, TmpFrame ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 230 GetFrameCoords( TmpFrame, tmprect ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 231 IF (NOT IsFrameObscured( TmpFrame )) AND ***** ^ not supported yet ***** ^ not supported yet 232 (Rectangles.RectIsInside( FrameRect, tmprect ) ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 233 FramePainter.RedrawArea( TmpFrame, FrameRect.col1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 234 FrameRect.row1, FrameRect.col2, FrameRect.row2 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 235 RETURN 236 END; 237 END; 238 239 (* otherwise clearpart(rec), then start from bottom and call 240 redrawarea for each frame that extends into rec *) 241 VWindows.SetBackColor( TheFrame^.WindowHandle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 242 VWindows.BackColor(TheFrame^.WindowHandle) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 243 VWindows.SetMonoAttr( TheFrame^.WindowHandle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 244 VWindows.MonoAttr(TheFrame^.WindowHandle) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 245 VWindows.ClearPart( TheFrame^.WindowHandle, FrameRect.col1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 246 FrameRect.row1, FrameRect.col2, FrameRect.row2 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 247 cnt := ListEnd; 248 WHILE cnt >= 1 DO 249 GetFrameFromList( ActiveFrameList, cnt, TmpFrame ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 250 GetFrameCoords( TmpFrame, tmprect ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 251 IF Rectangles.RectsIntersect( FrameRect, tmprect, intersection ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 252 FramePainter.RedrawArea( TmpFrame, intersection.col1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 253 intersection.row1, intersection.col2, intersection.row2 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 254 END; 255 DEC( cnt ); ***** ^ undeclared identifier ***** ^ not supported yet 256 END; 257 END EraseFrame; ***** ^ not supported yet 258 259 PROCEDURE RestoreWholeWindow( TheWindow: VWindows.AWindowHandle ); ***** ^ not supported yet 260 VAR 261 ActiveFrameList : GenLists.GenList; ***** ^ not supported yet 262 ListEnd, cnt: CARDINAL; 263 TmpFrame: ScrnTypes.DisplayFrame; ***** ^ not supported yet 264 BEGIN 265 GetAssociatedFrames( TheWindow, ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 266 VWindows.SetBackColor( TheWindow, VWindows.BackColor(TheWindow) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 267 VWindows.SetMonoAttr( TheWindow, VWindows.MonoAttr(TheWindow) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 268 VWindows.ClearPart( TheWindow, 1, 1, VWindows.EndCol(TheWindow), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 269 VWindows.EndRow(TheWindow) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 270 ListEnd := GenLists.ListLength( ActiveFrameList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 271 cnt := ListEnd; 272 WHILE cnt >= 1 DO 273 GetFrameFromList( ActiveFrameList, cnt, TmpFrame ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 274 FramePainter.RedrawArea( TmpFrame, TmpFrame^.startcol + 1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 275 TmpFrame^.startrow + 1, TmpFrame^.endcol + 1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 276 TmpFrame^.endrow + 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 277 (* Corrected 3 Nov 88 thanks to John McMonagle; was 278 0,0,0,0 in 1.5c *) 279 DEC( cnt ); ***** ^ undeclared identifier ***** ^ not supported yet 280 END; 281 END RestoreWholeWindow; ***** ^ not supported yet 282 283 284 PROCEDURE Init(); 285 BEGIN 286 IF Initialized THEN 287 RETURN; 288 ELSE 289 Initialized := TRUE; 290 END; 291 WindowListInitialized := FALSE; 292 (* 293 Diagnostics.Init(); 294 *) 295 296 ErrorManager.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 297 FramePainter.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 298 GenLists.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 299 Hash.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 300 ListUtils.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 301 Rectangles.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 302 ScrnTypes.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 303 VWindows.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 304 END Init; ***** ^ not supported yet 305 306 BEGIN 307 Initialized := FALSE; 308 Init(); ***** ^ not supported yet ***** ^ not supported yet 309 END FrameManager. ***** ^ not supported yet 351 errors