-void UMAInitToolbox( UInt16 inMoreMastersCalls )
-{
-#if !TARGET_CARBON
- ::MaxApplZone();
- for (long i = 1; i <= inMoreMastersCalls; i++)
- ::MoreMasters();
-
- ::InitGraf(&qd.thePort);
- ::InitFonts();
- ::InitWindows();
- ::InitMenus();
- ::TEInit();
- ::InitDialogs(0L);
- ::FlushEvents(everyEvent, 0);
- ::InitCursor();
- long total,contig;
- PurgeSpace(&total, &contig);
-#else
- InitCursor();
-#endif
-
-#if UMA_USE_APPEARANCE
- long theAppearance ;
- if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
- {
- sUMAHasAppearance = true ;
- RegisterAppearanceClient();
- if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
- {
- sUMAAppearanceVersion = theAppearance ;
- }
- else
- {
- sUMAAppearanceVersion = 0x0100 ;
- }
- }
-#endif // UMA_USE_APPEARANCE
-#if UMA_USE_8_6
-#if UMA_USE_WINDOWMGR
- if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr )
- {
- sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ;
- }
-#endif // UMA_USE_WINDOWMGR
-#endif
-}
-
-// process manager
-long UMAGetProcessMode()
-{
- OSErr err ;
- ProcessInfoRec processinfo;
- ProcessSerialNumber procno ;
-
- procno.highLongOfPSN = NULL ;
- procno.lowLongOfPSN = kCurrentProcess ;
- processinfo.processInfoLength = sizeof(ProcessInfoRec);
- processinfo.processName = NULL;
- processinfo.processAppSpec = NULL;
-
- err = ::GetProcessInformation( &procno , &processinfo ) ;
- wxASSERT( err == noErr ) ;
- return processinfo.processMode ;
-}
-
-bool UMAGetProcessModeDoesActivateOnFGSwitch()
-{
- return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
-}
-
-// menu manager
-
-void UMASetMenuTitle( MenuRef menu , StringPtr title )
-{
-#if !TARGET_CARBON
- long size = GetHandleSize( (Handle) menu ) ;
- const long headersize = 14 ;
- int oldlen = (**menu).menuData[0] + 1;
- int newlen = title[0] + 1 ;
-
- if ( oldlen < newlen )
- {
- // enlarge before adjusting
- SetHandleSize( (Handle) menu , size + (newlen - oldlen ) );
- }
-
- if ( oldlen != newlen )
- memmove( (char*) (**menu).menuData + newlen , (char*) (**menu).menuData + oldlen , size - headersize - oldlen ) ;
-
- memcpy( (char*) (**menu).menuData , title , newlen ) ;
- if ( oldlen > newlen )
- {
- // shrink after
- SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ) ;
- }
-#else
- SetMenuTitle( menu , title ) ;
-#endif
-}
-
-UInt32 UMAMenuEvent( EventRecord *inEvent )
-{
-#if UMA_USE_APPEARANCE
- if ( UMAHasAppearance() )
- {
- return MenuEvent( inEvent ) ;
- }
- else
-#endif
- {
- if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey)
- {
- return MenuKey( inEvent->message & charCodeMask ) ;
- }
- return NULL ;
- }
-}
-
-void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
-{
-#if UMA_USE_8_6 || TARGET_CARBON
- EnableMenuItem( inMenu , inItem ) ;
-#else
- EnableItem( inMenu , inItem ) ;
-#endif
-}
-
-void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
-{
-#if UMA_USE_8_6 || TARGET_CARBON
- DisableMenuItem( inMenu , inItem ) ;
-#else
- DisableItem( inMenu , inItem ) ;
-#endif
-}
-
-void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id )
-{
- Str255 label ;
- memcpy( label , l , l[0]+1 ) ;
- // hardcoded adding of the submenu combination for mac
-
- int theEnd = label[0] + 1;
- if (theEnd > 251)
- theEnd = 251; // mac allows only 255 characters
- label[theEnd++] = '/';
- label[theEnd++] = hMenuCmd;
- label[theEnd++] = '!';
- label[theEnd++] = id ;
- label[theEnd] = 0x00;
- label[0] = theEnd;
- MacAppendMenu(menu, label);
-}
-
-void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id )
-{
- Str255 label ;
- memcpy( label , l , l[0]+1 ) ;
- // hardcoded adding of the submenu combination for mac
-
- int theEnd = label[0] + 1;
- if (theEnd > 251)
- theEnd = 251; // mac allows only 255 characters
- label[theEnd++] = '/';
- label[theEnd++] = hMenuCmd;
- label[theEnd++] = '!';
- label[theEnd++] = id;
- label[theEnd] = 0x00;
- label[0] = theEnd;
- MacInsertMenuItem(menu, label , item);
-}
-
-void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers )
-{
- Str255 label ;
- memcpy( label , l , l[0]+1 ) ;
- if ( key )
- {
- int pos = label[0] ;
- label[++pos] = '/';
- label[++pos] = toupper( key );
- label[0] = pos ;
- }
- MacAppendMenu( menu , label ) ;
-}
-
-void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 key, UInt8 modifiers )
-{
- Str255 label ;
- memcpy( label , l , l[0]+1 ) ;
- if ( key )
- {
- int pos = label[0] ;
- label[++pos] = '/';
- label[++pos] = toupper( key );
- label[0] = pos ;
- }
- MacInsertMenuItem( menu , label , item) ;
-}
-
-void UMADrawMenuBar()
-{
- DrawMenuBar() ;
-}
-
-
-void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label )
-{
- ::SetMenuItemText( menu , item , label ) ;
-}