static void mac_adjustmenus(void) { WindowPtr window; MenuHandle menu; window = FrontWindow(); menu = GetMenuHandle(mApple); EnableItem(menu, 0); EnableItem(menu, iAbout); menu = GetMenuHandle(mFile); EnableItem(menu, 0); EnableItem(menu, iNew); if (window != NULL) EnableItem(menu, iClose); else DisableItem(menu, iClose); EnableItem(menu, iQuit); if (mac_wininfo(window)->adjustmenus != NULL) (*mac_wininfo(window)->adjustmenus)(window); else { DisableItem(menu, iSave); DisableItem(menu, iSaveAs); menu = GetMenuHandle(mEdit); DisableItem(menu, 0); menu = GetMenuHandle(mWindow); DisableItem(menu, 0); /* Until we get more than 1 item on it. */ } DrawMenuBar(); }
void toggle_menus( boolean game_started) { MenuHandle menu_interface, menu_game; short item; static boolean first_time= TRUE; /* First time, we insert the menus... */ if(first_time) { MenuHandle menu; /* Insert our fake menu */ menu= GetMenu(mFakeEmptyMenu); assert(menu); InsertMenu(menu, 0); menu= GetMenu(mInterface); assert(menu); InsertMenu(menu, -1); menu= GetMenu(mGame); assert(menu); InsertMenu(menu, -1); first_time= FALSE; } menu_interface= GetMenuHandle(mInterface); menu_game= GetMenuHandle(mGame); assert(menu_game && menu_interface); if(game_started) { DisableItem(menu_interface, 0); EnableItem(menu_game, 0); } else { DisableItem(menu_game, 0); EnableItem(menu_interface, 0); } /* Handle enabling/disabling everything.. */ for(item= iNewGame; item<=iCenterButton; ++item) { if(enabled_item(item)) { EnableItem(menu_interface, item); } else { DisableItem(menu_interface, item); } } return; }
void QTApp_AdjustMenus (WindowReference theWindow, MenuReference theMenu) { #if TARGET_OS_MAC #pragma unused(theMenu) #endif WindowObject myWindowObject = NULL; MovieController myMC = NULL; MenuReference myMenu; #if TARGET_OS_WIN32 myMenu = theMenu; #endif #if TARGET_OS_MAC myMenu = GetMenuHandle(kFileMenuResID); #endif if (theWindow != NULL) myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) myMC = (**myWindowObject).fController; // don't let us close the monitor window if (QTFrame_GetFrontAppWindow() == QTFrame_GetWindowReferenceFromWindow(GetDialogWindow(gMonitor))) QTFrame_SetMenuItemState(myMenu, IDM_FILECLOSE, kDisableMenuItem); #if TARGET_OS_MAC myMenu = GetMenuHandle(kTestMenuResID); #endif QTFrame_SetMenuItemState(myMenu, IDM_SHOW_VIDEO_SETTINGS, gVideoChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SHOW_SOUND_SETTINGS, gSoundChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_RECORD_VIDEO, gVideoChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_RECORD_VIDEO, (gVideoChannel && gRecordVideo) ? true : false); QTFrame_SetMenuItemState(myMenu, IDM_RECORD_SOUND, gSoundChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_RECORD_SOUND, (gSoundChannel && gRecordSound) ? true : false); QTFrame_SetMenuItemState(myMenu, IDM_RECORD_SPLIT, (gSoundChannel && gRecordSound && gVideoChannel && gRecordVideo) ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_RECORD_SPLIT, gSplitTracks ? true : false); QTFrame_SetMenuItemState(myMenu, IDM_QUARTER_SIZE, gVideoChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_QUARTER_SIZE, gQuarterSize); QTFrame_SetMenuItemState(myMenu, IDM_HALF_SIZE, gVideoChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_HALF_SIZE, gHalfSize); QTFrame_SetMenuItemState(myMenu, IDM_FULL_SIZE, gVideoChannel == NULL ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_FULL_SIZE, gFullSize); QTFrame_SetMenuItemState(myMenu, IDM_RECORD, (gSoundChannel && gRecordSound) || (gVideoChannel && gRecordVideo) ? kEnableMenuItem : kDisableMenuItem); }
wxMenu* wxFindMenuFromMacCommand( const HICommand &command , wxMenuItem* &item ) { wxMenu* itemMenu = NULL ; #ifndef __WXUNIVERSAL__ int id = 0 ; // for 'standard' commands which don't have a wx-menu if ( command.commandID == kHICommandPreferences || command.commandID == kHICommandQuit || command.commandID == kHICommandAbout ) { id = wxMacCommandToId( command.commandID ) ; wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; if ( mbar ) item = mbar->FindItem( id , &itemMenu ) ; } else if ( command.commandID != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 ) { id = wxMacCommandToId( command.commandID ) ; // make sure it is one of our own menus, or of the 'synthetic' apple and help menus , otherwise don't touch MenuItemIndex firstUserHelpMenuItem ; static MenuHandle helpMenuHandle = NULL ; if ( helpMenuHandle == NULL ) { if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) != noErr ) helpMenuHandle = NULL ; } // is it part of the application or the Help menu, then look for the id directly if ( ( GetMenuHandle( kwxMacAppleMenuId ) != NULL && command.menu.menuRef == GetMenuHandle( kwxMacAppleMenuId ) ) || ( helpMenuHandle != NULL && command.menu.menuRef == helpMenuHandle ) || wxMenuBar::MacGetWindowMenuHMenu() != NULL && command.menu.menuRef == wxMenuBar::MacGetWindowMenuHMenu() ) { wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; if ( mbar ) item = mbar->FindItem( id , &itemMenu ) ; } else { URefCon refCon = 0 ; GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , &refCon ) ; itemMenu = wxFindMenuFromMacMenu( command.menu.menuRef ) ; if ( itemMenu != NULL && refCon != 0) item = (wxMenuItem*) refCon; } } #endif return itemMenu ; }
void DoCommand(long mResult) { short theItem; short theMenu; Str255 daName; short daRefNum; theItem = LoWord(mResult); theMenu = HiWord(mResult); switch (theMenu) { case appleID: { if (theItem == 1) { Alert(rUserAlert, nil); } else { /* all non-About items in this menu are DAs */ /* type Str255 is an array in MPW 3 */ GetMenuItemText(GetMenuHandle(appleID), theItem, daName); daRefNum = OpenDeskAcc(daName); } break; } case fileID: { quit = 1; break; } case editID: { if (!SystemEdit(theItem-1)) // call Desk Manager to handle editing command if desk accessory window is the active window { switch (theItem) { case cutCommand: TECut(textH); break; case copyCommand: TECopy(textH); break; case pasteCommand: TEPaste(textH); break; case clearCommand: TEDelete(textH); break; default: break; } } } default: break; } HiliteMenu(0); }
wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title ) { // create the menu static SInt16 s_macNextMenuId = 3; SInt16 menuId = s_macNextMenuId++; // save existing menu in case we're embedding into an application // or sharing outside UI elements. WXHMENU oldMenu = GetMenuHandle(menuId); if ( oldMenu ) MacDeleteMenu(menuId); WXHMENU menu = NULL; CreateNewMenu( menuId , 0 , &menu ) ; if ( !menu ) { wxLogLastError(wxT("CreateNewMenu failed")); if ( oldMenu ) MacInsertMenu(oldMenu, -1); return NULL; } wxMenuImpl* c = new wxMenuCarbonImpl( peer, menu, oldMenu, menuId ); c->SetTitle(title); wxAssociateMenuWithMacMenu( menu , peer ) ; return c; }
void MakeMenus(void) { Handle mbarHdl; MenuHandle menuHdl; OSErr err; if ( !(mbarHdl = GetNewMBar( rMBar)) ) { ErrorHandler(eMem, nil); return; } SetMenuBar(mbarHdl); if ( (menuHdl = GetMenuHandle(mApple)) != nil) { AppendResMenu(menuHdl, 'DRVR'); } else ErrorHandler(eMenuHdl, nil); ERR_CHECK(HMGetHelpMenuHandle(&menuHdl)); DisableItem(menuHdl, 1); DrawMenuBar(); }
static void DoMenuCommand( long menuAndItem ) { int myMenuNum; int myItemNum; int myResult; Str255 myDAName; WindowPtr myWindow; myMenuNum = HiWord(menuAndItem); myItemNum = LoWord(menuAndItem); GetPort(&myWindow); switch (myMenuNum) { case mApple: switch( myItemNum ) { case iAbout: DoAboutBox(); break; default: GetMenuItemText(GetMenuHandle(mApple), myItemNum, myDAName); myResult = OpenDeskAcc(myDAName); break; } break; case mFile: switch (myItemNum) { case iQuit: Com_Quit_f(); break; } break; } HiliteMenu(0); }
/* ============= InitMacStuff ============= */ void InitMacStuff( void ) { Handle menuBar; char dir[MAX_OSPATH]; // init toolbox MaxApplZone(); MoreMasters(); InitGraf(&qd.thePort); InitFonts(); FlushEvents(everyEvent, 0); SetEventMask( -1 ); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); // init menu menuBar = GetNewMBar(rMenuBar); if(!menuBar) { Com_Error( ERR_FATAL, "MenuBar not found."); } SetMenuBar(menuBar); DisposeHandle(menuBar); AppendResMenu(GetMenuHandle(mApple),'DRVR'); DrawMenuBar(); Sys_InitConsole(); SetEventMask( -1 ); }
static SInt16 FindUniqueSubMenuID(void) // Returns the next available menu ID for a hierarchical // (or sub-) menu. Prior to Mac OS 8.0, the sub-menu // ID for a menu item was encoded in the item mark field // of the menu, which meant that sub-menus were required // to use an ID that fit into a byte. This routine will // search for such an ID and return it. // // We call this routine when we insert sub-menus into // the menu bar, namely on our head patch to MenuSelect. // Note that sub-menus go into the normal menu bar // (because we remove them on the tail patch to MenuSelect) // so this routine calls the standard GetMenuHandle to test // for uniqueness. { SInt16 result; result = 235; while ( GetMenuHandle(result) != NULL) { result -= 1; } // The following assert fires if a) the application's menu list // is full, ie we have more than 250 application menus, // ie *very* unlikely, or b) something bad has happened. // Either way, we want to know. Because the only // valid failure case is so unlikely, the higher // level ignore that possibility, so we don't have // an error return from this routine. assert(result > 0); return result; }
void check_menu_item( short menu, short item, NMBoolean checked) { #if OP_PLATFORM_MAC_CFM || OP_PLATFORM_MAC_MACHO #ifndef OP_PLATFORM_MAC_CARBON_FLAG CheckItem(GetMenuHandle(menu), item, checked); #else CheckMenuItem(GetMenuHandle(menu), item, checked); #endif #elif defined(OP_PLATFORM_WINDOWS) CheckMenuItem(GetMenu(screen_window), MAKE_MENU_COMMAND(menu, item), MF_BYCOMMAND | (checked ? MF_CHECKED : MF_UNCHECKED)); #endif return; }
/* ------- Miscellaneous Menu Commands -------------- */ void set_menu_enabled( short menu_id, short item, NMBoolean enabled) { #if defined(OP_PLATFORM_MAC_CFM) || defined(OP_PLATFORM_MAC_MACHO) MenuHandle menu= GetMenuHandle(menu_id); #ifndef OP_PLATFORM_MAC_CARBON_FLAG if (enabled) { EnableItem(menu, item); } else { DisableItem(menu, item); } #else if (enabled) { EnableMenuItem(menu, item); } else { DisableMenuItem(menu, item); } #endif // OP_PLATFORM_MAC_CARBON_FLAG #elif defined(OP_PLATFORM_WINDOWS) HMENU menu= GetMenu(screen_window); op_assert(menu); EnableMenuItem(menu, MAKE_MENU_COMMAND(menu_id, item), enabled ? MF_ENABLED : MF_GRAYED); #endif return; }
void MakeMenu() /* Put up a menu */ { Handle menuBar; MenuRef menu; long response; OSErr err; menuBar = GetNewMBar(rMenuBar); /* read menus into menu bar */ if ( menuBar != nil ) { SetMenuBar(menuBar); /* install menus */ // AppendResMenu(GetMenuHandle(mApple), 'DRVR'); err = Gestalt(gestaltMenuMgrAttr, &response); if ((err == noErr) && (response & gestaltMenuMgrAquaLayoutMask)) { menu = GetMenuHandle( mFile ); DeleteMenuItem( menu, iQuit ); DeleteMenuItem( menu, iQuitSeparator ); } DrawMenuBar(); } else ExitToShell(); }
static void set_about_item(void){ Str255 aboutitem; StringHandle abouthandle; GetMenuItemText( GetMenuHandle(mApple), iAbout, aboutitem); abouthandle = NewString( aboutitem); if( abouthandle){ StringPtr curApName = LMGetCurApName(); long len = Munger( (Handle)abouthandle, 1, "MathLink\252", 9, curApName + 1, *curApName); if( len > 0){ **abouthandle = (unsigned char)len; HLock( (Handle)abouthandle); SetMenuItemText( GetMenuHandle(mApple), iAbout, *abouthandle); } DisposeHandle( (Handle)abouthandle); } }
static boolean meallocmenuid (short *id) { /* 12/27/96 dmb: windows port */ register short i; register hdlmenubarlist hlist = menubarlist; register byte *pbitmap; boolean flFound = false; #ifdef MACVERSION //9/1/00 Timothy Paustian //got rid of nasty use of direct memory access. //not allowed in carbon #if TARGET_API_MAC_CARBON == 1 MenuBarHandle MenuList = nil; MenuList = GetMenuBar(); #else #define MenuList (*(Handle *)0xA1C) #endif #endif if (hlist == nil) return (false); pbitmap = (**hlist).menubitmap; for (i = 0; i < maxmenus; i++) { if (!BitTst (pbitmap, i)) { /*found one not in use*/ BitSet (pbitmap, i); *id = (**hlist).basemenuid + i; #ifdef MACVERSION if ((MenuList != nil) && (GetMenuHandle (*id) != nil)) /*2.1a6 dmb: in use by someone!*/ continue; #endif #ifdef WIN95VERSION *id *= 100; // 4.18.97 dmb: leave room for 99 items with their own, sequenced ids #endif flFound = true; break; } } /*for*/ #if MACVERSION && TARGET_API_MAC_CARBON //Code change by Timothy Paustian Tuesday, September 5, 2000 9:27:35 PM //Only dispose of in carbon if(MenuList != nil) DisposeMenuBar(MenuList); #endif return (flFound); /*all menu ids are in use*/ } /*meallocmenuid*/
IPopupMenu* IGraphicsCarbon::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect) { // Get the plugin gui frame rect within the host's window HIRect rct; HIViewGetFrame(this->mView, &rct); // Get the host's window rect within the screen Rect wrct; GetWindowBounds(this->mWindow, kWindowContentRgn, &wrct); #ifdef RTAS_API int xpos = wrct.left + this->GetLeftOffset() + pAreaRect->L; int ypos = wrct.top + this->GetTopOffset() + pAreaRect->B + 5; #else HIViewRef contentView; HIViewFindByID(HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView); HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView); int xpos = wrct.left + rct.origin.x + pAreaRect->L; int ypos = wrct.top + rct.origin.y + pAreaRect->B + 5; #endif MenuRef menuRef = CreateMenu(pMenu); if (menuRef) { int32_t popUpItem = 1; int32_t PopUpMenuItem = PopUpMenuSelect(menuRef, ypos, xpos, popUpItem); short result = LoWord(PopUpMenuItem) - 1; short menuIDResult = HiWord(PopUpMenuItem); IPopupMenu* resultMenu = 0; if (menuIDResult != 0) { MenuRef usedMenuRef = GetMenuHandle(menuIDResult); if (usedMenuRef) { if (GetMenuItemRefCon(usedMenuRef, 0, (URefCon*)&resultMenu) == noErr) { resultMenu->SetChosenItemIdx(result); } } } CFRelease(menuRef); return resultMenu; } else { return 0; } }
void windowDestroy(GLWindow *glw) { MenuHandle hMenu; aglSetDrawable(glw->glCtx, NULL); aglSetCurrentContext(NULL); aglDestroyContext(glw->glCtx); DisposeWindow((WindowPtr)glw->pWin); glw->pWin = NULL; if(glw->supportWindow) DisposeWindow((WindowPtr)glw->supportWindow); hMenu = GetMenuHandle (kMenuFile); DeleteMenu (kMenuFile); DisposeMenu (hMenu); hMenu = GetMenuHandle (kMenuApple); DeleteMenu (kMenuApple); DisposeMenu (hMenu); }
void QTApp_AdjustMenus (WindowReference theWindow, MenuReference theMenu) { #if TARGET_OS_MAC #pragma unused(theWindow, theMenu) #endif #if TARGET_OS_WIN32 #pragma unused(theWindow) #endif ApplicationDataHdl myAppData = NULL; MenuReference myMenu; #if TARGET_OS_WIN32 myMenu = theMenu; #endif #if TARGET_OS_MAC myMenu = GetMenuHandle(kTestMenuResID); #endif myAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromFrontWindow(); if (myAppData != NULL) { QTFrame_SetMenuItemState(myMenu, IDM_LOAD_MOVIE, kEnableMenuItem); if ((**myAppData).fMovie == NULL) QTFrame_SetMenuItemLabel(myMenu, IDM_LOAD_MOVIE, "Load QuickTime Movie..."); else QTFrame_SetMenuItemLabel(myMenu, IDM_LOAD_MOVIE, "Unload QuickTime Movie..."); QTFrame_SetMenuItemState(myMenu, IDM_SET_CENTER, ((**myAppData).fMovie == NULL) ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_WIDTH, ((**myAppData).fMovie == NULL) ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_SCALE, ((**myAppData).fMovie == NULL) ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SPIN_MOVIE, ((**myAppData).fMovie == NULL) ? kDisableMenuItem : kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_CHROMA, kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_USE_BUFFER, ((**myAppData).fMovie == NULL) ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_USE_WND_CENTER, ((**myAppData).fMovie == NULL) ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_COMPOSITE, ((**myAppData).fMovie == NULL) ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemCheck(myMenu, IDM_USE_BUFFER, (**myAppData).fUseOffscreenGWorld); QTFrame_SetMenuItemCheck(myMenu, IDM_USE_WND_CENTER, !(**myAppData).fUseMovieCenter); QTFrame_SetMenuItemCheck(myMenu, IDM_COMPOSITE, (**myAppData).fCompositeMovie); } else { QTFrame_SetMenuItemState(myMenu, IDM_LOAD_MOVIE, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_CENTER, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_WIDTH, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_SCALE, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SET_CHROMA, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_SPIN_MOVIE, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_USE_BUFFER, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_USE_WND_CENTER, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_COMPOSITE, kDisableMenuItem); } }
/* ----------- private code */ static void initialize_application( void) { Handle menubar; StringHandle userName; #ifndef OP_PLATFORM_MAC_CARBON_FLAG MaxApplZone(); MoreMasters(); MoreMasters(); MoreMasters(); InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(NULL); #else MoreMasterPointers(192); #endif // ! OP_PLATFORM_MAC_CARBON_FLAG InitCursor(); FlushEvents(everyEvent, 0); menubar= GetNewMBar(rMENU_BAR_ID); op_assert(menubar); SetMenuBar(menubar); DisposeHandle(menubar); AppendResMenu(GetMenuHandle(mApple), 'DRVR'); DrawMenuBar(); // Get the user name from the systemÉ userName = GetString (-16096); if (userName == NULL) strcpy(gNameString, "OpenPlay Test"); else { doCopyP2CStr(*userName,gNameString); ReleaseResource ((Handle) userName); } // ecf - we wanna enable enumeration by default... check_menu_item(mSpecial, iActiveEnumeration, active_enumeration); //install apple event handler for quitting AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,NewAEEventHandlerUPP((AEEventHandlerProcPtr)do_quit_apple_event),0L,false); return; }
/*! @brief ウィンドウの生成 @par 関数説明 ウィンドウを生成する。 決まったウィンドウサイズやスタイルがあるのであればあらかじめSet系関数で設定しておく。 @param nCmdShow WinMain関数で取得できる第三引数。 @return 0=成功。 @return 1=生成に失敗。 */ unsigned long Window::MakeWindow( int nCmdShow ) { //int w = 0, h = 0; unsigned long err; if ( wd.WindowParent ) { SetWindowStyleDirect( GetWindowStyle() | WS_CHILD ); } else { SetWindowStyleDirect( GetWindowStyle() & ( ~WS_CHILD ) ); } // 判定。 //if ( GetPositionX() < 0 ){ SetPositionX( 0 ); w = GetWindowWidth(); SetWindowWidth( 640 ); } //if ( GetPositionY() < 0 ){ SetPositionY( 0 ); h = GetWindowHeight(); SetWindowHeight( 480 ); } //ウィンドウの生成 wd.WindowHandle = CreateWindowEx( GetWindowStyleEx(), wd.wcx.lpszClassName,//MIKANCLASSNAME,//GetClassNameEx(), GetWindowName(), GetWindowStyle(), GetPositionX(), GetPositionY(), GetWindowWidth(), GetWindowHeight(), GetParentWindowHandle(), GetMenuHandle(), GetInstanceHandle(), GetParameter() ); /*if ( w > 0 || h > 0 ) { SetWindowSize( w, h ); SetWindow(); }*/ //生成に失敗したら1を返して終了 if ( wd.WindowHandle == NULL ) { err = GetLastError(); return err; } ShowWindow( wd.WindowHandle, nCmdShow ); UpdateWindow( wd.WindowHandle ); // SetWindowText( wd.WindowParent, GetWindowName() ); return 0; }
int init_macintosh( void) { static int initdone = 0; Handle menuBar; long attributes; /* semaphore required for preemptive threads */ if( initdone) return initdone == 1; initdone = -1; /* should I check for MLNK resource too as launch-filtering is done based on it? */ /* too late--since I'm running there likely wasn't a problem (this time anyway). */ menuBar = GetNewMBar(rMenuBar); if( menuBar){ SetMenuBar(menuBar); DisposeHandle(menuBar); }else{ MenuHandle am, fm, em; am = NewMenu( mApple, (unsigned char*)"\001\024"); fm = NewMenu( mFile, (unsigned char*)"\004File"); em = NewMenu( mEdit, (unsigned char*)"\004Edit"); if( !am || !fm || !em) return 0; AppendMenu( am, (unsigned char*)"\022About MathLink\252\311;-"); DisableMenuItem(am, 0); InsertMenu( am, 0); AppendMenu( fm, (unsigned char*)"\006Quit/Q"); InsertMenu( fm, 0); AppendMenu( em, (unsigned char*)"\043Undo/Z;-;Cut/X;Copy/C;Paste/V;Clear"); DisableMenuItem(em, 0); InsertMenu( em, 0); } AppendResMenu( GetMenuHandle(mApple), 'DRVR'); set_about_item(); DrawMenuBar(); about_filter_upp = NewModalFilterUPP( about_filter); outline_hook_upp = NewUserItemUPP( outline_hook); if( Gestalt( gestaltAppleEventsAttr, &attributes) == noErr && ((1 << gestaltAppleEventsPresent) & attributes)){ handle_core_ae_upp = NewAEEventHandlerUPP( handle_core_ae); (void) AEInstallEventHandler( kCoreEventClass, typeWildCard, handle_core_ae_upp, 0, false); }else{ return 0; /* this may be too strong since I am, after all, running. */ } initdone = 1; return initdone == 1; }
nsresult nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth) { for (int i = menu_First; i <= menu_Last; i++) { MenuHandle menu = GetMenu(i); NS_ASSERTION(menu, "menu failed to load"); if (menu) InsertMenu(menu, 0); } InsertMenu(GetMenu(submenu_Print), -1); InsertMenu(GetMenu(submenu_CompatibilityMode), -1); AppendResMenu(GetMenuHandle(menu_Apple), 'DRVR'); DrawMenuBar(); return NS_OK; }
static void mac_menucommand(long result) { short menu, item; WindowPtr window; #if !TARGET_API_MAC_CARBON Str255 da; #endif menu = HiWord(result); item = LoWord(result); window = FrontWindow(); /* Things which do the same whatever window we're in. */ switch (menu) { case mApple: switch (item) { case iAbout: mac_openabout(); goto done; #if !TARGET_API_MAC_CARBON default: GetMenuItemText(GetMenuHandle(mApple), item, da); OpenDeskAcc(da); goto done; #endif } break; case mFile: switch (item) { case iNew: mac_newkey(); goto done; case iClose: mac_closewindow(window); goto done; case iQuit: cleanup_exit(0); goto done; } break; } /* If we get here, handling is up to window-specific code. */ if (mac_wininfo(window)->menu != NULL) (*mac_wininfo(window)->menu)(window, menu, item); done: HiliteMenu(0); }
virtual void PopUp( wxWindow *WXUNUSED(win), int x, int y ) { long menuResult = ::PopUpMenuSelect(m_osxMenu, y, x, 0) ; if ( HiWord(menuResult) != 0 ) { MenuCommand macid; GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid ); int id = wxMacCommandToId( macid ); wxMenuItem* item = NULL ; wxMenu* realmenu ; item = m_peer->FindItem( id, &realmenu ) ; if ( item ) { m_peer->HandleCommandProcess(item, NULL ); } } }
EXPORT(sqInt) primitiveGetMenuHandle(void) { MenuHandle menuHandle; sqInt menuID; sqInt _return_value; menuID = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } menuHandle = GetMenuHandle(menuID); _return_value = interpreterProxy->positive64BitIntegerFor(((long) menuHandle)); if (interpreterProxy->failed()) { return null; } interpreterProxy->popthenPush(2, _return_value); return null; }
void QTApp_AdjustMenus (WindowReference theWindow, MenuReference theMenu) { #if TARGET_OS_MAC #pragma unused(theMenu) #endif MenuReference myMenu; #if TARGET_OS_WIN32 myMenu = theMenu; #endif #if TARGET_OS_MAC myMenu = GetMenuHandle(kTestMenuResID); #endif QTFrame_SetMenuItemCheck(myMenu, IDM_USE_BACKGROUND_IMAGE, gUseBackgroundPicture); }
int _handle_user_event( unsigned long ticks) { EventRecord event; if( WaitNextEvent(everyEvent, &event, ticks, nil)){ long menuResult = 0; short menuID, menuItem; WindowPtr window; Str255 daName; switch ( event.what ) { case mouseDown: if( FindWindow(event.where, &window) == inMenuBar) menuResult = MenuSelect(event.where); break; case keyDown: if( event.modifiers & cmdKey ) menuResult = MenuKey((short)event.message & charCodeMask); break; case kHighLevelEvent: AEProcessAppleEvent(&event); break; } menuID = HiWord(menuResult); menuItem = LoWord(menuResult); switch ( menuID ) { case mFile: MLDone = MLAbort = 1; break; case mApple: switch ( menuItem ) { case iAbout: do_about_box(); break; default: GetMenuItemText(GetMenuHandle(mApple), menuItem, daName); break; } HiliteMenu(0); } } return MLDone; }
XGPopControl::~XGPopControl() { if (fPop) delete fPop; DeleteAll(); fFont->Detach(); #if OPT_MACOS if (fControl) { MenuHandle menu = GetMenuHandle(); SetMenuHandle(NULL); DeleteMenu(0x4000 + GetViewID()); DisposeMenu(menu); } #endif #if OPT_WINOS if (fControl) { ::DestroyWindow(fControl); } #endif }
static MenuHandle GetSystemMenuHandle(SInt16 menuID) // An analogue of GetMenuHandle, this routine // returns a handle to an installed system menu // in the system menu list. { MenuHandle result; Handle saveMenuList; // Switch MenuList to SystemMenuList, call // GetMenuHandle and then switch it back. saveMenuList = LMGetMenuList(); LMSetMenuList(LMGetSystemMenuList()); result = GetMenuHandle(menuID); LMSetMenuList(saveMenuList); return result; }
void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult) { long menuID = HiWord(menuResult); long menuItem = LoWord(menuResult); switch (menuID) { case menu_Apple: switch (menuItem) { case cmd_About: ::Alert(128, nil); break; default: Str255 daName; GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName); #if !TARGET_CARBON OpenDeskAcc(daName); #endif break; } break; case menu_File: switch (menuItem) { case cmd_New: gTheApp->OpenWindow(); break; case cmd_Open: nsBrowserWindow * newWindow; gTheApp->OpenWindow((PRUint32)0, newWindow); newWindow->DoFileOpen(); break; case cmd_Quit: gTheApp->Exit(); break; } break; } }