shellupdate.c

Go to the documentation of this file.
00001 
00002 /*  $Id: shellupdate.c 1203 2006-04-05 22:58:09Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "quickdraw.h"
00032 #include "scrollbar.h"
00033 #include "shell.h"
00034 #include "shellbuttons.h"
00035 #include "shellprivate.h"
00036 #include "threads.h"
00037 #include "frontierwindows.h"
00038 
00039 
00040 
00041 #ifdef WIN95VERSION
00042 
00043 static PAINTSTRUCT globalWinPaintstruct;
00044 
00045 static void BeginUpdate (WindowPtr w) {
00046     HDC hdc;
00047     HWND hwnd;
00048     hdlwindowinfo hinfo;
00049     Rect r;
00050     
00051     assert (shellevent.what == updateEvt);
00052     
00053     getwindowinfo (w, &hinfo);
00054     
00055     if (hinfo != nil)
00056         (**hinfo).drawrgn = getupdateregion (w);
00057     
00058     hwnd = (HWND) w;
00059     hdc = BeginPaint (hwnd, &globalWinPaintstruct);
00060     winpushport (w, hdc);
00061     
00062     getlocalwindowrect (w, &r);
00063 
00064     /* if hbrBackground brush is NULL...
00065     pushbackcolor (&graycolor);
00066     eraserect (r);
00067     popbackcolor ();
00068     */
00069     }
00070 
00071 static void EndUpdate (WindowPtr w) {
00072     HWND hwnd;
00073 
00074     assert (shellevent.what == updateEvt);
00075 
00076     hwnd = (HWND) w;
00077     winpopport();
00078     EndPaint (hwnd, &globalWinPaintstruct);
00079     }
00080 
00081 #endif
00082 
00083 
00084 void shellupdatewindow (WindowPtr w) {
00085     
00086     /*
00087     1/17/91 dmb: draw scrollbars, buttons, etc. before window contents
00088     */
00089     
00090     hdlwindowinfo hinfo;
00091     register hdlwindowinfo hw;
00092     
00093     getwindowinfo (w, &hinfo);
00094     
00095     hw = hinfo; /*copy into register*/
00096     
00097     if ((hinfo == nil) || (**hinfo).fldisposewhenpopped) {
00098 
00099         #ifdef MACVERSION
00100             BeginUpdate (w);
00101             
00102             EndUpdate (w);
00103         #endif
00104         
00105         return;
00106         }
00107     
00108     BeginUpdate (w);
00109     
00110     if (!shellpushglobals (w))
00111         goto exit;
00112     
00113     //Code change by Timothy Paustian Monday, August 21, 2000 4:31:49 PM
00114     //Must pass a CGrafPtr to pushport on OS X to avoid a crash
00115     {
00116     CGrafPtr    thePort;
00117     #if TARGET_API_MAC_CARBON == 1
00118     thePort = GetWindowPort(w);
00119     #else
00120     thePort = (CGrafPtr)w;
00121     #endif
00122         
00123     pushport (thePort);/*7/7/90 DW: this probably is not necessary, shellpushglobals does it*/
00124     }
00125 #ifdef MACVERSION   
00126     if (!config.fldialog) /*if it's a dialog, the callback routine re-drew the controls*/
00127         DrawControls (w);
00128     
00129     if (config.flvertscroll)
00130         showscrollbar ((**hw).vertscrollbar); /*make sure it is visible*/
00131     
00132     shelldrawgrowicon (hw);
00133     
00134     if (config.flhorizscroll)
00135         showscrollbar ((**hw).horizscrollbar);
00136     //Code change by Timothy Paustian Saturday, April 29, 2000 11:07:46 PM
00137     //Changed to Opaque call for Carbon
00138     //This is working, but it is giving bact the coordinates in local not
00139     //global. It seems to make more sense to me so leave it.
00140     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00141     {
00142     CGrafPtr    thePort = GetWindowPort(w);
00143     (**hw).drawrgn = NewRgn(); //note we delete this below
00144     (**hw).drawrgn = GetPortVisibleRegion(thePort, (**hw).drawrgn);
00145     }
00146     #else
00147     //old code
00148     (**hw).drawrgn = (*w).visRgn; /*so updater knows what needs drawing*/
00149     #endif
00150 #endif
00151 
00152 #ifdef WIN95VERSION
00153 //  (**hw).drawrgn = getvisregion (w);
00154 
00155     pushcliprgn ((**hw).drawrgn, false);
00156 #endif
00157 
00158     if (shellrectneedsupdate (&(**hw).buttonsrect)) /*if window has an attached button list, draw it*/
00159         shelldrawbuttons ();
00160     
00161     drawwindowmessage (w);
00162     
00163     // 4.11.97 dmb: it appears that under Windows we need to push the clipk here.
00164     // Most likely, we should be establishing this wider clip soon arter window
00165     // creation, one time.
00166 
00167     if (shellrectneedsupdate (&(**hw).contentrect))
00168         (*shellglobals.updateroutine) ();
00169     
00170 #ifdef WIN95VERSION
00171     popclip ();
00172     
00173     DeleteObject ((**hw).drawrgn);
00174 #endif
00175 #ifdef MACVERSION
00176     //Code change by Timothy Paustian Saturday, April 29, 2000 11:11:12 PM
00177     //Changed to Opaque call for Carbon
00178     //Get rid of the drawrgn to prevent a memory leak
00179     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00180     DisposeRgn((**hw).drawrgn); 
00181     #endif
00182 #endif
00183     (**hw).drawrgn = nil; /*this is a temp, keep it nil normally*/
00184     
00185     popport (); /*7/7/90 DW: see comment for pusport, above*/
00186     
00187     shellpopglobals ();
00188     
00189     exit:
00190     
00191     EndUpdate (w);
00192     } /*shellupdatewindow*/
00193 
00194 
00195 void shellupdatecontent (Rect contentrect) {
00196     
00197     /*
00198     update the portion of contectrect in shellwindow that needs updating, 
00199     and validate the area updated
00200     
00201     2/11/91 dmb: it turns out that we usually want to update the scroll 
00202     bars at this time too, before redrawing contectrect
00203     
00204     12/9/91 dmb: quick bail-out if update rgn is empty
00205     
00206     9/22/92 dmb: don't draw scrollbars when update rgn is empty
00207     */
00208     
00209     register hdlwindowinfo hw = shellwindowinfo;
00210     register hdlregion contentrgn, updatergn;
00211     hdlregion actualupdatergn;
00212     
00213     actualupdatergn = getupdateregion (shellwindow);
00214 
00215     if (EmptyRgn (actualupdatergn)) {
00216         
00217         #ifdef WIN95VERSION
00218             DeleteObject (actualupdatergn);
00219         #endif
00220 
00221         return;
00222         }
00223     
00224     shellupdatescrollbars (hw);
00225     
00226     updatergn = NewRgn ();
00227 
00228     CopyRgn (actualupdatergn, updatergn); /*window's update rgn is global*/
00229     
00230     globaltolocalrgn (updatergn);
00231     
00232     #ifdef MACVERSION
00233         RectRgn (contentrgn = NewRgn (), &contentrect);
00234         #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00235         //in carbon a copy of the update region is returned.
00236         DisposeRgn(actualupdatergn);
00237         actualupdatergn = nil;
00238         #endif
00239     #endif
00240     #ifdef WIN95VERSION
00241         DeleteObject (actualupdatergn);
00242         insetrect (&contentrect, -1, -1);
00243         contentrgn = CreateRectRgn (contentrect.left, contentrect.top, contentrect.right, contentrect.bottom);
00244     #endif
00245     
00246     SectRgn (contentrgn, updatergn, contentrgn); /*re-use contentrgn*/
00247 
00248     
00249 #if defined(WIN95VERSION) && fldebug
00250 
00251 /****** DEBUG CODE *********/
00252     if (false) {
00253         
00254         RECT rrr;
00255 
00256         GetClientRect (shellwindow, &rrr);
00257 
00258         DeleteObject(contentrgn);
00259 
00260         contentrgn = CreateRectRgn (rrr.left, rrr.top, rrr.right, rrr.bottom);
00261 
00262         FillRect (getport(), &rrr, GetStockObject (WHITE_BRUSH));
00263         }
00264 
00265 #endif
00266 
00267     if (!EmptyRgn (contentrgn)) {
00268         
00269         (**hw).drawrgn = contentrgn; /*for display routines to refer to*/
00270         //Code change by Timothy Paustian Monday, June 19, 2000 3:09:46 PM
00271         //Changed to Opaque call for Carbon
00272         #ifdef MACVERSION
00273             #if TARGET_API_MAC_CARBON == 1
00274             ValidWindowRgn((WindowRef) hw, contentrgn);
00275             #else
00276             ValidRgn (contentrgn); /*no need to draw it again.  do now to simulate beginupdate*/
00277             #endif
00278         #endif
00279         #ifdef WIN95VERSION
00280             ValidateRgn (shellwindow, contentrgn);
00281         #endif
00282         
00283         pushcliprgn (contentrgn, false);
00284         
00285         (*shellglobals.updateroutine) ();
00286         
00287         popclip ();
00288         
00289         (**hw).drawrgn = nil; /*keep it neat, this guy is a temp*/
00290         }
00291     
00292     DisposeRgn (updatergn);
00293     
00294     DisposeRgn (contentrgn);
00295     } /*shellupdatecontent*/
00296 
00297 
00298 boolean shellupdatenow (WindowPtr wupdate) {
00299     
00300     /*
00301     can be called from within one of the callbacks to force an update
00302     to happen immediately, without waiting for the OS to generate an
00303     update event.
00304     
00305     dmb 8/14/90:  can't we just call the normal update routine?  this
00306     should be fine from the toolbox's point of view, but will not limit 
00307     the update to contentrect.
00308     */
00309 #ifdef MACVERSION
00310     hdlregion rgn;
00311 
00312     rgn = getupdateregion (wupdate);
00313 
00314     if (!EmptyRgn (rgn))
00315         shellupdatewindow (wupdate);
00316     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00317     //Code change by Timothy Paustian Thursday, May 18, 2000 10:24:57 PM
00318     //Changed because calling getupdateregion returns a copy of the region
00319     //we have to dispose of it to prevent a memory leak
00320     DisposeRgn(rgn);
00321     #endif
00322 #endif
00323 
00324 #ifdef WIN95VERSION
00325     releasethreadglobals ();
00326 
00327     UpdateWindow ((HWND) wupdate);
00328 
00329     grabthreadglobals ();
00330 #endif
00331     return (true);
00332     } /*shellupdatenow*/
00333 
00334 
00335 static boolean updatenowvisit (WindowPtr wupdate, ptrvoid refcon) {
00336 #pragma unused (refcon)
00337 
00338     shellupdatenow (wupdate);
00339     
00340     return (true);
00341     } /*updatenowvisit*/
00342 
00343 
00344 /*updates all windows immediately*/
00345 void shellupdateallnow (void) {
00346     
00347     shellvisittypedwindows (-1, &updatenowvisit, nil); /*visit all windows*/
00348     } /*shellupdateallnow*/
00349     
00350     
00351 boolean shellhandleupdate (void) {
00352     
00353     /*
00354     3/30/93 dmb: make sure it's a shell window
00355     
00356     5.1.6 dmb: no, even for non-shell windows, we need to begin/end update
00357     */
00358     
00359     WindowPtr w = (WindowPtr) shellevent.message;
00360     
00361     if (!isshellwindow (w)) {
00362         
00363         #ifdef MACVERSION
00364             BeginUpdate (w);
00365             EndUpdate (w);
00366         #endif
00367         
00368         return (false);
00369         }
00370         
00371     shellupdatewindow (w);
00372     
00373     return (true);
00374     } /*shellhandleupdate*/
00375 
00376 

Generated on Wed May 31 18:20:01 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6