appletglue.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletglue.c 482 2005-12-20 22:12:08Z 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 "quickdraw.h"
00032 #include "memory.h"
00033 #include "file.h"
00034 #include "launch.h"
00035 
00036 extern boolean equalidentifiers (bigstring bs1, bigstring bs2);
00037 boolean pushmacport (CGrafPtr p);
00038 boolean returnkeydown (void);
00039 boolean popmacport (void);
00040 void centerwindow (WindowPtr w, Rect rscreen);
00041 boolean rectlessthan (Rect r1, Rect r2);
00042 boolean unicaseequalstrings (void *pvoid1, void *pvoid2);
00043 
00044 // kw - 2005-12-15 - compiler warning rename
00045 boolean oldclutconverter (short idx, RGBColor *rgb);
00046 boolean emptyrect (Rect r);
00047 boolean pushhandleonhandle (Handle hsource, Handle hdest);
00048 void deleteinhandle (Handle h, unsigned long ix, unsigned long ctdelete);
00049 boolean pushathandlestart (ptrvoid, long, Handle);
00050 boolean assureappisrunning (OSType serverid, boolean flbringtofront);
00051 boolean findrunningapp (OSType id, void *info);
00052 void appletsegment (void);
00053 boolean ploticonsuite (Rect *r, short align, short transform, Handle iconsuite);
00054 
00055 
00056 unsigned short ttLabel [8] = {0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700};
00057 
00058 
00059 boolean ploticonsuite (Rect *r, short align, short transform, Handle iconsuite) {
00060 
00061     return (PlotIconSuite (r, align, transform, iconsuite) == noErr);
00062     } /*ploticonsuite*/
00063 
00064 
00065 boolean pushmacport (CGrafPtr p) {
00066     
00067     return pushport (p);
00068     } /*pushmacport*/
00069         
00070 
00071 boolean popmacport (void) {
00072     return popport ();
00073     } /*popmacport*/
00074 
00075 static boolean keydown (short keycode) {
00076 #ifdef MACVERSION
00077     KeyMap keys;
00078     
00079     GetKeys (keys);
00080     
00081     return (BitTst (&keys, keycode) != 0);
00082 #endif
00083 #ifdef WIN95VERSION
00084     return ((GetKeyState (keycode) & 0x8000) == 0x8000);
00085 #endif
00086     } /*keydown*/
00087     
00088 boolean returnkeydown (void) {
00089     
00090     return (keydown (35)); 
00091     } /*returnkeydown*/
00092     
00093 void centerwindow (WindowPtr w, Rect rscreen) {
00094 
00095     short h, v;
00096     Rect r;
00097     short minv;
00098     //Code change by Timothy Paustian Tuesday, May 16, 2000 9:21:16 PM
00099     //Changed to Opaque call for Carbon
00100     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00101     {
00102     CGrafPtr    thePort = GetWindowPort(w);
00103     GetPortBounds(thePort, &r);
00104     }
00105     #else
00106     r = (*w).portRect;
00107     #endif
00108     h = rscreen.left + (((rscreen.right - rscreen.left) - (r.right - r.left)) / 2);
00109     
00110     v = rscreen.top + (((rscreen.bottom - rscreen.top) - (r.bottom - r.top)) / 6);
00111     
00112     minv = getmenubarheight () + doctitlebarheight + 10;
00113     
00114     if (v < minv)
00115         v = minv;
00116     
00117     MoveWindow (w, h, v, false);
00118     } /*centerwindow*/
00119 
00120 
00121 boolean rectlessthan (Rect r1, Rect r2) {
00122     
00123     /*
00124     return true if r1 is "less than" r2.
00125     
00126     we look only at the top-left corners of the rectangles. a rectangle is
00127     less than the other rectangle if it's above the other guy vertically.
00128     
00129     if they're both at the same vertical position, then the guy to the left
00130     of the other is less than.
00131     
00132     this helps us implement a rational sort of tabbing thru objects, we go
00133     from top to bottom and left to right.
00134     */
00135     
00136     if (r1.top != r2.top) { /*comparison is based on tops*/
00137         
00138         return (r1.top < r2.top);
00139         }
00140     
00141     return (r1.left < r2.left);
00142     } /*rectlessthan*/
00143 
00144 
00145 boolean unicaseequalstrings (void *pvoid1, void *pvoid2) {
00146     
00147     return (equalidentifiers (pvoid1, pvoid2));
00148     } /*unicaseequalstrings*/
00149     
00150 
00151 static boolean getclut (short resid, CTabHandle *hdlctab) {
00152     
00153     Handle hdata;
00154     
00155     *hdlctab = nil;
00156     
00157     hdata = GetResource ('clut', resid);
00158     
00159     if (hdata == nil)
00160         return (false);
00161     
00162     *hdlctab = (CTabHandle) hdata;
00163     
00164     return (true);
00165     } /*getclut*/
00166 
00167 boolean oldclutconverter (short idx, RGBColor *rgb) {
00168 
00169     CTabHandle hdlctab;
00170 
00171     getclut (128, &hdlctab);
00172     
00173     *rgb = (**hdlctab).ctTable [idx].rgb;
00174 
00175     return (true);
00176     } /*oldclutconverter*/
00177     
00178     
00179 boolean emptyrect (Rect r) {
00180     
00181     /*
00182     return false if there are any pixels contained inside the rectangle.
00183     */
00184     
00185     return ((r.top >= r.bottom) || (r.left >= r.right));
00186     } /*emptyrect*/
00187     
00188     
00189 boolean assureappisrunning (OSType serverid, boolean flbringtofront) {
00190     
00191     /*
00192     if the application whose creator id is serverid is running, return true.
00193     
00194     if not, we look for the application and try to launch it. we wait until it's 
00195     actually running and ready to receive Apple Events.
00196     */
00197     
00198     bigstring appname;
00199     typrocessid psn;
00200     FSSpec fs;
00201     
00202     if (findrunningapplication (&serverid, appname, &psn)) /*already running, nothing to do*/
00203         return (true);
00204         
00205     if (!findapplication (serverid, &fs))
00206         return (false);
00207         
00208     if (!launchapplication (&fs, nil, flbringtofront))
00209         return (false);
00210         
00211     return (true);
00212     } /*assureappisrunning*/
00213     
00214     
00215 boolean pushhandleonhandle (Handle hsource, Handle hdest) {
00216     
00217     return (pushhandle (hsource, hdest));
00218     } /*pushhandleonhandle*/
00219 
00220 
00221 void deleteinhandle (Handle h, unsigned long ix, unsigned long ctdelete) {
00222     
00223     pullfromhandle (h, ix, ctdelete, nil);
00224     } /*deleteinhandle*/
00225 
00226 
00227 boolean pushathandlestart (ptrvoid pdata, long ctbytes, Handle h) {
00228 
00229     return (insertinhandle (h, 0, pdata, ctbytes));
00230     } /*pushathandlestart*/
00231     
00232     
00233 boolean findrunningapp (OSType id, void *info) {
00234 #pragma unused(info)
00235     return (findrunningapplication (&id, nil, nil));
00236     } /*findrunningapp*/
00237 
00238 
00239 void appletsegment (void) {
00240     } /*appletsegment*/
00241 
00242 

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