for_each(BumpTopCommand* option, ordered_context_menu_items) { err = InsertMenuItemTextWithCFString(carbon_context_menu, CFStringFromQString(option->name()), menu_size, // MenuItemIndex inAfterItem option->isSeparator() ? kMenuItemAttrSeparator : 0, // MenuItemAttributes inAttributes 0); // MenuCommand inCommandID if (option->has_subcommands()) { QStringList subcommand_names = option->subcommand_names(actors); err = CreateNibReference(CFSTR("ContextMenu"), &nib_ref); MenuRef carbon_context_sub_menu; err = CreateMenuFromNib(nib_ref, CFSTR("ItemContextMenu"), &carbon_context_sub_menu); err = ChangeMenuAttributes(carbon_context_sub_menu, kMenuAttrCondenseSeparators, NULL); DisposeNibReference(nib_ref); int sub_menu_size = 0; for_each(QString subcommand, subcommand_names) { err = InsertMenuItemTextWithCFString(carbon_context_sub_menu, CFStringFromQString(subcommand), sub_menu_size, // MenuItemIndex inAfterItem subcommand == "" ? kMenuItemAttrSeparator : 0, // MenuItemAttributes inAttributes 0); // MenuCommand inCommandID CGImageRef icon = option->iconForSubcommand(actors, sub_menu_size); if (icon) { err = SetMenuItemIconHandle (carbon_context_sub_menu, sub_menu_size+1, kMenuCGImageRefType, (Handle) icon); CGImageRelease(icon); } sub_menu_size++; }
static PyObject *IBNibRefObj_CreateMenuFromNib(IBNibRefObject *_self, PyObject *_args) { PyObject *_res = NULL; OSStatus _err; CFStringRef inName; MenuHandle outMenuRef; if (!PyArg_ParseTuple(_args, "O&", CFStringRefObj_Convert, &inName)) return NULL; _err = CreateMenuFromNib(_self->ob_itself, inName, &outMenuRef); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", MenuObj_New, outMenuRef); return _res; }
/* Constructor for CARBON_GUI class. */ CARBON_GUI::CARBON_GUI(int argc, char **argv, Stream_mixer *mix) : GUI(argc,argv,mix) { /* initialization stuff */ jmix = mix; memset(myLcd,0,sizeof(myLcd)); memset(myPos,0,sizeof(myPos)); vumeter=0; vuband=0; selectedChannel=NULL; memset(channel,0,sizeof(channel)); playlistManager=new PlaylistManager(); msgList=new Linklist(); /* init mutex used when accessing the statusbox buffer ... * this is needed because other threads can try to write status messages concurrently */ if(pthread_mutex_init(&_statusLock,NULL) == -1) { error("error initializing POSIX thread mutex creating a new CarbonChannel"); QuitApplicationEventLoop(); } // Create a Nib reference err = CreateNibReference(CFSTR("main"), &nibRef); if(err != noErr) error("Can't get NIB reference to obtain gui controls!!"); // Create the MainWindow using nib resource file err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window); if(err != noErr) { error("Can't create MainWindow!!"); QuitApplicationEventLoop(); } else { msg = new CarbonMessage(nibRef); /* make the main window also the frontmost one */ BringToFront(window); init_controls(); /* now create the menu to use for the menubar ... it's stored in nib */ err=CreateMenuFromNib(nibRef,CFSTR("MenuBar"),&mainMenu); if(err!=noErr) { msg->error("Can't create main menu (%d)!!",err); } /* install vumeter controls */ setupVumeters(); /* and the status box */ setupStatusWindow(); bufferInspector = new BufferInspector(window,nibRef,jmix); /* now we have to group windows together so if all are visible they will also be layered together */ err=CreateWindowGroup(kWindowGroupAttrLayerTogether,&mainGroup); err=SetWindowGroup(window,mainGroup); err=SetWindowGroup(vumeterWindow,mainGroup); err=SetWindowGroup(statusWindow,mainGroup); err=SetWindowGroup(bufferInspector->window,mainGroup); SetWindowGroupOwner(mainGroup,window); /* let's create a channel window for each active input channel */ unsigned int i; bool cc=false; for (i=0;i<MAX_CHANNELS;i++) { strcpy(ch_lcd[i],"00:00:00"); if(jmix->chan[i]) { CarbonChannel *newChan = new CarbonChannel(jmix,this,nibRef,i); channel[i] = newChan; /* if(i > 0) { RepositionWindow(channel[i]->window,channel[i-1]->window,kWindowCascadeOnParentWindow); } else { RepositionWindow(channel[i],window,kWindowCascadeOnParentWindow); } */ cc=true; } else { channel[i] = NULL; } } /* Ok, once MainWindow has been created and we have instantiated all acrive input channels, * we need an instance of CarbonStream to control the stream option window */ streamHandler = new CarbonStream(jmix,window,nibRef); /* by default we want at leat one active channel */ if(!cc) new_channel(); aboutWindow = new AboutWindow(window,nibRef); // The window was created hidden so show it. ShowWindow( window ); } }
GetHandleSize((Handle) file_alias), &file_list_element); HUnlock((Handle) file_alias); AEPutDesc(&file_list, 0, &file_list_element); } } UInt32 user_selection_type; MenuID menu_id; MenuItemIndex menu_item_index; IBNibRef nib_ref; err = CreateNibReference(CFSTR("ContextMenu"), &nib_ref); MenuRef carbon_context_menu; err = CreateMenuFromNib(nib_ref, CFSTR("ItemContextMenu"), &carbon_context_menu); // change double separators to just one separator: err = ChangeMenuAttributes(carbon_context_menu, kMenuAttrCondenseSeparators, NULL); DisposeNibReference(nib_ref); int num_submenu_items = 0; int menu_size = 0; for_each(BumpTopCommand* option, ordered_context_menu_items) { err = InsertMenuItemTextWithCFString(carbon_context_menu, CFStringFromQString(option->name()), menu_size, // MenuItemIndex inAfterItem option->isSeparator() ? kMenuItemAttrSeparator : 0, // MenuItemAttributes inAttributes 0); // MenuCommand inCommandID if (option->has_subcommands()) { QStringList subcommand_names = option->subcommand_names(actors);