/***************************************************** * * 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
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; }
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; }
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) { static const EventTypeSpec gTypes[] = { { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyUp }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseDragged }, { kEventClassMouse, kEventMouseUp }, { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, { kEventClassWindow, kEventWindowBoundsChanged }, { kEventClassWindow, kEventWindowDrawContent }, { SK_MacEventClass, SK_MacEventKind } }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(SkOSWindow::EventHandler); int count = SK_ARRAY_COUNT(gTypes); OSStatus result; result = InstallEventHandler(GetWindowEventTarget((WindowRef)hWnd), handlerUPP, count, gTypes, this, nil); SkASSERT(result == noErr); gCurrOSWin = this; gCurrEventQ = GetCurrentEventQueue(); gEventTarget = GetWindowEventTarget((WindowRef)hWnd); static bool gOnce = true; if (gOnce) { gOnce = false; gPrevNewHandler = set_new_handler(sk_new_handler); } }
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; }
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; }
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); } }
void CL_DisplayWindow_OpenGL::install_event_handler(EventTargetRef targ_ref, int remove_only) { static EventHandlerUPP window_handler_proc = 0; if (window_handler_proc == 0) window_handler_proc = NewEventHandlerUPP(&CL_DisplayWindow_OpenGL::on_window_event); static EventHandlerRef current_handler = 0; if (current_handler != 0) RemoveEventHandler(current_handler); if (remove_only) return; EventTypeSpec events[20]; events[0].eventClass = kEventClassKeyboard; events[0].eventKind = kEventRawKeyDown; events[1].eventClass = kEventClassKeyboard; events[1].eventKind = kEventRawKeyRepeat; events[2].eventClass = kEventClassKeyboard; events[2].eventKind = kEventRawKeyUp; events[3].eventClass = kEventClassMouse; events[3].eventKind = kEventMouseDown; events[4].eventClass = kEventClassMouse; events[4].eventKind = kEventMouseUp; events[5].eventClass = kEventClassMouse; events[5].eventKind = kEventMouseMoved; events[6].eventClass = kEventClassMouse; events[6].eventKind = kEventMouseWheelMoved; events[7].eventClass = kEventClassWindow; events[7].eventKind = kEventWindowCollapsing; events[8].eventClass = kEventClassWindow; events[8].eventKind = kEventWindowDrawContent; events[9].eventClass = kEventClassWindow; events[9].eventKind = kEventWindowShown; events[10].eventClass = kEventClassWindow; events[10].eventKind = kEventWindowClose; events[11].eventClass = kEventClassWindow; events[11].eventKind = kEventWindowActivated; events[12].eventClass = kEventClassWindow; events[12].eventKind = kEventWindowDeactivated; events[13].eventClass = kEventClassWindow; events[13].eventKind = kEventWindowBoundsChanged; events[14].eventClass = kEventClassWindow; events[14].eventKind = kEventWindowZoomed; events[15].eventClass = kEventClassWindow; events[15].eventKind = kEventWindowFocusAcquired; events[16].eventClass = kEventClassWindow; events[16].eventKind = kEventWindowFocusRelinquish; events[17].eventClass = kEventClassMouse; events[17].eventKind = kEventMouseDragged; events[18].eventClass = kEventClassKeyboard; events[18].eventKind = kEventRawKeyModifiersChanged; InstallEventHandler(targ_ref, window_handler_proc, 19, events, this, ¤t_handler); }
OP_STATUS MacOpMessageLoop::Init() { static EventTypeSpec appEventList[] = { {kEventClassOperaPlatformIndependent, kEventOperaMessage} }; mHandlerUPP = NewEventHandlerUPP(sMacMessageLoopHandler); InstallEventHandler(GetApplicationEventTarget(), mHandlerUPP, GetEventTypeCount(appEventList), appEventList, this, &mHandlerRef); return OpStatus::OK; }
// Set up application-wide event handlers OSStatus InstallApplicationEventHandlers( void ) { EventTypeSpec commandEventType = {kEventClassCommand, kEventCommandProcess}; OSStatus status; status = InstallEventHandler(GetApplicationEventTarget(), NewEventHandlerUPP(CommandProcess), 1, &commandEventType, NULL, NULL); require_noerr( status, CantInstallHICommandHandler ); CantInstallHICommandHandler: return status; }
extern OSStatus HICreateScrollingTextBox( const HIRect * inBounds, /* can be NULL */ CFStringRef inScrollingText, Boolean inAutoScroll, UInt32 inDelayBeforeAutoScroll, UInt32 inDelayBetweenAutoScroll, UInt16 inAutoScrollAmount, HIViewRef * outHIView) { *outHIView = NULL; EventRef theInitializeEvent = NULL; HIViewRef scrollView; OSStatus status; status = CreateEvent(NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), kEventAttributeUserEvent, &theInitializeEvent); // settings SetEventParameter(theInitializeEvent, kEventParamScrollingText, typeCFStringRef, sizeof(inScrollingText), &inScrollingText); SetEventParameter(theInitializeEvent, kEventParamAutoScroll, typeBoolean, sizeof(inAutoScroll), &inAutoScroll); SetEventParameter(theInitializeEvent, kEventParamDelayBeforeAutoScroll, typeUInt32, sizeof(inDelayBeforeAutoScroll), &inDelayBeforeAutoScroll); SetEventParameter(theInitializeEvent, kEventParamDelayBetweenAutoScroll, typeUInt32, sizeof(inDelayBetweenAutoScroll), &inDelayBetweenAutoScroll); SetEventParameter(theInitializeEvent, kEventParamAutoScrollAmount, typeSInt16, sizeof(inAutoScrollAmount), &inAutoScrollAmount); HIObjectRef hiObject; status = HIObjectCreate(GetScrollingTextBoxClass(), theInitializeEvent, &hiObject); HIViewSetVisible((HIViewRef)hiObject, true); if (!inAutoScroll) { // // Manual scrolling, we need to be embedded in a scroll view // status = HIScrollViewCreate(kHIScrollViewOptionsVertScroll, &scrollView); status = HIViewAddSubview(scrollView, (HIViewRef)hiObject); if (inBounds != NULL) HIViewSetFrame(scrollView, inBounds); EventTypeSpec event = {kEventClassControl, kEventControlDraw}; InstallEventHandler(GetControlEventTarget(scrollView), FrameView, 1, &event, NULL, NULL); *outHIView = scrollView; } else { if (inBounds != NULL) HIViewSetFrame((HIViewRef)hiObject, inBounds); *outHIView = (HIViewRef)hiObject; } return status; }
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); }
void CarbonEventHandler::WantEventTypes(EventTargetRef target, UInt32 inNumTypes, const EventTypeSpec *inList) { if (mHandlers == NULL) mHandlers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); EventHandlerRef handler; if (CFDictionaryGetValueIfPresent (mHandlers, target, (const void **)&handler)) // if there is already a handler for the target, add the type verify_noerr(AddEventTypesToHandler(handler, inNumTypes, inList)); else { verify_noerr(InstallEventHandler(target, TheEventHandler, inNumTypes, inList, this, &handler)); CFDictionaryAddValue(mHandlers, target, handler); } }
OSStatus TextViewInstallMenuHandlers( HIViewRef textView ) { EventTargetRef targetRef = GetControlEventTarget( textView ); static const EventTypeSpec sAppEvents[] = { { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus } }; OSStatus status = InstallEventHandler( targetRef, TextViewMenuEventHandler, GetEventTypeCount( sAppEvents ), sAppEvents, textView /*userData*/, NULL /*eventHandlerRef*/ ); return status; }
// Create a new demo window OSStatus NewWindow() { IBNibRef nibRef; WindowRef window; EventTypeSpec commandEventType = {kEventClassWindow, kEventWindowFocusAcquired}; OSStatus status = noErr; // 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"), &nibRef); require_noerr( status, CantGetNibRef ); // Then create a window. "MainWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created. status = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window); require_noerr( status, CantCreateWindow ); // We don't need the nib reference anymore. DisposeNibReference(nibRef); // Let's customize the HITextView in that window status = SetUpTheTextView( window ); check_noerr( status ); // The window was created hidden so show it. ShowWindow( window ); // by default, focus the HITextView at start status = TextViewFocusInWindow( window ); require_noerr( status, CantFocusTextView ); // set up the control state from the state of the text view status = UpdateControlsFromTextViewWindow( window ); require_noerr( status, CantSetControlState ); // Install a handler to update the UI when this window comes to the front status = InstallEventHandler(GetWindowEventTarget(window), NewEventHandlerUPP(WindowFocusAcquired), 1, &commandEventType, NULL, NULL); require_noerr( status, CantInstallWindowEventHandler ); CantFocusTextView: CantSetControlState: CantInstallWindowEventHandler: CantCreateWindow: CantGetNibRef: return status; }
// --------------------------------------------------------------------------- OSXWindowImpl::OSXWindowImpl(Window* window) : WindowImpl(window) { OSStatus s; WindowClass wc = kDocumentWindowClass; WindowAttributes wa = 0 // |kWindowCompositingAttribute |kWindowStandardDocumentAttributes |kWindowStandardHandlerAttribute |kWindowLiveResizeAttribute ; mRect.left = 100; mRect.right = mRect.left + 256; mRect.top = 100; mRect.bottom = mRect.top + 256; s = CreateNewWindow(wc,wa,&mRect,&mWindowRef); check_noerr(s); EventTypeSpec typeList[] = { { kEventClassWindow, kEventWindowClosed }, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowBoundsChanged }, { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyUp }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseDragged }, { kEventClassMouse, kEventMouseWheelMoved } }; int numTypes = sizeof(typeList)/sizeof(EventTypeSpec); EventHandlerUPP handlerUPP = NewEventHandlerUPP(OSXWindowImpl::memberDelegate); EventTargetRef theTarget; theTarget = GetWindowEventTarget(mWindowRef); InstallEventHandler( theTarget, handlerUPP, numTypes, typeList, this, NULL ); on_init(); }
void ui_main() { if( data.init_done ) return; data.init_done = 1; # if defined(NEKO_WINDOWS) { WNDCLASSEX wcl; HINSTANCE hinst = GetModuleHandle(NULL); memset(&wcl,0,sizeof(wcl)); wcl.cbSize = sizeof(WNDCLASSEX); wcl.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wcl.lpfnWndProc = WindowProc; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = hinst; wcl.hIcon = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); wcl.lpszMenuName = ""; wcl.lpszClassName = CLASS_NAME; wcl.hIconSm = 0; RegisterClassEx(&wcl); } data.tid = GetCurrentThreadId(); data.wnd = CreateWindow(CLASS_NAME,"",0,0,0,0,0,NULL,NULL,NULL,NULL); # elif defined(NEKO_MAC) MPCreateTask(nothing,NULL,0,0,0,0,0,NULL); // creates a MPTask that will enable Carbon MT data.tid = pthread_self(); EventTypeSpec ets = { UIEvent, eCall }; InstallEventHandler(GetApplicationEventTarget(),NewEventHandlerUPP(handleEvents),1,&ets,0,0); # elif defined(NEKO_LINUX) g_thread_init(NULL); gdk_threads_init(); gtk_init(NULL,NULL); setlocale(LC_NUMERIC,"POSIX"); // prevent broking atof() data.tid = pthread_self(); pthread_mutex_init(&data.lock,NULL); # endif }
//----------------------------------------------------------------------------// 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; }
/***************************************************** * * 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; }
Boolean MCScreenDC::open() { owndnd = False; mouseMoveRgn = NewRgn(); SetRectRgn(mouseMoveRgn, 0, 0, 1, 1); //create a invisible window, and set port to this window //so that later on at the very first time MC select and set font //will only affect in this invisible window, not other apps on the desk top, // when MC is first started. The size of the window is random. // Rect invisibleWinRect; Rect invisibleWinRect; SetRect(&invisibleWinRect, 0, 0, 20, 20); invisibleWin = NewCWindow(nil, &invisibleWinRect, "\p", False, kUtilityWindowClass, (WindowRef)(-1L), False, 0); long response; if (Gestalt(gestaltSystemVersion, &response) == noErr) { if (response >= 0x1030 && response < 0x1040) MCantialiasedtextworkaround = True; else MCantialiasedtextworkaround = False; } SetGWorld(GetWindowPort(invisibleWin), GetMainDevice()); vis = new MCVisualInfo; devdepth = 32; black_pixel.red = black_pixel.green = black_pixel.blue = 0; //black pixel white_pixel.red = white_pixel.green = white_pixel.blue = 0xFFFF; //white pixel black_pixel.pixel = 0; white_pixel.pixel = 0xFFFFFF; redbits = greenbits = bluebits = 8; redshift = 16; greenshift = 8; blueshift = 0; vis->red_mask = 0x00FF0000; vis->green_mask = 0x0000FF00; vis->blue_mask = 0x000000FF; MCzerocolor = MCbrushcolor = white_pixel; alloccolor(MCbrushcolor); MCselectioncolor = MCpencolor = black_pixel; alloccolor(MCselectioncolor); alloccolor(MCpencolor); gray_pixel.red = gray_pixel.green = gray_pixel.blue = 0x8888; alloccolor(gray_pixel); background_pixel.red = background_pixel.green = background_pixel.blue = 0xffff; alloccolor(background_pixel); //query the system for the hilited text color, and set ours RGBColor hiliteRGB; LMGetHiliteRGB(&hiliteRGB); MChilitecolor.red = hiliteRGB.red; MChilitecolor.green = hiliteRGB.green; MChilitecolor.blue = hiliteRGB.blue; alloccolor(MChilitecolor); MCColor *syscolors = getaccentcolors(); if (syscolors != NULL) MCaccentcolor = syscolors[4]; else { MCaccentcolor.red = MCaccentcolor.green = 0x0000; MCaccentcolor.blue = 0x8080; } alloccolor(MCaccentcolor); grabbed = False; tripleclick = doubleclick = False; MCdoubletime = GetDblTime() * 1000 / 60; opened = True; mousewindow = new _Drawable; activewindow = new _Drawable; lastactivewindow = new _Drawable; mousewindow->type = activewindow->type = lastactivewindow->type = DC_WINDOW; mousewindow->handle.window = activewindow->handle.window = lastactivewindow->handle.window = 0; //get handle of application menu bar menuBar = GetMenuBar(); SetMenuBar(menuBar); //set menu bar as current menulist //create Apple menu appleMenu = NewMenu(mApple, "\p\024"); //menu title is an apple icon InsertMenuItem(appleMenu, "\pAbout...", 0); InsertMenu(appleMenu, 0); DrawMenuBar(); //draw the menu bar with the Apple menu usetemp = False; Handle tmem = Get1IndResource('TMEM', 1); if (tmem != NULL) { char *ptr = *tmem; if (*(ptr + 1)) usetemp = True; } MCtemplatescrollbar->alloccolors(); if (IsMacEmulatedLF()) // no AM MCtemplatebutton->allocicons(); // preallocate these because GetItemMark can't distinguish them submenuIDs[0] = 1; submenuIDs[checkMark] = 1; submenuIDs[diamondMark] = 1; MCcursors[PI_NONE] = nil; MCblinkrate = GetCaretTime() * 1000 / 60; MCDisplay const *t_displays; getdisplays(t_displays, false); MCwbr = t_displays[0] . workarea; //TSM - INIT TSM APPLICATION AND INSTALL REQUIRED APPLEVENT HANDLERS TSMPositionToOffsetUPP = NewAEEventHandlerUPP(TSMPositionToOffset); TSMOffsetToPositionUPP = NewAEEventHandlerUPP(TSMOffsetToPosition); TSMUpdateHandlerUPP = NewAEEventHandlerUPP(TSMUpdateHandler); TSMUnicodeNotFromInputUPP = NewAEEventHandlerUPP(TSMUnicodeNotFromInputHandler); AEInstallEventHandler(kTextServiceClass, kPos2Offset, TSMPositionToOffsetUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kOffset2Pos, TSMOffsetToPositionUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kUpdateActiveInputArea, TSMUpdateHandlerUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod, TSMUnicodeNotFromInputUPP, 0L , False); openIME(); dragdropUPP = NewDragReceiveHandlerUPP(DragReceiveHandler); InstallReceiveHandler(dragdropUPP, NULL, NULL); dragmoveUPP = NewDragTrackingHandlerUPP(DragTrackingHandler); InstallTrackingHandler(dragmoveUPP, NULL, NULL); s_animation_current_time = s_animation_start_time = CFAbsoluteTimeGetCurrent(); //// Dock Menu Initialization EventTypeSpec t_menu_event_specs[1]; t_menu_event_specs[0] . eventClass = kEventClassMenu; t_menu_event_specs[0] . eventKind = kEventMenuPopulate; CreateNewMenu(0, 0, &f_icon_menu); s_icon_menu_event_handler_upp = NewEventHandlerUPP((EventHandlerProcPtr)handleiconmenuevent); InstallEventHandler(GetMenuEventTarget(f_icon_menu), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL); t_menu_event_specs[0] . eventClass = kEventClassCommand; t_menu_event_specs[0] . eventKind = kEventCommandProcess; InstallEventHandler(GetApplicationEventTarget(), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL); SetApplicationDockTileMenu(f_icon_menu); //// Color Profile Initialization CMGetDefaultProfileBySpace(cmRGBData, &m_dst_profile); CMProfileLocation t_location; t_location . locType = cmPathBasedProfile; strcpy(t_location . u . pathLoc . path, "/System/Library/ColorSync/Profiles/sRGB Profile.icc"); CMOpenProfile(&m_srgb_profile, &t_location); //// return True; }
LPSTR create_keyval (WindowRef wnd, LPCSTR attrs, BOOL *verify_conn) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; TKEYVAL keyval_t; ControlID controlID; WindowRef wkeyval; ControlRef control; EventRecord event; IBNibRef nibRef; OSStatus err; /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier ( CFSTR ("org.iodbc.adm")), CFSTR ("keyval"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wkeyval); DisposeNibReference (nibRef); /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVERIFYCONN_CNTL, wkeyval, keyval_t.verify_conn_cb); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSLIST_CNTL, wkeyval, keyval_t.key_list); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSKEYWORD_CNTL, wkeyval, keyval_t.key_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVALUE_CNTL, wkeyval, keyval_t.value_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSUPDATE_CNTL, wkeyval, keyval_t.bupdate); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSADD_CNTL, wkeyval, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (keyval_add_clicked), 1, &controlSpec, &keyval_t, NULL); InstallEventHandler (GetControlEventTarget (keyval_t.bupdate), NewEventHandlerUPP (keyval_update_clicked), 1, &controlSpec, &keyval_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSOK_CNTL, wkeyval, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (keyval_ok_clicked), 1, &controlSpec, &keyval_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSCANCEL_CNTL, wkeyval, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (keyval_cancel_clicked), 1, &controlSpec, &keyval_t, NULL); /* Parse the attributes line */ keyval_t.mainwnd = wkeyval; addkeywords_to_list (keyval_t.key_list, attrs, &keyval_t); AdvanceKeyboardFocus (wkeyval); /* Show the window and run the loop */ DeactivateControl (keyval_t.bupdate); KEYVAL = &keyval_t; ShowSheetWindow(wkeyval, wnd); /* The main loop */ while (keyval_t.mainwnd) WaitNextEvent (everyEvent, &event, 60L, cursorRgn); if (keyval_t.connstr) *verify_conn = keyval_t.verify_conn; } else goto error; return keyval_t.connstr; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return keyval_t.connstr; }
void create_login (HWND hwnd, LPCSTR username, LPCSTR password, LPCSTR dsn, TLOGIN * log_t) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; WindowRef wlogin; ControlRef control; ControlID controlID; EventRecord event; IBNibRef nibRef; OSStatus err; char msg[1024]; if (hwnd == NULL) return; /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.drvproxy")), CFSTR ("login"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wlogin); DisposeNibReference (nibRef); /* Set the title with the DSN */ if (dsn) { msg[0] = STRLEN ("Login for ") + STRLEN(dsn); sprintf (msg+1, "Login for %s", (char*)dsn); SetWTitle (wlogin, msg); } /* Set the control into the structure */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBUSER_CNTL, wlogin, log_t->username); GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBPASS_CNTL, wlogin, log_t->password); log_t->user = log_t->pwd = NULL; log_t->mainwnd = wlogin; /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBOK_CNTL, wlogin, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (login_ok_clicked), 1, &controlSpec, log_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBCANCEL_CNTL, wlogin, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (login_cancel_clicked), 1, &controlSpec, log_t, NULL); SetControlData (log_t->username, 0, kControlEditTextTextTag, username ? STRLEN (username) : STRLEN(""), (UInt8 *) username ? username : ""); SetControlData (log_t->password, 0, kControlEditTextPasswordTag, password ? STRLEN (password) : STRLEN(""), (UInt8 *) password ? password : ""); /* Show the window and run the loop */ AdvanceKeyboardFocus (wlogin); ShowWindow (wlogin); /* The main loop */ while (log_t->mainwnd) { switch (WaitNextEvent (everyEvent, &event, 60L, cursorRgn)) { }; } } else goto error; return; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return; }
//-------------------------------------------------------------------------------------------------// void OSXCarbonWindow::create( const String& name, unsigned int width, unsigned int height, bool fullScreen, const NameValuePairList *miscParams ) { bool hasDepthBuffer; String title = name; size_t fsaa_samples = 0; int left = 0; int top = 0; int depth = 32; if( miscParams ) { NameValuePairList::const_iterator opt = NULL; // Full screen anti aliasing opt = miscParams->find( "FSAA" ); if( opt != miscParams->end() ) fsaa_samples = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "left" ); if( opt != miscParams->end() ) left = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "top" ); if( opt != miscParams->end() ) top = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "title" ); if( opt != miscParams->end() ) title = opt->second; opt = miscParams->find( "depthBuffer" ); if( opt != miscParams->end() ) hasDepthBuffer = StringConverter::parseBool( opt->second ); opt = miscParams->find( "colourDepth" ); if( opt != miscParams->end() ) depth = StringConverter::parseUnsignedInt( opt->second ); } if(fullScreen) { GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); OSXContext *mainContext = (OSXContext*)rs->_getMainContext(); CGLContextObj share = NULL; if(mainContext == 0) { share = NULL; } else if(mainContext->getContextType() == "AGL") { OSXCarbonContext* aglShare = static_cast<OSXCarbonContext*>(mainContext); aglGetCGLContext(aglShare->getContext(), &((void*)share)); } else if(mainContext->getContextType() == "CGL") { OSXCGLContext* cglShare = static_cast<OSXCGLContext*>(mainContext); share = cglShare->getContext(); } // create the context createCGLFullscreen(width, height, depth, fsaa_samples, share); } else { int i = 0; AGLPixelFormat pixelFormat; GLint attribs[ 20 ]; attribs[ i++ ] = AGL_NO_RECOVERY; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_ACCELERATED; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_RGBA; attribs[ i++ ] = AGL_DOUBLEBUFFER; attribs[ i++ ] = AGL_ALPHA_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_STENCIL_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_DEPTH_SIZE; attribs[ i++ ] = depth; if(fsaa_samples > 1) { attribs[ i++ ] = AGL_MULTISAMPLE; attribs[ i++ ] = 1; attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB; attribs[ i++ ] = fsaa_samples; } attribs[ i++ ] = AGL_NONE; pixelFormat = aglChoosePixelFormat( NULL, 0, attribs ); // Create the AGLContext from our pixel format // Share it with main GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); OSXContext* mainContext = static_cast<OSXContext*>( rs->_getMainContext() ); if(mainContext == 0) { mAGLContext = aglCreateContext(pixelFormat, NULL); } else if(mainContext->getContextType() == "AGL") { OSXCarbonContext* context = static_cast<OSXCarbonContext*>( rs->_getMainContext() ); AGLContext shared = context->getContext(); mAGLContext = aglCreateContext(pixelFormat, context->getContext()); } else { // If we do not have an AGL, we can not clone it using this window LogManager::getSingleton().logMessage( "Warning: You asked to create a second window, " "when the previous window was not of this type. OgreOSXCarbonWindow can only share " "with an AGL context."); } NameValuePairList::const_iterator opt = 0; if(miscParams) opt = miscParams->find("externalWindowHandle"); if(!miscParams || opt == miscParams->end()) { // create the window rect in global coords ::Rect windowRect; windowRect.left = 0; windowRect.top = 0; windowRect.right = width; windowRect.bottom = height; // set the default attributes for the window WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize" if (miscParams) { opt = miscParams->find("border"); if( opt != miscParams->end() ) { String borderType = opt->second; if( borderType == "none" ) windowAttrs = kWindowNoTitleBarAttribute; else if( borderType == "fixed" ) windowAttrs = kWindowStandardFloatingAttributes; } } windowAttrs |= kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowHideOnFullScreenAttribute; // Create the window CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow); // Color the window background black SetThemeWindowBackground (mWindow, kThemeBrushBlack, true); // Set the title of our window CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII ); SetWindowTitleWithCFString( mWindow, titleRef ); // Center our window on the screen RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen ); // Get our view HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView ); // Set up our UPP for Window Events EventTypeSpec eventSpecs[] = { {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowClosed}, {kEventClassWindow, kEventWindowClose} }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler); // Install the standard event handler for the window EventTargetRef target = GetWindowEventTarget(mWindow); InstallStandardEventHandler(target); // We also need to install the WindowEvent Handler, we pass along the window with our requests InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef); // Display and select our window ShowWindow(mWindow); SelectWindow(mWindow); // Add our window to the window event listener class WindowEventUtilities::_addRenderWindow(this); } else { // TODO: The Contol is going to report the incorrect location with a // Metalic / Textured window. The default windows work just fine. // First get the HIViewRef / ControlRef mView = (HIViewRef)StringConverter::parseUnsignedLong(opt->second); mWindow = GetControlOwner(mView); // Lets try hiding the HIView //HIViewSetVisible(mView, false); // Get the rect bounds ::Rect ctrlBounds; GetControlBounds(mView, &ctrlBounds); GLint bufferRect[4]; bufferRect[0] = ctrlBounds.left; // left edge bufferRect[1] = ctrlBounds.bottom; // bottom edge bufferRect[2] = ctrlBounds.right - ctrlBounds.left; // width of buffer rect bufferRect[3] = ctrlBounds.bottom - ctrlBounds.top; // height of buffer rect aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); aglEnable (mAGLContext, AGL_BUFFER_RECT); mIsExternal = true; } // Set the drawable, and current context // If you do this last, there is a moment before the rendering window pops-up // This could go once inside each case above, before the window is displayed, // if desired. aglSetDrawable(mAGLContext, GetWindowPort(mWindow)); aglSetCurrentContext(mAGLContext); // Give a copy of our context to the render system mContext = new OSXCarbonContext(mAGLContext, pixelFormat); } mName = name; mWidth = width; mHeight = height; mActive = true; mClosed = false; mCreated = true; mIsFullScreen = fullScreen; }
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd), fAGLCtx(NULL) { OSStatus result; WindowRef wr = (WindowRef)hWnd; HIViewRef imageView, parent; HIViewRef rootView = HIViewGetRoot(wr); HIViewFindByID(rootView, kHIViewWindowContentID, &parent); result = HIImageViewCreate(NULL, &imageView); SkASSERT(result == noErr); result = HIViewAddSubview(parent, imageView); SkASSERT(result == noErr); fHVIEW = imageView; HIViewSetVisible(imageView, true); HIViewPlaceInSuperviewAt(imageView, 0, 0); if (true) { HILayoutInfo layout; layout.version = kHILayoutInfoVersionZero; set_bindingside(&layout.binding.left, parent, kHILayoutBindLeft); set_bindingside(&layout.binding.top, parent, kHILayoutBindTop); set_bindingside(&layout.binding.right, parent, kHILayoutBindRight); set_bindingside(&layout.binding.bottom, parent, kHILayoutBindBottom); set_axisscale(&layout.scale.x, parent); set_axisscale(&layout.scale.y, parent); set_axisposition(&layout.position.x, parent, kHILayoutPositionLeft); set_axisposition(&layout.position.y, rootView, kHILayoutPositionTop); HIViewSetLayoutInfo(imageView, &layout); } HIImageViewSetOpaque(imageView, true); HIImageViewSetScaleToFit(imageView, false); static const EventTypeSpec gTypes[] = { { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyUp }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseDragged }, { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseUp }, { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, { kEventClassWindow, kEventWindowBoundsChanged }, // { kEventClassWindow, kEventWindowDrawContent }, { SK_MacEventClass, SK_MacEventKind } }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(SkOSWindow::EventHandler); int count = SK_ARRAY_COUNT(gTypes); result = InstallEventHandler(GetWindowEventTarget(wr), handlerUPP, count, gTypes, this, nil); SkASSERT(result == noErr); gCurrOSWin = this; gCurrEventQ = GetCurrentEventQueue(); gEventTarget = GetWindowEventTarget(wr); static bool gOnce = true; if (gOnce) { gOnce = false; gPrevNewHandler = set_new_handler(sk_new_handler); } }
void tool_wind_open(void) { int x,t,rspace,wid; Rect wbox,box; ControlButtonContentInfo icon_info; HMHelpContentRec tag; EventTypeSpec wind_events[]={{kEventClassControl,kEventControlHit}}; GetAvailableWindowPositioningBounds(GetMainDevice(),&wbox); SetRect(&box,wbox.left,wbox.top,wbox.right,(wbox.top+28)); CreateNewWindow(kFloatingWindowClass,kWindowStandardFloatingAttributes|kWindowStandardHandlerAttribute,&box,&toolwind); ChangeWindowAttributes(toolwind,kWindowNoConstrainAttribute,kWindowCloseBoxAttribute|kWindowFullZoomAttribute|kWindowCollapseBoxAttribute|kWindowResizableAttribute); /* SetRect(&box,2,2,26,26); for (t=0;t!=maxtool;t++) { // create button icon_info.contentType=kControlContentCIconRes; icon_info.u.resID=500+t; CreateBevelButtonControl(toolwind,&box,NULL,kControlBevelButtonSmallBevel,kControlBehaviorToggles,&icon_info,0,0,0,&tool_ctrl[t]); // create tooltip tag.version=kMacHelpVersion; tag.tagSide=kHMDefaultSide; SetRect(&tag.absHotRect,0,0,0,0); tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent; tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,tool_tooltip_str[t],kCFStringEncodingMacRoman); tag.content[kHMMaximumContentIndex].contentType=kHMNoContent; HMSetControlHelpContent(tool_ctrl[t],&tag); // next button position OffsetRect(&box,24,0); if ((t==2) || (t==5) || (t==13) || (t==15) || (t==18)) OffsetRect(&box,5,0); } // remaining space rspace=wbox.right-(box.left+5); // group combo CreateNewMenu(group_combo_menu_id,kMenuAttrExcludesMarkColumn,&group_menu); InsertMenu(group_menu,kInsertHierarchicalMenu); wid=(rspace-5)/2; if (wid>200) wid=200; group_box=box; group_box.top++; group_box.bottom++; group_box.left+=5; group_box.right=group_box.left+wid; CreatePopupButtonControl(toolwind,&group_box,NULL,group_combo_menu_id,FALSE,0,0,0,&group_combo); // magnify slider wid=(rspace-5)/2; x=wbox.right-wid; SetRect(&box,x,5,(x+16),21); icon_info.contentType=kControlContentCIconRes; icon_info.u.resID=130; CreateIconControl(toolwind,&box,&icon_info,TRUE,&magnify_icon); tag.version=kMacHelpVersion; tag.tagSide=kHMDefaultSide; SetRect(&tag.absHotRect,0,0,0,0); tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent; tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,"Magnify",kCFStringEncodingMacRoman); tag.content[kHMMaximumContentIndex].contentType=kHMNoContent; HMSetControlHelpContent(magnify_icon,&tag); SetRect(&box,(x+20),5,(x+(wid-6)),25); magnify_proc=NewControlActionUPP(tool_wind_magnify_action); CreateSliderControl(toolwind,&box,(magnify_factor-1),5,210,kControlSliderDoesNotPoint,0,TRUE,magnify_proc,&magnify_slider); */ // tool window events tool_wind_upp=NewEventHandlerUPP(tool_wind_event_callback); InstallEventHandler(GetWindowEventTarget(toolwind),tool_wind_upp,GetEventTypeCount(wind_events),wind_events,NULL,&tool_wind_event); ShowWindow(toolwind); }
static WindowRef DrawDialogTheMacOSXWay(void) { // Create a window. "DLOG:257" is the name of the window object. This name is set in // InterfaceBuilder when the resource file is imported. OSStatus status = noErr; IBNibRef nibRef; WindowRef window = NULL; static HIObjectClassRef theClass; if (theClass == NULL) { static EventTypeSpec kFactoryEvents[] = { { kEventClassHIObject, kEventHIObjectConstruct }, { kEventClassHIObject, kEventHIObjectInitialize }, { kEventClassHIObject, kEventHIObjectDestruct }, { kEventClassControl, kEventControlHitTest }, { kEventClassControl, kEventControlTrack }, { kEventClassControl, kEventControlBoundsChanged }, { kEventClassControl, kEventControlDraw } }; HIObjectRegisterSubclass(kCustomSpotViewClassID, kHIViewClassID, 0, CustomSpotViewHandler, GetEventTypeCount(kFactoryEvents), kFactoryEvents, 0, &theClass); } status = CreateNibReference(CFSTR("main"), &nibRef); require_noerr(status, CantGetNibRef); status = CreateWindowFromNib(nibRef, CFSTR("DLOG:257"), &window); require_noerr(status, CantCreateWindow); // Let's react to User's commands. EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess}; InstallEventHandler(GetWindowEventTarget(window), MacOSXDialogCommandProcess, 1, &eventTypeCP, window, NULL); // we still assign the key filter on our edit text box so that only digits can be entered HIViewID hidnst = {0, 9}; HIViewRef numEditText; HIViewFindByID(HIViewGetRoot(window), hidnst, &numEditText); ControlKeyFilterUPP keyFilter = MyEditKeyFilter; SetControlData(numEditText, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter); SetKeyboardFocus(window, numEditText, kControlFocusNextPart); // we still set the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work // and still associate the previous edit text box with the scroll bar so it gets updated HIViewID hidsb = {0, 14}; HIViewRef scrollBar; HIViewFindByID(HIViewGetRoot(window), hidsb, &scrollBar); SetControlAction(scrollBar, ScrollBar32BitActionProc); SetControlReference(scrollBar, (SInt32)numEditText); // Move it! MoveWindow(window, 854, 271, false); // and use the replacement for ModalDialog // one good thing is that our behaviors are no longer half-done at the dialog level // and half-done at the control level, they are all handled by the view handlers ShowWindow(window); CantCreateWindow: CantGetNibRef: return (window); }
LPSTR create_gensetup (HWND hwnd, LPCSTR dsn, LPCSTR attrs, BOOL add, BOOL *verify_conn) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; TGENSETUP gensetup_t; ControlID controlID; WindowRef wgensetup; ControlRef control; EventRecord event; IBNibRef nibRef; OSStatus err; char msg[1024]; gensetup_t.verify_conn = true; /* Search the bundle for a .nib file named 'odbcadmin'. */ /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier ( CFSTR ("org.iodbc.adm")), CFSTR ("gensetup"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wgensetup); DisposeNibReference (nibRef); /* Set the title with the DSN */ if (dsn) { msg[0] = STRLEN ("Setup of ") + STRLEN(dsn); sprintf (msg+1, "Setup of %s", (char*)dsn); SetWTitle (wgensetup, msg); } /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSDSN_CNTL, wgensetup, gensetup_t.dsn_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVERIFYCONN_CNTL, wgensetup, gensetup_t.verify_conn_cb); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSLIST_CNTL, wgensetup, gensetup_t.key_list); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSKEYWORD_CNTL, wgensetup, gensetup_t.key_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSVALUE_CNTL, wgensetup, gensetup_t.value_entry); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSUPDATE_CNTL, wgensetup, gensetup_t.bupdate); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSADD_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_add_clicked), 1, &controlSpec, &gensetup_t, NULL); InstallEventHandler (GetControlEventTarget (gensetup_t.bupdate), NewEventHandlerUPP (gensetup_update_clicked), 1, &controlSpec, &gensetup_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSOK_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_ok_clicked), 1, &controlSpec, &gensetup_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, GSCANCEL_CNTL, wgensetup, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (gensetup_cancel_clicked), 1, &controlSpec, &gensetup_t, NULL); /* Parse the attributes line */ gensetup_t.mainwnd = wgensetup; parse_attribute_line (&gensetup_t, dsn, attrs, add); AdvanceKeyboardFocus (wgensetup); /* Show the window and run the loop */ DeactivateControl (gensetup_t.bupdate); DSNSETUP = &gensetup_t; ShowWindow (wgensetup); /* The main loop */ while (gensetup_t.mainwnd) { switch (WaitNextEvent (everyEvent, &event, 60L, cursorRgn)) { }; } *verify_conn = gensetup_t.verify_conn; } else goto error; return gensetup_t.connstr; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return gensetup_t.connstr; }
BOOL create_confirm_Internal (HWND hwnd, SQLPOINTER dsn, SQLPOINTER text, SQLCHAR waMode) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; ControlID controlID; ControlRef control; WindowRef wconfirm; TCONFIRM confirm_t; EventRecord event; IBNibRef nibRef; CFStringRef msg; OSStatus err; /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.drvproxy")), CFSTR ("confirmation"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wconfirm); DisposeNibReference (nibRef); /* Set the title with the DSN name */ if (dsn) { if (waMode == 'A') msg = CFStringCreateWithBytes (NULL, (unsigned char*)dsn, STRLEN(dsn), kCFStringEncodingUTF8, false); else msg = convert_wchar_to_CFString((wchar_t*)dsn); SetWindowTitleWithCFString (wconfirm, msg); CFRelease(msg); } /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFYES_CNTL, wconfirm, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (confirmadm_yes_clicked), 1, &controlSpec, &confirm_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFNO_CNTL, wconfirm, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (confirmadm_no_clicked), 1, &controlSpec, &confirm_t, NULL); /* Change the static field with the message */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFTEXT_CNTL, wconfirm, control); if (waMode == 'A') SetControlData (control, 0, kControlEditTextTextTag, STRLEN (text), text); else { msg = convert_wchar_to_CFString((wchar_t*)text); SetControlData (control, 0, kControlEditTextCFStringTag, sizeof(CFStringRef), &msg); CFRelease(msg); } DrawOneControl (control); confirm_t.yes_no = FALSE; confirm_t.mainwnd = wconfirm; /* Show the window and run the loop */ ShowWindow (wconfirm); /* The main loop */ while (confirm_t.mainwnd) WaitNextEvent (everyEvent, &event, 60L, cursorRgn); } else goto error; return confirm_t.yes_no; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return confirm_t.yes_no; }
void OSXCarbonWindow::createNewWindow(unsigned int width, unsigned int height, String title) { if(!mWindow) { // Create the window rect in global coords ::Rect windowRect; windowRect.left = 0; windowRect.top = 0; windowRect.right = width; windowRect.bottom = height; // Set the default attributes for the window WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize" windowAttrs |= kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowHideOnFullScreenAttribute | kWindowNoShadowAttribute; // Create the window CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow); // Color the window background black SetThemeWindowBackground(mWindow, kThemeBrushBlack, true); // Set the title of our window CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII ); SetWindowTitleWithCFString( mWindow, titleRef ); CFRelease(titleRef); mWindowTitle = title; // Center our window on the screen RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen ); // Get our view HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView ); // Set up our UPP for Window Events EventTypeSpec eventSpecs[] = { {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowClosed}, {kEventClassWindow, kEventWindowClose} }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler); // Install the standard event handler for the window EventTargetRef target = GetWindowEventTarget(mWindow); InstallStandardEventHandler(target); // We also need to install the WindowEvent Handler, we pass along the window with our requests InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef); } HIRect winBounds = CGRectZero; HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView)); HIViewGetBounds(root, &winBounds); HIRect viewBounds = CGRectZero; HIViewGetBounds(mView, &viewBounds); // Display and select our window if(!mHidden && mVisible) { ShowWindow(mWindow); SelectWindow(mWindow); } // Add our window to the window event listener class WindowEventUtilities::_addRenderWindow(this); }
int main(int argc, char *argv[]) { WindowRef window; HIViewRef content; HIViewRef combo; HIViewRef group; HIViewRef check; HIViewRef text; HIViewRef slider; HIViewRef quit; MenuRef menu; HIRect rect; // Window bounds Rect bounds = {0, 0, 436, 590}; // Create window CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowCompositingAttribute, &bounds, &window); // Set the title SetWindowTitleWithCFString(window, CFSTR("Accordion")); // Create an application menu CreateNewMenu(0, 0, &menu); // Set menu title SetMenuTitleWithCFString(menu, CFStringCreateWithPascalString(kCFAllocatorDefault, "\p\024", kCFStringEncodingMacRoman)); // Create an about item InsertMenuItemTextWithCFString(menu, CFSTR("About Accordion"), 0, 0, kHICommandAbout); // Insert the menu InsertMenu(menu, 0); // Create a standard window menu CreateStandardWindowMenu(0, &menu); // Insert the menu InsertMenu(menu, 0); // Show and position the window ShowWindow(window); RepositionWindow(window, NULL, kWindowCascadeOnMainScreen); // Find the window content HIViewFindByID(HIViewGetRoot(window), kHIViewWindowContentID, &content); // Set bounds for group box bounds.bottom = 92; bounds.right = 550; // Create group box CreateGroupBoxControl(window, &bounds, NULL, true, &group); // Place in the window HIViewAddSubview(content, group); HIViewPlaceInSuperviewAt(group, 20, 20); // Bounds of text bounds.bottom = 16; bounds.right = 74; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Instrument:"), NULL, &text); // Place in the group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 16, 18); // Bounds of combo box rect.size.height = 20; rect.size.width = 168; // Create combo box HIComboBoxCreate(&rect, CFSTR(" Accordion"), NULL, NULL, kHIComboBoxStandardAttributes, &combo); // Set visible and set command ID HIViewSetVisible(combo, true); HIViewSetCommandID(combo, kCommandInst); // Add the instruments for (int i = 0; i < Length(instruments); i++) { HIComboBoxAppendTextItem(combo, CFStringCreateWithCString(kCFAllocatorDefault, instruments[i], kCFStringEncodingMacRoman), NULL); // Set the current instrument if (strcmp(instruments[i], " Accordion") == 0) instrument = i; } // Place in the group box HIViewAddSubview(group, combo); HIViewPlaceInSuperviewAt(combo, 102, 16); // Bounds of check box bounds.bottom = 18; bounds.right = 121; // Create check box CreateCheckBoxControl(window, &bounds, CFSTR("Reverse"), false, true, &check); // Set the control ID and the command ID HIViewSetID(check, kHIViewIDReverse); HIViewSetCommandID(check, kCommandReverse); // Place in the group box HIViewAddSubview(group, check); HIViewPlaceInSuperviewAt(check, 286, 17); // Bounds of text bounds.bottom = 16; bounds.right = 32; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Key:"), NULL, &text); // Place in the group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 400, 18); // Bounds of combo box rect.size.width = 90; // Create combo box HIComboBoxCreate(&rect, CFSTR(" A/D/G"), NULL, NULL, kHIComboBoxStandardAttributes, &combo); // Set visible and set command ID HIViewSetVisible(combo, true); HIViewSetID(combo, kHIViewIDKey); HIViewSetCommandID(combo, kCommandKey); // Add keys for (int i = 0; i < Length(keys); i++) { HIComboBoxAppendTextItem(combo, CFStringCreateWithCString(kCFAllocatorDefault, keys[i], kCFStringEncodingMacRoman), NULL); // Set current key if (strcmp(keys[i], " A/D/G") == 0) key = i; } // Place in the group box HIViewAddSubview(group, combo); HIViewPlaceInSuperviewAt(combo, 440, 16); // Bounds of text bounds.bottom = 16; bounds.right = 54; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Volume:"), NULL, &text); // Place in the group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 16, 56); // Bounds of slider bounds.bottom = 16; bounds.right = 168; // Create slider CreateSliderControl(window, &bounds, MAXVOL, 0, MAXVOL, kControlSliderDoesNotPoint, 0, false, NULL, &slider); // Set command ID HIViewSetCommandID(slider, kCommandVolume); // Place in the group box HIViewAddSubview(group, slider); HIViewPlaceInSuperviewAt(slider, 100, 58); // Bounds of check box bounds.bottom = 18; bounds.right = 121; // Create check box CreateCheckBoxControl(window, &bounds, CFSTR("Notes"), false, true, &check); // Set the control ID and the command ID HIViewSetID(check, kHIViewIDNote); HIViewSetCommandID(check, kCommandNote); // Place in the group box HIViewAddSubview(group, check); HIViewPlaceInSuperviewAt(check, 286, 56); // Bounds of push button bounds.bottom = 20; bounds.right = 90; // Create push button CreatePushButtonControl(window, &bounds, CFSTR("Quit"), &quit); // Set command ID HIViewSetCommandID(quit, kHICommandQuit); // Place in the group box HIViewAddSubview(group, quit); HIViewPlaceInSuperviewAt(quit, 440, 54); // Group box bounds bounds.bottom = 48; bounds.right = 550; // Create group box CreateGroupBoxControl(window, &bounds, NULL, true, &group); // Place in the window HIViewAddSubview(content, group); HIViewPlaceInSuperviewAt(group, 20, 132); // Font style ControlFontStyleRec style; style.flags = kControlUseFontMask|kControlUseJustMask; style.font = kControlFontBigSystemFont; style.just = teCenter; // Bounds of text bounds.bottom = 16; bounds.right = 550; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Accordion"), &style, &text); // Place in the group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 0, 8); // Bounds of text bounds.bottom = 16; bounds.right = 550; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Play accordion on your keyboard"), &style, &text); // Place in the group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 0, 24); // Group box bounds bounds.bottom = 196; bounds.right = 550; // Create group box CreateGroupBoxControl(window, &bounds, NULL, true, &group); // Place in the window HIViewAddSubview(content, group); HIViewPlaceInSuperviewAt(group, 20, 200); // Button bounds bounds.bottom = SIZE; bounds.right = SIZE; // Create row of bass buttons for (int i = 0; i < Length(bassdisplay); i++) { int x = 15 + 44 * i; int y = 15; // Create button CreateBevelButtonControl(window, &bounds, NULL, kControlBevelButtonNormalBevel, kControlBehaviorPushbutton, NULL, 0, 0, 0, &bassdisplay[i]); // Place in the group box HIViewAddSubview(group, bassdisplay[i]); HIViewPlaceInSuperviewAt(bassdisplay[i], x, y); } // Create three rows of buttons for (int i = 0; i < Length(display); i++) { for (int j = 0; j < ((i == 1)? Length(display[i]): Length(display[i]) - 1); j++) { int x = (i == 1)? 37 + 44 * j: 59 + 44 * j; int y = 59 + 44 * i; // Create button CreateBevelButtonControl(window, &bounds, NULL, kControlBevelButtonNormalBevel, kControlBehaviorPushbutton, NULL, 0, 0, 0, &display[i][j]); // Place in the group box HIViewAddSubview(group, display[i][j]); HIViewPlaceInSuperviewAt(display[i][j], x, y); } } // Create spacebar button CreateBevelButtonControl(window, &bounds, NULL, kControlBevelButtonNormalBevel, kControlBehaviorPushbutton, NULL, 0, 0, 0, &spacebar); // Place in the group box HIViewAddSubview(group, spacebar); HIViewPlaceInSuperviewAt(spacebar, 16, 147); // Group box bounds, wider than the window to hide rounded corners bounds.bottom = 20; bounds.right = 598; // Create group box for fake status bar CreateGroupBoxControl(window, &bounds, NULL, false, &group); // Place in window at negative offset to hide rounded corners HIViewAddSubview(content, group); HIViewPlaceInSuperviewAt(group, -4, 416); // Text bounds bounds.bottom = 16; bounds.right = 590; // Font style style.flags = kControlUseFontMask|kControlUseJustMask; style.font = kControlFontSmallSystemFont; style.just = teCenter; // Create static text CreateStaticTextControl(window, &bounds, CFSTR("Press the keyboard keys as accordion buttons " "and the space bar as the bellows. 3rd button start."), &style, &text); // Place in group box HIViewAddSubview(group, text); HIViewPlaceInSuperviewAt(text, 0, 2); // Application events type spec EventTypeSpec applicationEvents[] = {{kEventClassApplication, kEventAppFrontSwitched}}; // Install event handler InstallApplicationEventHandler(NewEventHandlerUPP(ApplicationHandler), Length(applicationEvents), applicationEvents, NULL, NULL); // Mouse events type spec EventTypeSpec mouseEvents[] = {{kEventClassMouse, kEventMouseDown}}; // Install event handler on the event dispatcher, so that we can // see mouse events before the default handler gets them InstallEventHandler(GetEventDispatcherTarget(), NewEventHandlerUPP(MouseHandler), Length(mouseEvents), mouseEvents, NULL, NULL); // Window events type spec EventTypeSpec windowEvents[] = {{kEventClassWindow, kEventWindowClose}}; // Install event handler InstallWindowEventHandler(window, NewEventHandlerUPP(WindowHandler), Length(windowEvents), windowEvents, NULL, NULL); // Combo box events type spec EventTypeSpec comboBoxEvents[] = {{kEventClassHIComboBox, kEventComboBoxListItemSelected}}; // Install event handler InstallApplicationEventHandler(NewEventHandlerUPP(ComboBoxHandler), Length(comboBoxEvents), comboBoxEvents, NULL, NULL); // Command events type spec EventTypeSpec commandEvents[] = {{kEventClassCommand, kEventCommandProcess}}; // Install event handler InstallApplicationEventHandler(NewEventHandlerUPP(CommandHandler), Length(commandEvents), commandEvents, NULL, NULL); // Keyboard events type spec EventTypeSpec keyboardEvents[] = {{kEventClassKeyboard, kEventRawKeyDown}, {kEventClassKeyboard, kEventRawKeyUp}, {kEventClassKeyboard, kEventRawKeyModifiersChanged}}; // Install event handler on the event dispatcher InstallEventHandler(GetEventDispatcherTarget(), NewEventHandlerUPP(KeyboardHandler), Length(keyboardEvents), keyboardEvents, NULL, NULL); // Audio Unit graph AUGraph graph; // Audio Unit synthesizer and output node AUNode synthNode; AUNode outNode; // Component description ComponentDescription cd; cd.componentManufacturer = kAudioUnitManufacturer_Apple; cd.componentFlags = 0; cd.componentFlagsMask = 0; do { // New AU graph OSStatus status = NewAUGraph(&graph); if (status != noErr) { DisplayAlert(CFSTR("NewAUGraph"), CFSTR("Can't create a new AUGraph"), status); break; } // Synthesizer cd.componentType = kAudioUnitType_MusicDevice; cd.componentSubType = kAudioUnitSubType_DLSSynth; // New synthesizer node status = AUGraphNewNode(graph, &cd, 0, NULL, &synthNode); if (status != noErr) { DisplayAlert(CFSTR("AUGraphNewNode"), CFSTR("Can't create a new AUGraph node"), status); break; } // Output cd.componentType = kAudioUnitType_Output; cd.componentSubType = kAudioUnitSubType_DefaultOutput; // New output node status = AUGraphNewNode(graph, &cd, 0, NULL, &outNode); if (status != noErr) { DisplayAlert(CFSTR("AUGraphNewNode"), CFSTR("Can't create a new AUGraph node"), status); break; } // Open graph status = AUGraphOpen(graph); if (status != noErr) { DisplayAlert(CFSTR("AUGraphOpen"), CFSTR("Can't open AUGraph"), status); break; } // Connect synthesizer node to output node status = AUGraphConnectNodeInput(graph, synthNode, 0, outNode, 0); if (status != noErr) { DisplayAlert(CFSTR("AUGraphConnectNodeInput"), CFSTR("Can't connect AUGraph input node"), status); break; } // Get a synthesizer unit status = AUGraphGetNodeInfo(graph, synthNode, NULL, 0, NULL, &synthUnit); if (status != noErr) { DisplayAlert(CFSTR("AUGraphGetNodeInfo"), CFSTR("Can't get AUGraph node info"), status); break; } // Initialise status = AUGraphInitialize(graph); if (status != noErr) { DisplayAlert(CFSTR("AUGraphInitialize"), CFSTR("Can't initialize AUGraph"), status); break; } // Start status = AUGraphStart(graph); if (status != noErr) { DisplayAlert(CFSTR("AUGraphStart"), CFSTR("Can't start AUGraph"), status); break; } // Show the graph // CAShow(graph); } while (false); // Change instrument ChangeInstrument(instrument); // Run the application event loop RunApplicationEventLoop(); // Stop the graph AUGraphStop(graph); // Dispose of the graph DisposeAUGraph(graph); // Exit return 0; }