uisharing.c

Go to the documentation of this file.
00001 
00002 /*  $Id: uisharing.c 1213 2006-04-06 01:02:50Z 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 <uisharing.h>
00032 #include <uisinternal.h>
00033 
00034 
00035 #define glue static pascal ComponentResult
00036 
00037 
00038 tyWindowSharingGlobals wsGlobals = {0, 0, false};
00039 
00040 tyMenuSharingGlobals msGlobals = {0, 0};
00041     
00042 
00043 Boolean uisDisposeSharedMenus (void); /*for compatibility with earlier menu sharing toolkits*/
00044 
00045 Boolean uisIsSharedMenu (short);
00046 
00047 void uisEnableSharedMenus (Boolean);
00048 
00049 Boolean uisRunSharedMenuItem (short, short);
00050 
00051 
00052 
00053 static Boolean HaveComponentManager (void) {
00054 
00055     long result;
00056     
00057     if (Gestalt (gestaltComponentMgr, &result) != noErr)
00058         return (false);
00059     
00060     return (result != 0);
00061     } /*HaveComponentManager*/
00062 
00063 
00064 #ifndef isFrontier
00065 
00066 static Boolean isFrontProcess () {
00067     
00068     ProcessSerialNumber currentprocess, frontprocess;
00069     Boolean fl;
00070     
00071     GetCurrentProcess (&currentprocess);
00072     
00073     GetFrontProcess (&frontprocess);
00074     
00075     SameProcess (&currentprocess, &frontprocess, &fl);
00076     
00077     return (fl);
00078     } /*isFrontProcess*/
00079 
00080 #endif
00081     
00082 
00083 /* 2004-10-22 aradke: Not sure if this is the right thing to do for the Mach-O build,
00084         but at least it makes the link errors for _editGlue etc. go away
00085 */
00086 #if TARGET_RT_MAC_CFM || TARGET_RT_MAC_MACHO
00087 
00088 enum {
00089     uppCallComponentProcInfo = kPascalStackBased
00090             | RESULT_SIZE(kFourByteCode)
00091             | STACK_ROUTINE_PARAMETER(1, kFourByteCode)
00092 };
00093 
00094 extern UniversalProcPtr CallComponentUPP;
00095 
00096 #pragma options align=mac68k
00097 
00098 glue windoweventGlue (ComponentInstance comp, EventRecord *ev, tyWindowSharingGlobals *wsGlobals) {
00099     
00100     #define windoweventParamSize     (sizeof (ev) + sizeof (wsGlobals))
00101     
00102     struct windoweventGluePB {
00103         unsigned char   componentFlags;
00104         unsigned char   componentParamSize;
00105         short componentWhat;
00106         tyWindowSharingGlobals *wsGlobals;
00107         EventRecord *ev;
00108         ComponentInstance   comp;
00109     };
00110     
00111     struct windoweventGluePB pb;
00112     
00113     pb.componentFlags = 0;
00114     pb.componentParamSize = windoweventParamSize;
00115     pb.componentWhat = wsEventHandlerCommand;
00116     pb.wsGlobals = wsGlobals;
00117     pb.ev = ev;
00118     pb.comp = comp;
00119     
00120     #if TARGET_API_MAC_CARBON == 1
00121     return CallComponentDispatch((ComponentParameters *)&pb);
00122     #else   
00123     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00124     #endif
00125         } /*windoweventGlue*/
00126 
00127 
00128 glue windowiscardGlue (ComponentInstance comp, WindowPtr w) {
00129     
00130     #define windowiscardParamSize    (sizeof (w))
00131     
00132     struct windowiscardGluePB {
00133         unsigned char   componentFlags;
00134         unsigned char   componentParamSize;
00135         short componentWhat;
00136         WindowPtr w;
00137         ComponentInstance   comp;
00138     };
00139     
00140     struct windowiscardGluePB pb;
00141     
00142     pb.componentFlags = 0;
00143     pb.componentParamSize = windowiscardParamSize;
00144     pb.componentWhat = wsWindowIsCardCommand;
00145     pb.w = w;
00146     pb.comp = comp;
00147     
00148     #if TARGET_API_MAC_CARBON == 1
00149     return CallComponentDispatch((ComponentParameters *)&pb);
00150     #else   
00151     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00152     #endif
00153     } /*windowiscardGlue*/
00154     
00155     
00156 glue closewindowGlue (ComponentInstance comp, WindowPtr w) {
00157     
00158     #define closewindowParamSize     (sizeof (w))
00159     
00160     struct closewindowGluePB {
00161         unsigned char   componentFlags;
00162         unsigned char   componentParamSize;
00163         short componentWhat;
00164         WindowPtr w;
00165         ComponentInstance   comp;
00166     };
00167     
00168     struct closewindowGluePB pb;
00169     
00170     pb.componentFlags = 0;
00171     pb.componentParamSize = closewindowParamSize;
00172     pb.componentWhat = wsCloseWindowCommand;
00173     pb.w = w;
00174     pb.comp = comp;
00175     
00176     #if TARGET_API_MAC_CARBON == 1
00177     return CallComponentDispatch((ComponentParameters *)&pb);
00178     #else   
00179     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00180     #endif
00181     } /*windowiscardGlue*/
00182     
00183 
00184 #ifndef isFrontier
00185     
00186     glue initsharedmenusGlue (ComponentInstance comp) {
00187     
00188         #define initsharedmenusParamSize     (0L)
00189         
00190         struct initsharedmenusGluePB {
00191             unsigned char   componentFlags;
00192             unsigned char   componentParamSize;
00193             short componentWhat;
00194             ComponentInstance   comp;
00195         };
00196         
00197         struct initsharedmenusGluePB pb;
00198         
00199         pb.componentFlags = 0;
00200         pb.componentParamSize = initsharedmenusParamSize;
00201         pb.componentWhat = msInitSharedMenusCommand;
00202         pb.comp = comp;
00203         
00204         #if TARGET_API_MAC_CARBON == 1
00205         return CallComponentDispatch((ComponentParameters *)&pb);
00206         #else   
00207         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00208         #endif
00209         }   /*initsharedmenusGlue*/
00210         
00211     
00212     glue sharedmenuhitGlue (ComponentInstance comp, short idmenu, short iditem, Boolean *flshareditem) {
00213     
00214         #define sharedmenuhitParamSize   (sizeof (idmenu) + sizeof (iditem) + sizeof (flshareditem))
00215         
00216         struct sharedmenuhitGluePB {
00217             unsigned char   componentFlags;
00218             unsigned char   componentParamSize;
00219             short componentWhat;
00220             Boolean *flshareditem;
00221             short iditem;
00222             short idmenu;
00223             ComponentInstance   comp;
00224         };
00225         
00226         struct sharedmenuhitGluePB pb;
00227         
00228         pb.componentFlags = 0;
00229         pb.componentParamSize = sharedmenuhitParamSize;
00230         pb.componentWhat = msSharedMenuHitCommand;
00231         pb.flshareditem = flshareditem;
00232         pb.iditem = iditem;
00233         pb.idmenu = idmenu;
00234         pb.comp = comp;
00235         
00236         #if TARGET_API_MAC_CARBON == 1
00237         return CallComponentDispatch((ComponentParameters *)&pb);
00238         #else   
00239         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00240         #endif
00241         }   /*sharedmenuhitGlue*/
00242         
00243     
00244     glue sharedscriptrunningGlue (ComponentInstance comp, Boolean *flrunning) {
00245     
00246         #define sharedscriptrunningParamSize     (sizeof (flrunning))
00247         
00248         struct sharedscriptrunningGluePB {
00249             unsigned char   componentFlags;
00250             unsigned char   componentParamSize;
00251             short componentWhat;
00252             Boolean *flrunning;
00253             ComponentInstance   comp;
00254         };
00255         
00256         struct sharedscriptrunningGluePB pb;
00257         
00258         pb.componentFlags = 0;
00259         pb.componentParamSize = sharedscriptrunningParamSize;
00260         pb.componentWhat = msSharedScriptRunningCommand;
00261         pb.flrunning = flrunning;
00262         pb.comp = comp;
00263         
00264         #if TARGET_API_MAC_CARBON == 1
00265         return CallComponentDispatch((ComponentParameters *)&pb);
00266         #else   
00267         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00268         #endif
00269         }   /*sharedscriptrunningGlue*/
00270         
00271     
00272     glue cancelsharedscriptGlue (ComponentInstance comp) {
00273     
00274         #define cancelsharedscriptParamSize  (0L)
00275         
00276         struct cancelsharedscriptGluePB {
00277             unsigned char   componentFlags;
00278             unsigned char   componentParamSize;
00279             short componentWhat;
00280             ComponentInstance   comp;
00281         };
00282         
00283         struct cancelsharedscriptGluePB pb;
00284         
00285         pb.componentFlags = 0;
00286         pb.componentParamSize = cancelsharedscriptParamSize;
00287         pb.componentWhat = msCancelSharedScriptCommand;
00288         pb.comp = comp;
00289         
00290         #if TARGET_API_MAC_CARBON == 1
00291         return CallComponentDispatch((ComponentParameters *)&pb);
00292         #else   
00293         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00294         #endif
00295         }   /*cancelsharedscriptGlue*/
00296         
00297     
00298     glue checksharedmenusGlue (ComponentInstance comp, short idinsertafter) {
00299     
00300         #define checksharedmenusParamSize    (sizeof (idinsertafter))
00301         
00302         struct checksharedmenusGluePB {
00303             unsigned char   componentFlags;
00304             unsigned char   componentParamSize;
00305             short componentWhat;
00306             short idinsertafter;
00307             ComponentInstance   comp;
00308         };
00309         
00310         struct checksharedmenusGluePB pb;
00311         
00312         pb.componentFlags = 0;
00313         pb.componentParamSize = checksharedmenusParamSize;
00314         pb.componentWhat = msCheckSharedMenusCommand;
00315         pb.idinsertafter = idinsertafter;
00316         pb.comp = comp;
00317         
00318         #if TARGET_API_MAC_CARBON == 1
00319         return CallComponentDispatch((ComponentParameters *)&pb);
00320         #else   
00321         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00322         #endif
00323         }   /*checksharedmenusGlue*/
00324         
00325     
00326     glue disposesharedmenusGlue (ComponentInstance comp) {
00327     
00328         #define disposesharedmenusParamSize  (0L)
00329         
00330         struct disposesharedmenusGluePB {
00331             unsigned char   componentFlags;
00332             unsigned char   componentParamSize;
00333             short componentWhat;
00334             ComponentInstance   comp;
00335         };
00336         
00337         struct disposesharedmenusGluePB pb;
00338         
00339         pb.componentFlags = 0;
00340         pb.componentParamSize = disposesharedmenusParamSize;
00341         pb.componentWhat = msDisposeSharedMenusCommand;
00342         pb.comp = comp;
00343         
00344         #if TARGET_API_MAC_CARBON == 1
00345         return CallComponentDispatch((ComponentParameters *)&pb);
00346         #else   
00347         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00348         #endif
00349         }   /*disposesharedmenusGlue*/
00350         
00351     
00352     glue issharedmenuGlue (ComponentInstance comp, short idmenu, Boolean *flsharedmenu) {
00353     
00354         #define issharedmenuParamSize    (sizeof (idmenu) + sizeof (flsharedmenu))
00355         
00356         struct issharedmenuGluePB {
00357             unsigned char   componentFlags;
00358             unsigned char   componentParamSize;
00359             short componentWhat;
00360             Boolean *flsharedmenu;
00361             short idmenu;
00362             ComponentInstance   comp;
00363         };
00364         
00365         struct issharedmenuGluePB pb;
00366         
00367         pb.componentFlags = 0;
00368         pb.componentParamSize = issharedmenuParamSize;
00369         pb.componentWhat = msIsSharedMenuCommand;
00370         pb.flsharedmenu = flsharedmenu;
00371         pb.idmenu = idmenu;
00372         pb.comp = comp;
00373         
00374         #if TARGET_API_MAC_CARBON == 1
00375         return CallComponentDispatch((ComponentParameters *)&pb);
00376         #else   
00377         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00378         #endif
00379         }   /*issharedmenuGlue*/
00380         
00381     
00382     glue enablesharedmenusGlue (ComponentInstance comp, Boolean flenable) {
00383     
00384         #define enablesharedmenusParamSize   (sizeof (flenable))
00385         
00386         struct enablesharedmenusGluePB {
00387             unsigned char   componentFlags;
00388             unsigned char   componentParamSize;
00389             short componentWhat;
00390             Boolean flenable;
00391             ComponentInstance   comp;
00392         };
00393         
00394         struct enablesharedmenusGluePB pb;
00395         
00396         pb.componentFlags = 0;
00397         pb.componentParamSize = enablesharedmenusParamSize;
00398         pb.componentWhat = msEnableSharedMenusCommand;
00399         pb.flenable = flenable;
00400         pb.comp = comp;
00401         
00402         #if TARGET_API_MAC_CARBON == 1
00403         return CallComponentDispatch((ComponentParameters *)&pb);
00404         #else   
00405         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00406         #endif
00407         }   /*enablesharedmenusGlue*/
00408         
00409     
00410     glue runsharedmenuitemGlue (ComponentInstance comp, short idmenu, short iditem) {
00411     
00412         #define runsharedmenuitemParamSize   (sizeof (idmenu) + sizeof (iditem))
00413         
00414         struct runsharedmenuitemGluePB {
00415             unsigned char   componentFlags;
00416             unsigned char   componentParamSize;
00417             short componentWhat;
00418             short iditem;
00419             short idmenu;
00420             ComponentInstance   comp;
00421         };
00422         
00423         struct runsharedmenuitemGluePB pb;
00424         
00425         pb.componentFlags = 0;
00426         pb.componentParamSize = runsharedmenuitemParamSize;
00427         pb.componentWhat = msRunSharedMenuItemCommand;
00428         pb.iditem = iditem;
00429         pb.idmenu = idmenu;
00430         pb.comp = comp;
00431         
00432         #if TARGET_API_MAC_CARBON == 1
00433         return CallComponentDispatch(&pb);
00434         #else   
00435         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00436         #endif
00437         }   /*runsharedmenuitemGlue*/
00438         
00439     
00440     glue setscripterrorcallbackGlue (ComponentInstance comp, ProcPtr scripterrorproc) {
00441     
00442         #define setscripterrorcallbackParamSize  (sizeof (scripterrorproc))
00443         
00444         struct setscripterrorcallbackGluePB {
00445             unsigned char   componentFlags;
00446             unsigned char   componentParamSize;
00447             short componentWhat;
00448             ProcPtr scripterrorproc;
00449             ComponentInstance   comp;
00450         };
00451         
00452         struct setscripterrorcallbackGluePB pb;
00453         
00454         pb.componentFlags = 0;
00455         pb.componentParamSize = setscripterrorcallbackParamSize;
00456         pb.componentWhat = msSetScriptErrorCallbackCommand;
00457         pb.scripterrorproc = scripterrorproc;
00458         pb.comp = comp;
00459         
00460         #if TARGET_API_MAC_CARBON == 1
00461         return CallComponentDispatch((ComponentParameters *)&pb);
00462         #else   
00463         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00464         #endif
00465         }   /*setscripterrorcallbackGlue*/
00466     
00467     
00468     glue stubstartGlue (ComponentInstance comp) {
00469     
00470         #define stubstartParamSize   (0L)
00471         
00472         struct stubstartGluePB {
00473             unsigned char   componentFlags;
00474             unsigned char   componentParamSize;
00475             short componentWhat;
00476             ComponentInstance   comp;
00477         };
00478         
00479         struct stubstartGluePB pb;
00480         
00481         pb.componentFlags = 0;
00482         pb.componentParamSize = stubstartParamSize;
00483         pb.componentWhat = wsStubStartCommand;
00484         pb.comp = comp;
00485         
00486         #if TARGET_API_MAC_CARBON == 1
00487         return CallComponentDispatch((ComponentParameters *)&pb);
00488         #else   
00489         return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00490         #endif
00491         }   /*stubstartGlue*/
00492 
00493 #endif
00494 
00495 
00496 glue runhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) {
00497     
00498     #define runhandleParamSize   (sizeof (h) + sizeof (flscriptedcard) + sizeof (windowname) + sizeof (pt) + sizeof (filter))
00499     
00500     struct runhandleGluePB {
00501         unsigned char   componentFlags;
00502         unsigned char   componentParamSize;
00503         short componentWhat;
00504         uisEventCallback filter;
00505         Point pt;
00506         unsigned char *windowname;
00507         short flscriptedcard;
00508         Handle h;
00509         ComponentInstance   comp;
00510     };
00511     
00512     struct runhandleGluePB pb;
00513     
00514     pb.componentFlags = 0;
00515     pb.componentParamSize = runhandleParamSize;
00516     pb.componentWhat = wsRunFromHandleCommand;
00517     pb.filter = filter;
00518     pb.pt = pt;
00519     pb.windowname = windowname;
00520     pb.flscriptedcard = flscriptedcard;
00521     pb.h = h;
00522     pb.comp = comp;
00523     
00524     #if TARGET_API_MAC_CARBON == 1
00525     return CallComponentDispatch((ComponentParameters *)&pb);
00526     #else   
00527     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00528     #endif
00529     } /*runhandleGlue*/
00530 
00531 
00532 glue runmodalhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) {
00533     
00534     #define runmodalhandleParamSize  (sizeof (h) + sizeof (flscriptedcard) + sizeof (windowname) + sizeof (pt) + sizeof (filter))
00535     
00536     struct runmodalhandleGluePB {
00537         unsigned char   componentFlags;
00538         unsigned char   componentParamSize;
00539         short componentWhat;
00540         uisEventCallback filter;
00541         Point pt;
00542         unsigned char *windowname;
00543         short flscriptedcard;
00544         Handle h;
00545         ComponentInstance   comp;
00546     };
00547     
00548     struct runmodalhandleGluePB pb;
00549     
00550     pb.componentFlags = 0;
00551     pb.componentParamSize = runmodalhandleParamSize;
00552     pb.componentWhat = wsRunModalHandleCommand;
00553     pb.filter = filter;
00554     pb.pt = pt;
00555     pb.windowname = windowname;
00556     pb.flscriptedcard = flscriptedcard;
00557     pb.h = h;
00558     pb.comp = comp;
00559     
00560     #if TARGET_API_MAC_CARBON == 1
00561     return CallComponentDispatch((ComponentParameters *)&pb);
00562     #else   
00563     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00564     #endif
00565     } /*runmodalhandleGlue*/
00566 
00567 
00568 #ifndef isFrontier
00569 
00570 glue setobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle value) {
00571     
00572     #define setobjectvalueParamSize  (sizeof (hcard) + sizeof (name) + sizeof (value))
00573     
00574     struct setobjectvalueGluePB {
00575         unsigned char   componentFlags;
00576         unsigned char   componentParamSize;
00577         short componentWhat;
00578         Handle value;
00579         unsigned char *name;
00580         Handle hcard;
00581         ComponentInstance   comp;
00582     };
00583     
00584     struct setobjectvalueGluePB pb;
00585     
00586     pb.componentFlags = 0;
00587     pb.componentParamSize = setobjectvalueParamSize;
00588     pb.componentWhat = wsSetObjectValueCommand;
00589     pb.value = value;
00590     pb.name = name;
00591     pb.hcard = hcard;
00592     pb.comp = comp;
00593     
00594     #if TARGET_API_MAC_CARBON == 1
00595     return CallComponentDispatch((ComponentParameters *)&pb);
00596     #else   
00597     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00598     #endif
00599     } /*setobjectvalueGlue*/
00600     
00601 
00602 glue getobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *value) {
00603     
00604     #define getobjectvalueParamSize  (sizeof (hcard) + sizeof (name) + sizeof (value))
00605     
00606     struct getobjectvalueGluePB {
00607         unsigned char   componentFlags;
00608         unsigned char   componentParamSize;
00609         short componentWhat;
00610         Handle *value;
00611         unsigned char *name;
00612         Handle hcard;
00613         ComponentInstance   comp;
00614     };
00615     
00616     struct getobjectvalueGluePB pb;
00617     
00618     pb.componentFlags = 0;
00619     pb.componentParamSize = getobjectvalueParamSize;
00620     pb.componentWhat = wsGetObjectValueCommand;
00621     pb.value = value;
00622     pb.name = name;
00623     pb.hcard = hcard;
00624     pb.comp = comp;
00625     
00626     #if TARGET_API_MAC_CARBON == 1
00627     return CallComponentDispatch((ComponentParameters *)&pb);
00628     #else   
00629     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00630     #endif
00631     } /*getobjectvalueGlue*/
00632     
00633 
00634 glue getobjecthandleGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *h) {
00635     
00636     #define getobjecthandleParamSize     (sizeof (hcard) + sizeof (name) + sizeof (h))
00637     
00638     struct getobjecthandleGluePB {
00639         unsigned char   componentFlags;
00640         unsigned char   componentParamSize;
00641         short componentWhat;
00642         Handle *h;
00643         unsigned char *name;
00644         Handle hcard;
00645         ComponentInstance   comp;
00646     };
00647     
00648     struct getobjecthandleGluePB pb;
00649     
00650     pb.componentFlags = 0;
00651     pb.componentParamSize = getobjecthandleParamSize;
00652     pb.componentWhat = wsGetObjectHandleCommand;
00653     pb.h = h;
00654     pb.name = name;
00655     pb.hcard = hcard;
00656     pb.comp = comp;
00657     
00658     #if TARGET_API_MAC_CARBON == 1
00659     return CallComponentDispatch((ComponentParameters *)&pb);
00660     #else   
00661     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00662     #endif
00663     } /*getobjecthandleGlue*/
00664     
00665 
00666 glue recalcGlue (ComponentInstance comp, Handle h) {
00667     
00668     #define recalcParamSize  (sizeof (h))
00669     
00670     struct recalcGluePB {
00671         unsigned char   componentFlags;
00672         unsigned char   componentParamSize;
00673         short componentWhat;
00674         Handle h;
00675         ComponentInstance   comp;
00676     };
00677     
00678     struct recalcGluePB pb;
00679     
00680     pb.componentFlags = 0;
00681     pb.componentParamSize = recalcParamSize;
00682     pb.componentWhat = wsRecalcObjectCommand;
00683     pb.h = h;
00684     pb.comp = comp;
00685     
00686     #if TARGET_API_MAC_CARBON == 1
00687     return CallComponentDispatch((ComponentParameters *)&pb);
00688     #else   
00689     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00690     #endif
00691     } /*recalcGlue*/
00692 
00693 #endif
00694 
00695 
00696 glue editGlue (ComponentInstance comp, short editcommand) {
00697     
00698     #define editParamSize    (sizeof (editcommand))
00699     
00700     struct editGluePB {
00701         unsigned char   componentFlags;
00702         unsigned char   componentParamSize;
00703         short componentWhat;
00704         short editcommand;
00705         ComponentInstance   comp;
00706     };
00707     
00708     struct editGluePB pb;
00709     
00710     pb.componentFlags = 0;
00711     pb.componentParamSize = editParamSize;
00712     pb.componentWhat = wsEditCommand;
00713     pb.editcommand = editcommand;
00714     pb.comp = comp;
00715     
00716     #if TARGET_API_MAC_CARBON == 1
00717     return CallComponentDispatch((ComponentParameters *)&pb);
00718     #else   
00719     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00720     #endif
00721     } /*editGlue*/
00722 
00723 
00724 #ifndef isFrontier
00725 
00726 glue updateGlue (ComponentInstance comp, Handle h) {
00727     
00728     #define updateParamSize  (sizeof (h))
00729     
00730     struct updateGluePB {
00731         unsigned char   componentFlags;
00732         unsigned char   componentParamSize;
00733         short componentWhat;
00734         Handle h;
00735         ComponentInstance   comp;
00736     };
00737     
00738     struct updateGluePB pb;
00739     
00740     pb.componentFlags = 0;
00741     pb.componentParamSize = updateParamSize;
00742     pb.componentWhat = wsUpdateCommand;
00743     pb.h = h;
00744     pb.comp = comp;
00745     
00746     #if TARGET_API_MAC_CARBON == 1
00747     return CallComponentDispatch((ComponentParameters *) &pb);
00748     #else   
00749     return CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &pb);
00750     #endif
00751     } /*updateGlue*/
00752 
00753 #endif
00754 
00755 
00756 #pragma options align=reset
00757 
00758 #elif 0 // defined (THINK_C)
00759 
00760 glue windoweventGlue (ComponentInstance comp, EventRecord *ev, tyWindowSharingGlobals *wsGlobals) 
00761 
00762     = ComponentCallNow (wsEventHandlerCommand, sizeof (EventRecord *) + sizeof (tyWindowSharingGlobals *)); 
00763     /*windoweventGlue*/
00764 
00765 
00766 glue windowiscardGlue (ComponentInstance comp, WindowPtr w) 
00767     
00768     = ComponentCallNow (wsWindowIsCardCommand, sizeof (WindowPtr)); 
00769     /*windowiscardGlue*/
00770     
00771     
00772 glue closewindowGlue (ComponentInstance comp, WindowPtr w) 
00773     
00774     = ComponentCallNow (wsCloseWindowCommand, sizeof (WindowPtr)); 
00775     /*windowiscardGlue*/
00776     
00777 #ifndef isFrontier
00778 
00779     glue initsharedmenusGlue (ComponentInstance)
00780         
00781         = ComponentCallNow (msInitSharedMenusCommand, 0L); 
00782         /*initsharedmenusGlue*/
00783         
00784     
00785     glue sharedmenuhitGlue (ComponentInstance, short, short, Boolean *)
00786         
00787         = ComponentCallNow (msSharedMenuHitCommand, sizeof (short) + sizeof (short) + sizeof (Boolean *)); 
00788         /*sharedmenuhitGlue*/
00789         
00790     
00791     glue sharedscriptrunningGlue (ComponentInstance, Boolean *)
00792         
00793         = ComponentCallNow (msSharedScriptRunningCommand, sizeof (Boolean *));
00794         /*sharedscriptrunningGlue*/
00795         
00796     
00797     glue cancelsharedscriptGlue (ComponentInstance)
00798         
00799         = ComponentCallNow (msCancelSharedScriptCommand, 0L); 
00800         /*cancelsharedscriptGlue*/
00801         
00802     
00803     glue checksharedmenusGlue (ComponentInstance, short)
00804         
00805         = ComponentCallNow (msCheckSharedMenusCommand, sizeof (short)); 
00806         /*checksharedmenusGlue*/
00807         
00808     
00809     glue disposesharedmenusGlue (ComponentInstance)
00810         
00811         = ComponentCallNow (msDisposeSharedMenusCommand, 0L); 
00812         /*disposesharedmenusGlue*/
00813         
00814     
00815     glue issharedmenuGlue (ComponentInstance, short, Boolean *)
00816         
00817         = ComponentCallNow (msIsSharedMenuCommand, sizeof (short)); 
00818         /*issharedmenuGlue*/
00819         
00820     
00821     glue enablesharedmenusGlue (ComponentInstance, Boolean)
00822         
00823         = ComponentCallNow (msEnableSharedMenusCommand, sizeof (Boolean)); 
00824         /*enablesharedmenusGlue*/
00825         
00826     
00827     glue runsharedmenuitemGlue (ComponentInstance, short, short)
00828         
00829         = ComponentCallNow (msRunSharedMenuItemCommand, sizeof (short) + sizeof (short)); 
00830         /*runsharedmenuitemGlue*/
00831         
00832     
00833     glue setscripterrorcallbackGlue (ComponentInstance, ProcPtr)
00834         
00835         = ComponentCallNow (msSetScriptErrorCallbackCommand, sizeof (ProcPtr)); 
00836         /*setscripterrorcallbackGlue*/
00837     
00838     
00839     glue stubstartGlue (ComponentInstance comp) 
00840     
00841         = ComponentCallNow (wsStubStartCommand, 0L); 
00842         /*stubstartGlue*/
00843 
00844 #endif
00845 
00846 glue runhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) 
00847     
00848     = ComponentCallNow (wsRunFromHandleCommand, sizeof (Handle) + sizeof (short) + sizeof (char *) + sizeof (Point) + sizeof (uisEventCallback)); 
00849     /*runhandleGlue*/
00850 
00851 
00852 glue runmodalhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) 
00853     
00854     = ComponentCallNow (wsRunModalHandleCommand, sizeof (Handle) + sizeof (short) + sizeof (char *) + sizeof (Point) + sizeof (uisEventCallback)); 
00855     /*runmodalhandleGlue*/
00856 
00857 
00858 glue setobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle value) 
00859     
00860     = ComponentCallNow (wsSetObjectValueCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle)); 
00861     /*setobjectvalueGlue*/
00862     
00863 
00864 glue getobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *value) 
00865     
00866     = ComponentCallNow (wsGetObjectValueCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle *)); 
00867     /*getobjectvalueGlue*/
00868     
00869 
00870 glue getobjecthandleGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *h) 
00871     
00872     = ComponentCallNow (wsGetObjectHandleCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle *)); 
00873     /*getobjecthandleGlue*/
00874     
00875 
00876 glue recalcGlue (ComponentInstance comp, Handle h) 
00877     
00878     = ComponentCallNow (wsRecalcObjectCommand, sizeof (Handle)); 
00879     /*recalcGlue*/
00880 
00881 
00882 glue editGlue (ComponentInstance comp, short editcommand) 
00883     
00884     = ComponentCallNow (wsEditCommand, sizeof (short)); 
00885     /*editGlue*/
00886 
00887 
00888 glue updateGlue (ComponentInstance comp, Handle h) 
00889     
00890     = ComponentCallNow (wsUpdateCommand, sizeof (Handle)); 
00891     /*updateGlue*/
00892 
00893 #else
00894 
00895 glue windoweventGlue (ComponentInstance comp, EventRecord *ev, tyWindowSharingGlobals *wsGlobals) 
00896     
00897     ComponentCallNow (wsEventHandlerCommand, sizeof (EventRecord *) + sizeof (tyWindowSharingGlobals *)); 
00898     /*windoweventGlue*/
00899 
00900 
00901 glue windowiscardGlue (ComponentInstance comp, WindowPtr w) 
00902     
00903     ComponentCallNow (wsWindowIsCardCommand, sizeof (WindowPtr)); 
00904     /*windowiscardGlue*/
00905     
00906     
00907 glue closewindowGlue (ComponentInstance comp, WindowPtr w) 
00908     
00909     ComponentCallNow (wsCloseWindowCommand, sizeof (WindowPtr)); 
00910     /*windowiscardGlue*/
00911     
00912 
00913 #ifndef isFrontier
00914     
00915     glue initsharedmenusGlue (ComponentInstance)
00916         
00917         ComponentCallNow (msInitSharedMenusCommand, 0L); 
00918         /*initsharedmenusGlue*/
00919         
00920     
00921     glue sharedmenuhitGlue (ComponentInstance, short, short, Boolean *)
00922         
00923         ComponentCallNow (msSharedMenuHitCommand, sizeof (short) + sizeof (short) + sizeof (Boolean *)); 
00924         /*sharedmenuhitGlue*/
00925         
00926     
00927     glue sharedscriptrunningGlue (ComponentInstance, Boolean *)
00928         
00929         ComponentCallNow (msSharedScriptRunningCommand, sizeof (Boolean *));
00930         /*sharedscriptrunningGlue*/
00931         
00932     
00933     glue cancelsharedscriptGlue (ComponentInstance)
00934         
00935         ComponentCallNow (msCancelSharedScriptCommand, 0L); 
00936         /*cancelsharedscriptGlue*/
00937         
00938     
00939     glue checksharedmenusGlue (ComponentInstance, short)
00940         
00941         ComponentCallNow (msCheckSharedMenusCommand, sizeof (short)); 
00942         /*checksharedmenusGlue*/
00943         
00944     
00945     glue disposesharedmenusGlue (ComponentInstance)
00946         
00947         ComponentCallNow (msDisposeSharedMenusCommand, 0L); 
00948         /*disposesharedmenusGlue*/
00949         
00950     
00951     glue issharedmenuGlue (ComponentInstance, short, Boolean *)
00952         
00953         ComponentCallNow (msIsSharedMenuCommand, sizeof (short)); 
00954         /*issharedmenuGlue*/
00955         
00956     
00957     glue enablesharedmenusGlue (ComponentInstance, Boolean)
00958         
00959         ComponentCallNow (msEnableSharedMenusCommand, sizeof (Boolean)); 
00960         /*enablesharedmenusGlue*/
00961         
00962     
00963     glue runsharedmenuitemGlue (ComponentInstance, short, short)
00964         
00965         ComponentCallNow (msRunSharedMenuItemCommand, sizeof (short) + sizeof (short)); 
00966         /*runsharedmenuitemGlue*/
00967         
00968     
00969     glue setscripterrorcallbackGlue (ComponentInstance, ProcPtr)
00970         
00971         ComponentCallNow (msSetScriptErrorCallbackCommand, sizeof (ProcPtr)); 
00972         /*setscripterrorcallbackGlue*/
00973     
00974     
00975     glue stubstartGlue (ComponentInstance comp) 
00976     
00977         ComponentCallNow (wsStubStartCommand, 0L); 
00978         /*stubstartGlue*/
00979 
00980 #endif
00981 
00982 
00983 glue runhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) 
00984     
00985     ComponentCallNow (wsRunFromHandleCommand, sizeof (Handle) + sizeof (short) + sizeof (char *) + sizeof (Point) + sizeof (uisEventCallback)); 
00986     /*runhandleGlue*/
00987 
00988 
00989 glue runmodalhandleGlue (ComponentInstance comp, Handle h, short flscriptedcard, Str255 windowname, Point pt, uisEventCallback filter) 
00990     
00991     ComponentCallNow (wsRunModalHandleCommand, sizeof (Handle) + sizeof (short) + sizeof (char *) + sizeof (Point) + sizeof (uisEventCallback)); 
00992     /*runmodalhandleGlue*/
00993 
00994 
00995 glue setobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle value) 
00996     
00997     ComponentCallNow (wsSetObjectValueCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle)); 
00998     /*setobjectvalueGlue*/
00999     
01000 
01001 glue getobjectvalueGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *value) 
01002     
01003     ComponentCallNow (wsGetObjectValueCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle *)); 
01004     /*getobjectvalueGlue*/
01005     
01006 
01007 glue getobjecthandleGlue (ComponentInstance comp, Handle hcard, Str255 name, Handle *h) 
01008     
01009     ComponentCallNow (wsGetObjectHandleCommand, sizeof (Handle) + sizeof (char *) + sizeof (Handle *)); 
01010     /*getobjecthandleGlue*/
01011     
01012 
01013 glue recalcGlue (ComponentInstance comp, Handle h) 
01014     
01015     ComponentCallNow (wsRecalcObjectCommand, sizeof (Handle)); 
01016     /*recalcGlue*/
01017 
01018 
01019 glue editGlue (ComponentInstance comp, short editcommand) 
01020     
01021     ComponentCallNow (wsEditCommand, sizeof (short)); 
01022     /*editGlue*/
01023 
01024 
01025 glue updateGlue (ComponentInstance comp, Handle h) 
01026     
01027     ComponentCallNow (wsUpdateCommand, sizeof (Handle)); 
01028     /*updateGlue*/
01029 
01030 #endif
01031 
01032 #ifndef isFrontier
01033 
01034 Boolean uisDisposeSharedMenus (void) { /*dispose menu array and handles it contains*/
01035     
01036     if (msGlobals.menuserver == 0)
01037         return (false);
01038         
01039     return (disposesharedmenusGlue (msGlobals.menuserver) == noErr);
01040     } /*uisDisposeSharedMenus*/
01041 
01042 
01043 Boolean uisIsSharedMenu (short idmenu) { /*return true if the indicated menu is one of the shared menus*/
01044     
01045     Boolean flshared;
01046     
01047     if (msGlobals.menuserver != 0) {
01048         
01049         if (issharedmenuGlue (msGlobals.menuserver, idmenu, &flshared) == noErr)
01050             return (flshared);
01051         }
01052         
01053     return (false);
01054     } /*uisIsSharedMenu*/
01055 
01056 
01057 void uisEnableSharedMenus (Boolean flenable) { /*enables or disables the shared menus*/
01058     
01059     if (msGlobals.menuserver != 0)
01060         enablesharedmenusGlue (msGlobals.menuserver, flenable);
01061     } /*uisEnableSharedMenus*/
01062 
01063 
01064 Boolean uisRunSharedMenuItem (short idmenu, short iditem) {
01065      
01066     /*
01067     call the menu server to run the script linked to the indicated menu item.
01068     */
01069     
01070     if (msGlobals.menuserver == 0)
01071         return (false);
01072         
01073     return (runsharedmenuitemGlue (msGlobals.menuserver, idmenu, iditem) == noErr);
01074     } /*uisRunSharedMenuItem*/
01075     
01076 
01077 Boolean uisSharedMenuHit (short idmenu, short iditem) {
01078 
01079     Boolean flshareditem;
01080     
01081     if (msGlobals.menuserver == 0) 
01082         return (false);
01083         
01084     if (sharedmenuhitGlue (msGlobals.menuserver, idmenu, iditem, &flshareditem) != noErr)
01085         return (false);
01086         
01087     return (flshareditem); /*client handles if it wasn't a shared item*/
01088     } /*uisSharedMenuHit*/
01089     
01090 #endif
01091 
01092 Boolean uisHandleEvent (EventRecord *ev, Boolean *flcloseallwindows) {
01093     
01094     if (wsGlobals.windowserver != 0) {
01095         
01096         Boolean fl;
01097     
01098         wsGlobals.flcloseallwindows = false;
01099     
01100         fl = windoweventGlue (wsGlobals.windowserver, ev, &wsGlobals);
01101     
01102         *flcloseallwindows = wsGlobals.flcloseallwindows;
01103         
01104         if (fl)
01105             return (true); /*we handled the event*/
01106         }
01107     
01108     #ifndef isFrontier
01109     
01110     if (msGlobals.menuserver != 0) {
01111         
01112         switch ((*ev).what) {
01113             
01114             case nullEvent:
01115                 if (isFrontProcess ())
01116                     checksharedmenusGlue (msGlobals.menuserver, msGlobals.idinsertafter);
01117                 
01118                 break;
01119             } /*switch*/
01120         }
01121     
01122     #endif
01123     
01124     return (false); /*client app should handle the event*/
01125     } /*uisHandleEvent*/
01126     
01127 
01128 Boolean uisIsSharedWindow (WindowPtr w) {
01129     
01130     if (wsGlobals.windowserver == 0)
01131         return (false);
01132         
01133     if (w == nil)
01134         return (false);
01135         
01136     return (windowiscardGlue (wsGlobals.windowserver, w));
01137     } /*uisIsSharedWindow*/
01138     
01139     
01140 Boolean uisCloseSharedWindow (WindowPtr w) {
01141     
01142     if (wsGlobals.windowserver == 0)
01143         return (false);
01144         
01145     if (!uisIsSharedWindow (w))
01146         return (false); /*we didn't close it*/
01147         
01148     return (closewindowGlue (wsGlobals.windowserver, w)); 
01149     } /*uisCloseSharedWindow*/
01150     
01151     
01152 void uisCloseAllSharedWindows (void) {
01153     
01154     WindowPtr w = FrontWindow ();
01155     WindowPtr wnext;
01156     
01157     while (w != nil) {
01158         
01159         #if TARGET_API_MAC_CARBON == 1
01160         wnext = GetNextWindow(w);
01161         #else
01162         
01163         wnext = (WindowPtr) (*(WindowPeek) w).nextWindow;
01164         #endif
01165         
01166         if (uisIsSharedWindow (w))
01167             uisCloseSharedWindow (w);
01168         
01169         w = wnext; 
01170         } /*while*/
01171     } /*uisCloseAllSharedWindows*/
01172     
01173 #ifndef isFrontier
01174 
01175 static Boolean IACgetbinaryparam (AppleEvent *event, OSType keyword, Handle *hbinary, OSType *binarytype, OSErr *errcode) {
01176     
01177     AEDesc result;
01178     OSErr ec;
01179     
01180     *errcode = AEGetParamDesc (event, (AEKeyword) keyword, typeWildCard, &result);
01181     
01182     if (*errcode != noErr) 
01183         return (false);
01184     
01185     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
01186     
01187         copydatahandle (&result, hbinary);
01188         
01189     #else
01190     
01191         *hbinary = result.dataHandle;
01192     
01193     #endif
01194     
01195     *binarytype = result.descriptorType;
01196     
01197     return (true);
01198     } /*IACgetbinaryparam*/
01199 
01200 
01201 static Boolean IACgetstringparam (AppleEvent *event, OSType keyword, Str255 s, OSErr *errcode) {
01202     
01203     AEDesc result;
01204     Handle htext;
01205     long lenstring;
01206     
01207     *errcode = AEGetParamDesc (event, (AEKeyword) keyword, typeChar, &result);
01208     
01209     if (*errcode != noErr) 
01210         return (false);
01211     
01212     #if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
01213     
01214         copydatahandle (&result, &htext);
01215     
01216     #else
01217     
01218         htext = result.dataHandle;
01219     
01220     #endif
01221     
01222     lenstring = GetHandleSize (htext);
01223     
01224     if (lenstring > 255)
01225         lenstring = 255;
01226         
01227     s [0] = (unsigned char) lenstring;
01228     
01229     BlockMove (*htext, &s [1], lenstring);
01230     
01231     return (true);
01232     } /*IACgetstringparam*/
01233     
01234     
01235 static Boolean IACgetlongparam (AppleEvent *event, OSType keyword, long *val, OSErr *errcode) {
01236     
01237     register OSErr ec;
01238     DescType actualtype;
01239     Size actualsize;
01240     
01241     *errcode = AEGetParamPtr (
01242         
01243         event, (AEKeyword) keyword, typeLongInteger, 
01244         
01245         &actualtype, (Ptr) val, sizeof (long), &actualsize);
01246     
01247     if (*errcode != noErr) 
01248         return (false);
01249     
01250     return (true);
01251     } /*IACgetlongparam*/
01252     
01253 
01254 static void IACreturnboolean (AppleEvent *event, Boolean fl) {
01255     
01256     AEPutParamPtr (event, keyDirectObject, typeBoolean, (Ptr) &fl, sizeof (Boolean));
01257     } /*IACreturnboolean*/
01258 
01259 
01260 static pascal OSErr handleopencardwindow (AppleEvent *event, AppleEvent *reply, long refcon) {
01261 
01262     /*  
01263     installed as an AE handler, intended to be called by scripts that
01264     want to open a shared window in the application's window list.
01265     
01266     it's a tradeoff -- burn a little memory in every UI sharing-aware
01267     app, or make the SHUI server component perform an unnatural act. the
01268     problem is the component call needs a component instance. only the 
01269     host app knows which instance we're talking about. the server could
01270     manage its data according to ProcessSerialNumber, but this is not a
01271     natural way of doing things for Mac components. not impossible, just
01272     a bunch of extra code in a very hard place to debug. 3/21/93 DW
01273     
01274     here's a one-line script that calls this handler...
01275     
01276     appleEvent ('KAHL', 'SHUI', 'OPEN', '----', number ('zzzz'), 'card', scratchpad.cards.xxx, 'wtit', "Hello!")
01277     */
01278     
01279     OSErr ec;
01280     OSType idcomponent; 
01281     OSType binarytype;
01282     Handle packedcard;
01283     Str255 windowtitle;
01284     
01285     if (!IACgetlongparam (event, keyDirectObject, (long *) &idcomponent, &ec))
01286         return (ec);
01287 
01288     if (!IACgetbinaryparam (event, 'card', &packedcard, &binarytype, &ec))
01289         return (ec);
01290         
01291     if (!IACgetstringparam (event, 'wtit', windowtitle, &ec))
01292         return (ec);
01293         
01294     IACreturnboolean (event, uisOpenHandle (packedcard, false, windowtitle, 0, 0, nil));
01295     
01296     return (noErr);
01297     } /*handleopencardwindow*/
01298     
01299     
01300 Boolean uisStubStart (void) {
01301     
01302     if (wsGlobals.windowserver == 0)
01303         return (false);
01304         
01305     wsGlobals.errorcode = stubstartGlue (wsGlobals.windowserver);
01306     
01307     return (wsGlobals.errorcode == noErr);
01308     } /*uisStubStart*/
01309 
01310 #endif
01311 
01312 Boolean uisOpenHandle (Handle h, Boolean flscriptedcard, Str255 windowname, short top, short pleft, uisEventCallback filter) {
01313     
01314     Point pt;
01315     
01316     pt.h = pleft; pt.v = top;
01317     
01318     if (wsGlobals.windowserver == 0)
01319         return (false);
01320         
01321     wsGlobals.errorcode = runhandleGlue (wsGlobals.windowserver, h, flscriptedcard, windowname, pt, filter);
01322     
01323     return (wsGlobals.errorcode == noErr);
01324     } /*uisOpenHandle*/
01325     
01326     
01327 Boolean uisOpenCardResource (short id, Boolean flscriptedcard, Str255 windowname, short top, short pleft, uisEventCallback filter) {
01328     
01329     Handle h;
01330     
01331     h = GetResource ('CARD', id);
01332     
01333     if (h == nil) {
01334         
01335         wsGlobals.errorcode = ResError ();
01336         
01337         return (false);
01338         }
01339         
01340     DetachResource (h);
01341     
01342     return (uisOpenHandle (h, flscriptedcard, windowname, top, pleft, filter));
01343     } /*uisOpenCardResource*/
01344     
01345     
01346 Boolean uisRunModalHandle (Handle h, Boolean flscriptedcard, Str255 windowname, short top, short pleft, uisEventCallback filter) {
01347     
01348     Point pt;
01349     
01350     pt.h = pleft; pt.v = top;
01351     
01352     if (wsGlobals.windowserver == 0)
01353         return (false);
01354         
01355     wsGlobals.errorcode = runmodalhandleGlue (wsGlobals.windowserver, h, flscriptedcard, windowname, pt, filter);
01356     
01357     return (wsGlobals.errorcode == noErr);
01358     } /*uisRunModalHandle*/
01359     
01360     
01361 Boolean uisRunModalResource (short id, Boolean flscriptedcard, Str255 windowname, short top, short pleft, uisEventCallback filter) {
01362     
01363     Handle h;
01364     
01365     h = GetResource ('CARD', id);
01366     
01367     if (h == nil) {
01368         
01369         wsGlobals.errorcode = ResError ();
01370         
01371         return (false);
01372         }
01373         
01374     DetachResource (h);
01375     
01376     return (uisRunModalHandle (h, flscriptedcard, windowname, top, pleft, filter));
01377     } /*uisRunModalResource*/
01378     
01379 #ifndef isFrontier
01380 
01381 Boolean uisSetObjectValue (Handle hcard, Str255 name, Handle hvalue) {
01382     
01383     if (wsGlobals.windowserver == 0)
01384         return (false);
01385         
01386     return (setobjectvalueGlue (wsGlobals.windowserver, hcard, name, hvalue));
01387     } /*uisSetObjectValue*/
01388     
01389     
01390 Boolean uisGetObjectValue (Handle hcard, Str255 name, Handle *hvalue) {
01391     
01392     if (wsGlobals.windowserver == 0)
01393         return (false);
01394         
01395     return (getobjectvalueGlue (wsGlobals.windowserver, hcard, name, hvalue));
01396     } /*uisGetObjectValue*/
01397     
01398     
01399 Boolean uisUpdate (Handle hcard) {
01400     
01401     if (wsGlobals.windowserver == 0)
01402         return (false);
01403         
01404     return (updateGlue (wsGlobals.windowserver, hcard));
01405     } /*uisUpdate*/
01406     
01407     
01408 Boolean uisGetObjectHandle (Handle hcard, Str255 name, Handle *hvalue) {
01409     
01410     if (wsGlobals.windowserver == 0)
01411         return (false);
01412         
01413     return (getobjecthandleGlue (wsGlobals.windowserver, hcard, name, (Handle *) hvalue));
01414     } /*uisGetObjectHandle*/
01415     
01416 
01417 Boolean uisRecalcObject (Handle hobject) {
01418     
01419     if (wsGlobals.windowserver == 0)
01420         return (false);
01421         
01422     return (recalcGlue (wsGlobals.windowserver, hobject));
01423     } /*uisRecalcObject*/
01424     
01425 #endif
01426 
01427 Boolean uisEdit (short editcommand) {
01428         
01429     if (wsGlobals.windowserver == 0)
01430         return (false);
01431         
01432     return (editGlue (wsGlobals.windowserver, editcommand));
01433     } /*uisEdit*/
01434     
01435 
01436 Boolean uisInit (ProcPtr pcallback, short idinsertafter, OSType idclientapp, unsigned short bitarray) {
01437     
01438     /*
01439     initialize window sharing and menu sharing. 
01440     
01441     the pcallback is a routine that receives a Str255 as a parameter. it should
01442     display the string in a modal dialog box and wait for the user to click 
01443     on OK. it's used for reporting script compiling or runtime errors. pass in
01444     nil if you want errors to not be reported to the user (not a great thing
01445     to do to your users!).
01446     
01447     idinsertafter tells menu sharing where to begin allocating new menu ids.
01448     it's the same parameter that was passed to CheckSharedMenus in previous
01449     incarnations of menu sharing.
01450     
01451     idclientapp is the 4-character identifier of the client app. if it's
01452     'wxyz', then we'll get the shared menus at system.menubars.wxyz. If you
01453     pass in 0, the menu sharing server uses the Process Manager to get your
01454     id, as the creator id of the running application. This feature is supported
01455     in the UI sharing API only, as of June 12, 1993. A modification needs to
01456     be made to Frontier to support this fully.
01457     
01458     DW 8/18/93: added a 16-bit bit-array that allows the caller to modify
01459     the behavior of UI Sharing. if it's set to 0 (the usual case) you get 
01460     all the features.
01461     */
01462     
01463     Boolean flmenusharing = true, flwindowsharing = true;
01464     
01465     if (bitarray & noMenuSharing)
01466         flmenusharing = false;
01467         
01468     if (bitarray & noWindowSharing)
01469         flwindowsharing = false;
01470     
01471     wsGlobals.windowserver = 0;
01472     
01473     msGlobals.menuserver = 0;
01474     
01475     if ((!flmenusharing) && (!flwindowsharing))
01476         return (true);
01477     
01478     if (!HaveComponentManager ())
01479         return (false);
01480     
01481     if (flwindowsharing) {
01482     
01483         #ifndef isFrontier
01484         
01485         AEInstallEventHandler ('SHUI', 'OPEN', (EventHandlerProcPtr) &handleopencardwindow, 0, false);
01486         
01487         #endif
01488         
01489         
01490         wsGlobals.windowserver = OpenDefaultComponent (wsComponentType, wsComponentSubType);
01491         }
01492     
01493     #ifndef isFrontier
01494     
01495     if (flmenusharing) {
01496     
01497         msGlobals.menuserver = OpenDefaultComponent (msComponentType, msComponentSubType);
01498     
01499         msGlobals.idinsertafter = idinsertafter;
01500     
01501         if (msGlobals.menuserver != 0) {
01502     
01503             if (initsharedmenusGlue (msGlobals.menuserver) != noErr)
01504                 goto error;
01505         
01506             if (setscripterrorcallbackGlue (msGlobals.menuserver, pcallback) != noErr)
01507                 goto error;
01508             }
01509         }
01510     
01511     #endif
01512         
01513     return (true);
01514     
01515 #ifndef isFrontier
01516 error:
01517     
01518     uisClose ();
01519     
01520     return (false);
01521 #endif
01522     } /*uisInit*/
01523     
01524     
01525 void uisClose (void) {
01526 
01527     if (wsGlobals.windowserver != 0)        
01528         CloseComponent (wsGlobals.windowserver);
01529     
01530     #ifndef isFrontier
01531     
01532     if (msGlobals.menuserver != 0) 
01533         CloseComponent (msGlobals.menuserver);
01534     
01535     #endif
01536     } /*uisClose*/
01537     
01538     
01539     
01540     

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