gdkregion-generic.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // included by gdk2.pp
  2. {$IFDEF read_interface_types}
  3. PGdkRegionBox = ^TGdkRegionBox;
  4. TGdkRegionBox = TGdkSegment;
  5. {
  6. clip region
  7. }
  8. PGdkRegion = ^TGdkRegion;
  9. TGdkRegion = record
  10. size : longint;
  11. numRects : longint;
  12. rects : PGdkRegionBox;
  13. extents : TGdkRegionBox;
  14. end;
  15. {
  16. used to allocate buffers for points and link
  17. the buffers together
  18. }
  19. PPOINTBLOCK = ^TPOINTBLOCK;
  20. TPOINTBLOCK = record
  21. pts : array[0..(NUMPTSTOBUFFER)-1] of TGdkPoint;
  22. next : PPOINTBLOCK;
  23. end;
  24. {$ENDIF read_interface_types}
  25. //------------------------------------------------------------------------------
  26. {$IFDEF read_interface_rest}
  27. { 1 if two BOXs overlap.
  28. 0 if two BOXs do not overlap.
  29. Remember, x2 and y2 are not in the region
  30. }
  31. function gdkregion_EXTENTCHECK(r1, r2: PGdkRegionBox): boolean;
  32. {
  33. update region extents
  34. }
  35. procedure gdkregion_EXTENTS(r: PGdkRegionBox; idRect: PGdkRegion);
  36. {
  37. Check to see if there is enough memory in the present region.
  38. }
  39. function gdkregion_MEMCHECK(reg: PGdkRegion; var ARect, firstrect: PGdkRegionBox): boolean;
  40. { this routine checks to see if the previous rectangle is the same
  41. or subsumes the new rectangle to add.
  42. }
  43. function gdkregion_CHECK_PREVIOUS(Reg: PGdkRegion; R: PGdkRegionBox;
  44. Rx1,Ry1,Rx2,Ry2 : gint) : boolean;
  45. { add a rectangle to the given Region }
  46. procedure gdkregion_ADDRECT(reg: PGdkRegion; r: PGdkRegionBox;
  47. rx1, ry1, rx2, ry2: gint);
  48. { add a rectangle to the given Region }
  49. procedure gdkregion_ADDRECTNOX(reg: PGdkRegion; r: PGdkRegionBox; rx1,ry1,rx2,ry2: gint);
  50. { }
  51. function gdkregion_EMPTY_REGION(pReg: PGdkRegion): boolean;
  52. {pReg->numRects = 0}
  53. function gdkregion_REGION_NOT_EMPTY(pReg : PGdkRegion) : boolean;
  54. function gdkregion_INBOX(r: TGdkRegionBox; x,y : gint) : boolean;
  55. {$endif read_interface_rest}
  56. //------------------------------------------------------------------------------
  57. {$IFDEF read_implementation}
  58. function gdkregion_EXTENTCHECK(r1, r2: PGdkRegionBox): boolean;
  59. begin
  60. gdkregion_EXTENTCHECK:=(r1^.x2 > r2^.x1) and (r1^.x1 < r2^.x2) and (r1^.y2 > r2^.y1)
  61. and (r1^.y1 < r2^.y2)
  62. end;
  63. procedure gdkregion_EXTENTS(r: PGdkRegionBox; idRect: PGdkRegion);
  64. begin
  65. if (r^.x1 < idRect^.extents.x1) then idRect^.extents.x1 := r^.x1;
  66. if r^.y1 < idRect^.extents.y1 then idRect^.extents.y1 := r^.y1;
  67. if r^.x2 > idRect^.extents.x2 then idRect^.extents.x2 := r^.x2;
  68. end;
  69. function gdkregion_MEMCHECK(reg: PGdkRegion;
  70. var ARect, firstrect: PGdkRegionBox): boolean;
  71. begin
  72. {$IFNDEF KYLIX}
  73. if reg^.numRects >= reg^.size - 1 then begin
  74. firstrect := PGdkRegionBox(g_renew (SizeOf(TGdkRegionBox), firstrect,
  75. 2 * reg^.size));
  76. reg^.size:=reg^.size*2;
  77. Arect:=@firstrect[reg^.numRects];
  78. end;
  79. Result:=true;
  80. {$ENDIF}
  81. end;
  82. function gdkregion_CHECK_PREVIOUS(Reg: PGdkRegion; R: PGdkRegionBox;
  83. Rx1,Ry1,Rx2,Ry2 : gint) : boolean;
  84. begin
  85. {$IFNDEF KYLIX}
  86. gdkregion_CHECK_PREVIOUS:=
  87. not (((((Reg^.numRects > 0) and ((R - 1)^.y1 = Ry1))
  88. and ((R - 1)^.y2 = Ry2))
  89. and ((R - 1)^.x1 <= Rx1))
  90. and ((R - 1)^.x2 >= Rx2));
  91. {$ENDIF}
  92. end;
  93. procedure gdkregion_ADDRECT(reg: PGdkRegion; r: PGdkRegionBox;
  94. rx1, ry1, rx2, ry2: gint);
  95. begin
  96. if ((rx1 < rx2) and (ry1 < ry2)
  97. and gdkregion_CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)) then begin
  98. r^.x1 := rx1;
  99. r^.y1 := ry1;
  100. r^.x2 := rx2;
  101. r^.y2 := ry2;
  102. end;
  103. end;
  104. procedure gdkregion_ADDRECTNOX(reg: PGdkRegion; r: PGdkRegionBox;
  105. rx1,ry1,rx2,ry2: gint);
  106. begin
  107. if ((rx1 < rx2) and (ry1 < ry2)
  108. and gdkregion_CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)) then begin
  109. r^.x1 := rx1;
  110. r^.y1 := ry1;
  111. r^.x2 := rx2;
  112. r^.y2 := ry2;
  113. inc(reg^.numRects);
  114. end;
  115. end;
  116. function gdkregion_EMPTY_REGION(pReg: PGdkRegion): boolean;
  117. begin
  118. gdkregion_EMPTY_REGION:=pReg^.numRects=0;
  119. end;
  120. function gdkregion_REGION_NOT_EMPTY(pReg : PGdkRegion) : boolean;
  121. begin
  122. gdkregion_REGION_NOT_EMPTY:=pReg^.numRects<>0;
  123. end;
  124. function gdkregion_INBOX(r: TGdkRegionBox; x,y : gint) : boolean;
  125. begin
  126. gdkregion_INBOX:=(((r.x2 > x) and (r.x1 <= x)) and (r.y2 > y)) and (r.y1<= y);
  127. end;
  128. {$ENDIF}