⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mydocument.mm

📁 彩信浏览器
💻 MM
📖 第 1 页 / 共 2 页
字号:
- (IBAction)play:(id)sender{	if (!myMainloop) return;	[NSThread detachNewThreadSelector: @selector(startPlay:) toTarget: self withObject: NULL];	[self validateButtons: nil];}- (void)startPlay: (id)dummy{	// XXXX Jack thinks that this extra thread is no longer needed (20060124)	if (!myMainloop) return;    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];        assert([NSThread isMultiThreaded]);	myMainloop->play();	// We don't use refcounting on myMainloop, because	// otherwise our player infrastructure will be destructed in this	// thread, and at that time the window (and the ambulantWidget) is	// gone. So the main thread does the cleanup and zaps myMainloop.	while (myMainloop && (myMainloop->is_play_active()||myMainloop->is_pause_active())) {		AM_DBG NSLog(@"validating in separate thread");		[self validateButtons: nil];		sleep(1);	}	AM_DBG NSLog(@"validating in separate thread - final");	[self validateButtons: nil];    [pool release];	// myMainloop->release();}- (IBAction)stop:(id)sender{    AM_DBG NSLog(@"Stop");	if (myMainloop) myMainloop->stop();	[self validateButtons: nil];}- (void *)view{    return view;}- (void)close{	[self stop: self];	play_button = nil;	stop_button = nil;	pause_button = nil;#ifdef WITH_AUX_MAINLOOP	delete myAuxMainloop;	myAuxMainloop = NULL;#endif	delete myMainloop;	myMainloop = NULL;	delete embedder;	embedder = NULL;	[super close];}- (void)close: (id)dummy{	[self close];}- (void)fixMouse: (id)dummy{	mainloop *ml = myMainloop;#ifdef WITH_AUX_MAINLOOP	if (myAuxMainloop) ml = myAuxMainloop;#endif	if (!ml) return;	int cursor = ml->after_mousemove();	AM_DBG NSLog(@"Fixing mouse to %d", cursor);	if (cursor == 0) {		if ([NSCursor currentCursor] != [NSCursor arrowCursor]) {			[[NSCursor arrowCursor] set];			// XXX This is a bit of a hack: hovering over an anchor			// stats the status line, but the reset "never happens"			// so we clear the status line here. This should really			// be done more intelligently in smil_player.			if (status_line) [status_line setStringValue: @""];		}	} else if (cursor == 1) {		if ([NSCursor currentCursor] != [NSCursor pointingHandCursor])			[[NSCursor pointingHandCursor] set];	} else {		NSLog(@"Warning: unknown cursor index %d", cursor);	}}- (void)resetMouse: (id)dummy{	mainloop *ml = myMainloop;#ifdef WITH_AUX_MAINLOOP	if (myAuxMainloop) ml = myAuxMainloop;#endif	if (ml) ml->before_mousemove(0);}- (void)keyDown: (NSEvent *)ev{	mainloop *ml = myMainloop;#ifdef WITH_AUX_MAINLOOP	if (myAuxMainloop) ml = myAuxMainloop;#endif	NSString *chars = [ev characters];		if (chars && [chars length] == 1 && ml) {		unichar ch = [chars characterAtIndex:0];		// First, escape will exit fullscreen mode		if (ch == '\033') {			[self goWindowMode: self];			return;		}		ambulant::common::preferences* prefs = ambulant::common::preferences::get_preferences();		if (prefs->m_tabbed_links) {			if (ch == '\t') {				ml->on_focus_advance();				return;			}			if (ch == '\r' || ch == '\n') {				ml->on_focus_activate();				return;			}		}		ml->on_char(ch);	} else {		AM_DBG NSLog(@"MyDocument::keyDown: dropping %@", chars);	}}- (void) setStatusLine: (NSString *)message{	if (status_line) [status_line setStringValue: message];	[message release];}- (IBAction)goWindowMode:(id)sender{	if (!saved_window) {		NSLog(@"goWindowMode: already in window mode");		return;	}    // Get the screen information.    NSScreen* screen = [[view window] screen];	if (screen == NULL) screen = [NSScreen mainScreen];     NSDictionary* screenInfo = [screen deviceDescription];     NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"];    // Release the screen.    CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue];     CGDisplayErr err = CGDisplayRelease(displayID);    if (err != CGDisplayNoErr) {		NSLog(@"goFullScreen: CGDisplayRelease failed");		return;	}		// Attach our view to the normal window. 	NSWindow *mScreenWindow = [view window];	NSView *savedcontentview = [saved_window contentView];	[savedcontentview addSubview: view];	[view setFrame: saved_view_rect];	[savedcontentview setNeedsDisplay:YES];	[saved_window makeFirstResponder: view];	[saved_window setAcceptsMouseMovedEvents: YES];	// Tell our controller that the normal window is in use again.	NSWindowController* winController = [[self windowControllers]											 objectAtIndex:0];	[winController setWindow:saved_window];	// Get rid of the fullscreen window	[mScreenWindow close];	[saved_window makeKeyAndOrderFront:self];		// And clear saved_window, which signals we're in normal mode again.	[saved_window release];	saved_window = nil;}- (IBAction)goFullScreen:(id)sender{	if (saved_window) {		NSLog(@"goFullScreen: already in fullscreen mode");		return;	}    // Get the screen information.    NSScreen* screen = [[view window] screen];	if (screen == NULL) screen = [NSScreen mainScreen];     NSDictionary* screenInfo = [screen deviceDescription];     NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"];	NSLog(@"goFullScreen: screenID = %@", screenID);     // Capture the screen.    CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue];     CGDisplayErr err = CGDisplayCapture(displayID);    if (err != CGDisplayNoErr) {		NSLog(@"goFullScreen: CGDisplayCapture failed");		return;	}	// Create the full-screen window.	NSRect winRect = [screen frame];#if 1	// The (x, y) coordinates are nonzero for a non-primary screen, it appears that	// the rect is for the virtual combination of all screens, with (0, 0) rooted	// at the origin of the main screen.	winRect.origin.x = 0;	winRect.origin.y = 0;#endif	NSWindow *mScreenWindow;	mScreenWindow = [[FullScreenWindow alloc] initWithContentRect:winRect			styleMask:NSBorderlessWindowMask 			backing:NSBackingStoreBuffered 			defer:NO 			screen:screen];	// Establish the window attributes.	[mScreenWindow setDelegate:self];	[mScreenWindow setBackgroundColor: [NSColor blackColor]];	// Remember the old window, and move our view to the fullscreen	// window.	saved_window = [view window];	[saved_window retain];	// Create the outer view on the fullscreen window, and insert the	// ambulant view within it.	NSView *fsmainview = [[NSView alloc] initWithFrame: winRect];		id contentview = view;	saved_view_rect = [contentview frame];	[fsmainview addSubview: contentview];	NSRect contentRect = [contentview frame];	float xExtra = NSWidth(winRect) - NSWidth(contentRect);	float yExtra = NSHeight(winRect) - NSHeight(contentRect);	[contentview setFrameOrigin: NSMakePoint(xExtra/2, yExtra/2)];		[mScreenWindow setContentView: fsmainview];	[fsmainview setNeedsDisplay:YES];	[fsmainview release];	[mScreenWindow makeFirstResponder: contentview];	[mScreenWindow setAcceptsMouseMovedEvents: YES];	// Make the screen window the current document window.	// Be sure to retain the previous window if you want to  use it again.	NSWindowController* winController = [[self windowControllers]											 objectAtIndex:0];	[winController setWindow:mScreenWindow];	// The window has to be above the level of the shield window.	int32_t     shieldLevel = CGShieldingWindowLevel();	[mScreenWindow setLevel:shieldLevel];	// Show the window.	[mScreenWindow makeKeyAndOrderFront:self];}- (IBAction) toggleFullScreen: (id)sender{	if (saved_window)		[self goWindowMode: sender];	else		[self goFullScreen:sender];}#ifdef WITH_AUX_DOCUMENT- (BOOL)openAuxDocument: (NSURL *)auxUrl{//	embedder = new document_embedder(self);	delete myAuxMainloop;	if (myAuxView) {		[myAuxView removeFromSuperview];		myAuxView = NULL;	}	myAuxView = [[MyAmbulantView alloc] initWithFrame: [view bounds]];	[view addSubview: myAuxView];	[[view window] makeFirstResponder: myAuxView];	NSLog(@"openAuxDocument %@", auxUrl);	myAuxMainloop = new mainloop([[auxUrl absoluteString] UTF8String], myAuxView, false, NULL);	myAuxMainloop->play();	return true;}- (void)closeAuxDocument{	NSLog(@"closeAuxDocument");	delete myAuxMainloop;	myAuxMainloop = NULL;	if (myAuxView) {		[myAuxView removeFromSuperview];		myAuxView = NULL;		[[view window] makeFirstResponder: view];	}}#endif // WITH_AUX_DOCUMENT@end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -