Beispiel #1
0
int main( void )
{
    CFPlugInRef         plugIn;
	
    //  Load our plugin.
	
    plugIn = MyLoadPlugIn();
    if( plugIn ) {
	
        //  Initialize the application -- create the main window, set up its event handlers
        //  and install a event loop timer to periodically draw balls.
	
        Initialize();
		
        //  Start the main event loop. RunApplicationEventLoop will not complete until
        //  QuitApplicationEventLoop is called.
		
        RunApplicationEventLoop();
		
        //  We're done with the drawBall interface now, so call its release function to let
        //  it do any cleanup.

        (*gDrawBallInterface)->Release( gDrawBallInterface );
 
        //  Finally, release the CFPlugInRef itself.
 
        CFRelease( plugIn );
    }
    return 0;
}
Beispiel #2
0
void Shell::EventLoop(ShellIdleFunction idle_function)
{
	OSStatus error;
	error = InstallApplicationEventHandler(NewEventHandlerUPP(InputMacOSX::EventHandler),
										   GetEventTypeCount(INPUT_EVENTS),
										   INPUT_EVENTS,
										   NULL,
										   NULL);
	if (error != noErr)
		DisplayError("Unable to install handler for input events, error: %d.", error);

	error = InstallWindowEventHandler(window,
									  NewEventHandlerUPP(EventHandler),
									  GetEventTypeCount(WINDOW_EVENTS),
									  WINDOW_EVENTS,
									  NULL,
									  NULL);
	if (error != noErr)
		DisplayError("Unable to install handler for window events, error: %d.", error);

	EventLoopTimerRef timer;
	error = InstallEventLoopIdleTimer(GetMainEventLoop(),							// inEventLoop
									  0,											// inFireDelay
									  5 * kEventDurationMillisecond,				// inInterval (200 Hz)
									  NewEventLoopIdleTimerUPP(IdleTimerCallback),	// inTimerProc
									  (void*) idle_function,						// inTimerData,
									  &timer										// outTimer
									  );
	if (error != noErr)
		DisplayError("Unable to install Carbon event loop timer, error: %d.", error);

	RunApplicationEventLoop();
}
// --------------------------------------------------------------------------------------
int main(void)
{
	WindowRef window;
	
	initialize();		// initialization

	RunApplicationEventLoop();		// application event loop
	
									// finalization
	for (window = FrontNonFloatingWindow(); window != NULL; window = FrontNonFloatingWindow())
	{
		if (GetWindowKind(window) == kDialogWindowKind)
			ClosePrefsDialog(GetDialogFromWindow(window));
		else	// kApplicationWindowKind
		{
			HICommand closeCommand;
			
			closeCommand.attributes = 0;	// not from a menu, control, or window
			closeCommand.commandID = kHICommandClose;
			ProcessHICommand(&closeCommand);
		}
	}
	
	DisposeAEEventHandlerUPP(gOpenAppAEHandler);
	DisposeAEEventHandlerUPP(gQuitAppAEHandler);
	DisposeAEEventHandlerUPP(gViewsFontChangedAEHandler);
	DisposeEventHandlerUPP(gAppEventHandler);
	
	return 0;
}
// --------------------------------------------------------------------------------------
int main(void)
{
	WindowRef window;
	FourCharCode prefsWindowKind;
	
	initialize();		// initialization

	RunApplicationEventLoop();		// application event loop
	
									// finalization
	for (window = FrontNonFloatingWindow(); window != NULL; window = FrontNonFloatingWindow())
	{
		GetWindowProperty(window, kAppSignature, kPrefsWindowKindTag, sizeof(FourCharCode), 
							NULL, &prefsWindowKind);
		
		if (prefsWindowKind == kPrefsWindowKindDialog)
			ClosePrefsDialog(window);
		else	// kPrefsWindowKindWindow
		{
			HICommand closeCommand;
			
			closeCommand.attributes = 0;	// not from a menu, control, or window
			closeCommand.commandID = kHICommandClose;
			ProcessHICommand(&closeCommand);
		}
	}
	
	DisposeAEEventHandlerUPP(gOpenAppAEHandler);
	DisposeAEEventHandlerUPP(gQuitAppAEHandler);
	DisposeAEEventHandlerUPP(gViewsFontChangedAEHandler);
	DisposeEventHandlerUPP(gAppEventHandler);
	
	return 0;
}
Beispiel #5
0
int wxEventLoop::Run()
{
    wxEventLoopActivator activate(this);

    RunApplicationEventLoop();

    return m_exitcode;
}
Beispiel #6
0
void
R_runCarbonEventLoop(void)
{
#if 1
  RunApplicationEventLoop();
#else
  RunCurrentEventLoop(kEventDurationForever);
#endif
}
Beispiel #7
0
int main(int argc, char* argv[])
{
    IBNibRef 		nibRef;
    WindowRef 		window;
    HIViewRef		textView;
	OSStatus		err;

    // 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. "MainDocumentWindow" is the name of the window object. This name is set in 
    // InterfaceBuilder when the nib is created.
    err = CreateWindowFromNib(nibRef, CFSTR("MainDocumentWindow"), &window);
    require_noerr( err, CantCreateWindow );

    // We don't need the nib reference anymore.
    DisposeNibReference(nibRef);

	// Make the window's content area transparent
	err = MakeWindowTransparent(window);
    require_noerr( err, CantMakeWindowTransparent );

	// Get a reference to the TextView in the main window
	err = HIViewFindByID(HIViewGetRoot(window), gTextViewID, &textView);
	require_noerr( err, CantGetTextView );

	// Install our default options in the TextView
	err = MySetTextViewOptions(textView);
	require_noerr( err, CantSetTextViewOptions );

	// Make the TextView partially transparent
	err = TextViewSetAlpha(textView, 0.25);
	require_noerr( err, CantSetTextViewOptions );
	
    // The window was created hidden so show it.
    ShowWindow( window );

    // Call the event loop
    RunApplicationEventLoop();

CantSetTextViewOptions:
CantGetTextView:
CantMakeWindowTransparent:
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
	return err;
}
/*****************************************************
*
* main (argc, argv) 
*
* Purpose:  main program entry point
*
* Notes:	   You might want to change this to something more verbose
*
* Inputs:   argc     - the number of elements in the argv array
*				argv     - an array of pointers to the parameters to this application
*
* Returns:  int      - error code (0 == no error) 
*/
int main(int argc, char* argv[])
	{
	OSStatus status;
	
	// Can we run this particular demo application?
	long response;
	status = Gestalt(gestaltSystemVersion, &response);
	Boolean ok = ((noErr == status) && (response >= 0x00001030));
	if (!ok)
		{
		DialogRef theAlert;
		CreateStandardAlert(kAlertStopAlert, CFSTR("Mac OS X 10.3 (minimum) is required for this application"), NULL, NULL, &theAlert);
		RunStandardAlert(theAlert, NULL, NULL);
		ExitToShell();
		}
	
	// Create a Nib reference passing the name of the nib file (without the .nib extension)
	// CreateNibReference only searches into the application bundle.
	status = CreateNibReference(CFSTR("main"), &gIBNibRef);
	require_noerr(status, 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.
	status = SetMenuBarFromNib(gIBNibRef, CFSTR("MenuBar"));
	require_noerr(status, CantSetMenuBar);
	
	// Adding a Font menu
	MenuRef fontMenu = GetMenuRef(3);
	require(fontMenu != NULL, CantSetMenuBar);
	status = CreateStandardFontMenu(fontMenu, 0, 0, 0, NULL);
	require_noerr(status, CantSetMenuBar);
	
	// Enabling Preferences menu item
	EnableMenuCommand(NULL, kHICommandPreferences);
	
	// Let's react to User's commands.
	Install_AppleEventHandlers();
	
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	InstallEventHandler(GetApplicationEventTarget(), Handle_CommandProcess, 1, &eventTypeCP, NULL, NULL);
	
	EventTypeSpec eventTypeCUS = {kEventClassCommand, kEventCommandUpdateStatus};
	InstallEventHandler(GetApplicationEventTarget(), Handle_CommandUpdateStatus, 1, &eventTypeCUS, NULL, NULL);
	
	EventTypeSpec eventTypeAA = {kEventClassApplication,  kEventAppActivated};
	InstallEventHandler(GetApplicationEventTarget(), Handle_AppActivated, 1, &eventTypeAA, NULL, NULL);
	
	// Call the event loop
	RunApplicationEventLoop();
	
CantSetMenuBar:
CantGetNibRef:
	return status;
	}   // main
Beispiel #9
0
int main(int argc, char* argv[])
{
    OSStatus err;
    
    // Create and show our main window and menubar
    err = CreateMainWindow();
    
    // Call the event loop
    RunApplicationEventLoop();

    return err;
}
Beispiel #10
0
int main(int argc, char* argv[])
{
	IBNibRef 		nibRef;
	OSStatus		err;
	
	InitCursor();

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS.DLL was loaded (2.4 is required)");
		return 0;
	}

	// check the correct BASS_FX was loaded
	if (HIWORD(BASS_FX_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS_FX.DLL was loaded (2.4 is required)");
		return 0;
	}

	// initialize default output device
	if(!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	// Create Window and Stuff
	err = CreateNibReference(CFSTR("reverse"), &nibRef);
	if (err) return err;
	err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &win);
	if (err) return err;
	DisposeNibReference(nibRef);

	SetupControlHandler(10,kEventControlHit,OpenEventHandler);
	SetControlAction(GetControl(11),NewControlActionUPP(VolEventHandler));
	SetControlAction(GetControl(13),NewControlActionUPP(TempoEventHandler));
	SetControlAction(GetControl(15),NewControlActionUPP(PosEventHandler));
	SetupControlHandler(16,kEventControlHit,DirEventHandler);

	EventLoopTimerRef timer;
	InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/2,TimerProc,0,&timer);

	// The window was created hidden so show it.
	ShowWindow(win);
    
	// Call the event loop
	RunApplicationEventLoop();
   
	// Close output
	BASS_Free();

	return 0;
}
Beispiel #11
0
int wxApp::MainLoop()
{
    m_keepGoing = TRUE;
#if wxMAC_USE_RAEL
    RunApplicationEventLoop() ;
#else
    while (m_keepGoing)
    {
        MacDoOneEvent() ;
    }
#endif
    return 0;
}
Beispiel #12
0
/*
 * If we got no arguments install the apple event handlers and our event loop.
 */
void LauncherSetup_md(int argc) {
    OSErr err;
    AEEventHandlerUPP openDocEventHandler;
    AEEventHandlerUPP openAppEventHandler;
    char **argv = NULL;
    int no = 0;

    // If we got more than one argument we were launched from the commandline,
    // so don't install any handlers.
    if (argc > 1)
        return;

    if (gInitialized)
        return;

    gInitialized = true;

    // We need to handle open events for the functionality we're looking for.
    openDocEventHandler = NewAEEventHandlerUPP((AEEventHandlerProcPtr)OpenDocEventHandler);
    openAppEventHandler = NewAEEventHandlerUPP((AEEventHandlerProcPtr)OpenAppEventHandler);

    err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, openDocEventHandler, 0, TRUE);
    if(err) {
        fprintf(stderr, "Error installing open event handler\n");
        exit(-1);
    }

    err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, openAppEventHandler, 0, TRUE);
    if(err) {
        fprintf(stderr, "Error installing open app handler\n");
        exit(-1);
    }

    // Enter the event loop and handle appleevents.  If we were given files to open
    // they will appear here.
    RunApplicationEventLoop();

    if (gRunAppManager) {
        // Three arguments -- app name, no file, and null.
        argv = (char**)malloc(sizeof(char*) * 3);
        no = 0;
        argv[no++] = GetWebStartAppName();
        argv[no] = NULL;

        // Call into our main app.
        main(no, argv);
    } else {
        exit(0);
    }

}
Beispiel #13
0
void doloop(void)
{
	EventHandlerRef		menu_event;
	EventHandlerUPP		menu_upp;
	EventTypeSpec		app_menu_events[]={{kEventClassCommand,kEventProcessCommand}};
	
	menu_upp=NewEventHandlerUPP(app_event_menu);						   
	InstallEventHandler(GetApplicationEventTarget(),menu_upp,GetEventTypeCount(app_menu_events),app_menu_events,NULL,&menu_event);
	
	RunApplicationEventLoop();

	RemoveEventHandler(menu_event);
	DisposeEventHandlerUPP(menu_upp);
}
int main(void)
{
	OSStatus    err;
    UInt32      response;
        
    err = Gestalt(gestaltSystemVersion, (long *) &response);
    if (err == noErr) {
        if ( response < 0x1020 ) {
            SInt16 junkHit;
            
            (void) StandardAlert(
                kAlertStopAlert, 
                "\pLoginItemsAETest requires Mac OS X 10.2 or later.", 
                "\p",
                NULL, 
                &junkHit
            );
            
            err = userCanceledErr;
        }
    }
    
	// Start up the UI.
	
    if (err == noErr) {
        err = SetupUserInterface();
    }
	
	// Install our HICommand handler.
	
	if (err == noErr) {
		gApplicationEventHandlerUPP = NewEventHandlerUPP(ApplicationEventHandler);
		assert(gApplicationEventHandlerUPP != NULL);

		err = InstallApplicationEventHandler(gApplicationEventHandlerUPP, 
											 GetEventTypeCount(kApplicationEvents), 
											 kApplicationEvents, NULL, NULL);
	}
	
	// Run the application.
	
	if (err == noErr) {
		RunApplicationEventLoop();
	}

	DisplayError(err);

	return 0;
}
Beispiel #15
0
 void WindowBase::MainLoop()
 {
     OSXWindowData *windowData = (OSXWindowData*) GetWRefCon (mWindowHandle);
     windowData->StartedApplicationLoop = true;
     windowData->MainLoopEventHandler = NewEventLoopTimerUPP(MainLoopEventHandler);
     PRCORE_ASSERT_EXCEPTION( noErr !=  InstallEventLoopTimer (GetCurrentEventLoop(),
                                     0,
                                     mMainFreq,
                                     windowData->MainLoopEventHandler,
                                     (void *) windowData,
                                     &windowData->EventMainLoopReference
                                     ));
     
     
     RunApplicationEventLoop();
 }
Beispiel #16
0
int main( void )
{
	OSErr	err;
	
	err	= InitializeApplication();
	if ( err != noErr )	goto Bail;
	
	SendCommandProcessEvent( kHICommandNew );							//	Send a kHICommandNew to ourselves to create a default new window
	
	RunApplicationEventLoop();

Bail:	
	if ( g.mainNib != NULL )	DisposeNibReference( g.mainNib );
	if ( g.mainBundle != NULL )	CFRelease( g.mainBundle );
	return( noErr );
}
Beispiel #17
0
play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv) {
ProcessSerialNumber myPsn;
char myPsnStr[5+10+1+10+1];

	GetCurrentProcess(&myPsn);
	snprintf(myPsnStr, 5+10+1+10+1, "-psn_%u_%u", myPsn.highLongOfPSN, myPsn.lowLongOfPSN);
	myPsnStr[5+10+1+10]=0;

	if((argc==2) && !strcmp(myPsnStr, argv[1])) {
		m_config_set_option(config, "quiet", NULL);
		InitCursor();
		AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(AppleEventHandlerProc), 0, FALSE);
		RunApplicationEventLoop();
	}

	return files;
}
Beispiel #18
0
void cutils_test_refr_timer()
{
    int                         i, fireTimes = 0;
    const int                   kNumRefr = 5;
    const EventTimerInterval    kRefrTime = 0.5; // keep this shorter than 1 sec
    EventLoopTimerRef           timer = NULL, rltimer = NULL;
    OSStatus                    err;
    EventLoopTimerUPP           upp;
    
    LOG0("---- cutils_test_refr_timer ---------------------------------------");
    
    // start timer with long fire delay
    refr_timer(&timer, &cutils_test_refr_timercb, 2, 0, &fireTimes);
    
    for (i = 0; i < kNumRefr; i++)
    {
        // refresh timer with shorter fire delay. This should just (1) override
        // the previous one-shot fire and (2) continuously prolong the 
        // firing time making the timer fire only once
        refr_timer(&timer, &cutils_test_refr_timercb, kRefrTime, 0, &fireTimes);
    }
    
    // execution flow never blocks, so given the long fire delays our 
    // fireTimes counter must still be 0
    LOG("cutils_test_refr_timer:: fireTimes=%d", fireTimes);
    assert(fireTimes == 0);
    
    // install another timer just to get out of the run loop (see below):
    // we'll make it fire way after the sum of all previous fire delays
    upp = NewEventLoopTimerUPP(killrl_timercb);
    err = InstallEventLoopTimer(GetMainEventLoop(), kNumRefr * kRefrTime * 5, 
                                0, upp, NULL, &rltimer);
    assert(err == 0);
    
    // we need to run the app event loop to actually let the `timer' work
    RunApplicationEventLoop();
    
    LOG("cutils_test_refr_timer:: fireTimes=%d", fireTimes); 
    assert(fireTimes == 1);
    
    err = RemoveEventLoopTimer(rltimer);
    assert(err == 0);
    err = RemoveEventLoopTimer(timer);
    assert(err == 0);
}
Beispiel #19
0
bool AquaGui::run()
{
    double interval = _interval / 1000.0;


    OSStatus ret = InstallEventLoopTimer (GetMainEventLoop(), 0, interval, 
      DoAdvanceMovie, this, _advance_timer);
    if (ret != noErr) {
      return false;
    }

    RepositionWindow(myWindow, NULL, kWindowCascadeOnMainScreen);
    SelectWindow(myWindow);
    ShowWindow(myWindow);
	SetWindowModified(myWindow, false);
    RunApplicationEventLoop();
    return true;
}
Beispiel #20
0
int main(int argc, char* argv[])
{
	IBNibRef 		nibRef;
	OSStatus		err;

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize default output device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
	BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
	BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy); // setup proxy server location

	// Create Window and stuff
	err = CreateNibReference(CFSTR("netradio"), &nibRef);
	if (err) return err;
	err = CreateWindowFromNib(nibRef, CFSTR("Window"), &win);
	if (err) return err;
	DisposeNibReference(nibRef);

	int a;
	for (a=10;a<20;a++)
		SetupControlHandler(a,kEventControlHit,RadioEventHandler);
	SetupControlHandler(41,kEventControlHit,DirectEventHandler);
	{
		EventTypeSpec etype={'blah','blah'};
		InstallApplicationEventHandler(NewEventHandlerUPP(CustomEventHandler),1,&etype,NULL,NULL);
	}

	ShowWindow(win);
	RunApplicationEventLoop();

	BASS_Free();

    return 0; 
}
Beispiel #21
0
/**
	ui_loop : void -> void
	<doc>
	Starts the native UI event loop. This method can only be called from the main thread.
	</doc>
**/
static value ui_loop() {
	if( !val_bool(ui_is_main()) )
		neko_error();
#	if defined(NEKO_WINDOWS)
	{
		MSG msg;
		while( GetMessage(&msg,NULL,0,0) ) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			if( msg.message == WM_QUIT )
				break;
		}
	}
#	elif defined(NEKO_MAC)
	RunApplicationEventLoop();
#	else
	gtk_main();
#	endif
	return val_null;
}
Beispiel #22
0
void
temp_run_application_event_loop(void)
{
	OSStatus	err;
	EventRef	dummy_event;
	EventHandlerRef	install_handler;
	EventTypeSpec	event_spec = { 'KWIN', 'KWIN' };
	
	// Create UPP for dummy_event_handler and for quit_event_handler
	err = noErr;
	dummy_event = 0;
	
	g_dummy_event_handler_UPP = NewEventHandlerUPP(dummy_event_handler);
	g_quit_handler_UPP = NewEventHandlerUPP(quit_event_handler);
	if((g_dummy_event_handler_UPP == 0) || (g_quit_handler_UPP == 0)) {
		err = memFullErr;
	}
	
	if(err == noErr) {
		err = InstallApplicationEventHandler(g_dummy_event_handler_UPP,
											 1, &event_spec, 0, &install_handler);
		if(err == noErr) {
			err = MacCreateEvent(NULL, 'KWIN', 'KWIN',
								 GetCurrentEventTime(), kEventAttributeNone,
								 &dummy_event);
			if(err == noErr) {
				err = PostEventToQueue(GetMainEventQueue(),
									   dummy_event, kEventPriorityHigh);
			}
			if(err == noErr) {
				RunApplicationEventLoop();
			}
			
			(void)RemoveEventHandler(install_handler);
		}
	}
	
	if(dummy_event != NULL) {
		ReleaseEvent(dummy_event);
	}
}
Beispiel #23
0
int main(int argc, char* argv[])
{
    IBNibRef 		nibRef;
    WindowRef 		window;
    
    OSStatus		err;

    // 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);
    require_noerr( err, CantCreateWindow );

    // We don't need the nib reference anymore.
    DisposeNibReference(nibRef);
    
    // The window was created hidden so show it.
    ShowWindow( window );
	
	// Run the sample code
	err = RunRoundTripFlatteningSample( window );
	check_noerr( err );
    
    // Call the event loop
    RunApplicationEventLoop();

CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
	return err;
}
Beispiel #24
0
//---------------------------------------------------------------------------------------------
int main()
{
    static const EventTypeSpec  sApplicationEvents[] = {{ kEventClassCommand, kEventCommandProcess }};
    OSErr err;
    
    if (!SystemVersionRequired(0x1020))
    {
	DialogRef theAlert;
	CreateStandardAlert(kAlertStopAlert, CFSTR("Need 10.2 or later!"), NULL, NULL, &theAlert);
	RunStandardAlert(theAlert, NULL, NULL);
	return 0;
    }
    
    ProcessSerialNumber psn = {0, kCurrentProcess};
    err = GetProcessBundleLocation(&psn, &gApplicationBundleFSRef);

    err = CreateNibReference(CFSTR("CarbonSketch"), &gOurNibRef );
    require_noerr( err, CantGetNibRef );

    err = SetMenuBarFromNib( gOurNibRef, CFSTR("MenuBar") );
    require_noerr( err, SetMenuBarFromNib_FAILED );

    AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, DoOpenApp, 0, false);
    AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, DoOpenDocuments, 0, false);
//  AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, DoPrintDocuments, 0, false);

    InstallApplicationEventHandler( NewEventHandlerUPP(AppEventHandlerProc), 
                                    GetEventTypeCount(sApplicationEvents), 
                                    sApplicationEvents, 0, NULL );

    RunApplicationEventLoop();

SetMenuBarFromNib_FAILED:
    DisposeNibReference(gOurNibRef);

CantGetNibRef:
    return err;
}
int main(int argc, char* argv[])
{
    IBNibRef 	nibRef;
    OSStatus	err;

    // 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 );

    MakeWindow(nibRef);

    // don't need the nib reference anymore.
    DisposeNibReference(nibRef);

    const		EventTypeSpec   commandProcessEvents[]	= { { kEventClassCommand, kEventCommandProcess } };

    InstallAppleEventHandlers();
    InstallApplicationEventHandler( NewEventHandlerUPP(CommandProcessEventHandler), 
                                    GetEventTypeCount(commandProcessEvents), 
                                    commandProcessEvents, NULL, NULL );

    // Must initialize QuickTime first
    InitializeQuickTime ();

    // Call the event loop
    RunApplicationEventLoop();

CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
	return err;
}
Beispiel #26
0
Datei: main.c Projekt: eross/misc
int main(int argc, char* argv[])
{
    IBNibRef 		nibRef;
    WindowRef 		window;
    OSStatus		err;
    EventTypeSpec   cmdEvent	= {kEventClassCommand, kEventCommandProcess};

    // 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);
    require_noerr( err, CantCreateWindow );

    // We don't need the nib reference anymore.
    DisposeNibReference(nibRef);
    
    // The window was created hidden so show it.
    ShowWindow( window );
    
    InstallApplicationEventHandler(NewEventHandlerUPP(appCommandHandler), GetEventTypeCount(cmdEvent), &cmdEvent, 0, NULL);

    // Call the event loop
    RunApplicationEventLoop();
    
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
	return err;
}
//--------------------------------------------------------------------------------------------
int	main( int argc, char *argv[] )
{
	OSStatus				status;
	const   EventTypeSpec   commandProcessEvents[]		= { { kEventClassCommand, kEventCommandProcess } };
	
	status	= CreateNibReference( CFSTR("main"), &gMainNibRef );
	require_noerr( status, CantGetNibRef );
	
	status	= SetMenuBarFromNib( gMainNibRef, CFSTR("MenuBar") );
	require_noerr( status, CantSetMenuBar );
	
	InstallApplicationEventHandler( NewEventHandlerUPP(CommandProcessEventHandler), GetEventTypeCount(commandProcessEvents), commandProcessEvents, NULL, NULL );
	
	NSApplicationLoad();												//	Needed for Carbon based applications which call into Cocoa
	
	DoNewWindow( NULL );
	
	RunApplicationEventLoop();											//	In 10.4, RunApplicationEventLoop also handles our AutoRelease pool used in Cocoa.
	
CantSetMenuBar:
CantGetNibRef:
		return( status );
}
Beispiel #28
0
/*****************************************************
*
* Routine:	main (argc, argv)*
* Purpose:	main program entry point
*
* Inputs:	argc	 - the number of elements in the argv array
*			argv	 - an array of pointers to the parameters to this application
*
* Returns:	int		 - error code (0 == no error)
*/
int main(int argc, char* argv[])
{
	IBNibRef nibRef;
	OSStatus err;
	
	// 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);
	
	// A bit of an explanation...
	WindowRef window;
	CreateWindowFromNib(nibRef, CFSTR("Explain"), &window);
	ShowWindow(window);
	
	// We don't need the nib reference anymore.
	DisposeNibReference(nibRef);
	
	// Let's react to User's commands.
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	InstallEventHandler(GetApplicationEventTarget(), CommandProcess, 1, &eventTypeCP, NULL, NULL);
	
	// And start our dialogs
	StartTheDialogs();
	
	// Call the event loop
	RunApplicationEventLoop();
	
CantSetMenuBar:
CantGetNibRef:
		return err;
}
//----------------------------------------------------------------------------//
bool MacCEGuiRendererSelector::invokeDialog()
{
    loadDialogWindow();
    int rendererCount = populateRendererMenu();

    // 'cancel' if there are no renderers available
    if (rendererCount == 0)
        d_cancelled = true;
    // only bother with the dialog if there is a choice ;)
    else if (rendererCount > 1)
    {
        // set the event handling
        EventTypeSpec cmdEvt;	
        cmdEvt.eventClass = kEventClassCommand;
        cmdEvt.eventKind = kEventCommandProcess;
        
        InstallEventHandler(
            GetWindowEventTarget(d_dialog),
            NewEventHandlerUPP(MacCEGuiRendererSelector::eventDispatcher), 1,
            &cmdEvt, this, 0); 

        ShowWindow(d_dialog);
        RunApplicationEventLoop();
    }

    SInt32 idx = HIViewGetValue(d_rendererPopup);
    DisposeWindow(d_dialog);

    // bail out if user cancelled dialog or if selected index is 0
    if (d_cancelled || (idx == 0))
        return false;

    // set the last selected renderer - i.e. the one we want to use.
    d_lastSelected = d_rendererTypes[idx - 1];

    return true;
}
Beispiel #30
0
int
main(int argc, char* argv[])
{
    #pragma unused(argc)
    #pragma unused(argv)
    
    IBNibRef  nibRef;
    OSStatus  err;    
    
    err = CreateNibReference(CFSTR("main"), &nibRef);
    assert(err == noErr);
    
    err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
    assert(err == noErr);
    
    DisposeNibReference(nibRef);
    
    err = MyChooseFolder();
    if (err == noErr) {
        RunApplicationEventLoop();
    }
    
    return err;
}