Exemple #1
0
bool CARBON_GUI::init_controls() {
	int i;
	for(i=0;i<MAIN_CONTROLS_NUM;i++) {
		err = GetControlByID(window,&mainControlsID[i],&mainControls[i]);
		if(err != noErr) {
		//	printf("%d - %d - %d \n",i,mainControlsID[i].id,err);
			msg->error("Can't get control for button %d (%d)",i,err);
		}
	}
	
	/* By default start with live output enabled */
	jmix->set_lineout(true);
	SetControlValue(mainControls[SNDOUT_BUT],1);

	/* install main event handler+ */
	err = InstallWindowEventHandler (window, 
            NewEventHandlerUPP (MainWindowEventHandler), 
            GetEventTypeCount(events), events, 
            this, NULL);
	if(err != noErr) msg->error("Can't install main eventHandler");
	
	/* install main command handler */
    err = InstallWindowEventHandler (window, 
            NewEventHandlerUPP (MainWindowCommandHandler), 
            GetEventTypeCount(commands), commands, 
            this, NULL);
	if(err != noErr) msg->error("Can't install main commandHandler");
}
Exemple #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();
}
Exemple #3
0
MODULE_SCOPE void
TkMacOSXInitCarbonEvents(
    Tcl_Interp *interp)
{
    const EventTypeSpec dispatcherEventTypes[] = {
	{kEventClassKeyboard,	 kEventRawKeyDown},
	{kEventClassKeyboard,	 kEventRawKeyRepeat},
	{kEventClassKeyboard,	 kEventRawKeyUp},
	{kEventClassKeyboard,	 kEventRawKeyModifiersChanged},
	{kEventClassKeyboard,	 kEventRawKeyRepeat},
    };
    const EventTypeSpec applicationEventTypes[] = {
	{kEventClassMenu,	 kEventMenuBeginTracking},
	{kEventClassMenu,	 kEventMenuEndTracking},
	{kEventClassMenu,	 kEventMenuOpening},
	{kEventClassMenu,	 kEventMenuTargetItem},
	{kEventClassCommand,	 kEventCommandProcess},
	{kEventClassCommand,	 kEventCommandUpdateStatus},
	{kEventClassApplication, kEventAppActivated},
	{kEventClassApplication, kEventAppDeactivated},
	{kEventClassApplication, kEventAppQuit},
	{kEventClassApplication, kEventAppHidden},
	{kEventClassApplication, kEventAppShown},
	{kEventClassApplication, kEventAppAvailableWindowBoundsChanged},
	{kEventClassAppearance,	 kEventAppearanceScrollBarVariantChanged},
	{kEventClassFont,	 kEventFontPanelClosed},
	{kEventClassFont,	 kEventFontSelection},
    };

    carbonEventHandlerUPP = NewEventHandlerUPP(CarbonEventHandlerProc);
    carbonEventInterp = interp;
    ChkErr(InstallStandardApplicationEventHandler);
    ChkErr(InstallEventHandler, GetEventDispatcherTarget(),
	    carbonEventHandlerUPP, GetEventTypeCount(dispatcherEventTypes),
	    dispatcherEventTypes, (void *) carbonEventInterp, NULL);
    ChkErr(InstallEventHandler, GetApplicationEventTarget(),
	    carbonEventHandlerUPP, GetEventTypeCount(applicationEventTypes),
	    applicationEventTypes, (void *) carbonEventInterp, NULL);

#ifdef TK_MAC_DEBUG_CARBON_EVENTS
    TkMacOSXInitNamedSymbol(HIToolbox, void, DebugTraceEvent, OSType, UInt32,
	    Boolean);
    if (DebugTraceEvent) {
	unsigned int i;
	const EventTypeSpec *e;

	for (i = 0, e = dispatcherEventTypes;
		i < GetEventTypeCount(dispatcherEventTypes); i++, e++) {
	    DebugTraceEvent(e->eventClass, e->eventKind, 1);
	}
	for (i = 0, e = applicationEventTypes;
		i < GetEventTypeCount(applicationEventTypes); i++, e++) {
	    DebugTraceEvent(e->eventClass, e->eventKind, 1);
	}
	DebugTraceEvent = NULL; /* Only enable tracing once. */
    }
#endif /* TK_MAC_DEBUG_CARBON_EVENTS */
}
Exemple #4
0
/* initialize the status window (used to show console messages in the graphic environment */
void CARBON_GUI::setupStatusWindow() 
{
	OSStatus err=CreateWindowFromNib(nibRef,CFSTR("StatusWindow"),&statusWindow);
	if(err!=noErr) msg->error("Can't create status window (%d)!!",err);
	//SetDrawerParent(statusWindow,window);
	//SetDrawerPreferredEdge(statusWindow,kWindowEdgeBottom);
	//SetDrawerOffsets(statusWindow,20,20);
	
	/* install an eventHandler to intercept close requests */
	err = InstallWindowEventHandler (statusWindow, 
		NewEventHandlerUPP (StatusWindowEventHandler), 
		GetEventTypeCount(statusEvents), statusEvents, this, NULL);
	if(err != noErr) msg->error("Can't install status window eventHandler");
	
	/* and then install a command handler (to handle "clear" requests) */
	err=InstallWindowEventHandler(statusWindow,NewEventHandlerUPP(StatusWindowCommandHandler),
		GetEventTypeCount(commands),commands,this,NULL);
		
	/* obtain an HIViewRef for the status text box ... we have to use it 
	 * to setup various properties and to obain a TXNObject needed to manage its content */
	const ControlID txtid={ CARBON_GUI_APP_SIGNATURE, STATUS_TEXT_ID };
	err= HIViewFindByID(HIViewGetRoot(statusWindow), txtid, &statusTextView);
	if(err!=noErr) return;// msg->warning("Can't get textView for status window (%d)!!",err);
	statusText = HITextViewGetTXNObject(statusTextView);
	if(!statusText) {
		msg->error("Can't get statusText object from status window!!");
	}
//	TXNControlTag iControlTags[1] = { kTXNAutoScrollBehaviorTag };
//	TXNControlData iControlData[1] = { kTXNAutoScrollNever }; //kTXNAutoScrollWhenInsertionVisible };
//	err = TXNSetTXNObjectControls(statusText,false,1,iControlTags,iControlData);
	//TextViewSetObjectControlData
	//TextViewSetObjectControlData(statusText,kTXNAutoScrollBehaviorTag,kUn kTXNAutoScrollWhenInsertionVisible)
	/* setup status text font size and color */
	// Create type attribute data structure
	UInt32   fontSize = 10 << 16; // needs to be in Fixed format
	TXNAttributeData fsData,fcData;
	fsData.dataValue=fontSize;
	fcData.dataPtr=(void *)&black;
	TXNTypeAttributes attributes[] = {
		//{ kTXNQDFontStyleAttribute, kTXNQDFontStyleAttributeSize, bold },
		{ kTXNQDFontColorAttribute, kTXNQDFontColorAttributeSize,fcData}, //&lgrey },
		{ kTXNQDFontSizeAttribute, kTXNFontSizeAttributeSize,fsData }
	};
	err= TXNSetTypeAttributes( statusText, 2, attributes,
		kTXNStartOffset,kTXNEndOffset );
		
	/* block user input in the statusText box */
	TXNControlTag tags[] = { kTXNNoUserIOTag };
	TXNControlData vals[] = { kTXNReadOnly };
	err=TXNSetTXNObjectControls(statusText,false,1,tags,vals);
	if(err!=noErr) msg->error("Can't set statusText properties (%d)!!",err);
	// TXNSetScrollbarState(statusText,kScrollBarsAlwaysActive);
		
	//struct TXNBackground bg = {  kTXNBackgroundTypeRGB, black };
	//TXNSetBackground(statusText,&bg);
}
void* CContextOSX::CreateMainWindow(SSize /*Size*/, tint32 /*iWindowsOnly_MenuResourceID = -1*/, tint32 /*iWindowsOnly_IconResourceID = -1*/)
{
	gpMainContext = this;

	IBNibRef sNibRef;
    OSStatus                    err;
    static const EventTypeSpec    kAppEvents[] =
    {
        { kEventClassCommand, kEventCommandProcess },
		{ kCoreEventClass, kAEOpenDocuments }
    };

    // 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"), &sNibRef );
//    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( sNibRef, CFSTR("MenuBar") );
//    require_noerr( err, CantSetMenuBar );
    
    // Install our handler for common commands on the application target
//    InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler ),
//                                    GetEventTypeCount( kAppEvents ), kAppEvents,
//                                    0, NULL );

	WindowRef              gpWindow;
    err = CreateWindowFromNib( sNibRef, CFSTR("MainWindow"), &gpWindow );

    // Position new windows in a staggered arrangement on the main screen
    RepositionWindow( gpWindow, NULL, kWindowCascadeOnMainScreen );
    
    // The window was created hidden, so show it
//    ShowWindow( gpWindow );

	::InvalMenuBar();
	::DrawMenuBar();

	// Install application event handler
    InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler ),
                                    GetEventTypeCount( kAppEvents ), 
								   kAppEvents,
                                    this, 
								   NULL );
	

	InstallWindowEventHandler(gpWindow, GetWindowEventHandlerUPP(),
		GetEventTypeCount(kWindowEvents), kWindowEvents,
		gpWindow, NULL);

	return (void*)gpWindow;
}
int _glfwInstallEventHandlers( void )
{
    OSStatus error;

    _glfwWin.MouseUPP = NewEventHandlerUPP( _glfwMouseEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.MouseUPP,
                                 GetEventTypeCount( GLFW_MOUSE_EVENT_TYPES ),
                                 GLFW_MOUSE_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "glfwOpenWindow failing because it can't install mouse event handler\n" );
        return GL_FALSE;
    }

    _glfwWin.CommandUPP = NewEventHandlerUPP( _glfwCommandHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.CommandUPP,
                                 GetEventTypeCount( GLFW_COMMAND_EVENT_TYPES ),
                                 GLFW_COMMAND_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "glfwOpenWindow failing because it can't install command event handler\n" );
        return GL_FALSE;
    }

    _glfwWin.KeyboardUPP = NewEventHandlerUPP( _glfwKeyEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.KeyboardUPP,
                                 GetEventTypeCount( GLFW_KEY_EVENT_TYPES ),
                                 GLFW_KEY_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "glfwOpenWindow failing because it can't install key event handler\n" );
        return GL_FALSE;
    }

    return GL_TRUE;
}
Exemple #7
0
static int installEventHandlers( void )
{
    OSStatus error;

    _glfwWin.mouseUPP = NewEventHandlerUPP( mouseEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.mouseUPP,
                                 GetEventTypeCount( GLFW_MOUSE_EVENT_TYPES ),
                                 GLFW_MOUSE_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "Failed to install Carbon application mouse event handler\n" );
        return GL_FALSE;
    }

    _glfwWin.commandUPP = NewEventHandlerUPP( commandHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.commandUPP,
                                 GetEventTypeCount( GLFW_COMMAND_EVENT_TYPES ),
                                 GLFW_COMMAND_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "Failed to install Carbon application command event handler\n" );
        return GL_FALSE;
    }

    _glfwWin.keyboardUPP = NewEventHandlerUPP( keyEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.keyboardUPP,
                                 GetEventTypeCount( GLFW_KEY_EVENT_TYPES ),
                                 GLFW_KEY_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if( error != noErr )
    {
        fprintf( stderr, "Failed to install Carbon application key event handler\n" );
        return GL_FALSE;
    }

    return GL_TRUE;
}
Exemple #8
0
OPL_Dialog::OPL_Dialog(CFStringRef resname):
	m_window(0), m_status(true)
{
	OSStatus err;
	static EventTypeSpec dialog_events[] = {
		{ kEventClassCommand, kEventCommandProcess },
		{ kEventClassWindow, kEventWindowClose },
		{ kEventClassControl, kEventControlHit },
	};

	// create and show preferences dialog
	err = CreateWindowFromNib(g_main_nib, resname, &m_window);
	require_noerr(err, error);

	static EventHandlerUPP g_eventHandlerUPP = NULL;
	if (g_eventHandlerUPP == NULL)
		g_eventHandlerUPP = NewEventHandlerUPP(eventHandler);

	// install control event handler
	err = InstallWindowEventHandler(getWindow(), g_eventHandlerUPP,
		GetEventTypeCount(dialog_events), dialog_events, this, NULL);
	require_noerr(err, error);

error:
	/* do nothing */;
}
static void HandleStartEvent(NavCBRecPtr callBackParms, CustomData *data)
{
   data->context = callBackParms->context;

   CreateUserPaneControl(callBackParms->window, &data->bounds, kControlSupportsEmbedding, &data->userpane);

   InstallControlEventHandler(data->userpane,
                              GetHandlePaneEventsUPP(),
                              GetEventTypeCount(namedAttrsList),
                              namedAttrsList,
                              data,
                              NULL);

   EmbedControl(data->choice, data->userpane);
   EmbedControl(data->button, data->userpane);
   
   NavCustomControl(callBackParms->context, kNavCtlAddControl, data->userpane);
   
   HandleAdjustRect(callBackParms, data);
   
   if (data && !(data->defaultLocation).IsEmpty())
   {
      // Set default location for the modern Navigation APIs
      // Apple Technical Q&A 1151
      FSSpec theFSSpec;
      wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec);
      AEDesc theLocation = {typeNull, NULL};
      if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
         ::NavCustomControl(callBackParms->context, kNavCtlSetLocation, (void *) &theLocation);
   }
}
Exemple #10
0
wxMacSearchFieldControl::wxMacSearchFieldControl( wxTextCtrl *wxPeer,
                         const wxString& str,
                         const wxPoint& pos,
                         const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
{
    m_font = wxPeer->GetFont() ;
    m_windowStyle = style ;
    m_selection.selStart = m_selection.selEnd = 0;
    Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
    wxString st = str ;
    wxMacConvertNewlines10To13( &st ) ;
    wxCFStringRef cf(st , m_font.GetEncoding()) ;

    m_valueTag = kControlEditTextCFStringTag ;

    OptionBits attributes = kHISearchFieldAttributesSearchIcon;

    HIRect hibounds = { { bounds.left, bounds.top }, { bounds.right-bounds.left, bounds.bottom-bounds.top } };
    verify_noerr( HISearchFieldCreate(
        &hibounds,
        attributes,
        0, // MenuRef
        CFSTR(""),
        &m_controlRef
        ) );
    HIViewSetVisible (m_controlRef, true);

    verify_noerr( SetData<CFStringRef>( 0, kControlEditTextCFStringTag , cf ) ) ;

    ::InstallControlEventHandler( m_controlRef, GetwxMacSearchControlEventHandlerUPP(),
        GetEventTypeCount(eventList), eventList, wxPeer, NULL);
    SetNeedsFrame(false);
    wxMacUnicodeTextControl::InstallEventHandlers();
}
Exemple #11
0
static	void	DisplaySimpleWindow( void )
{
	OSErr					err;
	WindowRef				window;
	WindowStorage			*windowStorage;
	WindowGroupRef			windowGroup;
	static	EventHandlerUPP	simpleWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassCommand, kEventCommandProcess },
			{ kEventClassWindow, kEventWindowClickContentRgn },
			{ kEventClassWindow, kEventWindowBoundsChanging },
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowClose }
		};
	
	err	= CreateWindowFromNib( g.mainNib, CFSTR("MainWindow"), &window );
	if ( (err != noErr) || (window == NULL) )	goto Bail;
	
	if ( simpleWindowEventHandlerUPP == NULL ) simpleWindowEventHandlerUPP	= NewEventHandlerUPP( SimpleWindowEventHandlerProc );
	err	= InstallWindowEventHandler( window, simpleWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, window, NULL );

	windowStorage	= (WindowStorage*) NewPtrClear( sizeof(WindowStorage) );
	SetWRefCon( window, (long) windowStorage );

	err	= CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &windowGroup );
	if ( err == noErr )	err	= SetWindowGroupParent( windowGroup, g.windowGroups[1] );		//	Default group
	if ( err == noErr )	err	= SetWindowGroup( window, windowGroup );

	ShowWindow( window );

Bail:
	return;
}
GHOST_TSuccess GHOST_SystemCarbon::init()
{

	GHOST_TSuccess success = GHOST_System::init();
	if (success) {
		/*
		 * Initialize the cursor to the standard arrow shape (so that we can change it later on).
		 * This initializes the cursor's visibility counter to 0.
		 */
		::InitCursor();

		MenuRef windMenu;
		::CreateStandardWindowMenu(0, &windMenu);
		::InsertMenu(windMenu, 0);
		::DrawMenuBar();

		::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler);
		
		::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false);
		::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false);
		::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false);
		::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false);
		
	}
	return success;
}
static OSStatus MyMTViewRegister(CFStringRef myClassID)
{
    OSStatus                err = noErr;
    static HIObjectClassRef sMyViewClassRef = NULL;
	
    if ( sMyViewClassRef == NULL )
    {
        EventTypeSpec eventList[] = {
            { kEventClassHIObject, kEventHIObjectConstruct },
            { kEventClassHIObject, kEventHIObjectInitialize },
            { kEventClassHIObject, kEventHIObjectDestruct },

            { kEventClassControl, kEventControlDraw },
            { kEventClassControl, kEventControlHitTest },
	    { kEventClassControl, kEventControlTrack },
	};
		
        err = HIObjectRegisterSubclass( myClassID,
					kHIViewClassID,					// base class ID
					0,						// option bits
					MTViewHandler,					// construct proc
					GetEventTypeCount( eventList ),
					eventList,
					NULL,						// construct data
					&sMyViewClassRef );
    }
    return err;
}
OSStatus
TabbedWindow::RegisterWindowCarbonEventhandler()
{
    OSStatus status = paramErr;
    WindowRef window = this->GetWindow();
	
    static const EventTypeSpec windowEvents[] =
    {
        { kEventClassWindow, kEventWindowActivated },
        { kEventClassWindow, kEventWindowDeactivated },
        { kEventClassWindow, kEventWindowClose },
        { kEventClassWindow, kEventControlHit },
        { kEventClassControl, kEventControlHit },
        { kEventClassCommand, kEventProcessCommand },
        { kEventClassMenu, kEventMenuOpening }
    };
    
    // install the window event handler
    if( window != NULL )
    {
        status = InstallWindowEventHandler( window, NewEventHandlerUPP(EventHandlerProc), 
                                            GetEventTypeCount( windowEvents ), windowEvents,
                                            this, &fHandler );
    }
    return status;
}
void MakeWindow(IBNibRef 	nibRef)
{
    WindowRef	window;
    OSStatus		err;
    EventHandlerRef	ref;
    EventTypeSpec	winEvents[] = { { kEventClassCommand, kEventCommandProcess },
                                                { kEventClassWindow, kEventWindowClose },
                                                { kEventClassWindow, kEventWindowDrawContent },
                                                { kEventClassWindow, kEventWindowBoundsChanged }, 
                                                { kEventClassMovieExtractState, kEventKQueue } };

    err = CreateWindowFromNib(nibRef, CFSTR("Window"), &window);
    mWindow = window;

    mWinEventHandler = NewEventHandlerUPP(WindowEventHandler);
    err = InstallWindowEventHandler(window, mWinEventHandler, GetEventTypeCount( winEvents ), winEvents, 0, &ref);

    ControlRef control;

    err = GetControlByID( window, &kPlayBtnID, &control );
    mButtonRef = control;

    err = GetControlByID( window, &kMovNameTxtID, &control );
    mMovNameRef = control;

    ShowWindow(window);
}
Exemple #16
0
void palette_scenery_open(int x,int y)
{
	ControlID				ctrl_id;
	EventHandlerUPP			tab_event_upp;
	EventTypeSpec			tab_event_list[]={{kEventClassControl,kEventControlHit},
											  {kEventClassKeyboard,kEventRawKeyUp}};

		// open the window
		
	dialog_open(&palette_scenery_wind,"SceneryPalette");
	MoveWindow(palette_scenery_wind,x,y,FALSE);
	
		// setup the tabs
		
	dialog_set_tab(palette_scenery_wind,kSceneryTab,0,0,kSceneryTabCount);

	ctrl_id.signature=kSceneryTab;
	ctrl_id.id=0;
	GetControlByID(palette_scenery_wind,&ctrl_id,&palette_scenery_tab);
	
	tab_event_upp=NewEventHandlerUPP(palette_scenery_tab_proc);
	InstallControlEventHandler(palette_scenery_tab,tab_event_upp,GetEventTypeCount(tab_event_list),tab_event_list,palette_scenery_wind,NULL);

		// show palette
		
	ShowWindow(palette_scenery_wind);
}
Exemple #17
0
static	OSErr	InitializeApplication( void )
{
	OSErr						err;
	static const EventTypeSpec	sApplicationEvents[] =	{	{ kEventClassCommand, kEventCommandProcess }	};

	BlockZero( &g, sizeof(g) );
		
	g.mainBundle = CFBundleGetMainBundle();
	if ( g.mainBundle == NULL ) 	{ err = -1;	goto Bail;	}
	
	err	= CreateNibReferenceWithCFBundle( g.mainBundle, CFSTR("WindowFun"), &g.mainNib );
	if ( err != noErr )	goto Bail;
	if ( g.mainNib == NULL ) 		{ err = -1;	goto Bail;	}

	err	= SetMenuBarFromNib( g.mainNib, CFSTR("MenuBar") );
	if ( err != noErr )	goto Bail;

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

	//	Force the document group to be created first, so we can position our groups between the floating and document groups
	(void) GetWindowGroupOfClass( kDocumentWindowClass );
	
	//	Create our default WindowGroups and set their z-order
	err	= CreateWindowGroup( 0, &g.windowGroups[0] );
	err	= CreateWindowGroup( 0, &g.windowGroups[1] );
	err	= CreateWindowGroup( 0, &g.windowGroups[2] );

	//	Position our groups behind the floating group and in front of the document group
	SendWindowGroupBehind( g.windowGroups[2], GetWindowGroupOfClass( kDocumentWindowClass ) );
	SendWindowGroupBehind( g.windowGroups[1], g.windowGroups[2] );
	SendWindowGroupBehind( g.windowGroups[0], g.windowGroups[1] );

Bail:	
	return( err );
}
Exemple #18
0
static void
setup_menu_event_handler (void)
{
  static gboolean is_setup = FALSE;

  EventHandlerUPP menu_event_handler_upp;
  EventHandlerRef menu_event_handler_ref;
  const EventTypeSpec menu_events[] = {
    { kEventClassCommand, kEventCommandProcess },
    { kEventClassMenu, kEventMenuTargetItem },
    { kEventClassMenu, kEventMenuOpening },
    { kEventClassMenu, kEventMenuClosed }
  };

  if (is_setup)
    return;

  /* FIXME: We might have to install one per window? */

  menu_event_handler_upp = NewEventHandlerUPP (menu_event_handler_func);
  InstallEventHandler (GetApplicationEventTarget (), menu_event_handler_upp,
		       GetEventTypeCount (menu_events), menu_events, 0,
		       &menu_event_handler_ref);

#if 0
  /* FIXME: Remove the handler with: */
  RemoveEventHandler(menu_event_handler_ref);
  DisposeEventHandlerUPP(menu_event_handler_upp);
#endif

  is_setup = TRUE;
}
Exemple #19
0
static void makeNibWindow (IBNibRef nibRef) {
    OSStatus	err;
    short		i,j,l,k;
    EventHandlerRef	ref;
    ControlRef	targetCon[11], cref[3];
    
    err = CreateWindowFromNib(nibRef, CFSTR("SoundDialog"), &soundWin);
    if (err == noErr) {
    
        initSoundWindow();
        SetInitialTabState(soundWin, lastPaneSelected, kMaxNumTabs);
        
        EventTypeSpec	tabControlEvents[] ={ { kEventClassControl, kEventControlHit }};
        InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,soundWin),  PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, soundWin, NULL );

        EventTypeSpec	sliderControlEvents[] ={
            { kEventClassControl, kEventControlDraw },
            { kEventClassControl, kEventControlValueFieldChanged }
        };
        for (i=0;i<5;i++) {
            targetCon[i] = getControlRefByID('vMix',i,soundWin);
        }
        for (j=0;j<6;j++) {
            targetCon[j+5] = getControlRefByID('vMix',10+j,soundWin);
        }
        for (l=0;l<11;l++) {
            InstallControlEventHandler( targetCon[l],  sliderEventHandlerProc , GetEventTypeCount(sliderControlEvents), sliderControlEvents, (void *)targetCon[l], NULL );
        }

        EventTypeSpec	list[]={ { kEventClassCommand, kEventCommandProcess },};
        InstallWindowEventHandler (soundWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)soundWin, &ref);
		
        EventTypeSpec	ctrllist[]={ { kEventClassControl, kEventControlClick } };
        for (k=0;k<3;k++) {
			cref[k] = getControlRefByID('BMP ', k, soundWin);
		}
		InstallControlEventHandler(cref[0], NewEventHandlerUPP(s26proc), GetEventTypeCount(ctrllist), ctrllist, (void *)cref[0], NULL);   
		InstallControlEventHandler(cref[1], NewEventHandlerUPP(s86proc), GetEventTypeCount(ctrllist), ctrllist, (void *)cref[1], NULL);   
		InstallControlEventHandler(cref[2], NewEventHandlerUPP(spbproc), GetEventTypeCount(ctrllist), ctrllist, (void *)cref[2], NULL);   
		
        ShowSheetWindow(soundWin, hWndMain);
        
        err=RunAppModalLoopForWindow(soundWin);
    }
    return;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AURenderQualityPopup::RegisterEvents
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void	AURenderQualityPopup::RegisterEvents ()
{
	EventTypeSpec events[] = {
		{ kEventClassCommand, kEventCommandProcess}
	};
	
	WantEventTypes(GetWindowEventTarget(mView->GetCarbonWindow()), GetEventTypeCount(events), events);
}
Exemple #21
0
MODULE_SCOPE void
TkMacOSXInstallWindowCarbonEventHandler(
	Tcl_Interp *interp, WindowRef window)
{
    const EventTypeSpec windowEventTypes[] = {
	{kEventClassMouse,	 kEventMouseDown},
	{kEventClassMouse,	 kEventMouseUp},
	{kEventClassMouse,	 kEventMouseMoved},
	{kEventClassMouse,	 kEventMouseDragged},
	{kEventClassMouse,	 kEventMouseWheelMoved},
	{kEventClassWindow,	 kEventWindowActivated},
	{kEventClassWindow,	 kEventWindowDeactivated},
	{kEventClassWindow,	 kEventWindowUpdate},
	{kEventClassWindow,	 kEventWindowExpanding},
	{kEventClassWindow,	 kEventWindowBoundsChanged},
	{kEventClassWindow,	 kEventWindowDragStarted},
	{kEventClassWindow,	 kEventWindowDragCompleted},
	{kEventClassWindow,	 kEventWindowConstrain},
	{kEventClassWindow,	 kEventWindowGetRegion},
	{kEventClassWindow,	 kEventWindowDrawContent},
    };

    ChkErr(InstallEventHandler, GetWindowEventTarget(window),
	    carbonEventHandlerUPP, GetEventTypeCount(windowEventTypes),
	    windowEventTypes, (void *) (interp ? interp : carbonEventInterp),
	    NULL);

#ifdef TK_MAC_DEBUG_CARBON_EVENTS
    TkMacOSXInitNamedSymbol(HIToolbox, void, DebugTraceEvent, OSType, UInt32,
	    Boolean);
    if (DebugTraceEvent) {
	unsigned int i;
	const EventTypeSpec *e;

	for (i = 0, e = windowEventTypes;
		i < GetEventTypeCount(windowEventTypes); i++, e++) {
	    if (!(e->eventClass == kEventClassMouse && (
		    e->eventKind == kEventMouseMoved ||
		    e->eventKind == kEventMouseDragged))) {
		DebugTraceEvent(e->eventClass, e->eventKind, 1);
	    }
	}
    }
#endif /* TK_MAC_DEBUG_CARBON_EVENTS */
}
Exemple #22
0
int  _glfwInstallEventHandlers( void )
{
    OSStatus error;

    _glfwWin.MouseUPP = NewEventHandlerUPP( _glfwMouseEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.MouseUPP,
                                 GetEventTypeCount( GLFW_MOUSE_EVENT_TYPES ),
                                 GLFW_MOUSE_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if ( error != noErr )
    {
        return GL_FALSE;
    }

    _glfwWin.CommandUPP = NewEventHandlerUPP( _glfwCommandHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.CommandUPP,
                                 GetEventTypeCount( GLFW_COMMAND_EVENT_TYPES ),
                                 GLFW_COMMAND_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if ( error != noErr )
    {
      return GL_FALSE;
    }

    _glfwWin.KeyboardUPP = NewEventHandlerUPP( _glfwKeyEventHandler );

    error = InstallEventHandler( GetApplicationEventTarget(),
                                 _glfwWin.KeyboardUPP,
                                 GetEventTypeCount( GLFW_KEY_EVENT_TYPES ),
                                 GLFW_KEY_EVENT_TYPES,
                                 NULL,
                                 NULL );
    if ( error != noErr )
    {
        return GL_FALSE;
    }

    return GL_TRUE;
}
static void installAcessibilityEventHandler(HIObjectRef hiObject)
{
    if (!accessibilityEventHandlerUPP)
        accessibilityEventHandlerUPP = NewEventHandlerUPP(accessibilityEventHandler);

    InstallHIObjectEventHandler(hiObject, accessibilityEventHandlerUPP,
                                        GetEventTypeCount(accessibilityEvents),
                                        accessibilityEvents, 0, 0);
}
Exemple #24
0
void	AUPropertyControl::RegisterEvents ()
{
#if !__LP64__
	EventTypeSpec events[] = {
		{ kEventClassControl, kEventControlValueFieldChanged }	// N.B. OS X only
	};
	
	WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events);
#endif
}
void
QMacInputContext::initialize()
{
    if(!input_proc_handler) {
        input_proc_handlerUPP = NewEventHandlerUPP(QMacInputContext::globalEventProcessor);
        InstallEventHandler(GetApplicationEventTarget(), input_proc_handlerUPP,
                            GetEventTypeCount(input_events), input_events,
                            0, &input_proc_handler);
    }
}
Exemple #26
0
bool8 NPServerDialog (void)
{
	OSStatus	err;
	IBNibRef	nibRef;

	npserver.dialogcancel = true;

	err = CreateNibReference(kMacS9XCFString, &nibRef);
	if (err == noErr)
	{
		WindowRef	tWindowRef;

		err = CreateWindowFromNib(nibRef, CFSTR("ClientList"), &tWindowRef);
		if (err == noErr)
		{
			EventHandlerRef		eref;
			EventLoopTimerRef	tref;
			EventHandlerUPP		eventUPP;
			EventLoopTimerUPP	timerUPP;
			EventTypeSpec		windowEvents[] = { { kEventClassCommand, kEventCommandProcess      },
												   { kEventClassCommand, kEventCommandUpdateStatus } };
			HIViewRef			ctl;
			HIViewID			cid = { 'Chse', 0 };

			npserver.dialogprocess = kNPSDialogInit;

			eventUPP = NewEventHandlerUPP(NPServerDialogEventHandler);
			err = InstallWindowEventHandler(tWindowRef, eventUPP, GetEventTypeCount(windowEvents), windowEvents, (void *) tWindowRef, &eref);

			timerUPP = NewEventLoopTimerUPP(NPServerDialogTimerHandler);
			err = InstallEventLoopTimer(GetCurrentEventLoop(), 0.0f, 0.1f, timerUPP, (void *) tWindowRef, &tref);

			HIViewFindByID(HIViewGetRoot(tWindowRef), cid, &ctl);
			HIViewSetVisible(ctl, false);

			MoveWindowPosition(tWindowRef, kWindowServer, false);
			ShowWindow(tWindowRef);
			err = RunAppModalLoopForWindow(tWindowRef);
			HideWindow(tWindowRef);
			SaveWindowPosition(tWindowRef, kWindowServer);

			err = RemoveEventLoopTimer(tref);
			DisposeEventLoopTimerUPP(timerUPP);

			err = RemoveEventHandler(eref);
			DisposeEventHandlerUPP(eventUPP);

			CFRelease(tWindowRef);
		}

		DisposeNibReference(nibRef);
	}

	return (!npserver.dialogcancel);
}
Exemple #27
0
void dialog_preference_run(void)
{
	EventHandlerUPP			event_upp;
	EventTypeSpec			event_list[]={{kEventClassCommand,kEventProcessCommand}};
	
		// open the dialog
		
	dialog_open(&dialog_preference_wind,"Preferences");

		// set controls
		
	dialog_set_text(dialog_preference_wind,kPrefEngineName,0,setup.engine_name);
	dialog_set_combo(dialog_preference_wind,kPrefMipMapMode,0,setup.mipmap_mode);
	dialog_set_boolean(dialog_preference_wind,kPrefAutoTexture,0,setup.auto_texture);
	dialog_set_int(dialog_preference_wind,kPrefDuplicateOffset,0,setup.duplicate_offset);
	
	dialog_set_color(dialog_preference_wind,kPrefBackgroundColor,0,&setup.col.background);
	dialog_set_color(dialog_preference_wind,kPrefLineColor,0,&setup.col.mesh_line);
	dialog_set_color(dialog_preference_wind,kPrefMeshSelColor,0,&setup.col.mesh_sel);
	dialog_set_color(dialog_preference_wind,kPrefPolySelColor,0,&setup.col.poly_sel);
	
		// show window
	
	ShowWindow(dialog_preference_wind);
	
		// install event handler
		
	event_upp=NewEventHandlerUPP(preference_event_proc);
	InstallWindowEventHandler(dialog_preference_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL);
	
		// modal window
		
	dialog_preference_cancel=FALSE;
	RunAppModalLoopForWindow(dialog_preference_wind);
	
		// dialog to data
		
	if (!dialog_preference_cancel) {
		dialog_get_text(dialog_preference_wind,kPrefEngineName,0,setup.engine_name,256);
		setup.mipmap_mode=dialog_get_combo(dialog_preference_wind,kPrefMipMapMode,0);
		setup.auto_texture=dialog_get_boolean(dialog_preference_wind,kPrefAutoTexture,0);
		setup.duplicate_offset=dialog_get_int(dialog_preference_wind,kPrefDuplicateOffset,0);
		
		dialog_get_color(dialog_preference_wind,kPrefBackgroundColor,0,&setup.col.background);
		dialog_get_color(dialog_preference_wind,kPrefLineColor,0,&setup.col.mesh_line);
		dialog_get_color(dialog_preference_wind,kPrefMeshSelColor,0,&setup.col.mesh_sel);
		dialog_get_color(dialog_preference_wind,kPrefPolySelColor,0,&setup.col.poly_sel);
		
		setup_xml_write();
	}

		// close window
		
	DisposeWindow(dialog_preference_wind);
}
Exemple #28
0
bool LLCrashLoggerMac::init(void)
{	
	bool ok = LLCrashLogger::init();
	if(!ok) return false;
	if(mCrashBehavior != CRASH_BEHAVIOR_ASK) return true;
	
	// Real UI...
	OSStatus err;
	
	err = CreateNibReference(CFSTR("CrashReporter"), &nib);
	
	if(err == noErr)
	{
		err = CreateWindowFromNib(nib, CFSTR("CrashReporter"), &gWindow);
	}

	if(err == noErr)
	{
		// Set focus to the edit text area
		ControlRef textField = NULL;
		ControlID id;

		id.signature = 'text';
		id.id = 0;
		
		// Don't set err if any of this fails, since it's non-critical.
		if(GetControlByID(gWindow, &id, &textField) == noErr)
		{
			SetKeyboardFocus(gWindow, textField, kControlFocusNextPart);
		}
	}
	
	if(err == noErr)
	{
		ShowWindow(gWindow);
	}
	
	if(err == noErr)
	{
		// Set up an event handler for the window.
		EventTypeSpec handlerEvents[] = 
		{
			{ kEventClassCommand, kEventCommandProcess }
		};

		InstallWindowEventHandler(
				gWindow, 
				NewEventHandlerUPP(dialogHandler), 
				GetEventTypeCount (handlerEvents), 
				handlerEvents, 
				0, 
				&gEventHandler);
	}
	return true;
}
void MacOSXLoop::registerWindow( GenericWindow &rGenWin, WindowRef win )
{
    // Create the event handler
    EventTypeSpec evList[] = {
        { kEventClassWindow, kEventWindowUpdate },
        { kEventClassMouse, kEventMouseMoved }
    };
    EventHandlerUPP handler = NewEventHandlerUPP( WinEventHandler );
    InstallWindowEventHandler( win, handler, GetEventTypeCount( evList ),
                               evList, &rGenWin, NULL );
}
OP_STATUS MacOpMessageLoop::Init()
{
	static EventTypeSpec appEventList[] =
	{
		{kEventClassOperaPlatformIndependent, kEventOperaMessage}
	};

	mHandlerUPP = NewEventHandlerUPP(sMacMessageLoopHandler);
	InstallEventHandler(GetApplicationEventTarget(), mHandlerUPP, GetEventTypeCount(appEventList), appEventList, this, &mHandlerRef);

	return OpStatus::OK;
}