iowaattributes.c

Go to the documentation of this file.
00001 
00002 /*  $Id: iowaattributes.c 355 2005-01-11 22:48:55Z andreradke $    */
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 "shelltypes.h"
00032 #include <iac.h>
00033 #include <appletquickdraw.h>
00034 #include "iowacore.h"
00035 #include "iowaattributes.h"
00036 
00037 #ifdef coderesource
00038 
00039     #include <SetUpA4.h>
00040 
00041 #endif
00042 
00043 #ifdef iowaRuntime
00044     
00045     #include <appletquickdraw.h>
00046     #include "iowaruntime.h"
00047 
00048 #endif
00049 
00050 
00051 
00052 void consumetexthandle (Handle htext, bigstring bstext) {
00053     
00054     /*
00055     all of the IAC routines that take a text handle as a parameter
00056     just copy them into a bigstring and dispose of the handle.
00057     
00058     two things are at work here:
00059     
00060     1. object names are limited to 255 characters.
00061         
00062     2. heap-allocated AE parameters belong to the caller. they
00063     must either be linked into a structure or disposed of.
00064     */
00065         
00066     texthandletostring (htext, bstext);
00067     
00068     disposehandle (htext);
00069     } /*consumetexthandle*/
00070 
00071 
00072 boolean nocarderror (void) {
00073     
00074     if (iowadata != nil) /*it's not an error, therefore return false*/
00075         return (false);
00076     
00077     IACreturnerror (-1, "\pThere aren’t any Card Editor windows open at this time");
00078     
00079     return (true);
00080     } /*nocarderror*/
00081     
00082 
00083 boolean namedobjecterror (Handle objectname, hdlobject *hobject) {
00084     
00085     bigstring bsname, bserror;
00086     
00087     consumetexthandle (objectname, bsname);
00088     
00089     if (nocarderror ()) /*error*/
00090         return (true);
00091     
00092     if (lookupname (bsname, hobject)) /*no error*/
00093         return (false);
00094         
00095     copystring ("\pThere is no object named “", bserror);
00096     
00097     pushstring (bsname, bserror);
00098     
00099     pushstring ("\p” in the target Card Editor window", bserror);
00100     
00101     IACreturnerror (-1, bserror);
00102     
00103     return (true);
00104     } /*namedobjecterror*/
00105 
00106 
00107 #if 0
00108 
00109 static boolean IACpushobjectparam (hdlobject hobject, OSType keyword) {
00110 
00111     boolean fl;
00112     
00113     if (hobject == nil)
00114         fl = IACpushstringparam ("\p", keyword);
00115     
00116     else {
00117     
00118         IACglobals.dontdisposenextparam = true;
00119         
00120         fl = IACpushtextparam ((**hobject).objectname, keyword);
00121         }
00122     
00123     return (fl);
00124     } /*IACpushobjectparam*/
00125 
00126 #endif
00127 
00128     
00129 boolean IACgetobjectattributes (Handle objectname) {
00130     
00131     /*
00132     7/31/96 dmb: use new    IACglobals.dontdisposenextparam flag instead of 
00133     duplicating all of the handles that we pass
00134     
00135     7/31/96 dmb: xxx include the name of the next object and the first child 
00136     object in the attributes table [decided not to enable this yet.]
00137     */
00138     
00139     hdlobject hobject;
00140     Handle hvalue;
00141     tyobject obj;
00142     bigstring bsfont;
00143     
00144     if (nocarderror ()) /*error*/
00145         return (false);
00146     
00147     if (gethandlesize (objectname) == 0)
00148         hobject = (**iowadata).objectlist;
00149     else {
00150     
00151         if (namedobjecterror (objectname, &hobject)) 
00152             return (false);
00153         }
00154         
00155     obj = **hobject; /*copy for fast access*/
00156     
00157     GetFontName (obj.objectfont, bsfont);
00158     
00159     /*
00160     if (!copyhandle (obj.objectname, &obj.objectname))
00161         goto error;
00162     */
00163     
00164     getobjectvalue (hobject, &hvalue); /*1.0b15 -- allow for the object being in editmode*/
00165     
00166     /*
00167     if (!copyhandle (hvalue, &hvalue))
00168         goto error;
00169     
00170     if (!copyhandle (obj.objectscript, &obj.objectscript))
00171         goto error;
00172     
00173     if (!copyhandle (obj.objectrecalcscript, &obj.objectrecalcscript))
00174         goto error;
00175     
00176     if (!copyhandle (obj.objecterrormessage, &obj.objecterrormessage))
00177         goto error;
00178     */
00179     
00180     IACglobals.event = IACglobals.reply; /*push the params onto the reply record*/
00181     
00182     if (!IACpushlongparam (obj.objecttype, 'type'))
00183         goto error;
00184     
00185     if (!IACpushrectparam (&obj.objectrect, 'rect'))
00186         goto error;
00187     
00188     IACglobals.dontdisposenextparam = true;
00189         
00190     if (!IACpushtextparam (obj.objectname, 'name'))
00191         goto error;
00192     
00193     /* 7/31/96 dmb: decided not to put these in yet.
00194     
00195     if (!IACpushobjectparam (obj.nextobject, 'next'))
00196         goto error;
00197     
00198     if (!IACpushobjectparam (obj.childobjectlist, 'chld'))
00199         goto error;
00200     */
00201     
00202     IACglobals.dontdisposenextparam = true;
00203         
00204     if (!IACpushtextparam (hvalue, 'text'))
00205         goto error;
00206     
00207     IACglobals.dontdisposenextparam = true;
00208         
00209     if (!IACpushtextparam (obj.objectscript, 'scri'))
00210         goto error;
00211     
00212     IACglobals.dontdisposenextparam = true;
00213         
00214     if (!IACpushtextparam (obj.objectrecalcscript, 'rcsc'))
00215         goto error;
00216     
00217     if (!IACpushshortparam (obj.objectrecalcstatus, 'rcst'))
00218         goto error;
00219     
00220     if (!IACpushshortparam (obj.objectrecalcperiod, 'rcpd'))
00221         goto error;
00222     
00223     if (!IACpushstring4param (obj.objectlanguage, 'lang'))
00224         goto error;
00225     
00226     IACglobals.dontdisposenextparam = true;
00227         
00228     if (!IACpushtextparam (obj.objecterrormessage, 'errs'))
00229         goto error;
00230     
00231     if (!IACpushbooleanparam (obj.objectflag, 'flag'))
00232         goto error;
00233         
00234     if (!IACpushbooleanparam (obj.objectvisible, 'visi'))
00235         goto error;
00236         
00237     if (!IACpushbooleanparam (obj.objectenabled, 'enab'))
00238         goto error;
00239         
00240     if (!IACpushbooleanparam (obj.objecttransparent, 'tran'))
00241         goto error;
00242         
00243     if (!IACpushbooleanparam (obj.objectautosize, 'auto'))
00244         goto error;
00245         
00246     if (!IACpushbooleanparam (obj.objectinval, 'inva'))
00247         goto error;
00248         
00249     if (!IACpushbooleanparam (obj.objecthasframe, 'fram'))
00250         goto error;
00251         
00252     if (!IACpushstringparam (bsfont, 'font'))
00253         goto error;
00254     
00255     if (!IACpushshortparam (obj.objectfontsize, 'size'))
00256         goto error;
00257     
00258     if (!IACpushshortparam (obj.objectstyle, 'styl'))
00259         goto error;
00260     
00261     if (!IACpushshortparam ((short) obj.objectjustification, 'just'))
00262         goto error;
00263     
00264     if (!IACpushRGBColorparam (&obj.objectfillcolor, 'filc'))
00265         goto error;
00266     
00267     if (!IACpushRGBColorparam (&obj.objecttextcolor, 'txtc'))
00268         goto error;
00269     
00270     if (!IACpushRGBColorparam (&obj.objectframecolor, 'frmc'))
00271         goto error;
00272     
00273     if (!IACpushshortparam (obj.objectdropshadowdepth, 'sdwd'))
00274         goto error;
00275     
00276     if (!callgetattributes (hobject, IACglobals.reply)) /*1.0b15*/
00277         goto error;
00278         
00279     return (true);
00280     
00281     error:
00282     
00283     return (false);
00284     } /*IACgetobjectattributes*/
00285 
00286 
00287 static void invaldeferred (hdlobject h) {
00288 
00289     Rect r, rdeferred;
00290 
00291     getobjectinvalrect (h, &r);
00292     
00293     rdeferred = (**iowadata).deferredinvalrect;
00294     
00295     UnionRect (&rdeferred, &r, &rdeferred);
00296     
00297     (**iowadata).deferredinvalrect = rdeferred;
00298     } /*invaldeferred*/
00299     
00300     
00301 boolean IACsetobjectattributes (Handle objectname) {
00302     
00303     hdlobject hobject;
00304     tyobject obj;
00305     bigstring bsfont;
00306     Handle htext;
00307     Boolean fl;
00308     
00309     if (namedobjecterror (objectname, &hobject)) 
00310         return (false);
00311                 
00312     obj = **hobject; /*copy for fast access*/
00313     
00314     IACglobals.nextparamoptional = true;
00315     
00316     if (IACgetbooleanparam ('visi', &fl)) obj.objectvisible = fl; IACglobals.nextparamoptional = true;
00317     
00318     if (IACgetbooleanparam ('enab', &fl)) obj.objectenabled = fl; IACglobals.nextparamoptional = true;
00319     
00320     if (IACgetbooleanparam ('tran', &fl)) obj.objecttransparent = fl; IACglobals.nextparamoptional = true;
00321     
00322     if (IACgetbooleanparam ('auto', &fl)) obj.objectautosize = fl; IACglobals.nextparamoptional = true;
00323     
00324     if (IACgetbooleanparam ('inva', &fl)) obj.objectinval = fl; IACglobals.nextparamoptional = true;
00325     
00326     if (IACgetbooleanparam ('fram', &fl)) obj.objecthasframe = fl; IACglobals.nextparamoptional = true;
00327     
00328     IACgetshortparam ('size', &obj.objectfontsize); IACglobals.nextparamoptional = true;
00329     
00330     IACgetshortparam ('styl', &obj.objectstyle); IACglobals.nextparamoptional = true;
00331     
00332     IACgetshortparam ('rcst', &obj.objectrecalcstatus); IACglobals.nextparamoptional = true;
00333     
00334     IACgetshortparam ('rcpd', &obj.objectrecalcperiod); IACglobals.nextparamoptional = true;
00335     
00336     IACgetstring4param ('lang', &obj.objectlanguage); IACglobals.nextparamoptional = true;
00337     
00338     /*justification*/ {
00339         
00340         short x;
00341     
00342         if (IACgetshortparam ('just', &x))
00343             obj.objectjustification = (tyjustification) x;
00344         
00345         IACglobals.nextparamoptional = true;
00346         }
00347         
00348     /*the object rectangle*/ {
00349         
00350         if (IACgetrectparam ('rect', &obj.objectrect)) 
00351             invaldeferred (hobject);
00352         
00353         IACglobals.nextparamoptional = true;
00354         }
00355 
00356     /*the object type*/ {
00357     
00358         if (IACgetlongparam ('type', &obj.objecttype)) 
00359             invaldeferred (hobject);
00360         
00361         IACglobals.nextparamoptional = true;
00362         }
00363     
00364     /*the object flag*/ {
00365     
00366         if (IACgetbooleanparam ('flag', &fl)) {
00367         
00368             obj.objectflag = fl; 
00369             
00370             invaldeferred (hobject);
00371             }
00372     
00373         IACglobals.nextparamoptional = true;
00374         }
00375     
00376     IACgetRGBColorparam ('filc', &obj.objectfillcolor); IACglobals.nextparamoptional = true;
00377     
00378     IACgetRGBColorparam ('txtc', &obj.objecttextcolor); IACglobals.nextparamoptional = true;
00379     
00380     IACgetRGBColorparam ('frmc', &obj.objectframecolor); IACglobals.nextparamoptional = true;
00381     
00382     IACgetshortparam ('sdwd', &obj.objectdropshadowdepth); IACglobals.nextparamoptional = true;
00383     
00384     if (IACgetstringparam ('font', bsfont)) 
00385         GetFNum (bsfont, &obj.objectfont);
00386     
00387     **hobject = obj; /*copy it back into the heap*/
00388         
00389     if (IACgettextparam ('name', &htext)) 
00390         setobjectname (hobject, htext);
00391     
00392     IACglobals.nextparamoptional = true;
00393         
00394     if (IACgettextparam ('text', &htext)) 
00395         setobjectvalue (hobject, htext);
00396     
00397     IACglobals.nextparamoptional = true;
00398         
00399     if (IACgettextparam ('scri', &htext)) 
00400         setobjectscript (hobject, htext);
00401     
00402     IACglobals.nextparamoptional = true;
00403         
00404     if (IACgettextparam ('rcsc', &htext)) 
00405         setobjectrecalcscript (hobject, htext);
00406     
00407     IACglobals.nextparamoptional = true;
00408         
00409     if (IACgettextparam ('errs', &htext)) 
00410         setobjecterrormessage (hobject, htext);
00411         
00412     callsetattributes (hobject, IACglobals.event); /*1.0b15*/
00413     
00414     if (!emptyrect ((**iowadata).deferredinvalrect)) { /*1.0b15 -- redraw on every attribute change*/
00415         
00416         Rect r = (**iowadata).deferredinvalrect;
00417         
00418         iowainvalrect (&r);
00419         
00420         zerorect (&r);
00421         
00422         (**iowadata).deferredinvalrect = r;
00423         }
00424     
00425     invalobject (hobject);
00426     
00427     iowaupdatenow ();
00428         
00429     return (true);
00430     } /*IACsetobjectattributes*/
00431 
00432 
00433 boolean IACgetcardattributes (void) {
00434     
00435     tycard card;
00436     
00437     if (nocarderror ()) 
00438         return (false);
00439     
00440     card = **iowadata; /*copy for fast access, smaller code*/
00441     
00442     IACglobals.event = IACglobals.reply; /*push the params onto the reply record*/
00443     
00444     /*push name of the active text object on reply*/ {
00445         
00446         bigstring bs;
00447         
00448         if (card.activetextobject == nil)
00449             setstringlength (bs, 0);
00450         else
00451             texthandletostring ((**card.activetextobject).objectname, bs);
00452             
00453         if (!IACpushstringparam (bs, 'atob'))
00454             goto error;
00455         }
00456     
00457     if (!IACpushRGBColorparam (&card.backcolor, 'bakc'))
00458         goto error;
00459         
00460     if (!IACpushbooleanparam (card.flgrid, 'grid'))
00461         goto error;
00462         
00463     if (!IACpushshortparam (card.gridunits, 'grun'))
00464         goto error;
00465         
00466     if (!IACpushbooleanparam (card.flinvisiblegrid, 'grvs'))
00467         goto error;
00468         
00469     if (!IACpushbooleanparam (card.recalcneeded, 'rcal'))
00470         goto error;
00471         
00472     if (!IACpushlongparam (card.recalctickcount, 'rctc'))
00473         goto error;
00474         
00475     if (!IACpushshortparam (card.rightborder, 'rbor'))
00476         goto error;
00477         
00478     if (!IACpushshortparam (card.bottomborder, 'bbor'))
00479         goto error;
00480         
00481     if (!IACpushbooleanparam (card.floater, 'floa'))
00482         goto error;
00483         
00484     if (!IACpushlongparam (card.idwindow, 'wind'))
00485         goto error;
00486                     
00487     return (true);
00488     
00489     error:
00490     
00491     return (false);
00492     } /*IACgetcardattributes*/
00493 
00494 
00495 boolean IACsetcardattributes (void) {
00496     
00497     tycard card;
00498     /*bigstring nameactivetextobject;*/
00499     Boolean fl;
00500     
00501     if (nocarderror ())         
00502         return (false);
00503     
00504     card = **iowadata; /*copy for fast access, smaller code*/
00505     
00506     IACglobals.nextparamoptional = true;
00507     
00508     /*IACgetstringparam ('atob', nameactivetextobject); IACglobals.nextparamoptional = true;*/
00509 
00510     IACgetRGBColorparam ('bakc', &card.backcolor); IACglobals.nextparamoptional = true;
00511 
00512     if (IACgetbooleanparam ('grid', &fl)) card.flgrid = fl; IACglobals.nextparamoptional = true;
00513 
00514     IACgetshortparam ('grun', &card.gridunits); IACglobals.nextparamoptional = true;
00515     
00516     if (IACgetbooleanparam ('grvs', &fl)) card.flinvisiblegrid = fl; IACglobals.nextparamoptional = true;
00517 
00518     if (IACgetbooleanparam ('rcal', &fl)) {card.recalcneeded = fl; card.recalcobject = nil;}; IACglobals.nextparamoptional = true;
00519 
00520     IACgetlongparam ('rctc', &card.recalctickcount); IACglobals.nextparamoptional = true;
00521     
00522     IACgetshortparam ('rbor', &card.rightborder); IACglobals.nextparamoptional = true;
00523     
00524     IACgetshortparam ('bbor', &card.bottomborder); IACglobals.nextparamoptional = true;
00525     
00526     if (IACgetbooleanparam ('floa', &fl)) card.floater = fl; IACglobals.nextparamoptional = true;
00527 
00528     IACgetlongparam ('wind', &card.idwindow); IACglobals.nextparamoptional = true;
00529     
00530     card.fullupdate = true; /*force card to redraw on idle*/
00531     
00532     **iowadata = card; /*copy it back into the heap*/
00533     
00534     return (true);
00535     } /*IACsetcardattributes*/
00536     
00537     
00538 #ifndef iowaRuntime
00539     
00540     
00541     static void getCardAttributesVerb (void) {
00542         
00543         Boolean returnedValue;
00544         
00545         returnedValue = IACgetcardattributes ();
00546         
00547         IACreturnboolean (returnedValue);
00548         } /*getCardAttributesVerb*/
00549     
00550     
00551     static void setCardAttributesVerb (void) {
00552         
00553         Boolean returnedValue;
00554         
00555         returnedValue = IACsetcardattributes ();
00556         
00557         madechanges ();
00558         
00559         IACreturnboolean (returnedValue);
00560         } /*setCardAttributesVerb*/
00561     
00562     
00563     static void getObjectAttributesVerb (void) {
00564         
00565         Handle param1;
00566         Boolean returnedValue;
00567         
00568         if (!IACgettextparam ('prm1', &param1))
00569             return;
00570         
00571         returnedValue = IACgetobjectattributes (param1);
00572         
00573         IACreturnboolean (returnedValue);
00574         } /*getObjectAttributesVerb*/
00575     
00576     
00577     static void setObjectAttributesVerb (void) {
00578         
00579         Handle param1;
00580         Boolean returnedValue;
00581         
00582         if (!IACgettextparam ('prm1', &param1))
00583             return;
00584         
00585         returnedValue = IACsetobjectattributes (param1);
00586         
00587         madechanges ();
00588         
00589         IACreturnboolean (returnedValue);
00590         } /*setObjectAttributesVerb*/
00591     
00592     
00593     static pascal OSErr attributeshandler (AppleEvent *event, AppleEvent *reply, long refcon) {
00594     
00595         #ifdef coderesource
00596         
00597             EnterCallback ();
00598             
00599         #endif
00600         
00601         IACglobals.event = event; 
00602         
00603         IACglobals.reply = reply;
00604         
00605         IACglobals.refcon = refcon;
00606         
00607         switch (IACgetverbtoken ()) {
00608             
00609             case 'gacd':
00610                 getCardAttributesVerb ();
00611                 
00612                 break;
00613             
00614             case 'sacd':
00615                 setCardAttributesVerb ();
00616                 
00617                 break;
00618             
00619             case 'gaob':
00620                 getObjectAttributesVerb ();
00621                 
00622                 break;
00623             
00624             case 'saob':
00625                 setObjectAttributesVerb ();
00626                 
00627                 break;
00628             
00629             } /*switch*/
00630             
00631         #ifdef coderesource
00632         
00633             ExitCallback ();
00634             
00635         #endif
00636         
00637         return (noErr);
00638         } /*attributeshandler*/
00639     
00640     
00641     boolean installattributeshandler (void) {
00642         
00643         #ifdef coderesource
00644         
00645             PrepareCallback ();
00646             
00647         #endif
00648         
00649         IACinstallsystemhandler ('ceda', typeWildCard, (ProcPtr) &attributeshandler);
00650         
00651         return (true);
00652         } /*installattributeshandler*/
00653     
00654 #endif
00655 
00656 

Generated on Wed May 31 18:19:49 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6