shellcallbacks.c

Go to the documentation of this file.
00001 
00002 /*  $Id: shellcallbacks.c 1201 2006-04-05 22:31:38Z 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 "memory.h"
00032 #include "frontierconfig.h"
00033 #include "cursor.h"
00034 #include "font.h"
00035 #include "kb.h"
00036 #include "ops.h"
00037 #include "quickdraw.h"
00038 #include "resources.h"
00039 #include "strings.h"
00040 #include "frontierwindows.h"
00041 #include "shell.h"
00042 #include "shellprivate.h"
00043 #include "shellbuttons.h"
00044 #include "shellundo.h"
00045 #include "shell.rsrc.h"
00046 #include "oplist.h"
00047 #include "lang.h"
00048 #include "process.h"
00049 
00050 
00051 
00052 tyshellglobals globalsarray [cteditors];
00053 
00054 short topglobalsarray = 0; /*initially empty*/
00055 
00056 
00057 tyglobalsstack globalsstack; /*for push/pop globals*/
00058 
00059 
00060 
00061 boolean shellnewcallbacks (ptrcallbacks *callbacks) {
00062     
00063     if (topglobalsarray == cteditors) { 
00064         
00065         shellinternalerror (ideditorstackfull, STR_increase_cteditors);
00066         
00067         *callbacks = nil;
00068         
00069         return (false);
00070         }
00071     
00072     *callbacks = &globalsarray [topglobalsarray++];
00073         
00074     return (true);
00075     } /*shellnewcallbacks*/
00076 
00077 
00078 boolean shellfindcallbacks (short configresnum, short *ixarray) {
00079     
00080     /*
00081     search the callbacks array for a record whose resource number matches the
00082     indicated resnum.  return the index into the array of the record if found,
00083     return false if not found.
00084     */
00085     
00086     register short resnum = configresnum;
00087     register short i;
00088     
00089     for (i = 0; i < topglobalsarray; i++) {
00090         
00091         if (globalsarray [i].configresnum == resnum) {
00092         
00093             *ixarray = i;
00094             
00095             return (true);
00096             }
00097         } /*for*/
00098         
00099     return (false); /*loop terminated, not found*/
00100     } /*shellfindcallbacks*/
00101     
00102 
00103 static boolean shelldefaultundo (void) {
00104 
00105     /*
00106     the default undo routine, this is installed instead of noop if nothing 
00107     else has been installed by the handler.  redo if available; else undo.
00108     */
00109 
00110     short ixaction;
00111 
00112     if (!optionkeydown ()  &&  getredoaction (&ixaction))
00113         return (redolastaction (true));
00114     else
00115         return (undolastaction (true));
00116     } /*shelldefaultundo*/
00117 
00118 
00119 static boolean shelldefaultsetundostatus (void) {
00120     
00121     register hdlstring hstring;
00122     short ixbase = 0, ixaction;
00123     bigstring bsundo, bs;
00124 
00125     hstring = (**shellwindowinfo).hundostring;
00126 
00127     disposehandle ((Handle) hstring);
00128 
00129     hstring = nil; /*indicates no undo possible*/
00130 
00131     /* try to get redo first, else try to get undo */
00132 
00133     if (!optionkeydown ()  &&  getredoaction (&ixaction))
00134         ixbase = redostring;
00135     else {
00136         if (getundoaction (&ixaction))
00137             ixbase = undostring;
00138         }
00139 
00140     if (ixaction > 0) { /*it's an undoable operation*/
00141     
00142         if (getstringlist (undolistnumber, ixbase, bsundo)  &&
00143             getstringlist (undolistnumber, ixaction, bs)) {
00144             
00145             hdlstring h;
00146             
00147             pushstring (bs, bsundo);
00148 
00149             if (newheapstring (bsundo, &h))
00150                 hstring = h;
00151             }
00152         }
00153     
00154     (**shellwindowinfo).hundostring = hstring;
00155     
00156     return (true);
00157     } /*shelldefaultsetundostatus*/
00158 
00159 
00160 static boolean shelldefaultbuttonstatusroutine (short buttonnum, tybuttonstatus *status) {
00161     
00162     (*status).fldisplay = true;
00163     
00164     (*status).flenabled = true;
00165     
00166     (*status).flbold = (buttonnum == (**shellwindowinfo).lastbuttonhit);
00167     
00168     return (true);
00169     } /*shelldefaultbuttonstatusroutine*/
00170 
00171 
00172 boolean shelldefaultfontroutine (void) {
00173     
00174     /*
00175     if the handler doesn't define a font routine, wire it into us.  we just
00176     set the default font for the window and force a complete update.
00177     */
00178     
00179     register hdlwindowinfo hw = shellwindowinfo;
00180     
00181     (**hw).defaultfont = (**hw).selectioninfo.fontnum;
00182     
00183     (**hw).selectioninfo.fldirty = true;
00184     
00185     eraserect ((**hw).contentrect);
00186     
00187     windowinval (shellwindow);
00188     
00189     return (true);
00190     } /*shelldefaultfontroutine*/
00191     
00192 
00193 boolean shelldefaultsizeroutine (void) {
00194     
00195     /*
00196     if the handler doesn't define a size routine, wire it into us.  we just
00197     set the default size for the window and force a complete update.
00198     */
00199     
00200     register hdlwindowinfo hw = shellwindowinfo;
00201     
00202     (**hw).defaultsize = (**hw).selectioninfo.fontsize;
00203     
00204     (**hw).selectioninfo.fldirty = true;
00205     
00206     eraserect ((**hw).contentrect);
00207     
00208     windowinval (shellwindow);
00209     
00210     return (true);
00211     } /*shelldefaultsizeroutine*/
00212 
00213 
00214 #if 0
00215 
00216 static boolean shelldefaultstyleroutine (void) {
00217     
00218     /*
00219     if the handler doesn't define a style routine, wire it into us.  we just
00220     set the default style for the window and force a complete update.
00221     */
00222     
00223     register hdlwindowinfo hw = shellwindowinfo;
00224     
00225     shellsetdefaultstyle (hw); /*sets the defaultstyle field based on selectioninfo*/
00226     
00227     (**hw).selectioninfo.fldirty = true;
00228     
00229     eraserect ((**hw).contentrect);
00230     
00231     windowinval (shellwindow);
00232     
00233     return (true);
00234     } /*shelldefaultstyleroutine*/
00235 
00236 #endif
00237 
00238 
00239 boolean shelldefaultselectioninfo (void) {
00240 
00241     return (defaultselectioninfo (shellwindowinfo));
00242     } /*shelldefaultselectioninfo*/
00243 
00244 
00245 static boolean shelldefaultgettargetdata (short id) {
00246     
00247     return (false); /*dmb 4/5/91: only EFP windows can be targets now*/
00248     
00249     return (id == -1); /*true if target type is generic -- a shell verb*/
00250     } /*shelldefaultgettargetdata*/
00251 
00252 
00253 static boolean shelldefaultmsgroutine (bigstring bs, boolean flbackgroundmsg) {
00254 #pragma unused (flbackgroundmsg)
00255 
00256     shellsetwindowmessage (shellwindowinfo, bs);
00257     
00258     drawwindowmessage (shellwindow);
00259     
00260     return (true);
00261     } /*shelldefaultmsgroutine*/
00262 
00263 
00264 static boolean shelldefaultresetrectsroutine (hdlwindowinfo hinfo) {
00265     
00266     shellresetwindowrects (hinfo);
00267     
00268     return (true);
00269     } /*shelldefaultresetrectsroutine*/
00270 
00271 
00272 static void shelldefaultadjustcursor (void) {
00273     
00274     setcursortype (cursorisarrow);
00275     } /*shelldefaultadjustcursor*/
00276     
00277     
00278 static void shellchecknilroutine (callback *routine, callback defaultroutine) {
00279     
00280     if (*routine == nil)
00281     
00282         *routine = defaultroutine;
00283     } /*shellchecknilroutine*/
00284 
00285 
00286 static void shelltruedefault (void *routine) {
00287     
00288     shellchecknilroutine ((callback *) routine, &truenoop);
00289     } /*shelltruedefault*/
00290 
00291 
00292 static void shellfalsedefault (void *routine) {
00293     
00294     shellchecknilroutine ((callback *) routine, &falsenoop);
00295     } /*shellfalsedefault*/
00296 
00297 
00298 void shellpatchnilroutines (void) {
00299     
00300     /*
00301     call this when the callback routines are fully installed.  we check for any
00302     that the application might have left unfilled, and patch them with a routine
00303     that does nothing (truenoop).  this allows a set of handlers to catch
00304     certain events and do nothing on other types.
00305     */
00306     
00307     short i;
00308     
00309     for (i = 0; i < topglobalsarray; i++) {
00310         
00311         register tyshellglobals *cb = &globalsarray [i];
00312         
00313         shelltruedefault (&(*cb).initroutine);
00314         
00315         shelltruedefault (&(*cb).quitroutine);
00316         
00317         shelltruedefault (&(*cb).setglobalsroutine);
00318         
00319         shelltruedefault (&(*cb).pushroutine);
00320         
00321         shelltruedefault (&(*cb).poproutine);
00322         
00323         shelltruedefault (&(*cb).setsuperglobalsroutine);
00324         
00325         shelltruedefault (&(*cb).newrecordroutine);
00326         
00327         shelltruedefault (&(*cb).updateroutine);
00328         
00329         shelltruedefault (&(*cb).activateroutine);
00330         
00331         shelltruedefault (&(*cb).resumeroutine);
00332         
00333         shellfalsedefault (&(*cb).getcontentsizeroutine);
00334         
00335         shelltruedefault (&(*cb).resizeroutine);
00336         
00337         shellchecknilroutine ((callback *) &(*cb).resetrectsroutine, (callback) &shelldefaultresetrectsroutine);
00338         
00339         shellfalsedefault (&(*cb).scrollroutine);
00340         
00341         shelltruedefault (&(*cb).setscrollbarroutine);
00342         
00343         shelltruedefault (&(*cb).mouseroutine);
00344 
00345         shelltruedefault (&(*cb).rmouseroutine);
00346 
00347         shelltruedefault (&(*cb).cmouseroutine);
00348 
00349         shelltruedefault (&(*cb).wmouseroutine);
00350         
00351         shelltruedefault (&(*cb).buttonroutine);
00352         
00353         shellchecknilroutine ((callback *) &(*cb).buttonstatusroutine, (callback) &shelldefaultbuttonstatusroutine);
00354         
00355         shelltruedefault (&(*cb).presaveroutine);
00356         
00357         shelltruedefault (&(*cb).keystrokeroutine);
00358         
00359         shelltruedefault (&(*cb).cmdkeyfilterroutine);
00360         
00361         shellfalsedefault (&(*cb).titleclickroutine);
00362         
00363         shellchecknilroutine (&(*cb).undoroutine, shelldefaultundo);
00364         
00365         shellchecknilroutine (&(*cb).setundostatusroutine, &shelldefaultsetundostatus);
00366         
00367         shellfalsedefault (&(*cb).getundoglobalsroutine);
00368         
00369         shelltruedefault (&(*cb).setundoglobalsroutine);
00370         
00371         shelltruedefault (&(*cb).cutroutine);
00372         
00373         shelltruedefault (&(*cb).copyroutine);
00374         
00375         shelltruedefault (&(*cb).pasteroutine);
00376         
00377         shelltruedefault (&(*cb).clearroutine);
00378         
00379         shelltruedefault (&(*cb).selectallroutine);
00380         
00381         shellchecknilroutine (&(*cb).fontroutine, &shelldefaultfontroutine);
00382         
00383         shellchecknilroutine (&(*cb).sizeroutine, &shelldefaultsizeroutine);
00384         
00385         shellfalsedefault (&(*cb).styleroutine);
00386         
00387         shellchecknilroutine (&(*cb).setselectioninforoutine, &shelldefaultselectioninfo);
00388         
00389         shelltruedefault (&(*cb).leadingroutine);
00390         
00391         shelltruedefault (&(*cb).justifyroutine);
00392         
00393         shellfalsedefault (&(*cb).searchroutine);
00394         
00395         shellfalsedefault (&(*cb).replaceroutine);
00396         
00397         shellfalsedefault (&(*cb).executeroutine);
00398         
00399         shelltruedefault (&(*cb).disposerecordroutine);
00400         
00401         shelltruedefault (&(*cb).saveroutine);
00402         
00403         shelltruedefault (&(*cb).pagesetuproutine);
00404         
00405         shelltruedefault (&(*cb).beginprintroutine);
00406         
00407         shelltruedefault (&(*cb).endprintroutine);
00408         
00409         shelltruedefault (&(*cb).printroutine);
00410         
00411         shelltruedefault (&(*cb).setprintinfoproutine);
00412         
00413         shelltruedefault (&(*cb).setdatabaseroutine);
00414         
00415         shellfalsedefault ((callback *) &(*cb).getdatabaseroutine);
00416         
00417         shelltruedefault (&(*cb).fnumchangedroutine);
00418         
00419         shelltruedefault (&(*cb).loadroutine);
00420         
00421         shellfalsedefault (&(*cb).loadspecialroutine);
00422         
00423         shelltruedefault (&(*cb).precloseroutine);  /*4.1b5 dmb*/
00424         
00425         shelltruedefault (&(*cb).closeroutine);
00426         
00427         shelltruedefault (&(*cb).childcloseroutine);
00428         
00429         shelltruedefault (&(*cb).idleroutine);
00430         
00431         shelltruedefault (&(*cb).backgroundroutine);
00432         
00433         shellchecknilroutine ((callback *) &(*cb).gettargetdataroutine, (callback) &shelldefaultgettargetdata);
00434         
00435         shellfalsedefault (&(*cb).getvariableroutine);
00436         
00437         shelltruedefault (&(*cb).findusedblocksroutine);
00438         
00439         shellfalsedefault (&(*cb).settextmoderoutine);
00440         
00441         shellchecknilroutine ((callback *) &(*cb).zoomwindowroutine, (callback) shellzoomwindow);
00442         
00443         shellchecknilroutine ((callback *) &(*cb).msgroutine, (callback) &shelldefaultmsgroutine);
00444         
00445         shellchecknilroutine ((callback *) &(*cb).adjustcursorroutine, (callback) &shelldefaultadjustcursor);
00446         } /*for*/
00447     } /*shellpatchnilroutines*/
00448 
00449 
00450 void shellinithandlers (void) { 
00451     
00452     /*
00453     call the initroutine callback for each handler.
00454     */
00455 
00456     short i;
00457     
00458     for (i = 0; i < topglobalsarray; i++) {
00459         
00460         config = globalsarray [i].config; /*handler may want to refer to this*/
00461         
00462         (*globalsarray [i].initroutine) ();
00463         } /*for*/
00464     } /*shellinithandlers*/
00465     
00466 
00467 void shellloadbuttonlists (void) {
00468     
00469     register short i;
00470     register short resnum;
00471     
00472     for (i = 0; i < topglobalsarray; i++) {
00473         
00474         resnum = globalsarray [i].config.idbuttonstringlist; 
00475         
00476         if (resnum != 0) { /*a button list is attached*/
00477             
00478             if (!oploadstringlist (resnum, (hdllistrecord *) &globalsarray [i].buttonlist))
00479                 shellinternalerror (idbuttonlistmissing, STR_failed_to_load_a_button_list);
00480             }
00481         } /*for*/
00482     } /*shellloadbuttonlists*/
00483     
00484         
00485 boolean shellgetconfig (short resnum, tyconfigrecord *pconfig) {
00486     
00487     short ix = 0;
00488     
00489     if (!shellfindcallbacks (resnum, &ix))
00490         return (false);
00491         
00492     *pconfig = globalsarray [ix].config;
00493     
00494     return (true);
00495     } /*shellgetconfig*/
00496     
00497     
00498 boolean shellsetconfig (short resnum, tyconfigrecord pconfig) {
00499     
00500     short ix = 0;
00501     
00502     if (!shellfindcallbacks (resnum, &ix))
00503         return (false);
00504         
00505     globalsarray [ix].config = pconfig;
00506     
00507     return (true);
00508     } /*shellsetconfig*/
00509     
00510     
00511 boolean shellsetglobals (WindowPtr wglobals) {
00512     
00513     /*
00514     set up globals for the window.
00515     
00516     8/25/90 DW: when we're closing all the windows, we pop the globals stack
00517     but there are no windows open to set globals to.  we put a defensive driving
00518     check in at the lowest level -- it can do double-duty protecting against
00519     similar problems that might crop up elsewhere.  the call to see if the window
00520     list is empty is very, very cheap.
00521     */
00522     
00523     register WindowPtr w = wglobals;
00524     hdlwindowinfo hinfo;
00525     register hdlwindowinfo hw;
00526     short ix = 0;
00527     
00528     if (!wglobals || emptywindowlist ()) { /*defensive driving, avoid a crash, it CAN happen*/
00529         
00530         shellwindow = nil;
00531         
00532         shellwindowinfo = nil;
00533         
00534         shellundostack = nil; /*7/21/91 dmb*/
00535         
00536 #ifdef WIN95VERSION
00537         setport (NULL); // must clear port from prev globals
00538 #endif
00539 
00540         return (false);
00541         }
00542     
00543     if (!getwindowinfo (w, &hinfo)) /*chase the refcon field of the mac window*/
00544         return (false);
00545     
00546     hw = hinfo; /*copy into register*/
00547     
00548     shellwindow = w; /*a global, this is the window whose globals are current*/
00549     
00550     shellwindowinfo = hw; /*the windowinfo record whose globals are current*/
00551     
00552     shellundostack = (hdlundostack) (**hw).hundostack;
00553     
00554     shellredostack = (hdlundostack) (**hw).hredostack;
00555     
00556     shellfindcallbacks ((**hw).configresnum, &ix);
00557     
00558     shellglobals = globalsarray [ix];
00559     
00560     config = shellglobals.config;
00561     
00562     *shellglobals.windowholder = w;
00563     
00564     *shellglobals.infoholder = hw;
00565     
00566     *shellglobals.dataholder = (**hw).hdata;
00567     
00568     (*shellglobals.setglobalsroutine) ();
00569     
00570     //You must call with a GrafPtr or CGrafPtr.
00571     //Code change by Timothy Paustian Wednesday, August 23, 2000 9:08:56 PM
00572     //
00573     {
00574     #if TARGET_API_MAC_CARBON
00575     CGrafPtr thePort = GetWindowPort(w);
00576     #else
00577     GrafPtr thePort = (GrafPtr)w;
00578     #endif
00579     if (getport () != thePort) /*make sure w is current port; a courtesy to the content handler*/
00580         setport (thePort);
00581     }
00582 
00583     return (true);
00584     } /*shellsetglobals*/
00585     
00586 /*
00587 static stacktracer (short stacktop) {
00588     
00589     bigstring bs;
00590     hdlwindowinfo hinfo;
00591     Rect r;
00592     WindowPtr w;
00593     
00594     if (!frontrootwindow (&hinfo)) /%no windows open%/
00595         return;
00596     
00597     shorttostring (stacktop, bs);
00598      
00599     w = (**hinfo).macwindow;
00600     
00601     pushport (w);
00602     
00603     pushstyle (geneva, 9, 0);
00604     
00605     r = (*w).portRect;
00606     
00607     r.top = r.bottom - (globalfontinfo.ascent + globalfontinfo.descent); 
00608     
00609     r.left += 1; 
00610     
00611     r.right = r.left + 12;
00612     
00613     eraserect (r);
00614     
00615     movepento (r.left, r.bottom - 1);
00616     
00617     pendrawstring (bs);
00618     
00619     popstyle ();
00620     
00621     popport ();
00622     } /%stacktracer%/
00623 */
00624     
00625 boolean shellpushglobals (WindowPtr wpush) {
00626     
00627     /*
00628     8/31/90 DW: if the caller is pushing a nil window, just save off the state
00629     and don't set the context.  this allows you to save the global data, mess
00630     with some of the globals, and then pop yourself back to the way things were.
00631     */
00632     
00633     hdlwindowinfo hinfo;
00634     
00635     if (globalsstack.top >= ctglobals) {
00636         
00637         shellinternalerror (idglobalsstackfull, STR_globals_stack_overflow);
00638         
00639         return (false);
00640         }
00641     
00642     globalsstack.stack [globalsstack.top++] = shellwindow;
00643     
00644     /*stacktracer (globalsstack.top);*/
00645     
00646     /*
00647     if (wpush == nil) /%caller just wants state saved%/ {
00648         
00649         shellwindow = nil;
00650         
00651         return (true);
00652         }
00653     
00654     return (shellsetglobals (wpush));
00655     */
00656     
00657     if (getwindowinfo (wpush, &hinfo))
00658         (**hinfo).ctpushes++;
00659     
00660     if (shellsetglobals (wpush))
00661         (*shellglobals.pushroutine) ();
00662     
00663     return (true);
00664     } /*shellpushglobals*/
00665 
00666 
00667 boolean shellpopglobals (void) {
00668     
00669     WindowPtr w = shellwindow;
00670     hdlwindowinfo hinfo;
00671     
00672     if (globalsstack.top <= 0) {
00673     
00674         shellsetglobals (nil);
00675         
00676         return (false);
00677         }
00678     
00679     if (shellwindow != nil) { /*there are some globals currently set - set data to nil*/
00680         
00681         (*shellglobals.poproutine) ();
00682         
00683         *shellglobals.dataholder = nil;
00684         
00685         *shellglobals.infoholder = nil;
00686     
00687         (*shellglobals.setglobalsroutine) ();
00688         }
00689     
00690     shellsetglobals (globalsstack.stack [--globalsstack.top]);
00691     
00692     if (getwindowinfo (w, &hinfo)) {
00693         
00694         (**hinfo).ctpushes--;
00695         
00696         if ((**hinfo).fldisposewhenpopped)
00697             disposeshellwindow ((**hinfo).macwindow);
00698         }
00699     
00700     return (true);
00701     } /*shellpopglobals*/
00702 
00703 
00704 boolean shellpushwindowglobals (hdlwindowinfo hpush) {
00705     
00706     /*
00707     5.0a5 dmb: we do this often enough, it deserves its own routine
00708     */
00709 
00710     if (hpush == nil)
00711         return (false);
00712 
00713     return (shellpushglobals ((**hpush).macwindow));
00714     } /*shellpushwindowglobals*/
00715 
00716 
00717 /*
00718 void shellinvalidglobals (WindowPtr winvalid) {
00719     
00720     /%
00721     the indicated windowptr is no longer valid -- it was presumably 
00722     just disposed.  make sure that we'll never try to push its globals
00723     %/
00724     
00725     register WindowPtr w = winvalid;
00726     register short ix;
00727     
00728     for (ix = 0; ix < globalsstack.top; ++ix) {
00729         
00730         if (globalsstack.stack [ix] == w)
00731             globalsstack.stack [ix] = nil;
00732         }
00733     
00734     if (w == shellwindow)
00735         shellwindow = nil;
00736     
00737     processinvalidglobals (w); //every thread needs to know about the change*
00738     } /%shellinvalidglobals%/
00739 */
00740 
00741 
00742 boolean shellpushconfigglobals (short configresnum) {
00743     
00744     short ix;
00745     
00746     if (!shellfindcallbacks (configresnum, &ix))
00747         return (false);
00748     
00749     if (!shellpushglobals (nil)) /*save off old state*/
00750         return (false);
00751         
00752     shellglobals = globalsarray [ix];
00753     
00754     config = shellglobals.config;
00755     
00756     return (true);
00757     } /*shellpushconfigglobals*/
00758     
00759     
00760 boolean shellpushdefaultglobals (void) {
00761     
00762     return (shellpushconfigglobals (iddefaultconfig));
00763     } /*shellpushdefaultglobals*/
00764     
00765     
00766 boolean shellpushfrontglobals (void) {
00767     
00768     WindowPtr w;
00769     
00770     if (!frontshellwindow (&w))
00771         return (false);
00772     
00773     return (shellpushglobals (w));
00774     } /*shellpushfrontglobals*/
00775 
00776 
00777 boolean shellpushrootglobals (WindowPtr w) {
00778     
00779     /*
00780     set the globals with those of the root window of w 
00781     */
00782     
00783     hdlwindowinfo hinfo;
00784     
00785     if (!getrootwindow (w, &hinfo)) /*save only operates on root windows*/
00786         return (false);
00787     
00788     return (shellpushglobals ((**hinfo).macwindow));
00789     } /*shellpushrootglobals*/
00790 
00791 
00792 boolean shellpushparentglobals (void) {
00793     
00794     hdlwindowinfo hinfo, hparentinfo;
00795     
00796     if (!getwindowinfo (shellwindow, &hinfo))
00797         return (false);
00798         
00799     hparentinfo = (**hinfo).parentwindow;
00800     
00801     if (hparentinfo == nil)
00802         return (false);
00803         
00804     return (shellpushglobals ((**hparentinfo).macwindow));
00805     } /*shellpushparentglobals*/
00806 
00807 
00808 boolean shellgetfrontrootinfo (hdlwindowinfo *hinfo) {
00809     
00810     /*
00811     11/1/91 dmb: make sure we've got a real root, not a guest root
00812     */
00813     
00814     WindowPtr w;
00815     Handle hdata;
00816     
00817     if (!frontrootwindow (hinfo) || ((***hinfo).configresnum != iddefaultconfig)) {
00818         
00819         if (!shellfindwindow (iddefaultconfig, &w, hinfo, &hdata))
00820             return (false);
00821         
00822         getrootwindow (w, hinfo);
00823         }
00824     
00825     return (true);
00826     } /*shellgetfrontrootinfo*/
00827 
00828 
00829 boolean shellpushfrontrootglobals (void) {
00830     
00831     /*
00832     11/1/91 dmb: make sure we've got a real root, not a guest root
00833     */
00834     
00835     hdlwindowinfo hinfo;
00836     
00837     if (!shellgetfrontrootinfo (&hinfo))
00838         return (false);
00839     
00840     return (shellpushglobals ((**hinfo).macwindow));
00841     } /*shellpushfrontrootglobals*/
00842 
00843 
00844 boolean shellsetsuperglobals (void) {
00845     
00846     /*
00847     the "super" globals are a handle linked into the data record of a root
00848     window.  we don't know how or exactly where these globals are stored,
00849     but we do know who to ask -- the frontmost window of type iddefaultconfig.
00850     
00851     dmb: try the root window of the front window first.  only traverse the 
00852     window list for a default window if the front's root isn't the right type.
00853     why?  because the front window's root may not be the frontmost root window.
00854     */
00855     
00856     hdlwindowinfo hinfo;
00857     boolean fl;
00858     
00859     if (!shellgetfrontrootinfo (&hinfo))
00860         return (false);
00861     
00862     shellpushglobals ((**hinfo).macwindow);
00863     
00864     fl = (*shellglobals.setsuperglobalsroutine) ();
00865     
00866     shellpopglobals ();
00867     
00868     return (fl);
00869     } /*shellsetsuperglobals*/
00870 
00871 
00872 boolean shellgetundoglobals (long *globaldata) {
00873 
00874     return ((*shellglobals.getundoglobalsroutine) (globaldata));
00875     } /*shellgetundoglobals*/
00876 
00877 
00878 boolean shellsetundoglobals (long globaldata, boolean flundo) {
00879 
00880     return ((*shellglobals.setundoglobalsroutine) (globaldata, flundo));
00881     } /*shellsetundoglobals*/
00882 
00883 
00884 void shellclearwindowdata (void) {
00885     
00886     /*
00887     5.0b10 dmb: why this routine hasn't existed before, I don't know.
00888     Under windows, we really get bitten when any of these steps is omitted.
00889     There's no reason that the dispose callback should have to nil the 
00890     globals
00891 
00892     5.1.5b7 dmb: don't clear the actual dataholder global. Otherwise, 
00893     oppopglobals called from shellpopglobals doesn't know what it's popping
00894     */
00895     
00896     //*shellglobals.dataholder = nil;
00897     
00898     (**shellwindowinfo).hdata = nil;
00899     } /*shellclearwindowdata*/
00900 

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