예제 #1
0
void cvSetModeWindow_CARBON( const char* name, double prop_value)//Yannick Verdie
{
    OSStatus err = noErr;


    CV_FUNCNAME( "cvSetModeWindow_QT" );

    __BEGIN__;

    CvWindow* window;

    if(!name)
        CV_ERROR( CV_StsNullPtr, "NULL name string" );

    window = icvFindWindowByName( name );
    if( !window )
        CV_ERROR( CV_StsNullPtr, "NULL window" );

    if(window->flags & CV_WINDOW_AUTOSIZE)//if the flag CV_WINDOW_AUTOSIZE is set
        EXIT;

    if (window->status==CV_WINDOW_FULLSCREEN && prop_value==CV_WINDOW_NORMAL)
    {
        err = EndFullScreen(window->restoreState,0);
        if (err != noErr)
            fprintf(stdout,"Error EndFullScreen\n");
        window->window = window->oldwindow;
        ShowWindow( window->window );

        window->status=CV_WINDOW_NORMAL;
        EXIT;
    }

    if (window->status==CV_WINDOW_NORMAL && prop_value==CV_WINDOW_FULLSCREEN)
    {
        GDHandle device;
        err = GetWindowGreatestAreaDevice(window->window, kWindowTitleBarRgn, &device, NULL);
        if (err != noErr)
            fprintf(stdout,"Error GetWindowGreatestAreaDevice\n");

        HideWindow(window->window);
        window->oldwindow = window->window;
        err = BeginFullScreen(&(window->restoreState), device, 0, 0, &window->window, 0, fullScreenAllowEvents | fullScreenDontSwitchMonitorResolution);
        if (err != noErr)
            fprintf(stdout,"Error BeginFullScreen\n");

        window->status=CV_WINDOW_FULLSCREEN;
        EXIT;
    }

    __END__;
}
예제 #2
0
파일: win.c 프로젝트: Vykook/acme-sac
static void
full_screen(void)
{
	if(!amFullScreen) {
		oldWindow = theWindow;
		HideWindow(theWindow);
		GDHandle device;
		GetWindowGreatestAreaDevice(theWindow, kWindowTitleBarRgn, &device, NULL);
		BeginFullScreen(&fullScreenRestore, device, 0, 0, &theWindow, 0, 0);
		amFullScreen = 1;
		window_resized();
		Rectangle rect =  { { 0, 0 }, { bounds.size.width, bounds.size.height } };
		wmtrack(0, rect.max.x, rect.max.y, 0);
		drawqlock();
		flushmemscreen(rect);
		drawqunlock();
	} else
		leave_full_screen();
}
예제 #3
0
void
x_full_screen(int do_full)
{
	
#if 0
	WindowRef new_window;
	short	width, height;
	OSErr	ret;
	
	width = 640;
	height = 480;
	if(do_full && (g_mac_fullscreen_state == 0)) {
		g_main_window_saved = g_main_window;
		
		GetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
		ret = BeginFullScreen(&g_mac_fullscreen_state, 0,
							  &width, &height, &new_window, 0, 0);
		printf("Ret beginfullscreen: %d\n", (int)ret);
		printf("New width: %d, new height: %d\n", width, height);
		if(ret == noErr) {
			g_main_window = new_window;
		} else {
			g_mac_fullscreen_state = 0;
		}
	} else if(!do_full && (g_mac_fullscreen_state != 0)) {
		ret = EndFullScreen(g_mac_fullscreen_state, 0);
		printf("ret endfullscreen: %d\n", (int)ret);
		g_main_window = g_main_window_saved;
		g_mac_fullscreen_state = 0;
		//InitCursor();
		SetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
	}
	
	update_main_window_size();
	
	ShowWindow(g_main_window);
	BringToFront(g_main_window);
	update_window();
#endif
}
예제 #4
0
static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	Rect wrect, orect;
#if TARGET_API_MAC_CARBON
	Rect tmprect;
#endif

	/* Free any previous video mode */
	ROM_UnsetVideoMode(this, current);

	/* Create the ROM window and SDL video surface */
	current->flags = 0;		/* Clear flags */
	current->w = width;
	current->h = height;
	SetRect(&wrect, 0, 0, width, height);
	if ( SDL_Window ) {
		/* If we recreate the window, don't move it around */
#if TARGET_API_MAC_CARBON
		orect = *GetWindowPortBounds(SDL_Window, &tmprect);
#else
		orect = SDL_Window->portRect;
#endif
		OffsetRect(&wrect, orect.left, orect.top);
	} else {
		/* Center the window the first time we show it */
		OffsetRect(&wrect,
		(SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2);
	}

#if defined(__MACOSX__) && !USE_QUICKTIME
	/* Hum.. fullscreen mode is broken */
	flags &= ~SDL_FULLSCREEN;
#endif
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		/* Create the fullscreen window and use screen bits */
		current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN;
		if ( SDL_Window ) {
			DisposeWindow(SDL_Window);
		}
#if USE_QUICKTIME
		BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0);
#else
		SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
						(WindowPtr)-1, false, 0);
		ROM_HideMenuBar(this);
#endif
		current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
		current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
		this->UpdateRects = ROM_DirectUpdate;
	} else {
		GWorldPtr memworld;
		PixMapHandle pixmap;
		int style;

		style = noGrowDocProc;
		if ( flags & SDL_NOFRAME ) {
			style = plainDBox;
			current->flags |= SDL_NOFRAME;
		} else
		if ( flags & SDL_RESIZABLE ) {
			style = zoomDocProc;
			current->flags |= SDL_RESIZABLE;
		}
		if ( SDL_Window && (style == current_style) ) {
			/* Resize existing window, if necessary */
			if ( ((orect.right-orect.left) != width) ||
			     ((orect.bottom-orect.top) != height) ) {
				SizeWindow(SDL_Window, width, height, false);
			}
		} else {
			/* Recreate the window in the new style */
			if ( SDL_Window ) {
				DisposeWindow(SDL_Window);
			}
			SDL_Window = NewCWindow(nil, &wrect, "\p", true,
			                        style, (WindowPtr)-1, true, 0);

			/* Set the window title, if any */
			{ char *title;
				SDL_WM_GetCaption(&title, NULL);
				if ( title ) {
					Mac_SetCaption(this, title, NULL);
				}
			}
		}
		current_style = style;
		SetPalette(SDL_Window, SDL_CPal, false);
		ActivatePalette(SDL_Window);
		if ( NewGWorld(&memworld, 0,
#if TARGET_API_MAC_CARBON
			       GetWindowPortBounds(SDL_Window, &tmprect),
#else
			       &SDL_Window->portRect,
#endif
			       SDL_CTab, nil, 0) != noErr ) {
			SDL_SetError("NewGWorld() failed");
			return(NULL);
		}
		SetWRefCon(SDL_Window, (long)memworld);
		pixmap = GetGWorldPixMap(memworld);
		LockPixels(pixmap);
		current->pitch = (**pixmap).rowBytes & 0x3FFF;
		current->pixels = GetPixBaseAddr(pixmap);
		this->UpdateRects = ROM_WindowUpdate;
	}
	SetPortWindowPort(SDL_Window);
	SelectWindow(SDL_Window);

	/* Handle OpenGL support */
	if ( flags & SDL_OPENGL ) {
		if ( Mac_GL_Init(this) == 0 ) {
			current->flags |= SDL_OPENGL;
		} else {
			current = NULL;
		}
	}
	
	if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) )
	   current->flags |= SDL_HWPALETTE;
	   
	/* We're live! */
	return(current);
}
예제 #5
0
int main(int argc, char* argv[])
{
    IBNibRef 		nibRef;
    WindowRef 		window;
    
    OSStatus		err;
	
	eh2_EventHeapFactory* factory;

	//EY:
	char name[] = "fuller";
	if (argc>1) { //More than just the function call
		//strcpy(&name,argv[0]);
		printf("Arg num %d\n", argc);
		printf("Name without arg %s\n", name);
		printf("Want to connect to %s\n", argv[1]);
		strcpy(name,argv[1]);
	}
	
	printf("Connecting to %s\n", name);
	id = 0;
	wheelPos = 0;

    // Create a Nib reference passing the name of the nib file (without the .nib extension)
    // CreateNibReference only searches into the application bundle.
    err = CreateNibReference(CFSTR("main"), &nibRef);
    require_noerr( err, CantGetNibRef );
    
    // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar
    // object. This name is set in InterfaceBuilder when the nib is created.
    //err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
    //require_noerr( err, CantSetMenuBar );
    // Then create a window. "MainWindow" is the name of the window object. This name is set in 
    // InterfaceBuilder when the nib is created.
    //err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
	//err = CreateCustomWindow(null, ,&window);
	//UInt32 attributes = kWindowNoShadowAttribute | kWindowNoActivatesAttribute | kWindowOpaqueForEventsAttribute ;
	//UInt32 attributes = kWindowNoShadowAttribute | kWindowNoActivatesAttribute;
	//UInt32 attributes = 0x000000;
	Rect size;
	//[NSScreen mainScreen];
	size.top = 0;
	size.left = 0;
	size.bottom = 400;
	size.right = 600;
	printf("b4 create");


	//Have to make it a window that cannot refocus
	// + has to delegates all events to underlying window
    //err = CreateNewWindow(CGShieldingWindowLevel(),attributes,&size,&window);
	//err = CreateNewWindow(kModalWindowClass,attributes,&size,&window);
	err = CreateNewWindow(kFloatingWindowClass,0,&size,&window);
	//WindowActivationScope scope = kWindowActivationScopeNone;
	//SetWindowActivationScope(&window, scope);
	//err = CreateNewWindow(kOverlayWindowClass, overlayAttributes,&window,&size,null);
	Ptr      oldState;
	BeginFullScreen(&oldState,nil,0,0,&window,0,fullScreenAllowEvents);
	
	printf("aft create");
	require_noerr( err, CantCreateWindow );
	printf("no error");
	
    // We don't need the nib reference anymore.
    DisposeNibReference(nibRef);
    
	//Change the window such that it is transparent and passing the event 
	//[window setLevel:NSNormalWindowLevel]
	//setAlphaValue:
	//
	//window->setLevel(NSScreenSaverWindowLevel);
	//SetWindowAlpha(window, 0.5);
	SetWindowAlpha(window, 0.0);
	//SendWindowGroupBehind(window, GetWindowGroupOfClass(kDocumentWindowClass));
	
    // The window was created hidden so show it.
    ShowWindow( window );

	//EY:
    EventTypeSpec    eventTypes[1];
	EventHandlerUPP  handlerUPP;
	eventTypes[0].eventClass = kEventClassMouse;
	eventTypes[0].eventKind  = kEventMouseWheelMoved;
		
	handlerUPP = NewEventHandlerUPP(MouseHandler);
	
	//printf("install event handler\n");
	InstallApplicationEventHandler (handlerUPP,
									1, eventTypes,
									NULL, NULL);
	
	//Init event heap
	eh2_init(NULL,NULL);
	factory = eh2_EventHeapFactory::cs_getInstance();
	eventHeapPtr = factory->createEventHeap(
											NULL,
											name,
											-1
											);
	
    // Call the event loop
    RunApplicationEventLoop();

	CantCreateWindow:
	CantSetMenuBar:
	CantGetNibRef:
		return err;
}