OSXSpecifics.c

Go to the documentation of this file.
00001 
00002 /*  $Id: OSXSpecifics.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 "OSXSpecifics.h"
00029 
00030 /* OSXSpecifics.c
00031     
00032     This file and its header represent a one-stop shop for setting up OSX specific things.
00033     The goal is to only need to call the setup procedure once, and have the function pointers
00034     available for the rest of the time Frontier is running. I'll hone this down over time,
00035     but for right now, this is good enough.
00036     
00037 */
00038 
00039 
00040 //      if (strcmp((char*)*par->params[0], "true")==0) useQDText(1);
00041 //      else useQDText(0);
00042 
00043 
00044 
00045 static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr)
00046 {
00047     OSStatus    err;
00048     FSRef       frameworksFolderRef;
00049     CFURLRef    baseURL;
00050     CFURLRef    bundleURL;
00051     
00052     if ( bundlePtr == nil ) return( -1 );
00053     
00054     *bundlePtr = nil;
00055     
00056     baseURL = nil;
00057     bundleURL = nil;
00058     
00059     err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef);
00060     if (err == noErr) {
00061         baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef);
00062         if (baseURL == nil) {
00063             err = coreFoundationUnknownErr;
00064         }
00065     }
00066     if (err == noErr) {
00067         bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false);
00068         if (bundleURL == nil) {
00069             err = coreFoundationUnknownErr;
00070         }
00071     }
00072     if (err == noErr) {
00073         *bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
00074         if (*bundlePtr == nil) {
00075             err = coreFoundationUnknownErr;
00076         }
00077     }
00078     if (err == noErr) {
00079         if ( ! CFBundleLoadExecutable( *bundlePtr ) ) {
00080             err = coreFoundationUnknownErr;
00081         }
00082     }
00083 
00084     // Clean up.
00085     if (err != noErr && *bundlePtr != nil) {
00086         CFRelease(*bundlePtr);
00087         *bundlePtr = nil;
00088     }
00089     if (bundleURL != nil) {
00090         CFRelease(bundleURL);
00091     }   
00092     if (baseURL != nil) {
00093         CFRelease(baseURL);
00094     }   
00095     
00096     return err;
00097 }
00098 
00099 
00100 void useQDText(int i)
00101 {
00102     OSStatus            err;
00103     CFBundleRef         sysBundle;
00104     UInt32              newFlags = 0;
00105     char                s[64];
00106     QuartzTextPtr       QuartzText;
00107 
00108     
00109     s[0]=0;
00110     err = LoadFrameworkBundle( CFSTR("ApplicationServices.framework"), &sysBundle );
00111     if (err == noErr) {
00112         QuartzText = CFBundleGetFunctionPointerForName(sysBundle, CFSTR("SwapQDTextFlags") );
00113         if (QuartzText != nil) {
00114             //newFlags = kQDUseCGTextRendering | kQDUseCGTextMetrics;
00115             if (i == 1) err = QuartzText(kQDUseCGTextRendering);
00116             else {
00117                 err = QuartzText(0);
00118                 err = 0;
00119             }
00120         }
00121     }
00122 }

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