MCColor* MCScreenDC::getaccentcolors() { SInt32 response; if (Gestalt(gestaltAppearanceVersion, &response) == noErr) { // 1.0.1 or later // theme drawing only supported in version 1.1, OS 8.5 and later RegisterAppearanceClient(); // no harm in calling this multiple times if (response < 0x0110) MClook = LF_MAC; else { ThemeScrollBarThumbStyle tstyle; GetThemeScrollBarThumbStyle(&tstyle); MCproportionalthumbs = tstyle == kThemeScrollBarThumbProportional; } //get the 8 accent colors, for drawing scroll bar CTabHandle themeCT; //handle to the Theme color table if (GetThemeAccentColors(&themeCT) == noErr) { uint2 i = MCU_min(8, (*themeCT)->ctSize + 1); while (i--) { accentcolors[i].red = (*themeCT)->ctTable[i].rgb.red; accentcolors[i].green = (*themeCT)->ctTable[i].rgb.green; accentcolors[i].blue = (*themeCT)->ctTable[i].rgb.blue; } return accentcolors; } return NULL; } MClook = LF_MAC; return NULL; }
static int MacintoshInit() { MaxApplZone(); MoreMasters(); MoreMasters(); MoreMasters(); MoreMasters(); tcl_macQdPtr = &qd; if (TkMacHaveAppearance()) { RegisterAppearanceClient(); } InitGraf(&tcl_macQdPtr->thePort); InitFonts(); if (TkMacHaveAppearance() >= 0x110) { InitFloatingWindows(); } else { InitWindows(); } InitMenus(); InitDialogs((long) NULL); InitCursor(); FlushEvents(everyEvent, 0); SetEventMask(everyEvent); Tcl_MacSetEventProc(TkMacConvertEvent); return TCL_OK; }
// -------------------------------------------------------------------------------------- static void initialize(void) { OSStatus status; IBNibRef nib; OSErr error; RegisterAppearanceClient(); status = CreateNibReference(CFSTR("ExamplePrefs"), &nib); if (status != noErr) ExitToShell(); status = SetMenuBarFromNib(nib, CFSTR("MenuBar")); if (status != noErr) ExitToShell(); DisposeNibReference(nib); DrawMenuBar(); // do non time sensitive initialization after we get the application event loop going gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler); error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, false); if (error != noErr) ExitToShell(); /* If we supported them, we would install open documents and print documents handlers here and we would do most of the same initialization stuff that we do in the open application handler */ }
// -------------------------------------------------------------------------------------- static void initialize(void) { MenuBarHandle menuBar; OSErr error; MoreMasters(); // I doubt we actually need any extra master pointers InitGraf(&qd.thePort); // but I left the calls here as a reminder for where they InitFonts(); // belong if they are needed InitWindows(); InitMenus(); TEInit(); InitDialogs(NULL); InitCursor(); RegisterAppearanceClient(); menuBar = GetNewMBar(rMenuBar); // draw the menu bar as soon as possible if (menuBar == NULL) ExitToShell(); SetMenuBar(menuBar); DrawMenuBar(); // do non time sensitive initialization after we get the application event loop going gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler); error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, false); if (error != noErr) ExitToShell(); /* If we supported them, we would install open documents and print documents handlers here and we would do most of the same initialization stuff that we do in the open application handler. */ FlushEvents(everyEvent, 0); }
// -------------------------------------------------------------------------------------- static void initialize(void) { MenuBarHandle menuBar; OSErr error; /* I doubt we actually need any extra master pointers but I left the call here as a reminder for where it belongs if it is needed. */ MoreMasterPointers(64); // each call to MoreMasters allocates 64 master pointers InitCursor(); RegisterAppearanceClient(); menuBar = GetNewMBar(rMenuBar); // draw the menu bar as soon as possible if (menuBar == NULL) ExitToShell(); SetMenuBar(menuBar); DrawMenuBar(); // do non time sensitive initialization after we get the application event loop going gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler); error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, false); if (error != noErr) ExitToShell(); /* If we supported them, we would install open documents and print documents handlers here and we would do most of the same initialization stuff that we do in the open application handler. */ }
int main( int argc, char *argv[] ) { #ifdef OS9 ToolboxInit(); if ( HasAppearance() ) RegisterAppearanceClient(); #endif game.InitGL(); game.InitGame(); game.EventLoop(); game.Dispose(); #ifdef OS9 if ( HasAppearance() ) UnregisterAppearanceClient(); FlushEvents( everyEvent, 0 ); ExitToShell(); #endif }
void app_init(void) { RegisterAppearanceClient(); InitCursor(); MoreMasterPointers(128); FlushEvents(everyEvent,0); HMSetTagDelay(250); // setup paths file_paths_setup(&file_path_setup,TRUE); // no open files fileopen=FALSE; }
static void mac_startup(void) { Handle menuBar; TECInfoHandle ti; #if !TARGET_API_MAC_CARBON /* Init Memory Manager */ MaxApplZone(); /* Init QuickDraw */ InitGraf(&qd.thePort); /* Init Font Manager */ InitFonts(); /* Init Window Manager */ InitWindows(); /* Init Menu Manager */ InitMenus(); /* Init TextEdit */ TEInit(); /* Init Dialog Manager */ InitDialogs(NULL); #endif /* Get base system version (only used if there's no better selector) */ if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr || (mac_gestalts.sysvers &= 0xffff) < 0x700) fatalbox("PuTTYgen requires System 7 or newer"); /* Find out if we've got Color Quickdraw */ if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr) mac_gestalts.qdvers = gestaltOriginalQD; /* ... and the Appearance Manager? */ if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr) if (Gestalt(gestaltAppearanceAttr, NULL) == noErr) mac_gestalts.apprvers = 0x0100; else mac_gestalts.apprvers = 0; #if TARGET_RT_MAC_CFM /* Paranoia: Did we manage to pull in AppearanceLib? */ if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress) mac_gestalts.apprvers = 0; #endif #if TARGET_CPU_68K mac_gestalts.cntlattr = 0; mac_gestalts.windattr = 0; #else /* Mac OS 8.5 Control Manager (proportional scrollbars)? */ if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr || &SetControlViewSize == kUnresolvedCFragSymbolAddress) mac_gestalts.cntlattr = 0; /* Mac OS 8.5 Window Manager? */ if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr || &SetWindowContentColor == kUnresolvedCFragSymbolAddress) mac_gestalts.windattr = 0; #endif /* Text Encoding Conversion Manager? */ if ( #if TARGET_RT_MAC_CFM &TECGetInfo == kUnresolvedCFragSymbolAddress || #else InitializeUnicodeConverter(NULL) != noErr || #endif TECGetInfo(&ti) != noErr) mac_gestalts.encvvers = 0; else { mac_gestalts.encvvers = (*ti)->tecVersion; mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures; DisposeHandle((Handle)ti); } /* Navigation Services? */ if (NavServicesAvailable()) mac_gestalts.navsvers = NavLibraryVersion(); else mac_gestalts.navsvers = 0; /* We've been tested with the Appearance Manager */ if (mac_gestalts.apprvers != 0) RegisterAppearanceClient(); menuBar = GetNewMBar(128); if (menuBar == NULL) fatalbox("Unable to create menu bar."); SetMenuBar(menuBar); AppendResMenu(GetMenuHandle(mApple), 'DRVR'); mac_adjustmenus(); DrawMenuBar(); InitCursor(); windows.about = NULL; windows.licence = NULL; flags = FLAG_INTERACTIVE; /* Install Apple Event handlers. */ #if 0 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE); AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE); AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE); #endif AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE); }
boolean initmacintosh (void) { /* the magic stuff that every Macintosh application needs to do before doing anything else. 4/24/91 dmb: added memory config resource stuff 3.0.4 dmb: use LMGetCurStackBase, not CurStackBase global 3.0.4 dmb: pass 0L to InitDialogs */ register short i; register hdlmemoryconfig h; register long ctbytes; //Code change by Timothy Paustian Thursday, June 8, 2000 3:45:13 PM // #if TARGET_API_MAC_CARBON == 0 long ctstack; #endif long ctheap, ctcode; short ctmasters; h = (hdlmemoryconfig) Get1Resource ('MCFG', 1); if (h == nil) clearbytes (&macmemoryconfig, sizeof (macmemoryconfig)); else macmemoryconfig = **h; //Code change by Timothy Paustian Saturday, June 3, 2000 10:13:20 PM //Changed to Opaque call for Carbon //we don't need this in carbon. #if TARGET_API_MAC_CARBON == 0 if (h != nil) { /*first check stack size*/ ctbytes = (**h).minstacksize; ctstack = LMGetCurStackBase () - GetApplLimit (); /*current stack size*/ if (ctbytes > ctstack) SetApplLimit (LMGetCurStackBase () - ctbytes); } MaxApplZone (); #endif if (h != nil) { /*check heap size and master pointers*/ ctbytes = (**h).minheapsize; //Code change by Timothy Paustian Thursday, June 8, 2000 3:04:31 PM //Changed to Opaque call for Carbon //This is meaningless for OS X since it has unlimited memory. #if TARGET_API_MAC_CARBON == 1 //we need to do somethings else. FreeMem is going to return some large value //of all the available system memory //This whole thing is pointless. We can get as much memory as we need. #pragma unused (ctmasters) #pragma unused (ctcode) #pragma unused (ctheap) #else ctheap = FreeMem (); if (ctbytes > ctheap) { return (false); } ctbytes = (**h).avghandlesize; ctcode = (**h).reserveforcode; if ((ctbytes > 0) && (ctheap > ctcode)) { ctmasters = ((ctheap - ctcode) / ctbytes) / kNumberOfMasters; ctmasters = min (ctmasters, 1024); /*7.1b37 PBS: You'd think 1024 calls would be enough. With large memory alottments on Mac Classic, we're calling MoreMasters in excess of 20,000 times. That makes the app take a minute or so to start up! So instead I've chosen an arbitrary limit.*/ for (i = 1; i < ctmasters; i++) MoreMasters (); } #endif ReleaseResource ((Handle) h); /*we're done with it*/ } //Code change by Timothy Paustian Thursday, June 8, 2000 3:21:06 PM //Changed to Opaque call for Carbon //we don't need this initialization in carbon #if TARGET_API_MAC_CARBON == 0 InitGraf (&qd.thePort); InitFonts (); FlushEvents (everyEvent, 0); InitWindows (); InitMenus (); TEInit (); InitDialogs (0L); #endif InitCursor (); //Code change by Timothy Paustian Thursday, June 8, 2000 3:22:57 PM //Changed to Opaque call for Carbon //this is obsolete, we should be using gestalt for this. { long quickDrawFeatures; OSErr theErr = Gestalt(gestaltSystemVersion, &gSystemVersion); if(oserror(theErr)) ExitToShell(); theErr = Gestalt(gestaltQuickdrawFeatures, &quickDrawFeatures); if(oserror(theErr)) ExitToShell(); gHasColorQD = (quickDrawFeatures & (1 << gestaltHasColor)); //Nav services has to be present and we want the 1.1 or greater version. gCanUseNavServ = (NavServicesAvailable() && (NavLibraryVersion() >= 0x01108000)); } //SysEnvirons (1, &macworld); //gee I bet this isn't required anymore either. for (i = 1; i <= 5; i++) { /*register with Multifinder*/ EventRecord ev; EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/ } /*for*/ #if TARGET_API_MAC_CARBON == 1 RegisterAppearanceClient (); #endif return (true); } /*initmacintosh*/
static int MacintoshInit() { int i; long result, mask = 0x0700; /* mask = system 7.x */ #if GENERATING68K && !GENERATINGCFM SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH)); #endif MaxApplZone(); for (i = 0; i < 4; i++) { (void) MoreMasters(); } /* * Tk needs us to set the qd pointer it uses. This is needed * so Tk doesn't have to assume the availablity of the qd global * variable. Which in turn allows Tk to be used in code resources. */ tcl_macQdPtr = &qd; /* * If appearance is present, then register Tk as an Appearance client * This means that the mapping from non-Appearance to Appearance cdefs * will be done for Tk regardless of the setting in the Appearance * control panel. */ if (TkMacHaveAppearance()) { RegisterAppearanceClient(); } InitGraf(&tcl_macQdPtr->thePort); InitFonts(); if (TkMacHaveAppearance() >= 0x110) { InitFloatingWindows(); } else { InitWindows(); } InitMenus(); InitDialogs((long) NULL); InitCursor(); /* * Make sure we are running on system 7 or higher */ if ((NGetTrapAddress(_Gestalt, ToolTrap) == NGetTrapAddress(_Unimplemented, ToolTrap)) || (((Gestalt(gestaltSystemVersion, &result) != noErr) || (result < mask)))) { panic("Tcl/Tk requires System 7 or higher."); } /* * Make sure we have color quick draw * (this means we can't run on 68000 macs) */ if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr) || (result < gestalt32BitQD13))) { panic("Tk requires Color QuickDraw."); } FlushEvents(everyEvent, 0); SetEventMask(everyEvent); Tcl_MacSetEventProc(TkMacConvertEvent); return TCL_OK; }
void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded ) { #if !TARGET_CARBON ::MaxApplZone(); for (long i = 1; i <= inMoreMastersCalls; i++) ::MoreMasters(); if (!isEmbedded) { ::InitGraf(&qd.thePort); ::InitFonts(); ::InitMenus(); ::TEInit(); ::InitDialogs(0L); ::FlushEvents(everyEvent, 0); } long total,contig; PurgeSpace(&total, &contig); #endif ::InitCursor(); if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr) sUMASystemVersion = 0x0000 ; long theAppearance ; if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) { sUMAHasAppearance = true ; OSStatus status = RegisterAppearanceClient(); // If status equals appearanceProcessRegisteredErr it means the // appearance client already was registered (For example if we run // embedded, the host might have registered it). In such a case // we don't unregister it later on. if (status != appearanceProcessRegisteredErr) { // Appearance client wasn't registered yet. sUMAHasInittedAppearance = true; } if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) { sUMAAppearanceVersion = theAppearance ; } else { sUMAAppearanceVersion = 0x0100 ; } } if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) { sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; } #if TARGET_CARBON // Call currently implicitely done : InitFloatingWindows() ; #else if (!isEmbedded) { if ( sUMAHasWindowManager ) InitFloatingWindows() ; else InitWindows(); } #endif if ( NavServicesAvailable() ) { NavLoad() ; } long menuMgrAttr ; Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ; if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask ) sUMAHasAquaLayout = true ; if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress ) { FontFamilyID fontId ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TXNMacOSPreferredFontDescription fontDescriptions[] = { { fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } } ; int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ; // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke #if 0 // leads to unexpected content for clients, TODO configurable OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; #else OptionBits options = 0 ; #endif #if TARGET_CARBON if ( !UMAHasAquaLayout() ) #endif { options |= kTXNAlwaysUseQuickDrawTextMask ; } TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); } UMASetSystemIsInitialized(true); }