shellwindowverbs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: shellwindowverbs.c 1254 2006-04-12 20:27:14Z sethdill $    */
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 #ifdef MACVERSION 
00032 #include "player.h" /*7.0b4 PBS: QuickTime Player window*/
00033 #endif
00034 
00035 #include "shell.h"
00036 #include "shellprivate.h"
00037 #include "about.h"
00038 #include "file.h"
00039 #include "resources.h"
00040 #include "strings.h"
00041 #include "frontierwindows.h"
00042 #include "db.h"
00043 #include "command.h"
00044 #include "lang.h"
00045 #include "langexternal.h"
00046 #include "langinternal.h"
00047 #include "tablestructure.h"
00048 #include "scripts.h"
00049 #include "kernelverbs.h"
00050 #include "kernelverbdefs.h"
00051 #include "shellbuttons.h"
00052 #include "opinternal.h"
00053 #include "opbuttons.h"
00054 #include "tableverbs.h"
00055 
00056 
00057 #define windowerrorlist 268 
00058 #define notimplementederror 1
00059 
00060 
00061 typedef enum tywindowtoken { 
00062     
00063     isopenfunc,
00064     
00065     openfunc,
00066     
00067     isfrontfunc,
00068     
00069     bringtofrontfunc,
00070     
00071     sendtobackfunc,
00072     
00073     frontmostfunc,
00074     
00075     nextfunc,
00076     
00077     isvisiblefunc,
00078     
00079     showfunc,
00080     
00081     hidefunc,
00082     
00083     closefunc,
00084     
00085     updatefunc,
00086     
00087     ismenuscriptfunc,
00088     
00089     getposfunc,
00090     
00091     setposfunc,
00092     
00093     getsizefunc,
00094     
00095     setsizefunc,
00096     
00097     zoomfunc,
00098     
00099     runselectionfunc,
00100     
00101     scrollfunc,
00102     
00103     msgfunc,
00104     
00105     systemstatsfunc,
00106     
00107     quickscriptfunc,
00108     
00109     isdirtyfunc,
00110     
00111     setdirtyfunc,
00112     
00113     gettitlefunc,
00114     
00115     settitlefunc,
00116     
00117     aboutfunc,
00118     
00119     #ifdef MACVERSION
00120     
00121         playerfunc, /*7.0b4 PBS: QuickTime Player window*/
00122     
00123     #endif
00124     
00125     getfilefunc,
00126     
00127     isreadonlyfunc, /*7.0b6 PBS: return true if window is read-only*/
00128     
00129     ctwindowverbs
00130     } tywindowtoken;
00131 
00132 
00133 
00134 
00135 static boolean getwinaddressparam (hdltreenode hfirst, short pnum, hdlwindowinfo *hinfo) {
00136     
00137     hdlhashtable htable;
00138     bigstring bsname;
00139     tyvaluerecord val;
00140     hdlhashnode hnode;
00141     
00142     if (!getvarvalue (hfirst, pnum, &htable, bsname, &val, &hnode))
00143         return (false);
00144     
00145     *hinfo = nil;
00146     
00147     langexternalwindowopen (val, hinfo);
00148     
00149     return (true);
00150     } /*getwinaddressparam*/
00151 
00152 
00153 boolean getwinparam (hdltreenode hfirst, short pnum, hdlwindowinfo *hinfo) {
00154     
00155     /*
00156     9/19/91 dmb: we now handle strings as window specifications
00157     
00158     5.0d3 dmb: allow windows to be identified by path. also, visit 
00159     in front-to-back order in case of identical names (like "Untitled")
00160     */
00161     
00162     bigstring bsname;
00163     boolean fl;
00164     //hdlhashtable ht;
00165     
00166     disablelangerror ();
00167     
00168     fl = getwinaddressparam (hfirst, pnum, hinfo);
00169     
00170     enablelangerror ();
00171     
00172     if (fl && *hinfo)
00173         return (true);
00174     
00175     if (!getstringvalue (hfirst, pnum, bsname))
00176         return (false);
00177     /*
00178     disablelangerror ();
00179     
00180     langexpandtodotparams  (bsname, ht, bsname); // undo effect of deparsestring, bracketname
00181     
00182     enablelangerror ();
00183     */
00184     
00185     shellfindnamedwindow (bsname, hinfo); /*ignore result; hinfo is what counts*/
00186     
00187     return (true);
00188     } /*getwinparam*/
00189 
00190 
00191 boolean setwinvalue (WindowPtr pwindow, tyvaluerecord *val) {
00192     
00193     /*
00194     set val to the address of the database object contained by pwindow
00195     
00196     9/19/91 dmb: we name return a string representation so that window 
00197     verbs can be applied to all windows, not just db windows.  we still 
00198     need to try to access a db object if possible, so that a valid 
00199     language path can be returned rather than the window title (in case 
00200     brackets are needed).
00201     
00202     1/26/93 dmb: handle case where variable can't be found (because its 
00203     a local). no longer cause script to fail silently
00204     
00205     7.23.97 dmb: return full path of file windows
00206 
00207     5.0b16 dmb: for database objects, return an address, not a string
00208     */
00209     
00210     hdlexternalvariable hvariable = nil;
00211     hdlhashtable htable;
00212     bigstring bs;
00213     hdlwindowinfo hinfo;
00214     boolean fl = false;
00215     
00216     if (pwindow == nil)
00217         /*
00218         return (setaddressvalue (nil, zerostring, val));
00219         */
00220         return (setstringvalue (zerostring, val));
00221     
00222     shellpushglobals (pwindow);
00223     
00224     hinfo = shellwindowinfo;
00225 
00226     fl = (*shellglobals.getvariableroutine) (&hvariable);
00227     
00228     shellpopglobals ();
00229     
00230     if (fl)
00231         fl = langexternalfindvariable (hvariable, &htable, bs);
00232     
00233     if (!fl) { /*window doesn't represent a global database object*/
00234         
00235         shellgetwindowtitle (hinfo, bs); // 7.24.97 dmb: was windowgettitle
00236         
00237         if (hvariable != nil) {
00238             
00239             if (windowgetpath (pwindow, bs))
00240                 langexternalbracketname (bs);
00241             }
00242         }
00243     else {
00244         return (setaddressvalue (htable, bs, val));
00245         /*
00246         if (htable == filewindowtable)
00247             langexternalbracketname (bs);
00248         else
00249             langexternalgetquotedpath (htable, bs, bs);
00250         */
00251         }
00252     
00253     return (setstringvalue (bs, val));
00254     } /*setwinvalue*/
00255 
00256 
00257 static boolean isopenverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00258     
00259     /*
00260     returns true to the script if the window indicated by the address param is open.
00261     */
00262     
00263     hdlwindowinfo hinfo;
00264     
00265     flnextparamislast = true;
00266     
00267     if (!getwinparam (hparam1, 1, &hinfo))
00268         return (false);
00269     
00270     setbooleanvalue (hinfo != nil, vreturned);
00271     
00272     return (true);
00273     } /*isopenverb*/
00274 
00275 
00276 static boolean openverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
00277 #pragma unused (bserror)
00278 
00279     /*
00280     7.0b6 PBS: optional flReadOnly parameter allows outline-type windows
00281     to open in read-only mode.
00282     
00283     8.0.3b2: fixed missing scrollbar on Mac Classic.
00284     */
00285     
00286     hdlhashtable htable, hscripttable;
00287     bigstring bsname;
00288     tyvaluerecord val;
00289     hdlhashnode hnode;
00290     hdlexternalvariable hv;
00291     hdlwindowinfo hinfo;
00292     short ctparams;
00293     boolean flreadonly = false; /*editable by default*/
00294     boolean lflreturn = false;
00295     boolean flbuttontable = false;
00296     boolean flvisible = true;
00297 
00298     setbooleanvalue (false, vreturned);
00299     
00300     ctparams = langgetparamcount (hparam1);
00301     
00302     if (ctparams == 1)
00303     
00304         flnextparamislast = true;
00305         
00306     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
00307         return (false);
00308     
00309     if (val.valuetype != externalvaluetype) /*not a fatal error*/
00310         return (true);
00311         
00312     if (ctparams > 1) { /*7.0b6 PBS: if flReadOnly is supplied*/
00313     
00314         if (ctparams == 2)
00315             flnextparamislast = true;
00316         
00317         if (!getbooleanvalue (hparam1, 2, &flreadonly))
00318         
00319             return (false);
00320 
00321         if (ctparams > 2) { /*7.1b18 PBS: get table value for buttons*/
00322 
00323             flnextparamislast = true;
00324             
00325             if (!gettablevalue (hparam1, 3, &hscripttable))
00326                 return (false);
00327 
00328             flbuttontable = true;
00329             } /*if*/
00330         } /*if*/
00331 
00332     hv = (hdlexternalvariable) val.data.externalvalue;
00333     
00334     if ((flreadonly) && ((**hv).id == idwordprocessor)) { /*7.0b6 PBS: read-only wp-text is an error.*/
00335     
00336         hdlwindowinfo lhinfo;
00337                 
00338         langerrormessage (BIGSTRING ("\x5a""Can't open window as read-only because windows of type wp text don't support this feature."));
00339         
00340         if (shellfinddatawindow ((Handle) (**hv).variabledata, &lhinfo)) { /*window may be hidden -- if so, close*/
00341             
00342             if ((**lhinfo).flhidden) { /*if hidden, close the window*/
00343                 
00344                 shellclose ((**lhinfo).macwindow, false);
00345                 } /*if*/
00346             } /*if*/
00347         
00348         return (false);
00349         } /*if*/    
00350     
00351     if ((flbuttontable) && ((**hv).id != idoutlineprocessor)) { /*7.1b18 PBS: buttons for non-outlines is an error.*/
00352 
00353         hdlwindowinfo lhinfo;
00354 
00355         langerrormessage (BIGSTRING ("\x52""Can't attach buttons to window because windows only outlines support this feature."));
00356 
00357         if (shellfinddatawindow ((Handle) (**hv).variabledata, &lhinfo)) { /*window may be hidden -- if so, close*/
00358             
00359             if ((**lhinfo).flhidden) { /*if hidden, close the window*/
00360                 
00361                 shellclose ((**lhinfo).macwindow, false);
00362                 } /*if*/
00363             } /*if*/
00364         
00365         return (false);
00366         } /*if*/    
00367     
00368     if (flbuttontable) {
00369 
00370         flvisible = false;
00371         }/*if*/
00372 
00373     if (!langzoomvalwindow (htable, bsname, val, false))
00374         return (false);
00375         
00376     if (shellfinddatawindow ((Handle) (**hv).variabledata, &hinfo)) {
00377     
00378         switch ((**hv).id) {
00379         
00380             case idoutlineprocessor:
00381                 
00382                 if (flbuttontable) {
00383                 
00384                     opbuttonsattach (hinfo, hscripttable);
00385                     } /*if*/
00386 
00387                 else {
00388                     
00389                     (**hinfo).flhidebuttons = true;
00390 
00391                     (**hinfo).flsyntheticbuttons = false;
00392                     } /*else*/              
00393                             
00394                 break;
00395             
00396             case idscriptprocessor:
00397                 
00398                 (**hinfo).flhidebuttons = false;
00399                 
00400                 (**hinfo).flsyntheticbuttons = false;
00401                 
00402                 break;
00403             
00404             default:
00405             
00406                 (**hinfo).flhidebuttons = true;
00407                 
00408                 (**hinfo).flsyntheticbuttons = false;
00409             } /*switch*/
00410 
00411         #if defined(WIN95VERSION) || TARGET_API_MAC_CARBON /*8.0.3b2: Windows and OS X only. Fixes missing scrollbar on Classic.*/
00412         
00413             shellpushglobals ((**hinfo).macwindow);     
00414         
00415             shelladjustaftergrow ((**hinfo).macwindow);
00416 
00417             shellpopglobals ();
00418 #endif
00419         } /*if*/        
00420     
00421     if (!langzoomvalwindow (htable, bsname, val, true)) /*now make it visible*/
00422 
00423         return (false);
00424     
00425     lflreturn = langexternalsetreadonly (hv, flreadonly); /*7.0b6 PBS: set the read-only flag.*/
00426     
00427     (*vreturned).data.flvalue = lflreturn;
00428     
00429     return (lflreturn);
00430     } /*openverb*/
00431 
00432 
00433 static boolean isreadonlyverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00434     
00435     /*
00436     7.0b6 PBS: return true if a window is read-only, false otherwise.
00437     */
00438     
00439     hdlhashtable htable;
00440     tyvaluerecord val;
00441     hdlhashnode hnode;
00442     hdlexternalvariable hv;
00443     bigstring bsname;
00444     boolean flreadonly = false;
00445 
00446     flnextparamislast = true;
00447     
00448     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
00449         return (false);
00450     
00451     if (val.valuetype == externalvaluetype) { //7.1b33 dmb
00452 
00453         hv = (hdlexternalvariable) val.data.externalvalue;
00454     
00455         flreadonly = langexternalgetreadonly (hv);
00456         }
00457     
00458     setbooleanvalue (flreadonly, vreturned);
00459     
00460     return (true);  
00461     } /*isreadonlyverb*/
00462     
00463 
00464 static boolean isfrontverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00465     
00466     /*
00467     returns true to the script if the window indicated by the address param is 
00468     the frontmost window.
00469     */
00470     
00471     register boolean fl = false; /*not frontmost*/
00472     hdlwindowinfo hinfo;
00473     WindowPtr ptarget;
00474     
00475     flnextparamislast = true;
00476     
00477     if (!getwinparam (hparam1, 1, &hinfo))
00478         return (false);
00479     
00480     if (hinfo != nil) {
00481         
00482         if (shellfindtargetwindow (-1, &ptarget))
00483             fl = ptarget == (**hinfo).macwindow;
00484         
00485         /*
00486         getfrontwindowinfo (&hfrontinfo);
00487         
00488         fl = hinfo == hfrontinfo;
00489         */
00490         }
00491         
00492     setbooleanvalue (fl, vreturned);
00493     
00494     return (true);
00495     } /*isfrontverb*/
00496 
00497 
00498 static boolean bringtofrontverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00499     
00500     /*
00501     the verb takes an address -- the name of the object database variable to be 
00502     brought to the front.  if it's not in a window, we open a window at the front of
00503     the pile of windows.  
00504     
00505     return false if there was an error.
00506     
00507     this is needed for scripts that use a single keystroke to open a window, and use
00508     the same keystroke to process some information in the window.  e.g. cmd-J to jump
00509     through the table map, or cmd-= to evaluate an expression in the favorites window.
00510     
00511     5/10/91 dmb: with the frontmost verb working, this verb should no longer do 
00512     anything if the window isn't already open.
00513     */
00514     
00515     register boolean fl = false;
00516     hdlwindowinfo hinfo;
00517     
00518     flnextparamislast = true;
00519     
00520     if (!getwinparam (hparam1, 1, &hinfo))
00521         return (false);
00522     
00523     if (hinfo != nil) { /*a window is open*/
00524         
00525         shellbringtofront (hinfo);
00526         
00527         fl = true;
00528         }
00529     
00530     return (setbooleanvalue (fl, vreturned));
00531     } /*bringtofrontverb*/
00532 
00533 
00534 static boolean sendtobackverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00535     
00536     /*
00537     2.1b12 dmb: use new windowsendtoback
00538     */
00539     
00540     register boolean fl = false;
00541     hdlwindowinfo hinfo;
00542     
00543     flnextparamislast = true;
00544     
00545     if (!getwinparam (hparam1, 1, &hinfo))
00546         return (false);
00547     
00548     if (hinfo != nil) { /*a window is open*/
00549         
00550         windowsendtoback ((**hinfo).macwindow);
00551         
00552         fl = true;
00553         }
00554     
00555     setbooleanvalue (fl, vreturned);
00556     
00557     return (true); 
00558     } /*sendtobackverb*/
00559 
00560 
00561 
00562 static boolean frontmostverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00563     
00564     /*
00565     3/19/91 DW:
00566     
00567     return the address of the variable that's displayed in the frontmost window.
00568     
00569     doug, you're not going to like how this is implemented -- but I needed the
00570     functionality to fix a bug in the cmd-= ("favorites") script.
00571     
00572     7/10/91 dmb: return address value instead of a string
00573     */
00574     
00575     WindowPtr ptarget;
00576     
00577     if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
00578         return (false);
00579     
00580     if (shellfindtargetwindow (-1, &ptarget))
00581         return (setwinvalue (ptarget, vreturned));
00582     
00583     return (setwinvalue (nil, vreturned));
00584     } /*frontmostverb*/
00585 
00586 
00587 static boolean nextverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00588     
00589     /*
00590     return the address of the next shell window after the one indicated 
00591     by the parameter given
00592     */
00593     
00594     hdlwindowinfo hinfo;
00595     WindowPtr pnext;
00596     
00597     flnextparamislast = true;
00598     
00599     if (!getwinparam (hparam1, 1, &hinfo))
00600         return (false);
00601     
00602     if (hinfo != nil) { /*a window is open*/
00603         
00604         pnext = shellnextwindow ((**hinfo).macwindow);
00605         
00606         if (pnext != nil)
00607             return (setwinvalue (pnext, vreturned));
00608         }
00609     
00610     return (setwinvalue (nil, vreturned));
00611     } /*nextverb*/
00612 
00613 
00614 static boolean isvisibleverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00615     
00616     register boolean fl = false;
00617     hdlwindowinfo hinfo;
00618     
00619     flnextparamislast = true;
00620     
00621     if (!getwinparam (hparam1, 1, &hinfo))
00622         return (false);
00623     
00624     if (hinfo != nil) { /*a window is open*/
00625         
00626         fl = windowvisible ((**hinfo).macwindow);
00627         }
00628     
00629     setbooleanvalue (fl, vreturned);
00630     
00631     return (true); 
00632     } /*isvisibleverb*/
00633 
00634 
00635 static boolean showhideverb (hdltreenode hparam1, boolean flshow, tyvaluerecord *vreturned) {
00636     
00637     register boolean fl = false;
00638     hdlwindowinfo hinfo;
00639     
00640     flnextparamislast = true;
00641     
00642     if (!getwinparam (hparam1, 1, &hinfo))
00643         return (false);
00644     
00645     if (hinfo != nil) { /*a window is open*/
00646         
00647         if (flshow)
00648             shellunhidewindow (hinfo);
00649         else
00650             shellhidewindow (hinfo);
00651         
00652         fl = true;
00653         }
00654     
00655     setbooleanvalue (fl, vreturned);
00656     
00657     return (true); 
00658     } /*showhideverb*/
00659 
00660 
00661 static boolean closeverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00662     
00663     /*
00664      2005-09-14 creedon: added fldialog parameter
00665      
00666      8/26/92 dmb: don't allow the root window to be closed with this verb.
00667      
00668      (note: used to crash; need to call shellclose to handle root windows)
00669      */
00670     
00671     register boolean fl = false;
00672     hdlwindowinfo hinfo;
00673     boolean fldialog;
00674     tyvaluerecord val;
00675     short ctconsumed = 1;
00676     short ctpositional = 1;
00677     
00678     setbooleanvalue (false, &val); /* defaults to false */
00679     
00680     if (!getwinparam (hparam1, 1, &hinfo))
00681         return (false);
00682     
00683     flnextparamislast = true;
00684     
00685     if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x08""fldialog"), &val))
00686         return (false);
00687     
00688     fldialog = val.data.flvalue;
00689     
00690     if (hinfo != nil) { /* close it if it isn't a root window */
00691         
00692         // if ((**hinfo).parentwindow != nil /*|| shellgetexternaldata (hinfo, &hdata)*/)
00693         fl = shellclose ((**hinfo).macwindow, fldialog);
00694     }
00695     
00696     setbooleanvalue (fl, vreturned);
00697     
00698     return (true); 
00699 } /*closeverb*/
00700     
00701 
00702 static boolean updateverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00703     
00704     register boolean fl = false;
00705     hdlwindowinfo hinfo;
00706     
00707     flnextparamislast = true;
00708     
00709     if (!getwinparam (hparam1, 1, &hinfo))
00710         return (false);
00711     
00712     if (hinfo != nil) {
00713         
00714         shellwindowinval (hinfo);
00715         
00716         shellupdatenow ((**hinfo).macwindow);
00717         
00718         fl = true;
00719         }
00720     
00721     setbooleanvalue (fl, vreturned);
00722     
00723     return (true); 
00724     } /*updateverb*/
00725     
00726 
00727 static boolean ismenuscriptverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00728     
00729     /*
00730     return true if the frontmost window contains a menubar script
00731     
00732     the implementation is really ugly, but our hope is that we'll come 
00733     up with a way to address menubar scripts through the language and 
00734     get rid of this verb.
00735     
00736     9/25/91: well, the language still can't address menubar scripts, but 
00737     the window verbs now can.  so we can at least take a window parameter 
00738     like the rest or the verbs, instead of looking at the target window.
00739     */
00740     
00741     register boolean fl = false;
00742     hdlwindowinfo hinfo;
00743     
00744     flnextparamislast = true;
00745     
00746     if (!getwinparam (hparam1, 1, &hinfo))
00747         return (false);
00748     
00749     if (hinfo != nil) {
00750         
00751         shellpushglobals ((**hinfo).macwindow);
00752         
00753         if (shellglobals.configresnum == idscriptconfig)
00754             fl = scriptinmenubar ();
00755         
00756         shellpopglobals ();
00757         }
00758     
00759     /*
00760     WindowPtr target;
00761     boolean fl;
00762     
00763     if (!langcheckparamcount (hparam1, 0)) /%shouldn't have any parameters%/
00764         return (false);
00765     
00766     fl = false; /%default return is false%/
00767     
00768     if (shellfindtargetwindow (-1, &target)) {
00769         
00770         shellpushglobals (target);
00771         
00772         if (shellglobals.configresnum == idscriptconfig)
00773             fl = scriptinmenubar ();
00774         
00775         shellpopglobals ();
00776         }
00777     */
00778     
00779     return (setbooleanvalue (fl, vreturned));
00780     } /*ismenuscriptverb*/
00781 
00782 
00783 static boolean getboundsverb (hdltreenode hparam1, boolean flsize, tyvaluerecord *vreturned) {
00784     
00785     hdlwindowinfo hinfo;
00786     Rect r;
00787     hdlhashtable ht1, ht2;
00788     bigstring bs1, bs2;
00789     tyvaluerecord val;
00790     register boolean fl = false;
00791     
00792     if (!getwinparam (hparam1, 1, &hinfo))
00793         return (false);
00794     
00795     if (!getvarparam (hparam1, 2, &ht1, bs1))
00796         return (false);
00797     
00798     flnextparamislast = true;
00799     
00800     if (!getvarparam (hparam1, 3, &ht2, bs2))
00801         return (false);
00802     
00803     if (hinfo != nil) { /*a window is open*/
00804         register int x;
00805         
00806         shellgetglobalwindowrect (hinfo, &r);
00807         
00808         if (flsize)
00809             x = r.right - r.left;
00810         else
00811             x = r.left;
00812         
00813         setintvalue (x, &val);
00814         
00815         hashtableassign (ht1, bs1, val);
00816         
00817         if (flsize)
00818             val.data.intvalue = r.bottom - r.top;
00819         else
00820             val.data.intvalue = r.top;
00821         
00822         hashtableassign (ht2, bs2, val);
00823         
00824         fl = true;
00825         }
00826     
00827     setbooleanvalue (fl, vreturned);
00828     
00829     return (true); 
00830     } /*getboundsverb*/
00831 
00832 
00833 static boolean setboundsverb (hdltreenode hparam1, boolean flsize, tyvaluerecord *vreturned) {
00834     
00835     /*
00836     10/6/91 dmb: shellmovewindow and shellsizewindow now return a result
00837     */
00838     
00839     hdlwindowinfo hinfo;
00840     short int1, int2;
00841     register boolean fl = false;
00842     
00843     if (!getwinparam (hparam1, 1, &hinfo))
00844         return (false);
00845     
00846     if (!getintvalue (hparam1, 2, &int1))
00847         return (false);
00848     
00849     flnextparamislast = true;
00850     
00851     if (!getintvalue (hparam1, 3, &int2))
00852         return (false);
00853     
00854     if (hinfo != nil) { /*a window is open*/
00855         
00856         if (flsize)
00857             fl = shellsizewindow (hinfo, int1, int2);
00858         else
00859             fl = shellmovewindow (hinfo, int1, int2);
00860         }
00861     
00862     return (setbooleanvalue (fl, vreturned)); 
00863     } /*setboundsverb*/
00864 
00865 
00866 static boolean zoomverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00867     
00868     /*
00869     10/6/91 dmb: shellzoomwindow now returns a result
00870     */
00871     
00872     hdlwindowinfo hinfo;
00873     register boolean fl = false;
00874     
00875     flnextparamislast = true;
00876     
00877     if (!getwinparam (hparam1, 1, &hinfo))
00878         return (false);
00879     
00880     if (hinfo != nil) { /*a window is open*/
00881         
00882         shellpushglobals ((**hinfo).macwindow);
00883         
00884         fl = (*shellglobals.zoomwindowroutine) (hinfo, true);
00885         
00886         shellpopglobals ();
00887         }
00888     
00889     return (setbooleanvalue (fl, vreturned)); 
00890     } /*zoomverb*/
00891 
00892 
00893 static boolean getdirtywinparam (hdltreenode hfirst, short pnum, hdlwindowinfo *hinfo, hdlexternalvariable *hvariable) {
00894     
00895     /*
00896     unlike the normal getwinparam function, this one will accept the address 
00897     of an object whose window isn't open.  but it will also accept non-db windows.
00898     
00899     2.1b3 dmb: don't return false unless an error is generated
00900     */
00901     
00902     hdlhashtable htable;
00903     bigstring bs;
00904     tyvaluerecord val;
00905     boolean fl;
00906     hdlhashnode hnode;
00907     
00908     disablelangerror ();
00909     
00910     fl = getvarvalue (hfirst, pnum, &htable, bs, &val, &hnode);
00911     
00912     enablelangerror ();
00913     
00914     if (fl && (val.valuetype == externalvaluetype)) {
00915         
00916         *hvariable = (hdlexternalvariable) val.data.externalvalue;
00917         
00918         return (true);
00919         }
00920     
00921     *hvariable = nil;
00922     
00923     return (getwinparam (hfirst, pnum, hinfo));
00924     } /*getdirtywinparam*/
00925 
00926 
00927 static boolean isdirtyverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00928     
00929     /*
00930     4/16/92 dmb: find out if the object or window indicated in hparam1 is dirty.
00931     if it's  not an external value or a window, always return false
00932     
00933     2.1b3 dmb: don't count on hinfo being non-nil when hvariable is nil
00934     */
00935     
00936     hdlwindowinfo hinfo;
00937     hdlexternalvariable hvariable;
00938     boolean fldirty = false;
00939     
00940     flnextparamislast = true;
00941     
00942     if (!getdirtywinparam (hparam1, 1, &hinfo, &hvariable))
00943         return (false);
00944     
00945     if (hvariable != nil)
00946         fldirty = langexternalisdirty (hvariable);
00947     else
00948         if (hinfo != nil)
00949             fldirty = (**hinfo).flmadechanges;
00950     
00951     return (setbooleanvalue (fldirty, vreturned));
00952     } /*isdirtyverb*/
00953 
00954 
00955 static boolean setdirtyverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00956     
00957     /*
00958     4/16/92 dmb: set the dirtyness of the object or window indicated in hparam1.
00959     if it's  not an external value or a window, always return false
00960     
00961     2.1b3 dmb: don't count on hinfo being non-nil when hvariable is nil
00962     */
00963     
00964     hdlwindowinfo hinfo;
00965     hdlexternalvariable hvariable;
00966     boolean fldirty;
00967     boolean fl = false;
00968     
00969     if (!getdirtywinparam (hparam1, 1, &hinfo, &hvariable))
00970         return (false);
00971     
00972     flnextparamislast = true;
00973     
00974     if (!getbooleanvalue (hparam1, 2, &fldirty))
00975         return (false);
00976     
00977     if (hvariable != nil)
00978         fl = langexternalsetdirty (hvariable, fldirty);
00979     else
00980         if (hinfo != nil)
00981             fl = shellsetwindowchanges (hinfo, fldirty);
00982     
00983     return (setbooleanvalue (fl, vreturned));
00984     } /*setdirtyverb*/
00985 
00986 
00987 static boolean gettitleverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
00988     
00989     /*
00990     6/24/92 dmb: get the title of the object or window indicated in hparam1.
00991     if it's  not an external value or a window, always return the empty string
00992     */
00993     
00994     hdlwindowinfo hinfo;
00995     bigstring bstitle;
00996     boolean fl = false;
00997     
00998     flnextparamislast = true;
00999     
01000     if (!getwinparam (hparam1, 1, &hinfo))
01001         return (false);
01002     
01003     setemptystring (bstitle);
01004     
01005     if (hinfo != nil) {
01006         
01007         shellgetwindowtitle (hinfo, bstitle); // 7.24.97 dmb: was windowgettitle
01008         
01009         fl = true;
01010         }
01011     
01012     return (setstringvalue (bstitle, vreturned));
01013     } /*gettitleverb*/
01014 
01015 
01016 static boolean settitleverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01017     
01018     /*
01019     6/24/92 dmb: set the title of the object or window indicated in hparam1.
01020     if it's  not an external value or a window, always return false
01021     */
01022     
01023     hdlwindowinfo hinfo;
01024     bigstring bstitle;
01025     boolean fl = false;
01026     
01027     if (!getwinparam (hparam1, 1, &hinfo))
01028         return (false);
01029     
01030     flnextparamislast = true;
01031     
01032     if (!getstringvalue (hparam1, 2, bstitle))
01033         return (false);
01034     
01035     if (hinfo != nil) {
01036         
01037         shellsetwindowtitle (hinfo, bstitle); // 7.24.97 dmb: was windowsettitle
01038         
01039         shellwindowmenudirty ();
01040         
01041         fl = true;
01042         }
01043     
01044     return (setbooleanvalue (fl, vreturned));
01045     } /*settitleverb*/
01046 
01047 
01048 static boolean getfileverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01049     
01050     /*
01051     6/24/92 dmb: get the title of the object or window indicated in hparam1.
01052     if it's  not an external value or a window, always return the empty string
01053     */
01054     
01055     hdlwindowinfo hinfo;
01056     tyfilespec fs;
01057     
01058     flnextparamislast = true;
01059     
01060     if (!getwinparam (hparam1, 1, &hinfo))
01061         return (false);
01062     
01063     if ((hinfo != nil) && windowgetfspec ((**hinfo).macwindow, &fs))
01064         return (setfilespecvalue (&fs, vreturned));
01065     
01066     return (setstringvalue (zerostring, vreturned));
01067     } /*getfileverb*/
01068 
01069 
01070 static boolean windowfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
01071     
01072     /*
01073     10/3/91 dmb: moved a couple of verbs in from shellverbs.c -- they're the 
01074     odd ones out following zoomfunc.
01075     
01076     6/24/92 dmb: added gettitle, settitle verbs
01077     
01078     6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
01079     be run in the Frontier process
01080 
01081     6.2a8 AR: systemstatsfunc now works for GDBs (at least partly)
01082     */
01083     
01084     register hdltreenode hp = hparam1;
01085     register tyvaluerecord *v = vreturned;
01086     register short errornum = 0;
01087     
01088     if (v == nil) /*need Frontier process?*/
01089         return (true);
01090     
01091     setbooleanvalue (false, v); /*by default, window functions return true*/
01092     
01093     switch (token) {
01094         
01095         case isopenfunc:
01096             return (isopenverb (hp, v));
01097         
01098         case openfunc:
01099             return (openverb (hp, v, bserror));
01100         
01101         case isfrontfunc:
01102             return (isfrontverb (hp, v));
01103         
01104         case bringtofrontfunc:
01105             return (bringtofrontverb (hp, v));
01106         
01107         case sendtobackfunc:
01108             return (sendtobackverb (hp, v));
01109         
01110         case frontmostfunc:
01111             return (frontmostverb (hp, v));
01112         
01113         case nextfunc:
01114             return (nextverb (hp, v));
01115         
01116         case isvisiblefunc:
01117             return (isvisibleverb (hp, v));
01118     
01119         case showfunc:
01120             return (showhideverb (hp, true, v));
01121     
01122         case hidefunc:
01123             return (showhideverb (hp, false, v));
01124     
01125         case closefunc:
01126             return (closeverb (hp, v));
01127         
01128         case updatefunc:
01129             return (updateverb (hp, v));
01130         
01131         case ismenuscriptfunc:
01132             return (ismenuscriptverb (hp, v));
01133         
01134         case getposfunc:
01135             return (getboundsverb (hp, false, v));
01136         
01137         case setposfunc:
01138             return (setboundsverb (hp, false, v));
01139         
01140         case getsizefunc:
01141             return (getboundsverb (hp, true, v));
01142         
01143         case setsizefunc:
01144             return (setboundsverb (hp, true, v));
01145         
01146         case zoomfunc:
01147             return (zoomverb (hp, v));
01148         
01149         case runselectionfunc:
01150             if (!langcheckparamcount (hparam1, 0))
01151                 return (false);
01152             
01153             if (!shellpushtargetglobals ())
01154                 return (false);
01155             
01156             (*v).data.flvalue = (*shellglobals.executeroutine) ();
01157             
01158             shellpopglobals ();
01159             
01160             return (true);
01161         
01162         case scrollfunc: {
01163             tydirection dir;
01164             long count;
01165             
01166             if (!getdirectionvalue (hparam1, 1, &dir))
01167                 return (false);
01168             
01169             flnextparamislast = true;
01170             
01171             if (!getlongvalue (hparam1, 2, &count))
01172                 return (false);
01173             
01174             if (!shellpushtargetglobals ())
01175                 return (false);
01176             
01177             (*v).data.flvalue = (*shellglobals.scrollroutine) (dir, false, count);
01178             
01179             shellupdatescrollbars (shellwindowinfo);
01180             
01181             shellpopglobals ();
01182             
01183             return (true);
01184             }
01185         
01186         case msgfunc: {
01187             bigstring bs;
01188             
01189             flnextparamislast = true;
01190             
01191             if (!getstringvalue (hparam1, 1, bs))
01192                 return (false);
01193             
01194             (*v).data.flvalue = shellfrontwindowmessage (bs);
01195             
01196             return (true);
01197             }
01198         
01199         case systemstatsfunc:
01200             if (langgetparamcount (hparam1) == 0)
01201                 dbstatsmessage (nil, true);
01202             else {
01203                 hdlwindowinfo hinfo;
01204                 hdldatabaserecord hdb;
01205 
01206                 flnextparamislast = true;
01207                 
01208                 if (!getwinparam (hparam1, 1, &hinfo))
01209                     break;
01210                 
01211                 if (hinfo == nil || !shellgetdatabase ((**hinfo).macwindow, &hdb)) {
01212                     
01213                     getstringlist (langerrorlist, badwindowerror, bserror);
01214                     
01215                     break;
01216                     }
01217 
01218                 dbstatsmessage (hdb, false);
01219                 }
01220 
01221             return (setbooleanvalue (true, v));
01222         
01223         case quickscriptfunc:
01224             if (!langcheckparamcount (hparam1, 0))
01225                 return (false);
01226             
01227             (*v).data.flvalue = startcmddialog ();
01228 
01229             return (true);
01230         
01231         case isdirtyfunc:
01232             return (isdirtyverb (hparam1, v));
01233         
01234         case setdirtyfunc:
01235             return (setdirtyverb (hparam1, v));
01236         
01237         case gettitlefunc:
01238             return (gettitleverb (hparam1, v));
01239         
01240         case settitlefunc:
01241             return (settitleverb (hparam1, v));
01242         
01243         case aboutfunc:
01244             if (!langcheckparamcount (hparam1, 0))
01245                 return (false);
01246             
01247             (*v).data.flvalue = aboutcommand ();
01248             
01249             return (true);
01250         
01251         #ifdef MACVERSION
01252             
01253             case playerfunc: /*7.0b4 PBS: QuickTime Player window*/
01254                 if (!langcheckparamcount (hparam1, 0))
01255                     return (false);
01256                 
01257                 (*v).data.flvalue = playeropencommand ();
01258                 
01259                 return (true);
01260             
01261         #endif
01262         
01263         case getfilefunc:
01264             return (getfileverb (hparam1, v));
01265         
01266         case isreadonlyfunc: /*7.0b6 PBS: return true if a window is read-only*/
01267             return (isreadonlyverb (hparam1, v));
01268         
01269         default:
01270             errornum = notimplementederror;
01271             
01272             goto error;
01273         } /*switch*/
01274     
01275     error:
01276     
01277     if (errornum != 0) /*get error string*/
01278         getstringlist (windowerrorlist, errornum, bserror);
01279     
01280     return (false);
01281     } /*windowfunctionvalue*/
01282 
01283 
01284 boolean windowinitverbs (void) {
01285     
01286     return (loadfunctionprocessor (idwindowverbs, &windowfunctionvalue));
01287     } /*windowinitverbs*/
01288 
01289 
01290 
01291 

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