[comp.lang.pascal] PASCAL GIU RECT/EXPOSE detection routines.

oecheruo@silver.ucs.indiana.edu (Chima Echeruo) (06/01/91)

Hi,
I am still working on my simple user interface library for TP 5 & 6. I have
built most of the messaging system, window management and data structures -
bitmaps, ICONS etc.. In order to allow flexiblity for custom repainting of
exposed windows I have decided not to simply 'GetImage the underlying screen
background but to send messages to each window when its contents are over-
written. The window procedure then has the oppurtunity to 'GetImage the portion
of his window that is about to be overwritten. Later on, when the window
system discovers that a previously hidden region is about to be exposed, it
sends an EXPOSE message to the window with the region as the parameter. The
window can then 'PutImage the previously saved bitmap without having to get
the input focus (bring it's window to the top).

Since this procedure is very common for most windows, the base window class
will have defined procedures to handle the DESTROY/EXPOSE messages in case
the window or it's derivatives decide not to handle the messages. Right now,
I have a rough idea of the kind of data structures I am looking for:


	RECT	= Record
		    left,top,right,bottom	:integer;
		  end;

        RegPtr  = ^REGION;
	REGION  = Record
		    rc		:RECT;
                    next	:RegPtr;
		  end;

    I will need a function say, InvalidateRegion:
  
    procedure InvalidateRegion(var rgn	:REGION) {
         wnd:=First(WindowList);   {sorted by focus}
	 while (rgn is valid) and (wnd<>NIL) {
            destroyed_reg:=intersection(rgn,wnd^.region);
	    if (destroyed_reg is valid) then
            	sendmessage(wnd,DESTROYED,0,0,addr(destroyed_reg));
            rgn:=subtract_region(rgn,destroyed_reg);
	    free(destroyed_region);	    
	   wnd:=Next(wnd);
	}
    }

    the way I have it, most of the destroyed background ends up being sent to
the background window which can then paint it (during EXPOSE) with whatever
color or pattern that a user selects (or even a bitmap). My problem is with
a suitable subtract,intersect etc.. routine that works efficiently and can
handle non-contigious RECTs and consolidate them to one if possible. 

The RECT routines that I have seen only work with simple rectangles and cannot
create multiple non-contigious rects (Regions). Does anyone have some pointers
to some code? also, I know that Windows 3 exists but I cannot afford the SDK
nor do I need the power of a REAL GUI. I am looking at a SMALL GIU library that
can get my PC to look like a MAC without much work on the programmer's part.

thanks.
Chima Echeruo




--
-------------------------------------------------------------------------------
	        	----- Chima Oke Echeruo -----
   oecheruo@silver.ucs.indiana.edu   ++++++   oecheruo@amber.ucs.indiana.edu
-------------------------------------------------------------------------------