1/*********************************************************************************** 2 Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 4 (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 5 Jerremy Koot (jkoot@snes9x.com) 6 7 (c) Copyright 2002 - 2004 Matthew Kendora 8 9 (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 10 11 (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 12 13 (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 14 15 (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 16 Kris Bleakley (codeviolation@hotmail.com) 17 18 (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 19 Nach (n-a-c-h@users.sourceforge.net), 20 21 (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) 22 23 (c) Copyright 2006 - 2007 nitsuja 24 25 (c) Copyright 2009 - 2016 BearOso, 26 OV2 27 28 29 BS-X C emulator code 30 (c) Copyright 2005 - 2006 Dreamer Nom, 31 zones 32 33 C4 x86 assembler and some C emulation code 34 (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 35 Nach, 36 zsKnight (zsknight@zsnes.com) 37 38 C4 C++ code 39 (c) Copyright 2003 - 2006 Brad Jorsch, 40 Nach 41 42 DSP-1 emulator code 43 (c) Copyright 1998 - 2006 _Demo_, 44 Andreas Naive (andreasnaive@gmail.com), 45 Gary Henderson, 46 Ivar (ivar@snes9x.com), 47 John Weidman, 48 Kris Bleakley, 49 Matthew Kendora, 50 Nach, 51 neviksti (neviksti@hotmail.com) 52 53 DSP-2 emulator code 54 (c) Copyright 2003 John Weidman, 55 Kris Bleakley, 56 Lord Nightmare (lord_nightmare@users.sourceforge.net), 57 Matthew Kendora, 58 neviksti 59 60 DSP-3 emulator code 61 (c) Copyright 2003 - 2006 John Weidman, 62 Kris Bleakley, 63 Lancer, 64 z80 gaiden 65 66 DSP-4 emulator code 67 (c) Copyright 2004 - 2006 Dreamer Nom, 68 John Weidman, 69 Kris Bleakley, 70 Nach, 71 z80 gaiden 72 73 OBC1 emulator code 74 (c) Copyright 2001 - 2004 zsKnight, 75 pagefault (pagefault@zsnes.com), 76 Kris Bleakley 77 Ported from x86 assembler to C by sanmaiwashi 78 79 SPC7110 and RTC C++ emulator code used in 1.39-1.51 80 (c) Copyright 2002 Matthew Kendora with research by 81 zsKnight, 82 John Weidman, 83 Dark Force 84 85 SPC7110 and RTC C++ emulator code used in 1.52+ 86 (c) Copyright 2009 byuu, 87 neviksti 88 89 S-DD1 C emulator code 90 (c) Copyright 2003 Brad Jorsch with research by 91 Andreas Naive, 92 John Weidman 93 94 S-RTC C emulator code 95 (c) Copyright 2001 - 2006 byuu, 96 John Weidman 97 98 ST010 C++ emulator code 99 (c) Copyright 2003 Feather, 100 John Weidman, 101 Kris Bleakley, 102 Matthew Kendora 103 104 Super FX x86 assembler emulator code 105 (c) Copyright 1998 - 2003 _Demo_, 106 pagefault, 107 zsKnight 108 109 Super FX C emulator code 110 (c) Copyright 1997 - 1999 Ivar, 111 Gary Henderson, 112 John Weidman 113 114 Sound emulator code used in 1.5-1.51 115 (c) Copyright 1998 - 2003 Brad Martin 116 (c) Copyright 1998 - 2006 Charles Bilyue' 117 118 Sound emulator code used in 1.52+ 119 (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 120 121 S-SMP emulator code used in 1.54+ 122 (c) Copyright 2016 byuu 123 124 SH assembler code partly based on x86 assembler code 125 (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 126 127 2xSaI filter 128 (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 129 130 HQ2x, HQ3x, HQ4x filters 131 (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 132 133 NTSC filter 134 (c) Copyright 2006 - 2007 Shay Green 135 136 GTK+ GUI code 137 (c) Copyright 2004 - 2016 BearOso 138 139 Win32 GUI code 140 (c) Copyright 2003 - 2006 blip, 141 funkyass, 142 Matthew Kendora, 143 Nach, 144 nitsuja 145 (c) Copyright 2009 - 2016 OV2 146 147 Mac OS GUI code 148 (c) Copyright 1998 - 2001 John Stiles 149 (c) Copyright 2001 - 2011 zones 150 151 152 Specific ports contains the works of other authors. See headers in 153 individual files. 154 155 156 Snes9x homepage: http://www.snes9x.com/ 157 158 Permission to use, copy, modify and/or distribute Snes9x in both binary 159 and source form, for non-commercial purposes, is hereby granted without 160 fee, providing that this license information and copyright notice appear 161 with all copies and any derived work. 162 163 This software is provided 'as-is', without any express or implied 164 warranty. In no event shall the authors be held liable for any damages 165 arising from the use of this software or it's derivatives. 166 167 Snes9x is freeware for PERSONAL USE only. Commercial users should 168 seek permission of the copyright holders first. Commercial use includes, 169 but is not limited to, charging money for Snes9x or software derived from 170 Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 171 using Snes9x as a promotion for your commercial product. 172 173 The copyright holders request that bug fixes and improvements to the code 174 should be forwarded to them so everyone can benefit from the modifications 175 in future versions. 176 177 Super NES and Super Nintendo Entertainment System are trademarks of 178 Nintendo Co., Limited and its subsidiary companies. 179 ***********************************************************************************/ 180 181/*********************************************************************************** 182 SNES9X for Mac OS (c) Copyright John Stiles 183 184 Snes9x for Mac OS X 185 186 (c) Copyright 2001 - 2011 zones 187 (c) Copyright 2002 - 2005 107 188 (c) Copyright 2002 PB1400c 189 (c) Copyright 2004 Alexander and Sander 190 (c) Copyright 2004 - 2005 Steven Seeger 191 (c) Copyright 2005 Ryan Vogt 192 ***********************************************************************************/ 193 194 195#import "snes9x.h" 196#import "memmap.h" 197#import "snapshot.h" 198#import "movie.h" 199 200#import <wchar.h> 201#import <Cocoa/Cocoa.h> 202 203#import "mac-cocoatools.h" 204#import "mac-prefix.h" 205#import "mac-dialog.h" 206#import "mac-os.h" 207#import "mac-quicktime.h" 208#import "mac-screenshot.h" 209#import "mac-snes9x.h" 210#import "mac-stringtools.h" 211#import "mac-cart.h" 212 213typedef struct 214{ 215 NavDialogRef nref; 216 WindowRef parent; 217 FSRef ref; 218 Boolean reply; 219 char name[PATH_MAX + 1]; 220#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 221 IBNibRef customNib; 222 WindowRef customWindow; 223 HIViewRef customPane; 224 short customWidth, customHeight; 225#endif 226} NavState; 227 228extern wchar_t macRecordWChar[MOVIE_MAX_METADATA]; 229 230static NavEventUPP gSheetEventUPP; 231static NavObjectFilterUPP gSheetFilterUPP; 232static NavState gSheetNav; 233static NSAutoreleasePool *gPool; 234static NSPopUpButton *gPopM, *gPopI, *gPopV, *gPopH; 235 236static pascal void NavGenericOpenEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 237static pascal void NavGenericSaveEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 238static pascal Boolean NavOpenCartFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); 239static pascal Boolean NavDefrostFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); 240static pascal Boolean NavPlayMovieFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); 241#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 242static void GlobalPointToWindowLocalPoint (Point *, WindowRef); 243static pascal void NavOpenCartEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 244static pascal void NavRecordMovieToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 245static pascal void NavPlayMovieFromEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 246static pascal void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); 247#endif 248#ifdef MAC_TIGER_PANTHER_SUPPORT 249static pascal Boolean NavDefrostFromPreview (NavCBRecPtr, NavCallBackUserData); 250static pascal Boolean NavPlayMovieFromPreview (NavCBRecPtr, NavCallBackUserData); 251#endif 252 253 254@interface NavController : NSObject 255 256- (id) init; 257- (void) dealloc; 258- (IBAction) handleCompressButton: (id) sender; 259 260@end 261 262@implementation NavController 263 264- (id) init 265{ 266 self = [super init]; 267 return (self); 268} 269 270- (void) dealloc 271{ 272 [super dealloc]; 273} 274 275- (IBAction) handleCompressButton: (id) sender 276{ 277 MacQTVideoConfig(); 278} 279 280@end 281 282 283bool8 NavOpenROMImage (FSRef *ref) 284{ 285 OSStatus err; 286 NavDialogCreationOptions dialogOptions; 287 NavEventUPP eventUPP; 288 NavObjectFilterUPP filterUPP; 289 NavState nav; 290 291#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 292 if (systemVersion < 0x1060) 293 { 294 HIViewID cid = { 'PANE', 1000 }; 295 Rect rct; 296 297 err = CreateNibReference(kMacS9XCFString, &(nav.customNib)); 298 if (err) 299 return (false); 300 301 err = CreateWindowFromNib(nav.customNib, CFSTR("OpenROM"), &(nav.customWindow)); 302 if (err) 303 { 304 DisposeNibReference(nav.customNib); 305 return (false); 306 } 307 308 GetWindowBounds(nav.customWindow, kWindowContentRgn, &rct); 309 nav.customWidth = rct.right - rct.left; 310 nav.customHeight = rct.bottom - rct.top; 311 312 HIViewFindByID(HIViewGetRoot(nav.customWindow), cid, &(nav.customPane)); 313 } 314#endif 315 316 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 317 dialogOptions.optionFlags &= ~kNavAllowMultipleFiles; 318 dialogOptions.preferenceKey = 3; 319 dialogOptions.clientName = kMacS9XCFString; 320 dialogOptions.windowTitle = CFCopyLocalizedString(CFSTR("OpenROMMes"), "Open"); 321 dialogOptions.modality = kWindowModalityAppModal; 322 dialogOptions.parentWindow = NULL; 323 nav.parent = NULL; 324 325#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 326 eventUPP = NewNavEventUPP((systemVersion < 0x1060) ? NavOpenCartEventHandler : NavGenericOpenEventHandler); 327#else 328 eventUPP = NewNavEventUPP(NavGenericOpenEventHandler); 329#endif 330 filterUPP = NewNavObjectFilterUPP(NavOpenCartFilter); 331 332 err = NavCreateChooseFileDialog(&dialogOptions, NULL, eventUPP, NULL, filterUPP, &nav, &(nav.nref)); 333 if (err == noErr) 334 { 335 if (systemVersion >= 0x1060) 336 { 337 NSAutoreleasePool *pool; 338 NSView *view; 339 NSTextField *txtM, *txtI, *txtV, *txtH; 340 NSPopUpButton *popM, *popI, *popV, *popH; 341 NSArray *aryM, *aryI, *aryV, *aryH; 342 343 pool = [[NSAutoreleasePool alloc] init]; 344 345 view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, 433, 52)] autorelease]; 346 347 aryM = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROM6", @""), NSLocalizedString(@"OpenROM7", @""), nil]; 348 aryI = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROMa", @""), NSLocalizedString(@"OpenROMb", @""), NSLocalizedString(@"OpenROMc", @""), NSLocalizedString(@"OpenROMd", @""), nil]; 349 aryV = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROM8", @""), NSLocalizedString(@"OpenROM9", @""), nil]; 350 aryH = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROMe", @""), NSLocalizedString(@"OpenROMf", @""), nil]; 351 352 CocoaAddStatTextToView(view, @"OpenROM1", 5, 32, 84, 14, &txtM); 353 CocoaAddStatTextToView(view, @"OpenROM3", 214, 32, 96, 14, &txtI); 354 CocoaAddStatTextToView(view, @"OpenROM2", 5, 7, 84, 14, &txtV); 355 CocoaAddStatTextToView(view, @"OpenROM4", 214, 7, 96, 14, &txtH); 356 CocoaAddPopUpBtnToView(view, aryM, 91, 27, 116, 22, &popM); 357 CocoaAddPopUpBtnToView(view, aryI, 312, 27, 116, 22, &popI); 358 CocoaAddPopUpBtnToView(view, aryV, 91, 2, 116, 22, &popV); 359 CocoaAddPopUpBtnToView(view, aryH, 312, 2, 116, 22, &popH); 360 361 [txtM setAlignment: NSRightTextAlignment]; 362 [txtI setAlignment: NSRightTextAlignment]; 363 [txtV setAlignment: NSRightTextAlignment]; 364 [txtH setAlignment: NSRightTextAlignment]; 365 366 [popM selectItemAtIndex: romDetect ]; 367 [popI selectItemAtIndex: interleaveDetect]; 368 [popV selectItemAtIndex: videoDetect ]; 369 [popH selectItemAtIndex: headerDetect ]; 370 371 [(NSOpenPanel *) nav.nref setAccessoryView: view]; 372 373 err = NavDialogRun(nav.nref); 374 if (err) 375 NavDialogDispose(nav.nref); 376 377 romDetect = [popM indexOfSelectedItem]; 378 interleaveDetect = [popI indexOfSelectedItem]; 379 videoDetect = [popV indexOfSelectedItem]; 380 headerDetect = [popH indexOfSelectedItem]; 381 382 [pool release]; 383 } 384 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 385 else 386 { 387 err = NavDialogRun(nav.nref); 388 if (err) 389 NavDialogDispose(nav.nref); 390 } 391 #endif 392 } 393 394 DisposeNavObjectFilterUPP(filterUPP); 395 DisposeNavEventUPP(eventUPP); 396 397 CFRelease(dialogOptions.windowTitle); 398 399#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 400 if (systemVersion < 0x1060) 401 { 402 CFRelease(nav.customWindow); 403 DisposeNibReference(nav.customNib); 404 } 405#endif 406 407 if (err) 408 return (false); 409 else 410 { 411 if (nav.reply) 412 { 413 *ref = nav.ref; 414 return (true); 415 } 416 else 417 return (false); 418 } 419} 420 421bool8 NavBeginOpenROMImageSheet (WindowRef parent, CFStringRef mes) 422{ 423 OSStatus err; 424 NavDialogCreationOptions dialogOptions; 425 426#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 427 if (systemVersion < 0x1060) 428 { 429 HIViewID cid = { 'PANE', 1000 }; 430 Rect rct; 431 432 err = CreateNibReference(kMacS9XCFString, &(gSheetNav.customNib)); 433 if (err) 434 return (false); 435 436 err = CreateWindowFromNib(gSheetNav.customNib, CFSTR("OpenROM"), &(gSheetNav.customWindow)); 437 if (err) 438 { 439 DisposeNibReference(gSheetNav.customNib); 440 return (false); 441 } 442 443 GetWindowBounds(gSheetNav.customWindow, kWindowContentRgn, &rct); 444 gSheetNav.customWidth = rct.right - rct.left; 445 gSheetNav.customHeight = rct.bottom - rct.top; 446 447 HIViewFindByID(HIViewGetRoot(gSheetNav.customWindow), cid, &(gSheetNav.customPane)); 448 } 449#endif 450 451 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 452 dialogOptions.optionFlags &= ~kNavAllowMultipleFiles; 453 dialogOptions.preferenceKey = 3; 454 dialogOptions.clientName = kMacS9XCFString; 455 dialogOptions.windowTitle = CFCopyLocalizedString(CFSTR("OpenROMMes"), "Open"); 456 dialogOptions.message = mes; 457 dialogOptions.modality = kWindowModalityWindowModal; 458 dialogOptions.parentWindow = parent; 459 gSheetNav.parent = parent; 460 461#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 462 gSheetEventUPP = NewNavEventUPP((systemVersion < 0x1060) ? NavOpenCartEventHandler : NavGenericOpenEventHandler); 463#else 464 gSheetEventUPP = NewNavEventUPP(NavGenericOpenEventHandler); 465#endif 466 gSheetFilterUPP = NewNavObjectFilterUPP(NavOpenCartFilter); 467 468 err = NavCreateChooseFileDialog(&dialogOptions, NULL, gSheetEventUPP, NULL, gSheetFilterUPP, &gSheetNav, &(gSheetNav.nref)); 469 if (err == noErr) 470 { 471 if (systemVersion >= 0x1060) 472 { 473 NSView *view; 474 NSTextField *txtM, *txtI, *txtV, *txtH; 475 NSArray *aryM, *aryI, *aryV, *aryH; 476 477 gPool = [[NSAutoreleasePool alloc] init]; 478 479 view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, 433, 52)] autorelease]; 480 481 aryM = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROM6", @""), NSLocalizedString(@"OpenROM7", @""), nil]; 482 aryI = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROMa", @""), NSLocalizedString(@"OpenROMb", @""), NSLocalizedString(@"OpenROMc", @""), NSLocalizedString(@"OpenROMd", @""), nil]; 483 aryV = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROM8", @""), NSLocalizedString(@"OpenROM9", @""), nil]; 484 aryH = [NSArray arrayWithObjects: NSLocalizedString(@"OpenROM5", @""), @"---", NSLocalizedString(@"OpenROMe", @""), NSLocalizedString(@"OpenROMf", @""), nil]; 485 486 CocoaAddStatTextToView(view, @"OpenROM1", 5, 32, 84, 14, &txtM); 487 CocoaAddStatTextToView(view, @"OpenROM3", 214, 32, 96, 14, &txtI); 488 CocoaAddStatTextToView(view, @"OpenROM2", 5, 7, 84, 14, &txtV); 489 CocoaAddStatTextToView(view, @"OpenROM4", 214, 7, 96, 14, &txtH); 490 CocoaAddPopUpBtnToView(view, aryM, 91, 27, 116, 22, &gPopM); 491 CocoaAddPopUpBtnToView(view, aryI, 312, 27, 116, 22, &gPopI); 492 CocoaAddPopUpBtnToView(view, aryV, 91, 2, 116, 22, &gPopV); 493 CocoaAddPopUpBtnToView(view, aryH, 312, 2, 116, 22, &gPopH); 494 495 [txtM setAlignment: NSRightTextAlignment]; 496 [txtI setAlignment: NSRightTextAlignment]; 497 [txtV setAlignment: NSRightTextAlignment]; 498 [txtH setAlignment: NSRightTextAlignment]; 499 500 [gPopM selectItemAtIndex: romDetect ]; 501 [gPopI selectItemAtIndex: interleaveDetect]; 502 [gPopV selectItemAtIndex: videoDetect ]; 503 [gPopH selectItemAtIndex: headerDetect ]; 504 505 [(NSOpenPanel *) gSheetNav.nref setAccessoryView: view]; 506 507 err = NavDialogRun(gSheetNav.nref); 508 if (err) 509 { 510 [gPool release]; 511 NavDialogDispose(gSheetNav.nref); 512 DisposeNavObjectFilterUPP(gSheetFilterUPP); 513 DisposeNavEventUPP(gSheetEventUPP); 514 CFRelease(dialogOptions.windowTitle); 515 return (false); 516 } 517 } 518 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 519 else 520 { 521 err = NavDialogRun(gSheetNav.nref); 522 if (err) 523 { 524 NavDialogDispose(gSheetNav.nref); 525 DisposeNavObjectFilterUPP(gSheetFilterUPP); 526 DisposeNavEventUPP(gSheetEventUPP); 527 CFRelease(dialogOptions.windowTitle); 528 CFRelease(gSheetNav.customWindow); 529 DisposeNibReference(gSheetNav.customNib); 530 return (false); 531 } 532 } 533 #endif 534 } 535 else 536 { 537 DisposeNavObjectFilterUPP(gSheetFilterUPP); 538 DisposeNavEventUPP(gSheetEventUPP); 539 CFRelease(dialogOptions.windowTitle); 540 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 541 if (systemVersion < 0x1060) 542 { 543 CFRelease(gSheetNav.customWindow); 544 DisposeNibReference(gSheetNav.customNib); 545 } 546 #endif 547 return (false); 548 } 549 550 CFRelease(dialogOptions.windowTitle); 551 return (true); 552} 553 554bool8 NavEndOpenROMImageSheet (FSRef *ref) 555{ 556 if (systemVersion >= 0x1060) 557 { 558 romDetect = [gPopM indexOfSelectedItem]; 559 interleaveDetect = [gPopI indexOfSelectedItem]; 560 videoDetect = [gPopV indexOfSelectedItem]; 561 headerDetect = [gPopH indexOfSelectedItem]; 562 563 [gPool release]; 564 } 565 566 DisposeNavObjectFilterUPP(gSheetFilterUPP); 567 DisposeNavEventUPP(gSheetEventUPP); 568 569#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 570 if (systemVersion < 0x1060) 571 { 572 CFRelease(gSheetNav.customWindow); 573 DisposeNibReference(gSheetNav.customNib); 574 } 575#endif 576 577 if (gSheetNav.reply) 578 { 579 *ref = gSheetNav.ref; 580 return (true); 581 } 582 else 583 return (false); 584} 585 586bool8 NavFreezeTo (char *path) 587{ 588 OSStatus err; 589 NavDialogCreationOptions dialogOptions; 590 NavEventUPP eventUPP; 591 NavState nav; 592 CFStringRef numRef, romRef, baseRef; 593 CFMutableStringRef mesRef, saveRef; 594 SInt32 replaceAt; 595 char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; 596 597 _splitpath(Memory.ROMFilename, drive, dir, fname, ext); 598 romRef = CFStringCreateWithCString(kCFAllocatorDefault, fname, kCFStringEncodingUTF8); 599 numRef = CFCopyLocalizedString(CFSTR("FreezeToPos"), "1"); 600 baseRef = CFCopyLocalizedString(CFSTR("FreezeToMes"), "Freeze"); 601 mesRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef); 602 saveRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, romRef); 603 replaceAt = CFStringGetIntValue(numRef); 604 CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef); 605 CFStringAppendCString(saveRef, ".frz", CFStringGetSystemEncoding()); 606 607 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 608 dialogOptions.preferenceKey = 4; 609 dialogOptions.clientName = kMacS9XCFString; 610 dialogOptions.windowTitle = mesRef; 611 dialogOptions.saveFileName = saveRef; 612 dialogOptions.modality = kWindowModalityAppModal; 613 dialogOptions.parentWindow = NULL; 614 nav.parent = NULL; 615 616 eventUPP = NewNavEventUPP(NavGenericSaveEventHandler); 617 618 err = NavCreatePutFileDialog(&dialogOptions, 'SAVE', '~9X~', eventUPP, &nav, &(nav.nref)); 619 if (err == noErr) 620 { 621 err = NavDialogRun(nav.nref); 622 if (err) 623 NavDialogDispose(nav.nref); 624 } 625 626 DisposeNavEventUPP(eventUPP); 627 628 CFRelease(saveRef); 629 CFRelease(mesRef); 630 CFRelease(baseRef); 631 CFRelease(numRef); 632 CFRelease(romRef); 633 634 if (err) 635 return (false); 636 else 637 { 638 if (nav.reply) 639 { 640 char s[PATH_MAX + 1]; 641 642 err = FSRefMakePath(&(nav.ref), (unsigned char *) s, PATH_MAX); 643 snprintf(path, PATH_MAX + 1, "%s%s%s", s, MAC_PATH_SEPARATOR, nav.name); 644 645 return (true); 646 } 647 else 648 return (false); 649 } 650} 651 652bool8 NavDefrostFrom (char *path) 653{ 654 OSStatus err; 655 NavDialogCreationOptions dialogOptions; 656 NavEventUPP eventUPP; 657 NavObjectFilterUPP filterUPP; 658 NavState nav; 659 CFStringRef numRef, romRef, baseRef; 660 CFMutableStringRef mesRef; 661 SInt32 replaceAt; 662 char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; 663#ifdef MAC_TIGER_PANTHER_SUPPORT 664 NavPreviewUPP previewUPP; 665#endif 666 667 _splitpath(Memory.ROMFilename, drive, dir, fname, ext); 668 romRef = CFStringCreateWithCString(kCFAllocatorDefault, fname, kCFStringEncodingUTF8); 669 numRef = CFCopyLocalizedString(CFSTR("DefrostFromPos"), "1"); 670 baseRef = CFCopyLocalizedString(CFSTR("DefrostFromMes"), "Defrost"); 671 mesRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef); 672 replaceAt = CFStringGetIntValue(numRef); 673 CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef); 674 675 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 676 dialogOptions.optionFlags &= ~kNavAllowMultipleFiles; 677 dialogOptions.preferenceKey = 5; 678 dialogOptions.clientName = kMacS9XCFString; 679 dialogOptions.windowTitle = mesRef; 680 dialogOptions.modality = kWindowModalityAppModal; 681 dialogOptions.parentWindow = NULL; 682 nav.parent = NULL; 683 684 eventUPP = NewNavEventUPP(NavGenericOpenEventHandler); 685 filterUPP = NewNavObjectFilterUPP(NavDefrostFromFilter); 686#ifdef MAC_TIGER_PANTHER_SUPPORT 687 previewUPP = NewNavPreviewUPP(NavDefrostFromPreview); 688#endif 689 690#ifdef MAC_TIGER_PANTHER_SUPPORT 691 err = NavCreateChooseFileDialog(&dialogOptions, NULL, eventUPP, previewUPP, filterUPP, &nav, &(nav.nref)); 692#else 693 err = NavCreateChooseFileDialog(&dialogOptions, NULL, eventUPP, NULL, filterUPP, &nav, &(nav.nref)); 694#endif 695 if (err == noErr) 696 { 697 err = NavDialogRun(nav.nref); 698 if (err) 699 NavDialogDispose(nav.nref); 700 } 701 702#ifdef MAC_TIGER_PANTHER_SUPPORT 703 DisposeNavPreviewUPP(previewUPP); 704#endif 705 DisposeNavObjectFilterUPP(filterUPP); 706 DisposeNavEventUPP(eventUPP); 707 708 CFRelease(mesRef); 709 CFRelease(baseRef); 710 CFRelease(numRef); 711 CFRelease(romRef); 712 713 if (err) 714 return (false); 715 else 716 { 717 if (nav.reply) 718 { 719 err = FSRefMakePath(&(nav.ref), (unsigned char *) path, PATH_MAX); 720 return (true); 721 } 722 else 723 return (false); 724 } 725} 726 727bool8 NavRecordMovieTo (char *path) 728{ 729 OSStatus err; 730 NavDialogCreationOptions dialogOptions; 731 NavEventUPP eventUPP; 732 NavState nav; 733 CFStringRef numRef, romRef, baseRef; 734 CFMutableStringRef mesRef, saveRef; 735 SInt32 replaceAt; 736 char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; 737 738#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 739 if (systemVersion < 0x1060) 740 { 741 HIViewID cid = { 'PANE', 1000 }; 742 Rect rct; 743 744 err = CreateNibReference(kMacS9XCFString, &(nav.customNib)); 745 if (err) 746 return (false); 747 748 err = CreateWindowFromNib(nav.customNib, CFSTR("RecordSMV"), &(nav.customWindow)); 749 if (err) 750 { 751 DisposeNibReference(nav.customNib); 752 return (false); 753 } 754 755 GetWindowBounds(nav.customWindow, kWindowContentRgn, &rct); 756 nav.customWidth = rct.right - rct.left; 757 nav.customHeight = rct.bottom - rct.top; 758 759 HIViewFindByID(HIViewGetRoot(nav.customWindow), cid, &(nav.customPane)); 760 } 761#endif 762 763 _splitpath(Memory.ROMFilename, drive, dir, fname, ext); 764 romRef = CFStringCreateWithCString(kCFAllocatorDefault, fname, kCFStringEncodingUTF8); 765 numRef = CFCopyLocalizedString(CFSTR("RecordToPos"), "1"); 766 baseRef = CFCopyLocalizedString(CFSTR("RecordToMes"), "Record"); 767 mesRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef); 768 saveRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, romRef); 769 replaceAt = CFStringGetIntValue(numRef); 770 CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef); 771 CFStringAppendCString(saveRef, ".smv", CFStringGetSystemEncoding()); 772 773 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 774 dialogOptions.preferenceKey = 6; 775 dialogOptions.clientName = kMacS9XCFString; 776 dialogOptions.windowTitle = mesRef; 777 dialogOptions.saveFileName = saveRef; 778 dialogOptions.modality = kWindowModalityAppModal; 779 dialogOptions.parentWindow = NULL; 780 nav.parent = NULL; 781 782#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 783 eventUPP = NewNavEventUPP((systemVersion < 0x1060) ? NavRecordMovieToEventHandler : NavGenericSaveEventHandler); 784#else 785 eventUPP = NewNavEventUPP(NavGenericSaveEventHandler); 786#endif 787 788 err = NavCreatePutFileDialog(&dialogOptions, 'SMOV', '~9X~', eventUPP, &nav, &(nav.nref)); 789 if (err == noErr) 790 { 791 if (systemVersion >= 0x1060) 792 { 793 NSAutoreleasePool *pool; 794 NSView *view; 795 NSTextField *text; 796 NSButton *cb1p, *cb2p, *cb3p, *cb4p, *cb5p, *cbre; 797 NSString *comment; 798 799 pool = [[NSAutoreleasePool alloc] init]; 800 801 view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, 433, 54)] autorelease]; 802 803 CocoaAddStatTextToView(view, @"RecordSMV6", 5, 33, 104, 14, NULL); 804 CocoaAddStatTextToView(view, @"RecordSMV7", 5, 8, 63, 14, NULL); 805 CocoaAddEditTextToView(view, @"", 74, 6, 351, 19, &text); 806 CocoaAddCheckBoxToView(view, @"RecordSMV1", 112, 31, 29, 18, &cb1p); 807 CocoaAddCheckBoxToView(view, @"RecordSMV2", 150, 31, 29, 18, &cb2p); 808 CocoaAddCheckBoxToView(view, @"RecordSMV3", 188, 31, 29, 18, &cb3p); 809 CocoaAddCheckBoxToView(view, @"RecordSMV4", 226, 31, 29, 18, &cb4p); 810 CocoaAddCheckBoxToView(view, @"RecordSMV5", 264, 31, 29, 18, &cb5p); 811 CocoaAddCheckBoxToView(view, @"RecordSMV8", 356, 31, 51, 18, &cbre); 812 813 [cb1p setState: (macRecordFlag & (1 << 0) ? NSOnState : NSOffState)]; 814 [cb2p setState: (macRecordFlag & (1 << 1) ? NSOnState : NSOffState)]; 815 [cb3p setState: (macRecordFlag & (1 << 2) ? NSOnState : NSOffState)]; 816 [cb4p setState: (macRecordFlag & (1 << 3) ? NSOnState : NSOffState)]; 817 [cb5p setState: (macRecordFlag & (1 << 4) ? NSOnState : NSOffState)]; 818 [cbre setState: (macRecordFlag & (1 << 5) ? NSOnState : NSOffState)]; 819 820 [(NSOpenPanel *) nav.nref setAccessoryView: view]; 821 822 err = NavDialogRun(nav.nref); 823 if (err) 824 NavDialogDispose(nav.nref); 825 826 macRecordFlag = 0; 827 macRecordFlag |= ((([cb1p state] == NSOnState) ? 1 : 0) << 0); 828 macRecordFlag |= ((([cb2p state] == NSOnState) ? 1 : 0) << 1); 829 macRecordFlag |= ((([cb3p state] == NSOnState) ? 1 : 0) << 2); 830 macRecordFlag |= ((([cb4p state] == NSOnState) ? 1 : 0) << 3); 831 macRecordFlag |= ((([cb5p state] == NSOnState) ? 1 : 0) << 4); 832 macRecordFlag |= ((([cbre state] == NSOnState) ? 1 : 0) << 5); 833 834 comment = [text stringValue]; 835 if (comment) 836 { 837 NSUInteger cflen; 838 unichar unistr[MOVIE_MAX_METADATA]; 839 840 cflen = [comment length]; 841 if (cflen > MOVIE_MAX_METADATA - 1) 842 cflen = MOVIE_MAX_METADATA - 1; 843 844 [comment getCharacters: unistr range: NSMakeRange(0, cflen)]; 845 846 for (unsigned i = 0; i < cflen; i++) 847 macRecordWChar[i] = (wchar_t) unistr[i]; 848 macRecordWChar[cflen] = 0; 849 } 850 else 851 macRecordWChar[0] = 0; 852 853 [pool release]; 854 } 855 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 856 else 857 { 858 err = NavDialogRun(nav.nref); 859 if (err) 860 NavDialogDispose(nav.nref); 861 } 862 #endif 863 } 864 865 DisposeNavEventUPP(eventUPP); 866 867 CFRelease(saveRef); 868 CFRelease(mesRef); 869 CFRelease(baseRef); 870 CFRelease(numRef); 871 CFRelease(romRef); 872 873#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 874 if (systemVersion < 0x1060) 875 { 876 CFRelease(nav.customWindow); 877 DisposeNibReference(nav.customNib); 878 } 879#endif 880 881 if (err) 882 return (false); 883 else 884 { 885 if (nav.reply) 886 { 887 char s[PATH_MAX + 1]; 888 889 err = FSRefMakePath(&(nav.ref), (unsigned char *) s, PATH_MAX); 890 snprintf(path, PATH_MAX + 1, "%s%s%s", s, MAC_PATH_SEPARATOR, nav.name); 891 892 return (true); 893 } 894 else 895 return (false); 896 } 897} 898 899bool8 NavPlayMovieFrom (char *path) 900{ 901 OSStatus err; 902 NavDialogCreationOptions dialogOptions; 903 NavEventUPP eventUPP; 904 NavObjectFilterUPP filterUPP; 905 NavState nav; 906 CFStringRef numRef, romRef, baseRef; 907 CFMutableStringRef mesRef; 908 SInt32 replaceAt; 909 char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; 910#ifdef MAC_TIGER_PANTHER_SUPPORT 911 NavPreviewUPP previewUPP; 912#endif 913 914#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 915 if (systemVersion < 0x1060) 916 { 917 HIViewID cid = { 'PANE', 1000 }; 918 Rect rct; 919 920 err = CreateNibReference(kMacS9XCFString, &(nav.customNib)); 921 if (err) 922 return (false); 923 924 err = CreateWindowFromNib(nav.customNib, CFSTR("PlaySMV"), &(nav.customWindow)); 925 if (err) 926 { 927 DisposeNibReference(nav.customNib); 928 return (false); 929 } 930 931 GetWindowBounds(nav.customWindow, kWindowContentRgn, &rct); 932 nav.customWidth = rct.right - rct.left; 933 nav.customHeight = rct.bottom - rct.top; 934 935 HIViewFindByID(HIViewGetRoot(nav.customWindow), cid, &(nav.customPane)); 936 } 937#endif 938 939 _splitpath(Memory.ROMFilename, drive, dir, fname, ext); 940 romRef = CFStringCreateWithCString(kCFAllocatorDefault, fname, kCFStringEncodingUTF8); 941 numRef = CFCopyLocalizedString(CFSTR("PlayFromPos"), "1"); 942 baseRef = CFCopyLocalizedString(CFSTR("PlayFromMes"), "Play"); 943 mesRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef); 944 replaceAt = CFStringGetIntValue(numRef); 945 CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef); 946 947 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 948 dialogOptions.optionFlags &= ~kNavAllowMultipleFiles; 949 dialogOptions.preferenceKey = 6; 950 dialogOptions.clientName = kMacS9XCFString; 951 dialogOptions.windowTitle = mesRef; 952 dialogOptions.modality = kWindowModalityAppModal; 953 dialogOptions.parentWindow = NULL; 954 nav.parent = NULL; 955 956#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 957 eventUPP = NewNavEventUPP((systemVersion < 0x1060) ? NavPlayMovieFromEventHandler : NavGenericOpenEventHandler); 958#else 959 eventUPP = NewNavEventUPP(NavGenericOpenEventHandler); 960#endif 961 filterUPP = NewNavObjectFilterUPP(NavPlayMovieFromFilter); 962#ifdef MAC_TIGER_PANTHER_SUPPORT 963 previewUPP = NewNavPreviewUPP(NavPlayMovieFromPreview); 964#endif 965 966#ifdef MAC_TIGER_PANTHER_SUPPORT 967 err = NavCreateChooseFileDialog(&dialogOptions, NULL, eventUPP, previewUPP, filterUPP, &nav, &(nav.nref)); 968#else 969 err = NavCreateChooseFileDialog(&dialogOptions, NULL, eventUPP, NULL, filterUPP, &nav, &(nav.nref)); 970#endif 971 if (err == noErr) 972 { 973 if (systemVersion >= 0x1060) 974 { 975 NSAutoreleasePool *pool; 976 NSView *view; 977 NSButton *cbro, *cbqt; 978 979 pool = [[NSAutoreleasePool alloc] init]; 980 981 view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, 326, 29)] autorelease]; 982 983 CocoaAddCheckBoxToView(view, @"PlaySMV1", 5, 6, 76, 18, &cbro); 984 CocoaAddCheckBoxToView(view, @"PlaySMV2", 100, 6, 220, 18, &cbqt); 985 986 [cbro setState: (macPlayFlag & (1 << 0) ? NSOnState : NSOffState)]; 987 [cbqt setState: (macPlayFlag & (1 << 1) ? NSOnState : NSOffState)]; 988 989 [(NSOpenPanel *) nav.nref setAccessoryView: view]; 990 991 err = NavDialogRun(nav.nref); 992 if (err) 993 NavDialogDispose(nav.nref); 994 995 macPlayFlag = 0; 996 macPlayFlag |= ((([cbro state] == NSOnState) ? 1 : 0) << 0); 997 macPlayFlag |= ((([cbqt state] == NSOnState) ? 1 : 0) << 1); 998 999 [pool release]; 1000 } 1001 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1002 else 1003 { 1004 err = NavDialogRun(nav.nref); 1005 if (err) 1006 NavDialogDispose(nav.nref); 1007 } 1008 #endif 1009 } 1010 1011#ifdef MAC_TIGER_PANTHER_SUPPORT 1012 DisposeNavPreviewUPP(previewUPP); 1013#endif 1014 DisposeNavObjectFilterUPP(filterUPP); 1015 DisposeNavEventUPP(eventUPP); 1016 1017 CFRelease(mesRef); 1018 CFRelease(baseRef); 1019 CFRelease(numRef); 1020 CFRelease(romRef); 1021 1022#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1023 if (systemVersion < 0x1060) 1024 { 1025 CFRelease(nav.customWindow); 1026 DisposeNibReference(nav.customNib); 1027 } 1028#endif 1029 1030 if (err) 1031 return (false); 1032 else 1033 { 1034 if (nav.reply) 1035 { 1036 err = FSRefMakePath(&(nav.ref), (unsigned char *) path, PATH_MAX); 1037 return (true); 1038 } 1039 else 1040 return (false); 1041 } 1042} 1043 1044bool8 NavQTMovieRecordTo (char *path) 1045{ 1046 OSStatus err; 1047 NavDialogCreationOptions dialogOptions; 1048 NavEventUPP eventUPP; 1049 NavState nav; 1050 CFStringRef numRef, romRef, baseRef; 1051 CFMutableStringRef mesRef, saveRef; 1052 SInt32 replaceAt; 1053 char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; 1054 1055#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1056 if (systemVersion < 0x1060) 1057 { 1058 HIViewID cid = { 'PANE', 1000 }; 1059 Rect rct; 1060 1061 err = CreateNibReference(kMacS9XCFString, &(nav.customNib)); 1062 if (err) 1063 return (false); 1064 1065 err = CreateWindowFromNib(nav.customNib, CFSTR("QTMovie"), &(nav.customWindow)); 1066 if (err) 1067 { 1068 DisposeNibReference(nav.customNib); 1069 return (false); 1070 } 1071 1072 GetWindowBounds(nav.customWindow, kWindowContentRgn, &rct); 1073 nav.customWidth = rct.right - rct.left; 1074 nav.customHeight = rct.bottom - rct.top; 1075 1076 HIViewFindByID(HIViewGetRoot(nav.customWindow), cid, &(nav.customPane)); 1077 } 1078#endif 1079 1080 _splitpath(Memory.ROMFilename, drive, dir, fname, ext); 1081 romRef = CFStringCreateWithCString(kCFAllocatorDefault, fname, kCFStringEncodingUTF8); 1082 numRef = CFCopyLocalizedString(CFSTR("QTRecordPos"), "1"); 1083 baseRef = CFCopyLocalizedString(CFSTR("QTRecordMes"), "QT"); 1084 mesRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef); 1085 saveRef = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, romRef); 1086 replaceAt = CFStringGetIntValue(numRef); 1087 CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef); 1088 CFStringAppendCString(saveRef, ".mov", CFStringGetSystemEncoding()); 1089 1090 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 1091 dialogOptions.preferenceKey = 7; 1092 dialogOptions.clientName = kMacS9XCFString; 1093 dialogOptions.windowTitle = mesRef; 1094 dialogOptions.saveFileName = saveRef; 1095 dialogOptions.modality = kWindowModalityAppModal; 1096 dialogOptions.parentWindow = NULL; 1097 nav.parent = NULL; 1098 1099#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1100 eventUPP = NewNavEventUPP((systemVersion < 0x1060) ? NavQTMovieRecordToEventHandler : NavGenericSaveEventHandler); 1101#else 1102 eventUPP = NewNavEventUPP(NavGenericSaveEventHandler); 1103#endif 1104 1105 err = NavCreatePutFileDialog(&dialogOptions, 'MooV', 'TVOD', eventUPP, &nav, &(nav.nref)); 1106 if (err == noErr) 1107 { 1108 if (systemVersion >= 0x1060) 1109 { 1110 NSAutoreleasePool *pool; 1111 NSView *view; 1112 NSPopUpButton *fpop; 1113 NSButton *cbds, *cbov, *comp; 1114 NSArray *array; 1115 NavController *controller; 1116 1117 pool = [[NSAutoreleasePool alloc] init]; 1118 1119 controller = [[[NavController alloc] init] autorelease]; 1120 view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, 433, 31)] autorelease]; 1121 1122 array = [NSArray arrayWithObjects: @"0", @"1", @"2", @"3", @"4", @"5", nil]; 1123 CocoaAddStatTextToView(view, @"QTRecord3", 185, 9, 70, 14, NULL); 1124 CocoaAddCheckBoxToView(view, @"QTRecord1", 5, 7, 85, 18, &cbds); 1125 CocoaAddCheckBoxToView(view, @"QTRecord2", 97, 7, 71, 18, &cbov); 1126 CocoaAddMPushBtnToView(view, @"QTRecord4", 313, 1, 117, 28, &comp); 1127 CocoaAddPopUpBtnToView(view, array, 255, 4, 50, 22, &fpop); 1128 1129 [cbds setState: (macQTMovFlag & (1 << 0) ? NSOnState : NSOffState)]; 1130 [cbov setState: (macQTMovFlag & (1 << 1) ? NSOnState : NSOffState)]; 1131 [fpop selectItemAtIndex: (macQTMovFlag >> 8)]; 1132 1133 [comp setTarget: controller]; 1134 [comp setAction: @selector(handleCompressButton:)]; 1135 1136 [(NSOpenPanel *) nav.nref setAccessoryView: view]; 1137 1138 err = NavDialogRun(nav.nref); 1139 if (err) 1140 NavDialogDispose(nav.nref); 1141 1142 macQTMovFlag = 0; 1143 macQTMovFlag |= ((([cbds state] == NSOnState) ? 1 : 0) << 0); 1144 macQTMovFlag |= ((([cbov state] == NSOnState) ? 1 : 0) << 1); 1145 macQTMovFlag |= ([fpop indexOfSelectedItem] << 8); 1146 1147 [pool release]; 1148 } 1149 #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1150 else 1151 { 1152 err = NavDialogRun(nav.nref); 1153 if (err) 1154 NavDialogDispose(nav.nref); 1155 } 1156 #endif 1157 } 1158 1159 DisposeNavEventUPP(eventUPP); 1160 1161 CFRelease(saveRef); 1162 CFRelease(mesRef); 1163 CFRelease(baseRef); 1164 CFRelease(numRef); 1165 CFRelease(romRef); 1166 1167#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1168 if (systemVersion < 0x1060) 1169 { 1170 CFRelease(nav.customWindow); 1171 DisposeNibReference(nav.customNib); 1172 } 1173#endif 1174 1175 if (err) 1176 return (false); 1177 else 1178 { 1179 if (nav.reply) 1180 { 1181 char s[PATH_MAX + 1]; 1182 1183 err = FSRefMakePath(&(nav.ref), (unsigned char *) s, PATH_MAX); 1184 snprintf(path, PATH_MAX + 1, "%s%s%s", s, MAC_PATH_SEPARATOR, nav.name); 1185 1186 return (true); 1187 } 1188 else 1189 return (false); 1190 } 1191} 1192 1193bool8 NavBeginChooseFolderSheet (WindowRef parent) 1194{ 1195 OSStatus err; 1196 NavDialogCreationOptions dialogOptions; 1197 1198 err = NavGetDefaultDialogCreationOptions(&dialogOptions); 1199 dialogOptions.optionFlags &= ~kNavAllowMultipleFiles; 1200 dialogOptions.preferenceKey = 8; 1201 dialogOptions.clientName = kMacS9XCFString; 1202 dialogOptions.modality = kWindowModalityWindowModal; 1203 dialogOptions.parentWindow = parent; 1204 gSheetNav.parent = parent; 1205 1206 gSheetEventUPP = NewNavEventUPP(NavGenericOpenEventHandler); 1207 1208 err = NavCreateChooseFolderDialog(&dialogOptions, gSheetEventUPP, NULL, &gSheetNav, &(gSheetNav.nref)); 1209 if (err == noErr) 1210 { 1211 err = NavDialogRun(gSheetNav.nref); 1212 if (err) 1213 { 1214 NavDialogDispose(gSheetNav.nref); 1215 DisposeNavEventUPP(gSheetEventUPP); 1216 return (false); 1217 } 1218 } 1219 else 1220 { 1221 DisposeNavEventUPP(gSheetEventUPP); 1222 return (false); 1223 } 1224 1225 return (true); 1226} 1227 1228bool8 NavEndChooseFolderSheet (FSRef *ref) 1229{ 1230 DisposeNavEventUPP(gSheetEventUPP); 1231 1232 if (gSheetNav.reply) 1233 { 1234 *ref = gSheetNav.ref; 1235 return (true); 1236 } 1237 else 1238 return (false); 1239} 1240 1241static pascal void NavGenericOpenEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1242{ 1243 OSStatus err; 1244 NavReplyRecord reply; 1245 NavUserAction userAction; 1246 NavState *nav; 1247 AEDesc resultDesc; 1248 SInt32 count; 1249 1250 nav = (NavState *) callBackUD; 1251 1252 switch (callBackSelector) 1253 { 1254 case kNavCBEvent: 1255 break; 1256 1257 case kNavCBStart: 1258 nav->reply = false; 1259 break; 1260 1261 case kNavCBUserAction: 1262 userAction = NavDialogGetUserAction(callBackParms->context); 1263 switch (userAction) 1264 { 1265 case kNavUserActionChoose: 1266 err = NavDialogGetReply(callBackParms->context, &reply); 1267 if (err == noErr) 1268 { 1269 err = AECountItems(&(reply.selection), &count); 1270 if ((err == noErr) && (count == 1)) 1271 { 1272 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1273 if (err == noErr) 1274 { 1275 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1276 if (err == noErr) 1277 nav->reply = true; 1278 1279 err = AEDisposeDesc(&resultDesc); 1280 } 1281 } 1282 1283 err = NavDisposeReply(&reply); 1284 } 1285 1286 break; 1287 } 1288 1289 break; 1290 1291 case kNavCBTerminate: 1292 NavDialogDispose(nav->nref); 1293 1294 if (nav->parent) 1295 { 1296 EventRef event; 1297 HICommand cmd; 1298 1299 cmd.commandID = 'NvDn'; 1300 cmd.attributes = kEventAttributeUserEvent; 1301 cmd.menu.menuRef = NULL; 1302 cmd.menu.menuItemIndex = 0; 1303 1304 err = CreateEvent(kCFAllocatorDefault, kEventClassCommand, kEventCommandProcess, GetCurrentEventTime(), kEventAttributeUserEvent, &event); 1305 if (err == noErr) 1306 { 1307 err = SetEventParameter(event, kEventParamDirectObject, typeHICommand, sizeof(HICommand), &cmd); 1308 if (err == noErr) 1309 err = SendEventToWindow(event, nav->parent); 1310 1311 ReleaseEvent(event); 1312 } 1313 } 1314 1315 break; 1316 } 1317} 1318 1319static pascal void NavGenericSaveEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1320{ 1321 OSStatus err; 1322 NavReplyRecord reply; 1323 NavUserAction userAction; 1324 NavState *nav; 1325 AEDesc resultDesc; 1326 1327 nav = (NavState *) callBackUD; 1328 1329 switch (callBackSelector) 1330 { 1331 case kNavCBEvent: 1332 break; 1333 1334 case kNavCBStart: 1335 nav->reply = false; 1336 break; 1337 1338 case kNavCBUserAction: 1339 userAction = NavDialogGetUserAction(callBackParms->context); 1340 switch (userAction) 1341 { 1342 case kNavUserActionSaveAs: 1343 err = NavDialogGetReply(callBackParms->context, &reply); 1344 if (err == noErr) 1345 { 1346 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1347 if (err == noErr) 1348 { 1349 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1350 if (err == noErr) 1351 { 1352 Boolean r; 1353 1354 r = CFStringGetCString(reply.saveFileName, nav->name, PATH_MAX, kCFStringEncodingUTF8); 1355 if (r) 1356 nav->reply = true; 1357 } 1358 1359 err = AEDisposeDesc(&resultDesc); 1360 } 1361 1362 err = NavDisposeReply(&reply); 1363 } 1364 1365 break; 1366 } 1367 1368 break; 1369 1370 case kNavCBTerminate: 1371 NavDialogDispose(nav->nref); 1372 break; 1373 } 1374} 1375 1376#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 1377static pascal void NavOpenCartEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1378{ 1379 static Boolean embedded = false; 1380 1381 OSStatus err; 1382 NavReplyRecord reply; 1383 NavUserAction userAction; 1384 NavState *nav; 1385 HIViewRef ctl; 1386 HIViewID cid; 1387 HIViewPartCode part; 1388 AEDesc resultDesc; 1389 Point pt; 1390 SInt32 count; 1391 1392 nav = (NavState *) callBackUD; 1393 1394 switch (callBackSelector) 1395 { 1396 case kNavCBEvent: 1397 switch (callBackParms->eventData.eventDataParms.event->what) 1398 { 1399 case mouseDown: 1400 pt = callBackParms->eventData.eventDataParms.event->where; 1401 GlobalPointToWindowLocalPoint(&pt, callBackParms->window); 1402 1403 ctl = FindControlUnderMouse(pt, callBackParms->window, &part); 1404 if (ctl) 1405 { 1406 GetControlID(ctl, &cid); 1407 if (cid.signature == 'CCTL') 1408 part = HandleControlClick(ctl, pt, callBackParms->eventData.eventDataParms.event->modifiers, (ControlActionUPP) -1L); 1409 } 1410 1411 break; 1412 } 1413 1414 break; 1415 1416 case kNavCBStart: 1417 nav->reply = false; 1418 cid.signature = 'CCTL'; 1419 err = NavCustomControl(callBackParms->context, kNavCtlAddControl, nav->customPane); 1420 1421 cid.id = 101; 1422 HIViewFindByID(nav->customPane, cid, &ctl); 1423 SetControl32BitValue(ctl, romDetect + 1); 1424 1425 cid.id = 102; 1426 HIViewFindByID(nav->customPane, cid, &ctl); 1427 SetControl32BitValue(ctl, interleaveDetect + 1); 1428 1429 cid.id = 103; 1430 HIViewFindByID(nav->customPane, cid, &ctl); 1431 SetControl32BitValue(ctl, videoDetect + 1); 1432 1433 cid.id = 104; 1434 HIViewFindByID(nav->customPane, cid, &ctl); 1435 SetControl32BitValue(ctl, headerDetect + 1); 1436 1437 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1438 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1439 1440 embedded = true; 1441 1442 break; 1443 1444 case kNavCBAccept: 1445 cid.signature = 'CCTL'; 1446 1447 cid.id = 101; 1448 HIViewFindByID(nav->customPane, cid, &ctl); 1449 romDetect = GetControl32BitValue(ctl) - 1; 1450 1451 cid.id = 102; 1452 HIViewFindByID(nav->customPane, cid, &ctl); 1453 interleaveDetect = GetControl32BitValue(ctl) - 1; 1454 1455 cid.id = 103; 1456 HIViewFindByID(nav->customPane, cid, &ctl); 1457 videoDetect = GetControl32BitValue(ctl) - 1; 1458 1459 cid.id = 104; 1460 HIViewFindByID(nav->customPane, cid, &ctl); 1461 headerDetect = GetControl32BitValue(ctl) - 1; 1462 1463 break; 1464 1465 case kNavCBCustomize: 1466 if ((callBackParms->customRect.right == 0) && (callBackParms->customRect.bottom == 0)) // First call 1467 { 1468 embedded = false; 1469 1470 callBackParms->customRect.right = callBackParms->customRect.left + nav->customWidth; 1471 callBackParms->customRect.bottom = callBackParms->customRect.top + nav->customHeight; 1472 } 1473 1474 break; 1475 1476 case kNavCBAdjustRect: 1477 if (embedded) 1478 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1479 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1480 1481 break; 1482 1483 case kNavCBUserAction: 1484 userAction = NavDialogGetUserAction(callBackParms->context); 1485 switch (userAction) 1486 { 1487 case kNavUserActionChoose: 1488 err = NavDialogGetReply(callBackParms->context, &reply); 1489 if (err == noErr) 1490 { 1491 err = AECountItems(&(reply.selection), &count); 1492 if ((err == noErr) && (count == 1)) 1493 { 1494 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1495 if (err == noErr) 1496 { 1497 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1498 if (err == noErr) 1499 nav->reply = true; 1500 1501 err = AEDisposeDesc(&resultDesc); 1502 } 1503 } 1504 1505 err = NavDisposeReply(&reply); 1506 } 1507 1508 break; 1509 } 1510 1511 break; 1512 1513 case kNavCBTerminate: 1514 NavDialogDispose(nav->nref); 1515 1516 if (nav->parent) 1517 { 1518 EventRef event; 1519 HICommand cmd; 1520 1521 cmd.commandID = 'NvDn'; 1522 cmd.attributes = kEventAttributeUserEvent; 1523 cmd.menu.menuRef = NULL; 1524 cmd.menu.menuItemIndex = 0; 1525 1526 err = CreateEvent(kCFAllocatorDefault, kEventClassCommand, kEventCommandProcess, GetCurrentEventTime(), kEventAttributeUserEvent, &event); 1527 if (err == noErr) 1528 { 1529 err = SetEventParameter(event, kEventParamDirectObject, typeHICommand, sizeof(HICommand), &cmd); 1530 if (err == noErr) 1531 err = SendEventToWindow(event, nav->parent); 1532 1533 ReleaseEvent(event); 1534 } 1535 } 1536 1537 break; 1538 } 1539} 1540 1541static pascal void NavPlayMovieFromEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1542{ 1543 static Boolean embedded = false; 1544 1545 OSStatus err; 1546 NavReplyRecord reply; 1547 NavUserAction userAction; 1548 NavState *nav; 1549 HIViewRef ctl; 1550 HIViewID cid; 1551 HIViewPartCode part; 1552 AEDesc resultDesc; 1553 Point pt; 1554 SInt32 count; 1555 1556 nav = (NavState *) callBackUD; 1557 1558 switch (callBackSelector) 1559 { 1560 case kNavCBEvent: 1561 switch (callBackParms->eventData.eventDataParms.event->what) 1562 { 1563 case mouseDown: 1564 pt = callBackParms->eventData.eventDataParms.event->where; 1565 GlobalPointToWindowLocalPoint(&pt, callBackParms->window); 1566 1567 ctl = FindControlUnderMouse(pt, callBackParms->window, &part); 1568 if (ctl) 1569 { 1570 GetControlID(ctl, &cid); 1571 if (cid.signature == 'PCTL') 1572 part = HandleControlClick(ctl, pt, callBackParms->eventData.eventDataParms.event->modifiers, (ControlActionUPP) -1L); 1573 } 1574 1575 break; 1576 } 1577 1578 break; 1579 1580 case kNavCBStart: 1581 nav->reply = false; 1582 cid.signature = 'PCTL'; 1583 err = NavCustomControl(callBackParms->context, kNavCtlAddControl, nav->customPane); 1584 1585 for (cid.id = 101; cid.id <= 102; cid.id++) 1586 { 1587 HIViewFindByID(nav->customPane, cid, &ctl); 1588 SetControl32BitValue(ctl, (macPlayFlag & (1 << (cid.id - 101))) ? true : false); 1589 } 1590 1591 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1592 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1593 1594 embedded = true; 1595 1596 break; 1597 1598 case kNavCBAccept: 1599 macPlayFlag = 0; 1600 cid.signature = 'PCTL'; 1601 1602 for (cid.id = 101; cid.id <= 102; cid.id++) 1603 { 1604 HIViewFindByID(nav->customPane, cid, &ctl); 1605 if (GetControl32BitValue(ctl)) 1606 macPlayFlag |= (1 << (cid.id - 101)); 1607 } 1608 1609 break; 1610 1611 case kNavCBCustomize: 1612 if ((callBackParms->customRect.right == 0) && (callBackParms->customRect.bottom == 0)) // First call 1613 { 1614 embedded = false; 1615 1616 callBackParms->customRect.right = callBackParms->customRect.left + nav->customWidth; 1617 callBackParms->customRect.bottom = callBackParms->customRect.top + nav->customHeight; 1618 } 1619 1620 break; 1621 1622 case kNavCBAdjustRect: 1623 if (embedded) 1624 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1625 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1626 1627 break; 1628 1629 case kNavCBUserAction: 1630 userAction = NavDialogGetUserAction(callBackParms->context); 1631 switch (userAction) 1632 { 1633 case kNavUserActionChoose: 1634 err = NavDialogGetReply(callBackParms->context, &reply); 1635 if (err == noErr) 1636 { 1637 err = AECountItems(&(reply.selection), &count); 1638 if ((err == noErr) && (count == 1)) 1639 { 1640 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1641 if (err == noErr) 1642 { 1643 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1644 if (err == noErr) 1645 nav->reply = true; 1646 1647 err = AEDisposeDesc(&resultDesc); 1648 } 1649 } 1650 1651 err = NavDisposeReply(&reply); 1652 } 1653 1654 break; 1655 } 1656 1657 break; 1658 1659 case kNavCBTerminate: 1660 NavDialogDispose(nav->nref); 1661 break; 1662 } 1663} 1664 1665static pascal void NavRecordMovieToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1666{ 1667 static Boolean embedded = false; 1668 1669 OSStatus err; 1670 NavReplyRecord reply; 1671 NavUserAction userAction; 1672 NavState *nav; 1673 HIViewRef ctl; 1674 HIViewID cid; 1675 HIViewPartCode part; 1676 CFStringRef sref; 1677 CFIndex cflen; 1678 AEDesc resultDesc; 1679 Point pt; 1680 UniChar unistr[MOVIE_MAX_METADATA]; 1681 1682 nav = (NavState *) callBackUD; 1683 1684 switch (callBackSelector) 1685 { 1686 case kNavCBEvent: 1687 switch (callBackParms->eventData.eventDataParms.event->what) 1688 { 1689 case mouseDown: 1690 pt = callBackParms->eventData.eventDataParms.event->where; 1691 GlobalPointToWindowLocalPoint(&pt, callBackParms->window); 1692 1693 ctl = FindControlUnderMouse(pt, callBackParms->window, &part); 1694 if (ctl) 1695 { 1696 GetControlID(ctl, &cid); 1697 if (cid.signature == 'RCTL') 1698 { 1699 if (cid.id == 107) 1700 { 1701 HIViewRef tmp; 1702 1703 err = GetKeyboardFocus(callBackParms->window, &tmp); 1704 if ((err == noErr) && (tmp != ctl)) 1705 err = SetKeyboardFocus(callBackParms->window, ctl, kControlFocusNextPart); 1706 } 1707 1708 part = HandleControlClick(ctl, pt, callBackParms->eventData.eventDataParms.event->modifiers, (ControlActionUPP) -1L); 1709 } 1710 } 1711 1712 break; 1713 } 1714 1715 break; 1716 1717 case kNavCBStart: 1718 nav->reply = false; 1719 cid.signature = 'RCTL'; 1720 err = NavCustomControl(callBackParms->context, kNavCtlAddControl, nav->customPane); 1721 1722 for (cid.id = 101; cid.id <= 106; cid.id++) 1723 { 1724 HIViewFindByID(nav->customPane, cid, &ctl); 1725 SetControl32BitValue(ctl, (macRecordFlag & (1 << (cid.id - 101))) ? true : false); 1726 } 1727 1728 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1729 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1730 1731 embedded = true; 1732 break; 1733 1734 case kNavCBAccept: 1735 macRecordFlag = 0; 1736 cid.signature = 'RCTL'; 1737 1738 for (cid.id = 101; cid.id <= 106; cid.id++) 1739 { 1740 HIViewFindByID(nav->customPane, cid, &ctl); 1741 if (GetControl32BitValue(ctl)) 1742 macRecordFlag |= (1 << (cid.id - 101)); 1743 } 1744 1745 cid.id = 107; 1746 HIViewFindByID(nav->customPane, cid, &ctl); 1747 CopyEditTextCFString(ctl, &sref); 1748 if (sref) 1749 { 1750 cflen = CFStringGetLength(sref); 1751 if (cflen > MOVIE_MAX_METADATA - 1) 1752 cflen = MOVIE_MAX_METADATA - 1; 1753 1754 CFStringGetCharacters(sref, CFRangeMake(0, cflen), unistr); 1755 1756 for (int i = 0; i < cflen; i++) 1757 macRecordWChar[i] = (wchar_t) unistr[i]; 1758 macRecordWChar[cflen] = 0; 1759 1760 CFRelease(sref); 1761 } 1762 else 1763 macRecordWChar[0] = 0; 1764 1765 break; 1766 1767 case kNavCBCustomize: 1768 if ((callBackParms->customRect.right == 0) && (callBackParms->customRect.bottom == 0)) // First call 1769 { 1770 embedded = false; 1771 1772 callBackParms->customRect.right = callBackParms->customRect.left + nav->customWidth; 1773 callBackParms->customRect.bottom = callBackParms->customRect.top + nav->customHeight; 1774 } 1775 1776 break; 1777 1778 case kNavCBAdjustRect: 1779 if (embedded) 1780 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1781 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1782 1783 break; 1784 1785 case kNavCBUserAction: 1786 userAction = NavDialogGetUserAction(callBackParms->context); 1787 switch (userAction) 1788 { 1789 case kNavUserActionSaveAs: 1790 err = NavDialogGetReply(callBackParms->context, &reply); 1791 if (err == noErr) 1792 { 1793 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1794 if (err == noErr) 1795 { 1796 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1797 if (err == noErr) 1798 { 1799 Boolean r; 1800 1801 r = CFStringGetCString(reply.saveFileName, nav->name, PATH_MAX, kCFStringEncodingUTF8); 1802 if (r) 1803 nav->reply = true; 1804 } 1805 1806 err = AEDisposeDesc(&resultDesc); 1807 } 1808 1809 err = NavDisposeReply(&reply); 1810 } 1811 1812 break; 1813 } 1814 1815 break; 1816 1817 case kNavCBTerminate: 1818 NavDialogDispose(nav->nref); 1819 break; 1820 } 1821} 1822 1823static pascal void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 1824{ 1825 static Boolean embedded = false; 1826 1827 OSStatus err; 1828 NavReplyRecord reply; 1829 NavUserAction userAction; 1830 NavState *nav; 1831 HIViewRef ctl; 1832 HIViewID cid; 1833 HIViewPartCode part; 1834 AEDesc resultDesc; 1835 Point pt; 1836 1837 nav = (NavState *) callBackUD; 1838 1839 switch (callBackSelector) 1840 { 1841 case kNavCBEvent: 1842 switch (callBackParms->eventData.eventDataParms.event->what) 1843 { 1844 case mouseDown: 1845 pt = callBackParms->eventData.eventDataParms.event->where; 1846 GlobalPointToWindowLocalPoint(&pt, callBackParms->window); 1847 1848 ctl = FindControlUnderMouse(pt, callBackParms->window, &part); 1849 if (ctl) 1850 { 1851 GetControlID(ctl, &cid); 1852 if (cid.signature == 'QCTL') 1853 part = HandleControlClick(ctl, pt, callBackParms->eventData.eventDataParms.event->modifiers, (ControlActionUPP) -1L); 1854 1855 if (cid.id == 103) 1856 MacQTVideoConfig(); 1857 } 1858 1859 break; 1860 } 1861 1862 break; 1863 1864 case kNavCBStart: 1865 nav->reply = false; 1866 cid.signature = 'QCTL'; 1867 err = NavCustomControl(callBackParms->context, kNavCtlAddControl, nav->customPane); 1868 1869 for (cid.id = 101; cid.id <= 102; cid.id++) 1870 { 1871 HIViewFindByID(nav->customPane, cid, &ctl); 1872 SetControl32BitValue(ctl, (macQTMovFlag & (1 << (cid.id - 101))) ? true : false); 1873 } 1874 1875 cid.id = 104; 1876 HIViewFindByID(nav->customPane, cid, &ctl); 1877 SetControl32BitValue(ctl, ((macQTMovFlag & 0xFF00) >> 8) + 1); 1878 1879 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1880 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1881 1882 embedded = true; 1883 1884 break; 1885 1886 case kNavCBAccept: 1887 macQTMovFlag = 0; 1888 cid.signature = 'QCTL'; 1889 1890 for (cid.id = 101; cid.id <= 102; cid.id++) 1891 { 1892 HIViewFindByID(nav->customPane, cid, &ctl); 1893 if (GetControl32BitValue(ctl)) 1894 macQTMovFlag |= (1 << (cid.id - 101)); 1895 } 1896 1897 cid.id = 104; 1898 HIViewFindByID(nav->customPane, cid, &ctl); 1899 macQTMovFlag |= ((GetControl32BitValue(ctl) - 1) << 8); 1900 1901 break; 1902 1903 case kNavCBCustomize: 1904 if ((callBackParms->customRect.right == 0) && (callBackParms->customRect.bottom == 0)) // First call 1905 { 1906 embedded = false; 1907 1908 callBackParms->customRect.right = callBackParms->customRect.left + nav->customWidth; 1909 callBackParms->customRect.bottom = callBackParms->customRect.top + nav->customHeight; 1910 } 1911 1912 break; 1913 1914 case kNavCBAdjustRect: 1915 if (embedded) 1916 MoveControl(nav->customPane, ((callBackParms->customRect.right - callBackParms->customRect.left) - nav->customWidth ) / 2 + callBackParms->customRect.left, 1917 ((callBackParms->customRect.bottom - callBackParms->customRect.top ) - nav->customHeight) / 2 + callBackParms->customRect.top); 1918 1919 break; 1920 1921 case kNavCBUserAction: 1922 userAction = NavDialogGetUserAction(callBackParms->context); 1923 switch (userAction) 1924 { 1925 case kNavUserActionSaveAs: 1926 err = NavDialogGetReply(callBackParms->context, &reply); 1927 if (err == noErr) 1928 { 1929 err = AEGetNthDesc(&(reply.selection), 1, typeFSRef, NULL, &resultDesc); 1930 if (err == noErr) 1931 { 1932 err = AEGetDescData(&resultDesc, &(nav->ref), sizeof(FSRef)); 1933 if (err == noErr) 1934 { 1935 Boolean r; 1936 1937 r = CFStringGetCString(reply.saveFileName, nav->name, PATH_MAX, kCFStringEncodingUTF8); 1938 if (r) 1939 nav->reply = true; 1940 } 1941 1942 err = AEDisposeDesc(&resultDesc); 1943 } 1944 1945 err = NavDisposeReply(&reply); 1946 } 1947 1948 break; 1949 } 1950 1951 break; 1952 1953 case kNavCBTerminate: 1954 NavDialogDispose(nav->nref); 1955 break; 1956 } 1957} 1958#endif 1959 1960static pascal Boolean NavOpenCartFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) 1961{ 1962 OSStatus err; 1963 AEDesc resultDesc; 1964 Boolean result = true; 1965 1966 err = AECoerceDesc(theItem, typeFSRef, &resultDesc); 1967 if (err == noErr) 1968 { 1969 FSRef ref; 1970 1971 err = AEGetDescData(&resultDesc, &ref, sizeof(FSRef)); 1972 if (err == noErr) 1973 { 1974 FSCatalogInfo catinfo; 1975 HFSUniStr255 unistr; 1976 1977 err = FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags, &catinfo, &unistr, NULL, NULL); 1978 if ((err == noErr) && !(catinfo.nodeFlags & kFSNodeIsDirectoryMask) && (unistr.length > 4)) 1979 { 1980 UInt16 i = unistr.length; 1981 1982 if ((unistr.unicode[i - 4] == '.') && 1983 (((unistr.unicode[i - 3] == 's') && (unistr.unicode[i - 2] == 'r') && (unistr.unicode[i - 1] == 'm')) || 1984 ((unistr.unicode[i - 3] == 'f') && (unistr.unicode[i - 2] == 'r') && (unistr.unicode[i - 1] == 'z')) || 1985 ((unistr.unicode[i - 3] == 's') && (unistr.unicode[i - 2] == 'm') && (unistr.unicode[i - 1] == 'v')) || 1986 ((unistr.unicode[i - 3] == 'm') && (unistr.unicode[i - 2] == 'o') && (unistr.unicode[i - 1] == 'v')) || 1987 ((unistr.unicode[i - 3] == 's') && (unistr.unicode[i - 2] == 'p') && (unistr.unicode[i - 1] == 'c')) || 1988 ((unistr.unicode[i - 3] == 'r') && (unistr.unicode[i - 2] == 't') && (unistr.unicode[i - 1] == 'c')) || 1989 ((unistr.unicode[i - 3] == 'd') && (unistr.unicode[i - 2] == 'a') && (unistr.unicode[i - 1] == 't')) || 1990 ((unistr.unicode[i - 3] == 'o') && (unistr.unicode[i - 2] == 'u') && (unistr.unicode[i - 1] == 't')) || 1991 ((unistr.unicode[i - 3] == 'c') && (unistr.unicode[i - 2] == 'h') && (unistr.unicode[i - 1] == 't')) || 1992 ((unistr.unicode[i - 3] == 'i') && (unistr.unicode[i - 2] == 'p') && (unistr.unicode[i - 1] == 's')) || 1993 ((unistr.unicode[i - 3] == 'u') && (unistr.unicode[i - 2] == 'p') && (unistr.unicode[i - 1] == 's')) || 1994 ((unistr.unicode[i - 3] == 'p') && (unistr.unicode[i - 2] == 'n') && (unistr.unicode[i - 1] == 'g')))) 1995 result = false; 1996 } 1997 } 1998 1999 AEDisposeDesc(&resultDesc); 2000 } 2001 2002 return (result); 2003} 2004 2005static pascal Boolean NavDefrostFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) 2006{ 2007 OSStatus err; 2008 AEDesc resultDesc; 2009 Boolean result = true; 2010 2011 err = AECoerceDesc(theItem, typeFSRef, &resultDesc); 2012 if (err == noErr) 2013 { 2014 FSRef ref; 2015 2016 err = AEGetDescData(&resultDesc, &ref, sizeof(FSRef)); 2017 if (err == noErr) 2018 { 2019 FSCatalogInfo catinfo; 2020 HFSUniStr255 unistr; 2021 2022 err = FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catinfo, &unistr, NULL, NULL); 2023 if ((err == noErr) && !(catinfo.nodeFlags & kFSNodeIsDirectoryMask)) 2024 { 2025 if (((FileInfo *) &catinfo.finderInfo)->fileType != 'SAVE') 2026 { 2027 UInt16 i = unistr.length; 2028 2029 if (i < 4) 2030 result = false; 2031 else 2032 if ((unistr.unicode[i - 4] == '.') && (unistr.unicode[i - 3] == 'f') && (unistr.unicode[i - 2] == 'r')) 2033 result = true; 2034 else 2035 result = false; 2036 } 2037 } 2038 } 2039 2040 AEDisposeDesc(&resultDesc); 2041 } 2042 2043 return (result); 2044} 2045 2046static pascal Boolean NavPlayMovieFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) 2047{ 2048 OSStatus err; 2049 AEDesc resultDesc; 2050 Boolean result = true; 2051 2052 err = AECoerceDesc(theItem, typeFSRef, &resultDesc); 2053 if (err == noErr) 2054 { 2055 FSRef ref; 2056 2057 err = AEGetDescData(&resultDesc, &ref, sizeof(FSRef)); 2058 if (err == noErr) 2059 { 2060 FSCatalogInfo catinfo; 2061 HFSUniStr255 unistr; 2062 2063 err = FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catinfo, &unistr, NULL, NULL); 2064 if ((err == noErr) && !(catinfo.nodeFlags & kFSNodeIsDirectoryMask)) 2065 { 2066 if (((FileInfo *) &catinfo.finderInfo)->fileType != 'SMOV') 2067 { 2068 UInt16 i = unistr.length; 2069 2070 if (i < 4) 2071 result = false; 2072 else 2073 if ((unistr.unicode[i - 4] == '.') && (unistr.unicode[i - 3] == 's') && (unistr.unicode[i - 2] == 'm') && (unistr.unicode[i - 1] == 'v')) 2074 result = true; 2075 else 2076 result = false; 2077 } 2078 } 2079 } 2080 2081 AEDisposeDesc(&resultDesc); 2082 } 2083 2084 return (result); 2085} 2086 2087#ifdef MAC_TIGER_PANTHER_SUPPORT 2088static pascal Boolean NavDefrostFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 2089{ 2090 if (systemVersion >= 0x1050) 2091 return (true); 2092 2093 OSStatus err; 2094 Boolean previewShowing, result = false; 2095 2096 err = NavCustomControl(callBackParms->context, kNavCtlIsPreviewShowing, &previewShowing); 2097 if ((err == noErr) && previewShowing) 2098 { 2099 AEDesc resultDesc; 2100 2101 err = AECoerceDesc((AEDesc *) callBackParms->eventData.eventDataParms.param, typeFSRef, &resultDesc); 2102 if (err == noErr) 2103 { 2104 FSRef ref; 2105 2106 err = AEGetDescData(&resultDesc, &ref, sizeof(FSRef)); 2107 if (err == noErr) 2108 { 2109 FSCatalogInfo catinfo; 2110 2111 err = FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoContentMod, &catinfo, NULL, NULL, NULL); 2112 if ((err == noErr) && !(catinfo.nodeFlags & kFSNodeIsDirectoryMask)) 2113 { 2114 CFMutableStringRef sref; 2115 2116 sref = CFStringCreateMutable(kCFAllocatorDefault, 0); 2117 if (sref) 2118 { 2119 CFAbsoluteTime at; 2120 CFDateFormatterRef format; 2121 CFLocaleRef locale; 2122 CFStringRef datstr; 2123 2124 err = UCConvertUTCDateTimeToCFAbsoluteTime(&(catinfo.contentModDate), &at); 2125 locale = CFLocaleCopyCurrent(); 2126 format = CFDateFormatterCreate(kCFAllocatorDefault, locale, kCFDateFormatterShortStyle, kCFDateFormatterMediumStyle); 2127 datstr = CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, format, at); 2128 CFStringAppend(sref, datstr); 2129 CFRelease(datstr); 2130 CFRelease(format); 2131 CFRelease(locale); 2132 2133 CGContextRef ctx; 2134 CGRect bounds; 2135 CGrafPtr port; 2136 Rect rct; 2137 int rightedge; 2138 2139 port = GetWindowPort(callBackParms->window); 2140 GetWindowBounds(callBackParms->window, kWindowContentRgn, &rct); 2141 2142 err = QDBeginCGContext(port, &ctx); 2143 2144 rightedge = (callBackParms->previewRect.right < (rct.right - rct.left - 11)) ? callBackParms->previewRect.right : (rct.right - rct.left - 11); 2145 2146 bounds.origin.x = (float) callBackParms->previewRect.left; 2147 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.bottom); 2148 bounds.size.width = (float) (rightedge - callBackParms->previewRect.left); 2149 bounds.size.height = (float) (callBackParms->previewRect.bottom - callBackParms->previewRect.top); 2150 2151 CGContextClipToRect(ctx, bounds); 2152 2153 CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f); 2154 CGContextFillRect(ctx, bounds); 2155 CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 1.0f); 2156 2157 bounds.origin.x = (float) (callBackParms->previewRect.left + ((callBackParms->previewRect.right - callBackParms->previewRect.left - 128) >> 1)); 2158 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.top - 120 - 25); 2159 bounds.size.width = 128.0f; 2160 bounds.size.height = 120.0f; 2161 2162 DrawThumbnailResource(&ref, ctx, bounds); 2163 2164 HIThemeTextInfo textinfo; 2165 2166 textinfo.version = 0; 2167 textinfo.state = kThemeStateActive; 2168 textinfo.fontID = kThemeSmallSystemFont; 2169 textinfo.verticalFlushness = kHIThemeTextVerticalFlushTop; 2170 textinfo.horizontalFlushness = kHIThemeTextHorizontalFlushCenter; 2171 textinfo.options = 0; 2172 textinfo.truncationPosition = kHIThemeTextTruncationMiddle; 2173 textinfo.truncationMaxLines = 0; 2174 textinfo.truncationHappened = false; 2175 2176 bounds.origin.x = (float) (callBackParms->previewRect.left + 10); 2177 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.top - 153 - 20); 2178 bounds.size.width = (float) (callBackParms->previewRect.right - callBackParms->previewRect.left - 20); 2179 bounds.size.height = 20.0f; 2180 2181 err = HIThemeDrawTextBox(sref, &bounds, &textinfo, ctx, kHIThemeOrientationInverted); 2182 2183 CGContextSynchronize(ctx); 2184 2185 err = QDEndCGContext(port, &ctx); 2186 2187 CFRelease(sref); 2188 2189 result = true; 2190 } 2191 } 2192 } 2193 2194 AEDisposeDesc(&resultDesc); 2195 } 2196 } 2197 2198 return (result); 2199} 2200 2201static pascal Boolean NavPlayMovieFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) 2202{ 2203 if (systemVersion >= 0x1050) 2204 return (true); 2205 2206 OSStatus err; 2207 Boolean previewShowing, result = false; 2208 2209 err = NavCustomControl(callBackParms->context, kNavCtlIsPreviewShowing, &previewShowing); 2210 if ((err == noErr) && previewShowing) 2211 { 2212 AEDesc resultDesc; 2213 2214 err = AECoerceDesc((AEDesc *) callBackParms->eventData.eventDataParms.param, typeFSRef, &resultDesc); 2215 if (err == noErr) 2216 { 2217 FSRef ref; 2218 2219 err = AEGetDescData(&resultDesc, &ref, sizeof(FSRef)); 2220 if (err == noErr) 2221 { 2222 char path[PATH_MAX + 1]; 2223 2224 err = FSRefMakePath(&ref, (unsigned char *) path, PATH_MAX); 2225 if (err == noErr) 2226 { 2227 MovieInfo movinfo; 2228 int r; 2229 2230 r = S9xMovieGetInfo(path, &movinfo); 2231 if (r == SUCCESS) 2232 { 2233 UTCDateTime utctime; 2234 CGContextRef ctx; 2235 CGRect bounds; 2236 CGrafPtr port; 2237 Rect rct; 2238 CFStringRef sref; 2239 UInt64 t; 2240 int rightedge, border, width, l, sec, min, hr, n; 2241 char cstr[256], cbuf[512]; 2242 UniChar unistr[MOVIE_MAX_METADATA]; 2243 2244 sref = CFCopyLocalizedString(CFSTR("MoviePrevBorder"), "1"); 2245 if (sref) 2246 { 2247 border = CFStringGetIntValue(sref); 2248 CFRelease(sref); 2249 } 2250 else 2251 border = 1; 2252 2253 sref = CFCopyLocalizedString(CFSTR("MoviePrevWidth"), "1"); 2254 if (sref) 2255 { 2256 width = CFStringGetIntValue(sref); 2257 CFRelease(sref); 2258 } 2259 else 2260 width = 1; 2261 2262 // Date 2263 2264 t = (UInt64) movinfo.TimeCreated + ((365 * 66 + 17) * 24 * 60 * 60); 2265 utctime.highSeconds = (UInt16) (t >> 32); 2266 utctime.lowSeconds = (UInt32) (t & 0xFFFFFFFF); 2267 utctime.fraction = 0; 2268 2269 CFAbsoluteTime at; 2270 CFDateFormatterRef format; 2271 CFLocaleRef locale; 2272 CFStringRef datstr; 2273 Boolean e; 2274 2275 err = UCConvertUTCDateTimeToCFAbsoluteTime(&utctime, &at); 2276 locale = CFLocaleCopyCurrent(); 2277 format = CFDateFormatterCreate(kCFAllocatorDefault, locale, kCFDateFormatterShortStyle, kCFDateFormatterNoStyle); 2278 datstr = CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, format, at); 2279 e = CFStringGetCString(datstr, cbuf, sizeof(cbuf), CFStringGetSystemEncoding()); 2280 CFRelease(datstr); 2281 CFRelease(format); 2282 strcat(cbuf, "\n"); 2283 format = CFDateFormatterCreate(kCFAllocatorDefault, locale, kCFDateFormatterNoStyle, kCFDateFormatterMediumStyle); 2284 datstr = CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, format, at); 2285 e = CFStringGetCString(datstr, cstr, sizeof(cstr), CFStringGetSystemEncoding()); 2286 CFRelease(datstr); 2287 CFRelease(format); 2288 strcat(cbuf, cstr); 2289 strcat(cbuf, "\n"); 2290 CFRelease(locale); 2291 2292 // Length 2293 2294 l = (movinfo.LengthFrames + 30) / ((movinfo.Opts & MOVIE_OPT_PAL) ? 50 : 60); 2295 sec = l % 60; l /= 60; 2296 min = l % 60; l /= 60; 2297 hr = l % 60; 2298 2299 sprintf(cstr, "%02d:%02d:%02d\n", hr, min, sec); 2300 strcat(cbuf, cstr); 2301 2302 // Frames 2303 2304 sprintf(cstr, "%d\n", movinfo.LengthFrames); 2305 strcat(cbuf, cstr); 2306 2307 // 2308 2309 port = GetWindowPort(callBackParms->window); 2310 GetWindowBounds(callBackParms->window, kWindowContentRgn, &rct); 2311 2312 err = QDBeginCGContext(port, &ctx); 2313 2314 rightedge = (callBackParms->previewRect.right < (rct.right - rct.left - 11)) ? callBackParms->previewRect.right : (rct.right - rct.left - 11); 2315 2316 bounds.origin.x = (float) callBackParms->previewRect.left; 2317 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.bottom); 2318 bounds.size.width = (float) (rightedge - callBackParms->previewRect.left); 2319 bounds.size.height = (float) (callBackParms->previewRect.bottom - callBackParms->previewRect.top); 2320 2321 CGContextClipToRect(ctx, bounds); 2322 2323 CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f); 2324 CGContextFillRect(ctx, bounds); 2325 CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 1.0f); 2326 2327 // Thumbnail 2328 2329 bounds.origin.x = (float) (callBackParms->previewRect.left + ((callBackParms->previewRect.right - callBackParms->previewRect.left - 128) >> 1)); 2330 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.top - 120 - 25); 2331 bounds.size.width = 128.0f; 2332 bounds.size.height = 120.0f; 2333 2334 DrawThumbnailResource(&ref, ctx, bounds); 2335 2336 // Text 2337 2338 HIThemeTextInfo textinfo; 2339 2340 textinfo.version = 0; 2341 textinfo.state = kThemeStateActive; 2342 textinfo.fontID = kThemeSmallSystemFont; 2343 textinfo.verticalFlushness = kHIThemeTextVerticalFlushTop; 2344 textinfo.options = 0; 2345 textinfo.truncationPosition = kHIThemeTextTruncationMiddle; 2346 textinfo.truncationMaxLines = 0; 2347 textinfo.truncationHappened = false; 2348 2349 bounds.origin.x = (float) (((callBackParms->previewRect.right - callBackParms->previewRect.left - width) >> 1) + callBackParms->previewRect.left + border + 7); 2350 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.top - 153 - 60); 2351 bounds.size.width = (float) callBackParms->previewRect.right - bounds.origin.x; 2352 bounds.size.height = 60.0f; 2353 2354 sref = CFStringCreateWithCString(kCFAllocatorDefault, cbuf, CFStringGetSystemEncoding()); 2355 if (sref) 2356 { 2357 textinfo.horizontalFlushness = kHIThemeTextHorizontalFlushLeft; 2358 err = HIThemeDrawTextBox(sref, &bounds, &textinfo, ctx, kHIThemeOrientationInverted); 2359 CFRelease(sref); 2360 } 2361 2362 bounds.origin.x = (float) callBackParms->previewRect.left; 2363 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.top - 153 - 60); 2364 bounds.size.width = (float) (((callBackParms->previewRect.right - callBackParms->previewRect.left - width) >> 1) + border); 2365 bounds.size.height = 60.0f; 2366 2367 sref = CFCopyLocalizedString(CFSTR("MoviePrevMes"), "MovieInfo"); 2368 if (sref) 2369 { 2370 textinfo.horizontalFlushness = kHIThemeTextHorizontalFlushRight; 2371 err = HIThemeDrawTextBox(sref, &bounds, &textinfo, ctx, kHIThemeOrientationInverted); 2372 CFRelease(sref); 2373 } 2374 2375 bounds.origin.x = (float) (((callBackParms->previewRect.right - callBackParms->previewRect.left - 132) >> 1) + callBackParms->previewRect.left); 2376 bounds.origin.y = (float) (rct.bottom - rct.top - callBackParms->previewRect.bottom + 10); 2377 bounds.size.width = 132.0f; 2378 bounds.size.height = (float) (callBackParms->previewRect.bottom - callBackParms->previewRect.top - 223 - 10); 2379 2380 n = wcslen(movinfo.Metadata); 2381 2382 for (int i = 0; i < n; i++) 2383 unistr[i] = (UniChar) movinfo.Metadata[i]; 2384 unistr[n] = 0; 2385 2386 sref = CFStringCreateWithCharacters(kCFAllocatorDefault, unistr, n); 2387 if (sref) 2388 { 2389 textinfo.horizontalFlushness = kHIThemeTextHorizontalFlushLeft; 2390 err = HIThemeDrawTextBox(sref, &bounds, &textinfo, ctx, kHIThemeOrientationInverted); 2391 CFRelease(sref); 2392 } 2393 2394 CGContextSynchronize(ctx); 2395 2396 err = QDEndCGContext(port, &ctx); 2397 2398 result = true; 2399 } 2400 } 2401 } 2402 2403 AEDisposeDesc(&resultDesc); 2404 } 2405 } 2406 2407 return (result); 2408} 2409#endif 2410 2411#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT 2412static void GlobalPointToWindowLocalPoint (Point *pt, WindowRef window) 2413{ 2414 if (systemVersion >= 0x1040) 2415 { 2416 HIViewRef view; 2417 HIPoint cpt = CGPointMake((float) pt->h, (float) pt->v); 2418 2419 HIViewFindByID(HIViewGetRoot(window), kHIViewWindowContentID, &view); 2420 HIPointConvert(&cpt, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, view); 2421 pt->h = (short) cpt.x; 2422 pt->v = (short) cpt.y; 2423 } 2424#ifdef MAC_PANTHER_SUPPORT 2425 else 2426 QDGlobalToLocalPoint(GetWindowPort(window), pt); 2427#endif 2428} 2429#endif 2430