FRAMEPAI.MOD 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. IMPLEMENTATION MODULE FramePainter;
  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/framepai.mov 1.6 17 Mar 1991 17:55:28 coleb $
  12. *
  13. *)
  14. IMPORT FrameManager;
  15. IMPORT GenLists;
  16. IMPORT Key;
  17. IMPORT LowLevel;
  18. IMPORT M2Strings;
  19. IMPORT MsColors;
  20. IMPORT Numbers;
  21. IMPORT FAPI;
  22. IMPORT PosUtils;
  23. IMPORT Rectangles;
  24. IMPORT ScrnTypes;
  25. IMPORT ScrnUtl1;
  26. IMPORT StrEdit;
  27. IMPORT SYSTEM;
  28. IMPORT VWindows;
  29. VAR
  30. Initialized : BOOLEAN;
  31. PROCEDURE Init();
  32. BEGIN
  33. IF Initialized THEN
  34. RETURN;
  35. ELSE
  36. Initialized := TRUE;
  37. END;
  38. FrameManager.Init();
  39. GenLists.Init();
  40. Key.Init();
  41. LowLevel.Init();
  42. M2Strings.Init();
  43. MsColors.Init();
  44. Numbers.Init();
  45. PosUtils.Init();
  46. Rectangles.Init();
  47. ScrnTypes.Init();
  48. ScrnUtl1.Init();
  49. StrEdit.Init();
  50. VWindows.Init();
  51. END Init;
  52. PROCEDURE InColorMode(): BOOLEAN;
  53. VAR
  54. ModeData: FAPI.VIOMODEINFO;
  55. BEGIN
  56. ModeData.cb := SYSTEM.TSIZE(FAPI.VIOMODEINFO);
  57. IF FAPI.VIOGETMODE(SYSTEM.ADR(ModeData), 0) # 0 THEN
  58. RETURN FALSE;
  59. END;
  60. IF ModeData.color = FAPI.UCHAR(0) THEN
  61. RETURN FALSE;
  62. ELSE
  63. RETURN TRUE;
  64. END;
  65. END InColorMode;
  66. PROCEDURE DrawLine( col1, row1, col2, row2: CARDINAL; TheChar:
  67. CHAR );
  68. VAR
  69. row : CARDINAL;
  70. linestr : ARRAY [0..80] OF CHAR;
  71. BEGIN
  72. IF col1 < col2 THEN
  73. (*We're drawing a horizontal line.*)
  74. LowLevel.Fill( SYSTEM.ADR(linestr), 1+HIGH(linestr), TheChar);
  75. StrEdit.SetLength( linestr, col2 - col1 +1);
  76. VWindows.DrawStr( VWindows.CurrentWindow, col1, row1,
  77. SYSTEM.ADR(linestr), col2 - col1 + 1 );
  78. ELSE
  79. (*We're drawing a vertical line.*)
  80. FOR row := row1 TO row2 DO
  81. VWindows.DrawStr( VWindows.CurrentWindow, col1, row,
  82. SYSTEM.ADR(TheChar), 1 );
  83. END;
  84. END;
  85. END DrawLine;
  86. PROCEDURE GetFrameCoords( TheFrame: ScrnTypes.DisplayFrame; VAR
  87. rect: Rectangles.ARectangle );
  88. BEGIN
  89. Rectangles.DefineRectangle( rect, TheFrame^.startcol +
  90. 1, TheFrame^.startrow + 1, TheFrame^.endcol + 1,
  91. TheFrame^.endrow + 1 )
  92. END GetFrameCoords;
  93. PROCEDURE RedrawEdField( TheFrame: ScrnTypes.DisplayFrame;
  94. FieldCount: CARDINAL; VAR area: Rectangles.ARectangle;
  95. Selected: BOOLEAN );
  96. VAR
  97. cnt, TypeCode, AbsCol, AbsRow, TmpLength,
  98. EdFieldHeight, EdFieldWidth : CARDINAL;
  99. TmpList: GenLists.GenList;
  100. TmpAdr: SYSTEM.ADDRESS;
  101. EdArea, intersection : Rectangles.ARectangle;
  102. PROCEDURE DrawPartOfStr( StrAdr: SYSTEM.ADDRESS; StrSize, col,
  103. row: CARDINAL; VAR area: Rectangles.ARectangle );
  104. VAR
  105. StrArea, intersection : Rectangles.ARectangle;
  106. LeadChop: CARDINAL;
  107. BEGIN
  108. StrSize := LowLevel.ScanEQ( StrSize, 0C, StrAdr );
  109. Rectangles.DefineRectangle( StrArea, col, row, col +
  110. StrSize - 1, row );
  111. IF Rectangles.RectsIntersect( StrArea, area, intersection ) THEN
  112. IF StrSize # 0 THEN
  113. (* Added this test 8 Nov 88 at suggestion of John
  114. McMonagle because DrawStr does a NullScan if last
  115. parameter is 0. *)
  116. IF intersection.col1 > INTEGER(col) THEN
  117. LeadChop := CARDINAL(intersection.col1) - col;
  118. ELSE
  119. LeadChop := 0;
  120. END;
  121. VWindows.DrawStr( TheFrame^.WindowHandle,
  122. intersection.col1, intersection.row1,
  123. LowLevel.AddAddr(StrAdr, LeadChop), (intersection.col2 -
  124. intersection.col1) + 1 );
  125. END;
  126. END;
  127. END DrawPartOfStr;
  128. BEGIN
  129. AbsRow := ScrnUtl1.AbsFieldRow( TheFrame, FieldCount );
  130. AbsCol := ScrnUtl1.AbsFieldCol( TheFrame, FieldCount );
  131. ScrnUtl1.GetEdField( TheFrame, FieldCount, TmpList );
  132. IF Selected THEN
  133. ScrnUtl1.SetPointerBarColors( TheFrame );
  134. ELSE
  135. ScrnUtl1.SetFieldColors( TheFrame, FieldCount );
  136. END;
  137. EdFieldHeight := ScrnUtl1.FieldHeight( TheFrame, FieldCount );
  138. EdFieldWidth := ScrnUtl1.FieldWidth( TheFrame, FieldCount );
  139. Rectangles.DefineRectangle( EdArea, AbsCol, AbsRow, AbsCol
  140. + EdFieldWidth - 1, AbsRow + EdFieldHeight - 1 );
  141. IF Rectangles.RectsIntersect( EdArea, area, intersection ) THEN
  142. VWindows.ClearPart( TheFrame^.WindowHandle, intersection.col1,
  143. intersection.row1, intersection.col2, intersection.row2 );
  144. END;
  145. EdFieldHeight := Numbers.Min( EdFieldHeight,
  146. GenLists.ListLength( TmpList ) );
  147. (*EdFieldHeight gets the lesser of the full height
  148. of the editor window or the number of lines
  149. presently in it.*)
  150. FOR cnt := 1 TO EdFieldHeight DO
  151. (* write each row in editor window *)
  152. GenLists.GetElmtAdr( TmpList, cnt, TmpAdr, TmpLength,
  153. TypeCode );
  154. DrawPartOfStr( TmpAdr, TmpLength, AbsCol,
  155. CARDINAL(AbsRow) + cnt - 1, intersection );
  156. END;
  157. END RedrawEdField;
  158. PROCEDURE RedrawArea( TheFrame: ScrnTypes.DisplayFrame; col1,
  159. row1, col2, row2: CARDINAL );
  160. VAR
  161. inside: BOOLEAN;
  162. FrameRect, TheArea, intersection, EdRect,
  163. EdToDraw: Rectangles.ARectangle;
  164. TmpFieldPtr: ScrnTypes.InputFieldPtr;
  165. ImagePtr: ScrnTypes.ImageElmtPtr;
  166. tmprow, tmpcol, tmpfield, LeadChop, EdFieldCount, ImageCount,
  167. FieldListEnd, ImageListEnd,
  168. TmpLength: CARDINAL;
  169. EdFieldHeight, EdFieldWidth, AbsoluteRow, AbsoluteCol: INTEGER;
  170. TheBox : VWindows.BoxStr;
  171. tmpforeg, tmpbackg: MsColors.AColor;
  172. tmpatrb: MsColors.AMonoAttribute;
  173. BEGIN
  174. (* First, we find each field that's in the area we have to
  175. redraw, taking TheFrame^.RowsScrolled and
  176. TheFrame^.ColsScrolled into account.*)
  177. GetFrameCoords( TheFrame, FrameRect );
  178. Rectangles.DefineRectangle( TheArea, col1, row1, col2, row2 );
  179. (* We could check here to make sure TheArea is inside
  180. FrameRect, but we'll let the caller be responsible for
  181. that. *)
  182. IF TheFrame^.ClearFirst THEN
  183. (* clear underlying window if this screen is "ClearFirst" *)
  184. ScrnUtl1.SetNormalColors( TheFrame );
  185. VWindows.ClearPart( TheFrame^.WindowHandle, col1, row1, col2, row2 );
  186. END;
  187. IF TheFrame^.EntryBox[0] # 0C THEN
  188. (* Oh no. We may have to restore some or all of the box. *)
  189. Rectangles.ShrinkRect( FrameRect );
  190. IF Rectangles.RectIsInside( TheArea, FrameRect ) THEN
  191. (* Breathe sigh of relief. TheArea does not extend
  192. into the box. *)
  193. Rectangles.ExpandRect( FrameRect );
  194. ELSE
  195. Rectangles.ExpandRect( FrameRect );
  196. IF Rectangles.RectsIntersect( FrameRect, TheArea, intersection ) THEN
  197. (* Actually, we already know they intersect; this just computes
  198. the intersection for us. *)
  199. END;
  200. (* The code below is temporarily determining whether
  201. the frame is active from capitalization of the
  202. .action char. If it's uppercase, we know the
  203. frame is inactive, so we redraw the ExitBox. *)
  204. IF TheFrame^.action <= 'Z' THEN
  205. TheBox := TheFrame^.ExitBox;
  206. ELSE
  207. TheBox := TheFrame^.EntryBox;
  208. END;
  209. ScrnUtl1.SetBorderColors( TheFrame );
  210. IF TheArea.col2 >= FrameRect.col2 THEN
  211. DEC( col2 );
  212. (* We're doing something tricky here. We know
  213. there's a box, and we know the area to be
  214. redrawn extends into it on the right side, so
  215. that means we also know that col2 is wrong--the
  216. area to be redrawn is actually one column less
  217. wide than we had supposed. *)
  218. DrawLine( intersection.col2, intersection.row1,
  219. intersection.col2, intersection.row2, TheBox[4] );
  220. IF intersection.row1 = FrameRect.row1 THEN
  221. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col2,
  222. intersection.row1, SYSTEM.ADR(TheBox[2]), 1 );
  223. END;
  224. IF intersection.row2 = FrameRect.row2 THEN
  225. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col2,
  226. intersection.row2, SYSTEM.ADR(TheBox[7]), 1 );
  227. END;
  228. END;
  229. IF TheArea.col1 <= FrameRect.col1 THEN
  230. INC( col1 );
  231. DrawLine( intersection.col1, intersection.row1,
  232. intersection.col1, intersection.row2, TheBox[3] );
  233. IF intersection.row1 = FrameRect.row1 THEN
  234. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col1,
  235. intersection.row1, SYSTEM.ADR(TheBox[0]), 1 );
  236. END;
  237. IF intersection.row2 = FrameRect.row2 THEN
  238. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col1,
  239. intersection.row2, SYSTEM.ADR(TheBox[5]), 1 );
  240. END;
  241. END;
  242. IF TheArea.row2 >= FrameRect.row2 THEN
  243. DEC( row2 );
  244. DrawLine( intersection.col1, intersection.row2,
  245. intersection.col2, intersection.row2, TheBox[6] );
  246. IF intersection.col1 = FrameRect.col1 THEN
  247. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col1,
  248. intersection.row2, SYSTEM.ADR(TheBox[5]), 1 );
  249. END;
  250. IF intersection.col2 = FrameRect.col2 THEN
  251. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col2,
  252. intersection.row2, SYSTEM.ADR(TheBox[7]), 1 );
  253. END;
  254. END;
  255. IF TheArea.row1 <= FrameRect.row1 THEN
  256. INC( row1 );
  257. DrawLine( intersection.col1, intersection.row1,
  258. intersection.col2, intersection.row1, TheBox[1] );
  259. IF intersection.col1 = FrameRect.col1 THEN
  260. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col1,
  261. intersection.row1, SYSTEM.ADR(TheBox[0]), 1 );
  262. END;
  263. IF intersection.col2 = FrameRect.col2 THEN
  264. VWindows.DrawStr( VWindows.CurrentWindow, intersection.col2,
  265. intersection.row1, SYSTEM.ADR(TheBox[2]), 1 );
  266. END;
  267. END;
  268. ScrnUtl1.SetNormalColors( TheFrame );
  269. END;
  270. END;
  271. IF NOT GenLists.Initialized( TheFrame^.ImageList ) THEN
  272. RETURN;
  273. END;
  274. EdFieldCount := 0;
  275. ImageCount := 1;
  276. ImageListEnd := ScrnUtl1.NumberOfImages( TheFrame );
  277. WHILE ImageCount <= ImageListEnd DO
  278. ScrnUtl1.GetImagePtr( TheFrame, ImageCount, ImagePtr );
  279. TmpLength := M2Strings.Length(ImagePtr^.text);
  280. tmprow := ImagePtr^.row;
  281. tmpcol := ImagePtr^.col;
  282. tmpfield := ImagePtr^.field;
  283. tmpforeg := ImagePtr^.foreg;
  284. tmpbackg := ImagePtr^.backg;
  285. tmpatrb := ImagePtr^.atrb;
  286. ScrnUtl1.DecodeWord( tmprow );
  287. ScrnUtl1.DecodeWord( tmpcol );
  288. ScrnUtl1.DecodeWord( tmpfield );
  289. ScrnUtl1.DecodeByte( tmpforeg );
  290. ScrnUtl1.DecodeByte( tmpbackg );
  291. ScrnUtl1.DecodeByte( tmpatrb );
  292. IF tmprow <= TheFrame^.headline THEN
  293. (* Is this image element protected from scrolling? *)
  294. AbsoluteRow := INTEGER(TheFrame^.startrow + tmprow);
  295. (* If so, it's always going to be in the same place; we
  296. don't have to subtract RowsScrolled to find out where
  297. to write it. *)
  298. ELSE
  299. (* This image element is not protected from scrolling; we
  300. have to add the absolute starting row of the window and
  301. then subtract RowsScrolled to find out where to write it. *)
  302. AbsoluteRow := INTEGER(TheFrame^.startrow + tmprow)
  303. - INTEGER( TheFrame^.RowsScrolled );
  304. IF AbsoluteRow <= INTEGER(TheFrame^.startrow + TheFrame^.headline)
  305. THEN
  306. (* Image element has been scrolled up out of the visible
  307. part of the window; it's either underneath the area
  308. protected by the headline, or it's above the window
  309. altogether; could be negative. *)
  310. AbsoluteRow := AbsoluteRow - INTEGER( TheFrame^.headline );
  311. END;
  312. END;
  313. (*A negative value for AbsoluteRow here indicates
  314. that the field would have been scrolled off the top
  315. of the screen.*)
  316. AbsoluteCol := INTEGER(TheFrame^.startcol + tmpcol)
  317. - INTEGER( TheFrame^.ColsScrolled );
  318. LeadChop := 0;
  319. IF (tmpfield # 0) THEN
  320. ScrnUtl1.GetFieldPtr( TheFrame, tmpfield, TmpFieldPtr );
  321. END;
  322. IF (tmpfield # 0) AND (TmpFieldPtr^.typ = ScrnTypes.EditorCode) THEN
  323. AbsoluteRow := ScrnUtl1.AbsFieldRow( TheFrame, tmpfield );
  324. AbsoluteCol := ScrnUtl1.AbsFieldCol( TheFrame, tmpfield );
  325. EdFieldHeight := ScrnUtl1.FieldHeight( TheFrame, tmpfield );
  326. EdFieldWidth := ScrnUtl1.FieldWidth( TheFrame, tmpfield );
  327. Rectangles.DefineRectangle(EdRect , AbsoluteCol, AbsoluteRow,
  328. (AbsoluteCol + EdFieldWidth) - 1,
  329. (AbsoluteRow + EdFieldHeight) - 1 );
  330. inside := Rectangles.RectsIntersect(TheArea,EdRect,EdToDraw);
  331. ELSE
  332. IF NOT Numbers.IntIsBetween(row1, AbsoluteRow, row2) THEN
  333. inside := FALSE;
  334. ELSIF (AbsoluteCol > INTEGER(col2)) THEN
  335. inside := FALSE;
  336. ELSIF (AbsoluteCol < INTEGER(col1)) THEN
  337. IF (AbsoluteCol + INTEGER(TmpLength)) < INTEGER(col1) THEN
  338. inside := FALSE;
  339. ELSE
  340. LeadChop := CARDINAL(INTEGER(col1) - AbsoluteCol);
  341. inside := TRUE;
  342. END;
  343. ELSE
  344. inside := TRUE;
  345. END;
  346. END;
  347. IF inside THEN
  348. IF (tmpfield # 0) THEN
  349. (* Uh oh. It's not a normal piece of text. *)
  350. IF (TmpFieldPtr^.typ = ScrnTypes.GroupMember) AND
  351. TmpFieldPtr^.selected THEN
  352. (* It's a choice field (member of a group) and it's
  353. selected, so we use selection colors *)
  354. ScrnUtl1.SetSelectionColors( TheFrame );
  355. ELSIF (TmpFieldPtr^.typ = ScrnTypes.EditorCode) AND
  356. (EdFieldCount = 0) THEN
  357. (* Note the first editor field, but don't write it. Editor
  358. fields have to be written last because
  359. lines below onto which the bottom part of the editor field
  360. overlaps may not be in the background color. Spaces will
  361. be written over them in whatever that color is, and we
  362. don't want to wipe out the bottom of the editor field. *)
  363. EdFieldCount := tmpfield;
  364. ELSE
  365. (* use normal colors for this field*)
  366. ScrnUtl1.SetFieldColors( TheFrame, tmpfield );
  367. END;
  368. ELSE
  369. (* use normal colors for this field*)
  370. VWindows.SetForeColor( TheFrame^.WindowHandle,
  371. tmpforeg );
  372. VWindows.SetBackColor( TheFrame^.WindowHandle,
  373. tmpbackg );
  374. VWindows.SetMonoAttr( TheFrame^.WindowHandle,
  375. tmpatrb );
  376. END;
  377. IF (tmpfield = 0) OR (TmpFieldPtr^.typ # ScrnTypes.EditorCode) THEN
  378. IF (AbsoluteCol + INTEGER(TmpLength)) >= (INTEGER(col2) + 1) THEN
  379. (*If the string would extend past the right boundary.*)
  380. TmpLength := CARDINAL((( INTEGER(col2) - AbsoluteCol)
  381. + 1) - INTEGER(LeadChop));
  382. VWindows.DrawStr( TheFrame^.WindowHandle,
  383. CARDINAL( (AbsoluteCol + INTEGER(LeadChop))),
  384. CARDINAL(AbsoluteRow),
  385. LowLevel.AddAddr(SYSTEM.ADR(ImagePtr^.text),
  386. LeadChop), TmpLength );
  387. ELSE
  388. VWindows.DrawStr( TheFrame^.WindowHandle,
  389. CARDINAL( (AbsoluteCol + INTEGER(LeadChop))),
  390. CARDINAL(AbsoluteRow),
  391. LowLevel.AddAddr(SYSTEM.ADR(ImagePtr^.text),
  392. LeadChop), TmpLength - LeadChop );
  393. END;
  394. END;
  395. END;
  396. INC( ImageCount );
  397. END;
  398. IF EdFieldCount = 0 THEN
  399. RETURN;
  400. END;
  401. FieldListEnd := ScrnUtl1.FieldListTotal( TheFrame );
  402. WHILE (EdFieldCount <= FieldListEnd) DO
  403. ScrnUtl1.GetFieldPtr( TheFrame, EdFieldCount, TmpFieldPtr );
  404. IF (TmpFieldPtr^.typ = ScrnTypes.EditorCode) THEN
  405. (* It's an editor field. *)
  406. AbsoluteRow := ScrnUtl1.AbsFieldRow( TheFrame, EdFieldCount );
  407. AbsoluteCol := ScrnUtl1.AbsFieldCol( TheFrame, EdFieldCount );
  408. EdFieldHeight := ScrnUtl1.FieldHeight( TheFrame, EdFieldCount );
  409. EdFieldWidth := ScrnUtl1.FieldWidth( TheFrame, EdFieldCount );
  410. Rectangles.DefineRectangle(EdRect , AbsoluteCol, AbsoluteRow,
  411. (AbsoluteCol + EdFieldWidth) - 1,
  412. AbsoluteRow + EdFieldHeight - 1 );
  413. IF Rectangles.RectsIntersect(TheArea,EdRect,EdToDraw) THEN
  414. (* We now know we have to display at least part of
  415. the editor field *)
  416. RedrawEdField( TheFrame, EdFieldCount, EdToDraw, FALSE );
  417. END;
  418. END;
  419. INC( EdFieldCount );
  420. END;
  421. END RedrawArea;
  422. PROCEDURE RedrawField( TheFrame: ScrnTypes.DisplayFrame; TheField:
  423. CARDINAL; Selected: BOOLEAN );
  424. (* Selected tells us whether the pointer bar is on this
  425. field, not whether it's a selected member of a choice
  426. group; we'll figure out the latter from the field
  427. itself.*)
  428. VAR
  429. FieldRec: ScrnTypes.InputFieldRecord;
  430. ImageRec: ScrnTypes.ImageElement;
  431. spot : CARDINAL;
  432. CurrentChoice, save : BOOLEAN;
  433. SelChar: ARRAY [0..0] OF CHAR;
  434. FrameArea : Rectangles.ARectangle;
  435. BEGIN
  436. CurrentChoice := FALSE;
  437. ScrnUtl1.GetFieldRec( TheFrame, TheField, FieldRec );
  438. ScrnUtl1.GetFieldImageRec( TheFrame, TheField, ImageRec );
  439. IF Selected THEN
  440. ScrnUtl1.SetPointerBarColors( TheFrame );
  441. ELSIF (FieldRec.typ = ScrnTypes.GroupMember) AND
  442. (FieldRec.selected) THEN
  443. CurrentChoice := TRUE;
  444. (* We do this to prevent selection character from being
  445. highlighted if the choice is already selected. *)
  446. ScrnUtl1.SetSelectionColors( TheFrame );
  447. ELSE
  448. ScrnUtl1.SetFieldColors( TheFrame, TheField );
  449. END;
  450. IF (FieldRec.typ = ScrnTypes.EditorCode) THEN
  451. Rectangles.DefineRectangle( FrameArea, TheFrame^.startcol + 1,
  452. TheFrame^.startrow + 1, TheFrame^.endcol + 1,
  453. TheFrame^.endrow + 1 );
  454. RedrawEdField( TheFrame, TheField, FrameArea, Selected );
  455. RETURN;
  456. END;
  457. ScrnUtl1.GetFieldImageRec( TheFrame, TheField, ImageRec );
  458. VWindows.DrawStr( TheFrame^.WindowHandle,
  459. ImageRec.col + TheFrame^.startcol - TheFrame^.ColsScrolled,
  460. ImageRec.row + TheFrame^.startrow - TheFrame^.RowsScrolled,
  461. SYSTEM.ADR(ImageRec.text), M2Strings.Length(ImageRec.text) );
  462. (*Now hilite the selection character, if there is one.*)
  463. IF CurrentChoice OR (Selected AND NOT InColorMode()) THEN
  464. (*Don't bother if it's a choice field in selection
  465. colors, and don't bother if the field is already
  466. selected and the screen isn't in a color mode.*)
  467. RETURN;
  468. END;
  469. IF (FieldRec.typ = ScrnTypes.GroupMember) AND
  470. (FieldRec.ChoiceKey <= Key.Extended) THEN
  471. SelChar[0] := CHR(FieldRec.ChoiceKey);
  472. ELSIF (FieldRec.typ = ScrnTypes.GotoCode) AND
  473. (FieldRec.MenuKey <= Key.Extended) THEN
  474. SelChar[0] := CHR(FieldRec.MenuKey);
  475. ELSE
  476. RETURN;
  477. END;
  478. save := PosUtils.CaseSensitive;
  479. PosUtils.CaseSensitive := TRUE;
  480. IF NOT PosUtils.PresentPos( SelChar, ImageRec.text, spot ) THEN
  481. PosUtils.CaseSensitive := save;
  482. RETURN;
  483. END;
  484. PosUtils.CaseSensitive := save;
  485. ScrnUtl1.SetSelCharColors( TheFrame, TheField );
  486. IF Selected THEN
  487. VWindows.SetBackColor( TheFrame^.WindowHandle,
  488. TheFrame^.pbbak );
  489. END;
  490. VWindows.DrawStr( TheFrame^.WindowHandle,
  491. ImageRec.col + TheFrame^.startcol -
  492. TheFrame^.ColsScrolled + spot, ImageRec.row +
  493. TheFrame^.startrow - TheFrame^.RowsScrolled,
  494. SYSTEM.ADR(ImageRec.text[spot]), 1 );
  495. END RedrawField;
  496. PROCEDURE ShowDisplayFrame(VAR FrameRec : ScrnTypes.DisplayFrame;
  497. Col1, Row1, ColX, RowX : CARDINAL);
  498. (* Displays the screen in FrameRec on the screen
  499. in the window defined by Col1, Row1, ColX, RowX.
  500. Col1, Row1 = upper left hand corner of window;
  501. ColX, RowX = lower right corner coordinates.
  502. Note: if Col1=0, then this proc uses the default values for
  503. the window coordinates.*)
  504. BEGIN (* ShowDisplayFrame *)
  505. IF Col1 > 0 THEN
  506. (*Correct the origin: starting col and row are
  507. decremented by one to represent "zero".*)
  508. FrameRec^.startcol := Col1-1;
  509. FrameRec^.endcol := ColX-1;
  510. FrameRec^.startrow := Row1-1;
  511. FrameRec^.endrow := RowX - 1;
  512. ELSE
  513. Col1 := FrameRec^.startcol + 1;
  514. Row1 := FrameRec^.startrow + 1;
  515. ColX := FrameRec^.endcol + 1;
  516. RowX := FrameRec^.endrow + 1;
  517. END;
  518. FrameManager.FrameActivated( FrameRec );
  519. FrameManager.FrameIsInForeGround( FrameRec );
  520. (* We have to call both because FrameActivated won't
  521. bring the frame to the foreground if it is already
  522. active. Note that we don't do this in RedrawArea,
  523. because RedrawArea is what FrameManager uses to
  524. restore areas of the screen -- if each call to
  525. RedrawArea changed the ordering of frames in
  526. FrameManager's FrameList, it would get stuck. *)
  527. IF NOT ScrnUtl1.BoxInFrame(FrameRec) THEN
  528. RedrawArea( FrameRec, Col1, Row1, ColX, RowX );
  529. ELSE
  530. (* draw the proper box for this screen *)
  531. ScrnUtl1.SetBorderColors( FrameRec );
  532. VWindows.DrawBox( FrameRec^.WindowHandle,
  533. FrameRec^.ExitBox, Col1, Row1, ColX, RowX );
  534. (*We draw the ExitBox because the frame is not active
  535. at this point.*)
  536. ScrnUtl1.WriteBetween( FrameRec^.WindowHandle, FrameRec^.Caption,
  537. Col1 + 1, Row1, ColX - 1, RowX );
  538. RedrawArea( FrameRec, Col1 + 1, Row1 + 1, ColX - 1, RowX - 1 );
  539. END;
  540. END ShowDisplayFrame;
  541. BEGIN
  542. Initialized := FALSE;
  543. Init();
  544. END FramePainter.