~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Frontier Kernel
Frontier/Common/source/appletglue.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: appletglue.c,v 1.3 2005/01/11 22:48:04 andreradke Exp $ */ 3 4 /****************************************************************************** 5 6 UserLand Frontier(tm) -- High performance Web content management, 7 object database, system-level and Internet scripting environment, 8 including source code editing and debugging. 9 10 Copyright (C) 1992-2004 UserLand Software, Inc. 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 26 ******************************************************************************/ 27 28 #include "frontier.h" 29 #include "standard.h" 30 31 #include "quickdraw.h" 32 #include "memory.h" 33 #include "file.h" 34 #include "launch.h" 35 36 extern boolean equalidentifiers (bigstring bs1, bigstring bs2); 37 boolean pushmacport (CGrafPtr p); 38 boolean returnkeydown (void); 39 boolean popmacport (void); 40 void centerwindow (WindowPtr w, Rect rscreen); 41 boolean rectlessthan (Rect r1, Rect r2); 42 boolean unicaseequalstrings (void *pvoid1, void *pvoid2); 43 boolean oldclutconverter (short index, RGBColor *rgb); 44 boolean emptyrect (Rect r); 45 boolean pushhandleonhandle (Handle hsource, Handle hdest); 46 void deleteinhandle (Handle h, unsigned long ix, unsigned long ctdelete); 47 boolean pushathandlestart (ptrvoid, long, Handle); 48 boolean assureappisrunning (OSType serverid, boolean flbringtofront); 49 boolean findrunningapp (OSType id, void *info); 50 void appletsegment (void); 51 boolean ploticonsuite (Rect *r, short align, short transform, Handle iconsuite); 52 53 54 unsigned short ttLabel [8] = {0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700}; 55 56 57 boolean ploticonsuite (Rect *r, short align, short transform, Handle iconsuite) { 58 59 return (PlotIconSuite (r, align, transform, iconsuite) == noErr); 60 } /*ploticonsuite*/ 61 62 63 boolean pushmacport (CGrafPtr p) { 64 65 return pushport (p); 66 } /*pushmacport*/ 67 68 69 boolean popmacport (void) { 70 return popport (); 71 } /*popmacport*/ 72 73 static boolean keydown (short keycode) { 74 #ifdef MACVERSION 75 KeyMap keys; 76 77 GetKeys (keys); 78 79 return (BitTst (&keys, keycode) != 0); 80 #endif 81 #ifdef WIN95VERSION 82 return ((GetKeyState (keycode) & 0x8000) == 0x8000); 83 #endif 84 } /*keydown*/ 85 86 boolean returnkeydown (void) { 87 88 return (keydown (35)); 89 } /*returnkeydown*/ 90 91 void centerwindow (WindowPtr w, Rect rscreen) { 92 93 short h, v; 94 Rect r; 95 short minv; 96 //Code change by Timothy Paustian Tuesday, May 16, 2000 9:21:16 PM 97 //Changed to Opaque call for Carbon 98 #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1 99 { 100 CGrafPtr thePort = GetWindowPort(w); 101 GetPortBounds(thePort, &r); 102 } 103 #else 104 r = (*w).portRect; 105 #endif 106 h = rscreen.left + (((rscreen.right - rscreen.left) - (r.right - r.left)) / 2); 107 108 v = rscreen.top + (((rscreen.bottom - rscreen.top) - (r.bottom - r.top)) / 6); 109 110 minv = getmenubarheight () + doctitlebarheight + 10; 111 112 if (v < minv) 113 v = minv; 114 115 MoveWindow (w, h, v, false); 116 } /*centerwindow*/ 117 118 119 boolean rectlessthan (Rect r1, Rect r2) { 120 121 /* 122 return true if r1 is "less than" r2. 123 124 we look only at the top-left corners of the rectangles. a rectangle is 125 less than the other rectangle if it's above the other guy vertically. 126 127 if they're both at the same vertical position, then the guy to the left 128 of the other is less than. 129 130 this helps us implement a rational sort of tabbing thru objects, we go 131 from top to bottom and left to right. 132 */ 133 134 if (r1.top != r2.top) { /*comparison is based on tops*/ 135 136 return (r1.top < r2.top); 137 } 138 139 return (r1.left < r2.left); 140 } /*rectlessthan*/ 141 142 143 boolean unicaseequalstrings (void *pvoid1, void *pvoid2) { 144 145 return (equalidentifiers (pvoid1, pvoid2)); 146 } /*unicaseequalstrings*/ 147 148 149 static boolean getclut (short resid, CTabHandle *hdlctab) { 150 151 Handle hdata; 152 153 *hdlctab = nil; 154 155 hdata = GetResource ('clut', resid); 156 157 if (hdata == nil) 158 return (false); 159 160 *hdlctab = (CTabHandle) hdata; 161 162 return (true); 163 } /*getclut*/ 164 165 boolean oldclutconverter (short index, RGBColor *rgb) { 166 167 CTabHandle hdlctab; 168 169 getclut (128, &hdlctab); 170 171 *rgb = (**hdlctab).ctTable [index].rgb; 172 173 return (true); 174 } /*oldclutconverter*/ 175 176 177 boolean emptyrect (Rect r) { 178 179 /* 180 return false if there are any pixels contained inside the rectangle. 181 */ 182 183 return ((r.top >= r.bottom) || (r.left >= r.right)); 184 } /*emptyrect*/ 185 186 187 boolean assureappisrunning (OSType serverid, boolean flbringtofront) { 188 189 /* 190 if the application whose creator id is serverid is running, return true. 191 192 if not, we look for the application and try to launch it. we wait until it's 193 actually running and ready to receive Apple Events. 194 */ 195 196 bigstring appname; 197 typrocessid psn; 198 FSSpec fs; 199 200 if (findrunningapplication (&serverid, appname, &psn)) /*already running, nothing to do*/ 201 return (true); 202 203 if (!findapplication (serverid, &fs)) 204 return (false); 205 206 if (!launchapplication (&fs, nil, flbringtofront)) 207 return (false); 208 209 return (true); 210 } /*assureappisrunning*/ 211 212 213 boolean pushhandleonhandle (Handle hsource, Handle hdest) { 214 215 return (pushhandle (hsource, hdest)); 216 } /*pushhandleonhandle*/ 217 218 219 void deleteinhandle (Handle h, unsigned long ix, unsigned long ctdelete) { 220 221 pullfromhandle (h, ix, ctdelete, nil); 222 } /*deleteinhandle*/ 223 224 225 boolean pushathandlestart (ptrvoid pdata, long ctbytes, Handle h) { 226 227 return (insertinhandle (h, 0, pdata, ctbytes)); 228 } /*pushathandlestart*/ 229 230 231 boolean findrunningapp (OSType id, void *info) { 232 233 return (findrunningapplication (&id, nil, nil)); 234 } /*findrunningapp*/ 235 236 237 void appletsegment (void) { 238 } /*appletsegment*/ 239 240 241

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.