PageRenderTime 70ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/src/front/frontcl/ft/ftredraw.c

https://github.com/akdh/Ingres
C | 468 lines | 241 code | 32 blank | 195 comment | 46 complexity | e3b5686937c93b5b5e0f27ca410ba1fb MD5 | raw file
  1. /*
  2. ** FTredraw
  3. **
  4. ** Copyright (c) 2004 Ingres Corporation
  5. **
  6. ** ftredraw.c
  7. **
  8. ** History:
  9. ** 05/06/88 (dkh) - Updated for Venus.
  10. ** 07/23/88 (dkh) - Modified to handle scrolled forms.
  11. ** 10/22/88 (dkh) - Performance changes.
  12. ** 13-jan-89 (bruceb)
  13. ** If redrawing a single frame, and that frame has the
  14. ** fdREBUILD flag set, than call FTbuild.
  15. ** 04/10/89 (dkh) - Reset IIFTscScreenCleared once screen updated.
  16. ** 08/04/89 (dkh) - Added support for 80/132 runtime switching.
  17. ** 08/15/89 (dkh) - Fixed problem with ABF calling another process
  18. ** from a popup. On return from subprocess, all
  19. ** visible forms are now redisplayed as opposed to
  20. ** just the popup being redisplayed.
  21. ** 08/30/89 (dkh) - Put in some patches to better handle displaying
  22. ** big forms for the first time.
  23. ** 10/02/89 (dkh) - Changed IIFTscSizeChg() to IIFTcsChgSize().
  24. ** 12/30/89 (dkh) - Changed screen update scheme to make it look more
  25. ** atomic.
  26. ** 04/21/90 (dkh) - Fixed us #595 by changing positioning scheme.
  27. ** 11/14/90 (dkh) - Fixed bug 34449. Removed call to center
  28. ** destination since it duplicates code that
  29. ** is now in TDrefresh().
  30. ** 08/17/91 (dkh) - Fixed bug 38952. Screen updates for large forms
  31. ** that have scrolled vertically should now draw
  32. ** with less odd behavior.
  33. ** 08/18/91 (dkh) - Fixed bug 38752. Put in some workarounds to
  34. ** make things work for the compressed view of
  35. ** a vision visual query. The real fix should
  36. ** be to change vision to create more sociable forms.
  37. ** 10-jun-92 (rogerf) - Added FTWNRedraw function and call to it if
  38. ** SCROLLBARS is defined.
  39. ** 01/26/93 (dkh) - Added ifdef around forward declaration of FTWNRedraw()
  40. ** so it does not become a link problem for VMS.
  41. ** 14-mar-95 (peeje01: jmbp) Cross-integration from 6500db_su4_us42
  42. ** Original comment follows:
  43. ** ** 06-aug-92 (kirke)
  44. ** ** For DOUBLEBYTE ports always force a redraw of all fields
  45. ** ** so that DB characters underneath the border get redrawn.
  46. ** 21-jan-1999 (hanch04)
  47. ** replace nat and longnat with i4
  48. ** 31-aug-2000 (hanch04)
  49. ** cross change to main
  50. ** replace nat and longnat with i4
  51. ** 25-Oct-2005 (hanje04)
  52. ** Add prototype for fix_start() to prevent compiler
  53. ** errors with GCC 4.0 due to conflict with implicit declaration.
  54. */
  55. # include <compat.h>
  56. # include <gl.h>
  57. # include <sl.h>
  58. # include <iicommon.h>
  59. # include <fe.h>
  60. # include "ftframe.h"
  61. # ifdef SCROLLBARS
  62. # include <wn.h>
  63. # endif
  64. FUNC_EXTERN WINDOW *FTfindwin();
  65. FUNC_EXTERN VOID IIFTrRedisp();
  66. FUNC_EXTERN VOID IIFTgdiGetDispInfo();
  67. FUNC_EXTERN VOID IIFTcsChgSize();
  68. # ifdef SCROLLBARS
  69. FUNC_EXTERN VOID FTWNRedraw();
  70. # endif
  71. static fix_start(
  72. WINDOW *win);
  73. GLOBALREF bool IIFTscScreenCleared;
  74. /*{
  75. ** Name: FTredraw - Redraw passed in form on the terminal screen.
  76. **
  77. ** Description:
  78. ** Given a form, redraw it to the terminal screen. The mode to
  79. ** display the form in determines whether the terminal is updateable
  80. ** or not. Terminal cursor is left put at field designated by
  81. ** the field number. If argument "all" is TRUE, then update screen
  82. ** with "all" possibly visible forms, including the passed in one.
  83. **
  84. ** Inputs:
  85. ** frm Pointer to form to display.
  86. ** dispmode Display mode of form.
  87. ** fldno Number indicating field where cursor is to be left.
  88. ** all Boolean to display "all" possibly visible fields.
  89. **
  90. ** Outputs:
  91. ** None.
  92. **
  93. ** Returns:
  94. ** None.
  95. ** Exceptions:
  96. ** None.
  97. **
  98. ** Side Effects:
  99. ** Screen display is updated.
  100. **
  101. ** History:
  102. ** 05/06/88 (dkh) - Updated for Venus.
  103. */
  104. VOID
  105. FTredraw(frm, dispmode, fldno, all)
  106. FRAME *frm;
  107. i4 dispmode;
  108. i4 fldno;
  109. i4 all;
  110. {
  111. FIELD *fld;
  112. WINDOW *win = NULL;
  113. i4 isfull;
  114. i4 yoffset;
  115. i4 xoffset;
  116. i4 getout = FALSE;
  117. i4 rebuild = FALSE;
  118. i4 start_modified = FALSE;
  119. IIFTcsChgSize();
  120. # ifdef DOUBLEBYTE
  121. all = TRUE;
  122. # endif
  123. if (all)
  124. {
  125. /*
  126. ** Display all possibly visible forms.
  127. */
  128. IIFTrRedisp();
  129. frm->frmflags &= ~(fdDISPRBLD | fdREDRAW | fdREBUILD);
  130. }
  131. else
  132. {
  133. IIFTgdiGetDispInfo(&isfull, &yoffset, &xoffset);
  134. if (isfull)
  135. {
  136. curscr->_begy = yoffset;
  137. curscr->_begx = xoffset;
  138. }
  139. if (frm->frmflags & fdREBUILD)
  140. {
  141. rebuild = TRUE;
  142. }
  143. if (!isfull && (frm->frmflags & fdDISPRBLD))
  144. {
  145. IIFTrRedisp();
  146. frm->frmflags &= ~(fdDISPRBLD | fdREDRAW | fdREBUILD);
  147. getout = TRUE;
  148. }
  149. if (fldno != -1)
  150. {
  151. fld = frm->frfld[fldno];
  152. /*
  153. ** This means that the form must be a fullscreen.
  154. ** Otherwise, this flag would have been cleared
  155. ** above.
  156. **
  157. ** If we are dealing with a vision compress view
  158. ** form that is large, alway rebuild and set curscr
  159. ** offsets to get it to display correctly.
  160. */
  161. if (frm->frmflags & (fdDISPRBLD | fdREBUILD | fdVIS_CMPVW))
  162. {
  163. /*
  164. ** Rebuild the fullscreen form image.
  165. */
  166. FTbuild(frm, (bool)FALSE, FTwin, (bool)FALSE);
  167. TDboxfix(FTwin);
  168. frm->frmflags &=
  169. ~(fdDISPRBLD | fdREDRAW | fdREBUILD);
  170. win = FTfindwin(fld, FTwin, FTutilwin);
  171. fix_start(win);
  172. start_modified = TRUE;
  173. }
  174. else
  175. {
  176. win = FTfindwin(fld, FTwin, FTutilwin);
  177. }
  178. TDmove(win, (i4) 0, (i4) 0);
  179. /*
  180. ** Only refresh to current field if we have not
  181. ** modified the start location for curscr.
  182. */
  183. if (!start_modified)
  184. {
  185. TDrefresh(win);
  186. }
  187. }
  188. if (getout)
  189. {
  190. #ifdef SCROLLBARS
  191. FTWNRedraw(frm, fldno);
  192. #endif
  193. return;
  194. }
  195. /*
  196. ** If screen has cleared and current form is a
  197. ** popup, then need to rebuild complete screen
  198. ** image. Rebuilding of complete screen image
  199. ** will cause forms to be completely rebuilt, so
  200. ** special display sync flags can be reset.
  201. */
  202. if (IIFTscScreenCleared && !isfull)
  203. {
  204. IIFTrRedisp();
  205. frm->frmflags &= ~fdREDRAW;
  206. IIFTscScreenCleared = FALSE;
  207. #ifdef SCROLLBARS
  208. FTWNRedraw(frm, fldno);
  209. #endif
  210. return;
  211. }
  212. /*
  213. ** If there is a parent, then we have a form that
  214. ** has popup style with borders. Use parent so
  215. ** borders will show up as well.
  216. */
  217. win = (FTwin->_parent != NULL) ? FTwin->_parent : FTwin;
  218. if (IIFTscScreenCleared || frm->frmflags & fdREDRAW)
  219. {
  220. TDtouchwin(win);
  221. frm->frmflags &= ~fdREDRAW;
  222. IIFTscScreenCleared = FALSE;
  223. }
  224. if (rebuild)
  225. {
  226. /*
  227. ** FTbuild into FTwin. However, touch the parent
  228. ** form (if any) so as to handle popups with
  229. ** borders.
  230. **
  231. ** FTbuild turns off the fdREBUILD flag.
  232. */
  233. if (frm->frmflags & fdREBUILD)
  234. {
  235. FTbuild(frm, (bool)FALSE, FTwin, (bool)FALSE);
  236. TDboxfix(FTwin);
  237. }
  238. TDtouchwin(win);
  239. }
  240. TDrefresh(win);
  241. /*
  242. ** Set scroll coordinates if the frame is a vision
  243. ** compress view frame. This allows the compressed
  244. ** frame to actually stayed scroll if we are viewing
  245. ** a large visual query with "zoomout".
  246. **
  247. ** A much better fix is to fix vision to build forms
  248. ** similar to the application flow diagram that does
  249. ** not need to scroll.
  250. */
  251. if (frm->frmflags & fdVIS_CMPVW)
  252. {
  253. IIFTsccSetCurCoord();
  254. }
  255. }
  256. #ifdef SCROLLBARS
  257. FTWNRedraw(frm, fldno);
  258. #endif
  259. }
  260. static
  261. fix_start(win)
  262. WINDOW *win;
  263. {
  264. i4 first_visible;
  265. i4 middle;
  266. i4 available;
  267. /*
  268. ** If starting location for window is not visible given the
  269. ** current values of curscr->_begy, then adjust _begy till
  270. ** the window is visible in the middle of the screen. But
  271. ** not beyond the edges of the form.
  272. **
  273. ** We don't adjust for _begx since that doesn't cause
  274. ** scroll behaviors, the window is simply repainted.
  275. */
  276. first_visible = -curscr->_begy;
  277. available = LINES - IITDflu_firstlineused - 1;
  278. middle = available/2;
  279. /*
  280. ** If row is above screen, scroll view back up or
  281. ** scroll data down.
  282. */
  283. if (win->_begy < first_visible)
  284. {
  285. /*
  286. ** Push starting location all the way to the top
  287. ** if the starting location is normally visible
  288. ** with no vertical scrolling of form.
  289. ** Otherwise, just put starting point
  290. ** at middle of screen. The -1 in the
  291. ** if statement is to go to zero based addressing.
  292. */
  293. if (win->_begy < available - 1)
  294. {
  295. curscr->_begy = 0;
  296. }
  297. else if ((curscr->_begy += middle) > 0)
  298. {
  299. /*
  300. ** This is redundant, but if
  301. ** we move back to much, just
  302. ** set to no vertical scrolling.
  303. */
  304. curscr->_begy = 0;
  305. }
  306. }
  307. else if (win->_begy > (first_visible + available - 1))
  308. {
  309. /*
  310. ** If row is below screen, scroll view down or
  311. ** data up. Note that the -1 in the above if
  312. ** statement is needed since we to know the
  313. ** last visible row.
  314. */
  315. if (win->_begy + middle - 1 > FTwin->_maxy - 1)
  316. {
  317. curscr->_begy = -(FTwin->_maxy - available);
  318. }
  319. else
  320. {
  321. curscr->_begy = -(win->_begy - (available - middle));
  322. }
  323. }
  324. }
  325. #ifdef SCROLLBARS
  326. /*{
  327. ** Name: FTWNredraw - Continue FTredraw by adding ScrollBars
  328. **
  329. ** Description:
  330. ** Determine if Horizontal and/or vertical Scroll Bars are
  331. ** needed in a GUI environment.
  332. **
  333. ** Inputs:
  334. ** frm Pointer to form to display.
  335. ** fldno Number indicating field where cursor is to be left.
  336. **
  337. ** Outputs:
  338. ** None.
  339. **
  340. ** Returns:
  341. ** None.
  342. ** Exceptions:
  343. ** None.
  344. **
  345. ** Side Effects:
  346. ** Form scrollbar(s) are generated if needed.
  347. **
  348. ** History:
  349. ** 10-jun-92 (rogerf) Written.
  350. */
  351. VOID
  352. FTWNRedraw(frm, fldno)
  353. FRAME *frm;
  354. i4 fldno;
  355. {
  356. FLDHDR *fldHdr;
  357. FIELD **frfld;
  358. i2 i;
  359. i2 j;
  360. i2 vis;
  361. i2 wid;
  362. /* note... field must be fully visible on current screen */
  363. /* COUNT *VISIBLE* FIELDS, IF ONLY 1, DISABLE VERTICAL SCROLLBAR */
  364. /* CHECK IF ANY FIELD IS WIDER THAN SCREEN, IF NOT DISABLE HORIZ S-BAR */
  365. for (j = frm->frfldno, frfld = frm->frfld, i = vis = wid = 0;
  366. i < j;
  367. i++)
  368. {
  369. FIELD *fld;
  370. fld = (FIELD*) *frfld++;
  371. if (fld->fltag == FREGULAR)
  372. {
  373. if (!(fld->fld_var.flregfld->flhdr.fhdflags & fdINVISIBLE) &&
  374. !(fld->fld_var.flregfld->flhdr.fhd2flags & fdREADONLY))
  375. ++vis;
  376. if (fld->fld_var.flregfld->flhdr.fhposx +
  377. fld->fld_var.flregfld->flhdr.fhmaxx >= COLS)
  378. wid = 1;
  379. }
  380. else
  381. {
  382. if (!(fld->fld_var.fltblfld->tfhdr.fhdflags & (fdINVISIBLE | fdTFINVIS)))
  383. ++vis;
  384. if (fld->fld_var.fltblfld->tfhdr.fhposx +
  385. fld->fld_var.fltblfld->tfhdr.fhmaxx >= COLS)
  386. wid = 1;
  387. }
  388. }
  389. /* CURRENT FIELD? */
  390. if (fldno >= 0)
  391. {
  392. /* VISIBLE FIELD(S) */
  393. if (vis > 0)
  394. {
  395. i4 posx;
  396. fldHdr = (FLDHDR*) frm->frfld[fldno]->fld_var.flregfld;
  397. /* IF TABLE FIELD... ADJUST OFFSET FOR RELATIVE COLUMN */
  398. posx = fldHdr->fhposx;
  399. if (frm->frfld[fldno]->fltag == FTABLE)
  400. {
  401. TBLFLD *tf = frm->frfld[fldno]->fld_var.fltblfld;
  402. FLDCOL **fc = tf->tfflds;
  403. i2 i;
  404. for (i = 0; i < tf->tfcurcol; i++, ++fc)
  405. posx += (*fc)->flhdr.fhmaxx;
  406. }
  407. if ((vis == 1) && (wid > 0)) /* 1 vis fld + fld > form width */
  408. {
  409. WNFbarCreate(TRUE, 0, 0, /* suppress vert scroll bar */
  410. posx, /* current field column */
  411. frm->frmaxx); /* max form columns */
  412. return;
  413. }
  414. else if ((vis > 1) && (wid > 0)) /* many flds + fld > form width */
  415. {
  416. WNFbarCreate(TRUE,
  417. fldHdr->fhposy, /* current field row */
  418. frm->frmaxy, /* max form rows */
  419. posx, /* current field column */
  420. frm->frmaxx); /* max form columns */
  421. return;
  422. }
  423. else if ((vis > 1) && (wid == 0)) /* many flds, all < form width */
  424. {
  425. WNFbarCreate(TRUE,
  426. fldHdr->fhposy, /* current field row */
  427. frm->frmaxy, /* max form rows */
  428. 0, 0); /* suppress horiz scroll bar */
  429. return;
  430. }
  431. }
  432. }
  433. WNFbarDestroy();
  434. return;
  435. }
  436. #endif