megastubs2.c

Go to the documentation of this file.
00001 
00002 /*  $Id: megastubs2.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 #ifdef MACVERSION
00032     #include <IAC.h>
00033     #include <uisharing.h>
00034     #include "filealias.h"
00035 #endif
00036 
00037 #include "bitmaps.h"
00038 #include "dialogs.h"
00039 #include "memory.h"
00040 #include "error.h"
00041 #include "file.h"
00042 #include "launch.h"
00043 #include "fileloop.h"
00044 #include "strings.h"
00045 #include "frontierwindows.h"
00046 #include "zoom.h"
00047 #include "lang.h"
00048 #include "langinternal.h"
00049 #include "langipc.h"
00050 #include "langexternal.h"
00051 #include "langsystem7.h"
00052 #include "scripts.h"
00053 #include "shell.h"
00054 #include "shellbuttons.h"
00055 #include "shellhooks.h"
00056 #include "shellprint.h"
00057 
00058 #ifdef MACVERSION
00059 #include "osacomponent.h"
00060 #endif
00061 
00062 #include "process.h"
00063 
00064 
00065 
00066 // tyshellglobals shellglobals;
00067 
00068 
00069 // bitmaps.c
00070 
00071 extern HWND currentport;
00072 extern HDC currentportDC;
00073 
00074 static HDC offscreenDC = NULL;
00075 static HBITMAP oldbitmap;
00076 static Rect offscreenrect;
00077 static HWND saveDC;
00078 
00079 
00080 void initbitmaps (boolean fl) {
00081     } /*initbitmaps*/
00082 
00083 
00084 boolean openbitmap (Rect r, WindowPtr w) {
00085     
00086     /*
00087     5.0fc2 rab: plugged memory leak calling GetDC
00088     */
00089 
00090     HDC hdc = NULL; // = GetDC (w);
00091     HBITMAP bitmap;
00092     
00093     assert (w == currentport);
00094 
00095     offscreenDC = NULL; //*** disable: CreateCompatibleDC (hdc);
00096     
00097     if (offscreenDC == NULL)
00098         return (false);
00099 
00100     bitmap = CreateCompatibleBitmap (hdc, r.right - r.left, r.bottom - r.top);
00101     
00102     if (bitmap == NULL) {
00103         
00104         DeleteDC (offscreenDC);
00105         
00106         offscreenDC = NULL;
00107 
00108         return (false);
00109         }
00110     
00111     oldbitmap = SelectObject (offscreenDC, bitmap);
00112     
00113     SetViewportOrgEx (offscreenDC, r.left, r.top, NULL);
00114     
00115     offscreenrect = r;
00116     
00117     saveDC = (HWND) currentportDC;
00118 
00119     currentportDC = offscreenDC;
00120 
00121     return (true);
00122     } /*openbitmap*/
00123 
00124 
00125 //boolean openbitmapcopy (Rect r, WindowPtr w) {return false;}
00126 
00127 void closebitmap (WindowPtr w) {
00128     
00129     HBITMAP bitmap;
00130     Rect *r = &offscreenrect;
00131 
00132     if (offscreenDC != NULL) {
00133 
00134         currentport = w;
00135         
00136         currentportDC = (HDC) saveDC;
00137         
00138         BitBlt ((HDC) saveDC, r->left, r->top, r->right - r->left, r->bottom - r->top, offscreenDC, 0,0, SRCAND);
00139         
00140         bitmap = SelectObject (offscreenDC, oldbitmap);
00141         
00142         DeleteObject (bitmap);
00143 
00144         DeleteDC (offscreenDC);
00145 
00146         offscreenDC = NULL;
00147         }
00148     } /*closebitmap*/
00149 
00150 
00151 // launch.c
00152 
00153 boolean activateapplicationwindow (typrocessid id, WindowPtr w) {return (false);}
00154 
00155 
00156 // zoom.c
00157 
00158 void zoominit (void) {}
00159 
00160 void zoomtoorigin (WindowPtr w) {hidewindow (w);}
00161 
00162 void zoomfromorigin (WindowPtr w) {
00163     
00164     /*
00165     5.0.1 dmb: call SetFocus. Fixes the "Deaf QuickScript" bug.
00166     */
00167 
00168     releasethreadglobals ();
00169 
00170     SetWindowPos (w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
00171     ShowWindow (w, SW_SHOWNORMAL);
00172     SetFocus (w);
00173 
00174     grabthreadglobals ();
00175     
00176     /*
00177     config = origconfig;
00178     shellglobals = origglobals;
00179     setport (saveport);
00180     */
00181 
00182     shellactivatewindow (w, true);
00183     } /*zoomfromorigin*/
00184 
00185 void zoomwindowfromcenter (Rect r, WindowPtr w) {
00186     
00187     zoomfromorigin (w);
00188     } /*zoomwindowfromcenter*/
00189 
00190 void zoomwindowtocenter (Rect r, WindowPtr w) {
00191     
00192     hidewindow (w);
00193     } /*zoomwindowtocenter*/
00194 
00195 void zoomsetdefaultrect (WindowPtr w, Rect r) {}
00196 
00197 
00198 #ifndef isFrontier
00199 
00200 // script.c
00201 
00202 boolean scriptrunsuspendscripts (void) {return true;}
00203 
00204 boolean scriptrunresumescripts (void) {return true;}
00205 
00206 
00207 // process.c
00208 
00209 unsigned short fldisableyield = 0;
00210 
00211 hdlprocessrecord currentprocess = nil;
00212 
00213 boolean initprocess (void) {return true;}
00214 
00215 unsigned long processstackspace (void) {
00216     
00217 #if MACVERSION
00218     return (StackSpace ());
00219 #endif
00220 
00221 #if WIN95VERSION
00222     return (0x7fff); // 3/10/97 dmb: no equivalent measure (stackavail) under Windows
00223 #endif
00224     } /*processstackspace*/
00225 
00226 #if winhybrid
00227 
00228 boolean debuggingcurrentprocess (void) {return false;}
00229 
00230 boolean processruntext (Handle htext) {bigstring bs; return langrunhandle (htext, bs);}
00231 
00232 boolean processisoneshot (boolean fl) {return true;}
00233 
00234 #endif
00235 
00236 boolean processagentsleep (long ctseconds) {return true;}
00237 
00238 boolean pushprocess (hdlprocessrecord hp) {return true;}
00239 
00240 boolean popprocess (void) {return true;}
00241 
00242 boolean processbusy (void) {return true;}
00243 
00244 boolean processyield (void) {return true;}
00245 
00246 boolean processdisposecode (hdltreenode hcode) {return false;}
00247 
00248 void processchecktimeouts (void) {}
00249 
00250 void processclose (void) {}
00251 
00252 void processinvalidglobals (WindowPtr w) {}
00253 
00254 boolean processrunning (void) {return true;}
00255 
00256 
00257 // land.c
00258 
00259 //pascal boolean landeventfilter (EventRecord *ev) {return false;}
00260 
00261 
00262 // lang.c
00263 
00264 boolean flscriptrunning = false;
00265 
00266 boolean langzoomobject (const bigstring bs) {return (false);}
00267 
00268 boolean initlang (void) {return true;}
00269 
00270 
00271 
00272 // langcallbacks.c
00273 
00274 boolean langbackgroundtask (boolean fl) {return true;}
00275 
00276 boolean langpartialeventloop (short mask) {
00277 
00278     return shellpartialeventloop (mask);
00279     } /*langpartialeventloop*/
00280 
00281 // langexternal.c
00282 
00283 boolean langexternalzoomfrom (tyvaluerecord val, hdlhashtable ht, bigstring bs, Rect r) {return false;}
00284 
00285 boolean langexternalwindowopen (tyvaluerecord val, hdlwindowinfo *hw) {return false;}
00286 
00287 boolean tablezoomtoname (hdlhashtable ht, bigstring bs) {return false;}
00288 
00289 boolean initscripts (void) {return true;}
00290 
00291 
00292 #endif // isFrontier
00293 
00294 // osacomponent.c
00295 
00296 void osacomponentshutdown (void) {};
00297 
00298 
00299 // langdialog.c
00300 
00301 boolean langdialogrunning (void) {return false;}
00302 
00303 
00304 // langmodeless.c
00305 
00306 boolean langrunmodeless (hdltreenode hparam1, tyvaluerecord *vreturned) {return false;}
00307 
00308 
00309 // langipc.c
00310 
00311 typrocessid langipcself;
00312 static boolean fltoolkitinitialized = false;
00313 
00314 #ifdef MACVERSION
00315 
00316 static pascal Boolean openfilespec (ptrfilespec pfs) {
00317     
00318     if (!shellopenfile (pfs)) {
00319         
00320         IACreturnerror (getoserror (), nil);
00321         
00322         return (false);
00323         }
00324         
00325     return (true);
00326     } /*openfilespec*/
00327     
00328 
00329 static pascal OSErr handleopen (AppleEvent *event, AppleEvent *reply, long refcon) {
00330     
00331     IACglobals.event = event;
00332     
00333     IACglobals.reply = reply;
00334     
00335     IACglobals.refcon = refcon;
00336     
00337     return (IACdrivefilelist (&openfilespec));
00338     } /*handleopen*/
00339 
00340         
00341 static pascal OSErr handlequit (AppleEvent *event, AppleEvent *reply, long refcon) {
00342     
00343     if (!shellcloseall (nil, true)) /*user hit Cancel button in save dialog*/
00344         return (userCanceledErr);
00345     
00346     shellexitmaineventloop (); /*sets flag for next iteration*/
00347     
00348     return (noErr);
00349     } /*handlequit*/
00350     
00351     
00352 static pascal OSErr handleopenapp (const AppleEvent *event, AppleEvent *reply, long refcon) {
00353     
00354     if (!shellopendefaultfile ())
00355         return (getoserror ());
00356     
00357     return (noErr);
00358     } /*handleopenapp*/
00359 
00360 
00361 boolean landeventfilter (EventRecord *ev) {
00362     
00363     /*
00364     watch for high level events (AppleEvents)
00365     
00366     return true if we consume the event, false otherwise.
00367     */
00368     
00369     if ((*ev).what == kHighLevelEvent) {
00370     
00371         AEProcessAppleEvent (ev);
00372         
00373         return (true); /*consume the event*/        
00374         }
00375     
00376     return (false); /*don't consume the event*/
00377     } /*landeventfilter*/
00378 
00379 #endif
00380 
00381 boolean langipcinit (void) {
00382     
00383     return (true);
00384     } /*langipcinit*/
00385 
00386 
00387 boolean langipcstart (void) {
00388     
00389     /*
00390     register with the IAC toolkit, using the identifier defined in land.h, 
00391     and registering the verbs that scriptrunners must implement.
00392     */
00393     
00394 #ifdef MACVERSION
00395     
00396     GetCurrentProcess (&langipcself);
00397     
00398     if (!IACinstallhandler (kCoreEventClass, kAEOpenApplication, (ProcPtr) &handleopenapp))
00399         goto error;
00400     
00401     if (!IACinstallhandler (kCoreEventClass, kAEOpenDocuments, (ProcPtr) &handleopen))
00402         goto error;
00403     
00404     if (!IACinstallhandler (kCoreEventClass, kAEQuitApplication, (ProcPtr) &handlequit))
00405         goto error;
00406 
00407     error:
00408     
00409 #endif
00410 
00411     return (true);
00412     } /*langipcstart*/
00413 
00414 void langipcshutdown () {}
00415 
00416 // misc
00417 
00418 //void initsegment (void) {}
00419 
00420 
00421 #ifdef MACVERSION
00422 
00423 // uiSharing
00424 
00425 Boolean isModelessCardEvent (EventRecord *ev);
00426 Boolean isModelessCardEvent (EventRecord *ev) {return false;}
00427 
00428 Boolean uisIsSharedWindow (WindowPtr w) {return false;}
00429 
00430 Boolean uisCloseSharedWindow (WindowPtr w) {return false;}
00431 
00432 void uisCloseAllSharedWindows (void) {}
00433 
00434 Boolean uisEdit (short item) {return false;}
00435     
00436 
00437 // launch.c
00438 
00439 typrocessid getcurrentprocessid (void) {
00440     
00441     ProcessSerialNumber psn;
00442     
00443     GetCurrentProcess (&psn);
00444     
00445     return (psn);
00446     } /*getcurrentprocessid*/
00447 
00448 
00449 boolean getapplicationfilespec (bigstring bsprogram, tyfilespec *fs) {
00450     
00451     ProcessInfoRec processinfo;
00452     ProcessSerialNumber psn;
00453     
00454     assert (bsprogram == nil);
00455     
00456     processinfo.processInfoLength = sizeof (processinfo);
00457     processinfo.processName = nil; /*place to store process name*/
00458     processinfo.processAppSpec = fs; /*place to store process filespec*/
00459     
00460     psn.highLongOfPSN = 0;
00461     psn.lowLongOfPSN = kCurrentProcess;
00462     
00463     if (GetProcessInformation (&psn, &processinfo) != noErr)
00464         return (false);
00465     
00466     return (true);
00467     } /*getapplicationfilespec*/
00468 
00469 
00470 // about.c
00471 
00472 void aboutsegment (void) {}
00473 
00474 boolean openabout (boolean fl, long n) {return false;}
00475 
00476 
00477 #endif
00478 
00479 #ifdef WIN95VERSION
00480 
00481 short dialogcountitems (DialogPtr pdialog) {return 0;}
00482 
00483 void disabledialogitem (DialogPtr pdialog, short itemnumber) {}
00484     
00485 void enabledialogitem (DialogPtr pdialog, short itemnumber) {}
00486 
00487 void hidedialogitem (DialogPtr pdialog, short itemnumber) {}
00488 
00489 void showdialogitem (DialogPtr pdialog, short itemnumber) {}
00490 
00491 boolean customdialog (short id, short defaultitem, dialogcallback itemhitcallback) {return false;}
00492 
00493 long FreeMem (void) {
00494     MEMORYSTATUS ms;
00495 
00496     ms.dwLength = sizeof (MEMORYSTATUS);
00497     GlobalMemoryStatus (&ms);
00498 
00499     return (ms.dwAvailPageFile);
00500     }
00501 
00502 void DrawPicture (Handle hpicture, const Rect *frame) {}
00503 
00504 void UpdateDialog (WindowPtr w) {}
00505 
00506 
00507 #endif

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