home *** CD-ROM | disk | FTP | other *** search
- /*
- HASMenus.c from Hsoi's App Shell. © 1995-1997 John C. Daub. All rights reserved.
-
- This file deals with menus: what to do when something is selected, adjusting
- the menus, etc...if it's something to do with a menu, it's dealt with in
- this file (more or less).
- */
-
- #pragma mark ••• #includes •••
-
- #ifndef _WASTE_
- #include "WASTE.h"
- #endif
- #include "WETabs.h"
- #ifndef _WASTEOBJECTS_
- #include "WASTE_Objects.h"
- #endif
- #include "HASGlobals.h"
- #ifndef __HSOIS_APP_SHELL__
- #include "HASMain.h"
- #endif
- #include "HASMenus.h"
- #include "HASMenuWindows.h"
- #include "HASDialogs.h"
- #include "HASUtilCursors.h"
- #include "HASHelp.h"
- #include "HASFiles.h"
- #include "HASMiscEvents.h"
- #include "HASPreferences.h"
- #include "HASWindows.h"
- #include "HASUtilities.h"
- #include "HASUtilPStrings.h"
- #include "HASPrinting.h"
- #include "HASSoundSpeech.h"
-
- #if HAS_DEBUG
- #include "HASTest.h"
- #include "HASUtilTest.h"
- #endif
-
- #pragma mark -
- #pragma mark ••• globals •••
-
- static MenuCRsrcHandle sColors; // handle to the 'mctb' resource for the Color Menu
-
-
- #pragma mark -
- #pragma mark ••• Utility Routines •••
-
- /*
- * HsoiEqualColor() does just that: sees if 2 RGBColors are the same/equal
- */
-
-
- Boolean HsoiEqualColor( const RGBColor *rgb1, const RGBColor *rgb2 )
- {
- return ( (rgb1->red == rgb2->red) && (rgb1->green == rgb2->green) && (rgb1->blue == rgb2->blue) );
- }
-
-
- /*
- * HsoiFindMenuItemText() will cycle through all the items in a given menu to find
- * some certain item. Used to select fonts and font sizes.
- */
-
- short HsoiFindMenuItemText( MenuRef menu, ConstStr255Param stringToFind )
- {
- short item;
- Str255 itemString;
-
- for ( item = CountMenuItems( menu ); item >= 1; item-- )
- {
- GetMenuItemText( menu, item, itemString );
- if ( EqualString( itemString, stringToFind, false, false ) )
- break;
- }
-
- return item;
- }
-
-
-
-
- /* What this function does is make sure the font size menu works right and looks right.
- Other functions deal with checkmarks and so forth, but what this will do is make
- the Size menu's text be drawn in outline style or plain style. Why do this? Well,
- A Size menu item displayed in outline style will let the user know that that size
- is one that'll draw right. With the advent of truetype and postscript fonts (and
- other scalable fonts), this is probably outdated, but i'm sure people (i know i do)
- will still have old bitmapped fonts lying around, so it'd be nice to know what
- font sizes will look ok.
-
- Try it...find a bitmapped font that's on your system and find a truetype. Select
- the truetype from the Font menu...then check the size menu...everything (more or
- less) should be in outline style. Then, select the bitmapped font...only the
- size(s) available of that bitmap should be in outline style. For a further example,
- check out TeachText/SimpleText...that works the same way, as probably does your
- favorite word processing program (or it should)
- */
-
- /* Some "quirks" with this, which are also quirks with all the Text ment/sub-menu
- things...if a range of text is selected (and also if that range might have
- different attributes to it (different sizes, fonts, styles, etc.), stuff in the
- text menus don't get checked, and the outlining of sizes i'm not 100% sure just
- how it's determined, but i think it's done by whatever the first font in the
- selection range is. (like i typed some text...some in Monaco (TrueType)
- and some in Adobe Garamond (didn't have a 9 point size, bitmap). select all.
- with the monaco stuff typed first (and first in the selection range), the size
- menu drew all the sizes in outline. but then i changed the monaco text to
- garamond and vice versa, select all, and then the size menu drew in the
- available sizes for garamond)
-
- According to Inside Macintosh (either Overview, Menus, or Text), you should try
- to do more than just check things...like if 2 fonts are in a selection range,
- use a hyphen - to show all the fonts that are in the active selection range.
-
- I'll probably work on that for a later release...if you get something working,
- let me know! I'd love to see the source!
- */
-
-
- void HsoiMaintainFontMenu( void )
- {
- MenuRef menu;
- short numItems;
- Boolean temp;
- short mode = weDoFont; // get only the attributes we need...it'll save some processing time
- TextStyle ts;
- WindowRef window;
- short counter;
- Str255 tempString;
- long theNumber;
-
- // get a window reference
-
- window = FrontWindow();
-
- // we don't have to check what the front window is necessarily, cause the size
- // menu will only be able to be displayed if FrontWindow() == a window with a
- // WE instance...so, if the front window isn't as such, just return
- // (this is probably sloppy, but eh...) :\
-
-
-
- if ( ( window != nil ) && ( HsoiIsDocumentWindow( window ) ) )
- {
- // get the style info associated with the WE instance
- // (this is being done similar to how Marco did the font/size/style/etc
- // menus in AdjustMenus()
-
- temp = WEContinuousStyle( (unsigned short *)&mode, &ts, HsoiGetWindowWE(window) );
-
- // let's get ready to do the menu...
-
- // i really shouldn't use constants (i.e. subtract 5 from the number of menu
- // items there are - for the "other" "smaller" "larger" and the 2 separator
- // lines) to make menu modification easier, but eh...
-
- // furthermore, smaller, larger, and other should be outlined if these are
- // supported font sizes, e.g. it's a TrueType font.
-
- menu = GetMenuHandle( mSize );
-
- numItems = CountMenuItems( menu );
-
- // here's the bad constant adjustment...
-
- numItems -= 5;
-
- // now, go through all the menu items/font sizes, and see just which ones
- // to outline or not outline...gotta love RealFont().
-
- for ( counter = 1; counter <= numItems; counter++ )
- {
- GetMenuItemText( menu, counter, tempString ); // get the menu item text...
- StringToNum( tempString, &theNumber ); // convert the menu item to a long
-
- // now, if that number size is a supported size, outline it, else plaintext.
- // RealFont is the magic routine for this!
-
- if ( RealFont( ts.tsFont, theNumber ) )
- SetItemStyle( menu, counter, outline );
- else
- SetItemStyle( menu, counter, kPlainStyle );
- }
-
- } // it's not a WE window, so just return...
-
- else
- {
- return;
- }
-
- return;
- }
-
-
- /* This gets the menus created and up and running. */
-
- void HsoiSetUpMenus( void )
- {
- Handle menuBar = nil;
- MenuRef menu = nil;
- short count;
- StringHandle helpMenuString, endString;
-
- /* With this menuBar stuff, do something to get the app's name from
- the resource file...then change the About... name to it...e.g.
- app name: The Killer App. change menu item to: About The Killer App…
-
- remember to change the menu item properly to deal with meta chars
- */
-
- #if HAS_DEBUG
- menuBar = GetNewMBar( rTestMBAR ); // Create the menu bar
- #else
- menuBar = GetNewMBar( rMenuBar ); // create the menu bar w/o testing stuff
- #endif
-
- if ( menuBar )
- {
- SetMenuBar( menuBar );
- HsoiForgetHandle( (Handle *)&menuBar );
- AppendResMenu( GetMenuHandle( mApple ), TYPE_DESK_ACCESSORY ); // add Apple Menu Items
-
- menu = GetMenu( mFont );
- AppendResMenu( menu, TYPE_FONT );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- menu = GetMenu( mSize );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- menu = GetMenu( mStyle );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- menu = GetMenu( mJustification );
- SetItemIcon( menu, iLeftAlign, rLeftJustIcon );
- SetItemIcon( menu, iCenterAlign, rCenterJustIcon );
- SetItemIcon( menu, iRightAlign, rRightJustIcon );
- SetItemIcon( menu, iFullAlign, rFullJustIcon );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- // load the menu color table for the color menu
-
- sColors = (MenuCRsrcHandle)GetResource( TYPE_MENU_COLOR_TABLE, mColor );
- if ( ResError() != noErr )
- return; //not the best error handling....
-
- // make sure this resource will not get purged..
-
- HNoPurge( (Handle)sColors );
-
- // and stick it in it's submenu place...
-
- menu = GetMenu( mColor );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- // get the features menu up..
-
- menu = GetMenu( mFeatures );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- menu = GetMenu( mHiliting );
- InsertMenu( menu, NOT_A_NORMAL_MENU );
-
- // put our help stuff in the Help menu (the Balloon help thing in the upper right
- // hand corner of the menu bar?) Since we're running in System 7, help stuff
- // should now always go under the help menu (not in the Apple Menu). Your users
- // will come to expect that
-
- // get the handle to the help menu
-
- HMGetHelpMenuHandle( &menu );
-
- // how many items are on it?
-
- count = CountMenuItems( menu );
-
- // the menu item's text will be the app's name + the word " Help..."
- // get the app's name from the 'STR ' name resource (-16396)
-
- // get the name string
-
- helpMenuString = GetString( strAppNameString );
- DetachResource( (Handle)helpMenuString );
-
- // append the " Help..." to it
-
- endString = GetString( strHelpMenuItemText );
- DetachResource( (Handle)endString );
- HsoiConcatString( *helpMenuString, *endString );
-
- // make sure it sticks around for the duration
-
- HNoPurge( (Handle)helpMenuString );
- HLockHi( (Handle)helpMenuString );
-
- // add it to the help menu
-
- InsertMenuItem( menu, *helpMenuString, count + 1 );
-
- // it can go bye bye now if it wants to
-
- HUnlock( (Handle)helpMenuString );
- HPurge( (Handle)helpMenuString );
-
- // remember what the help item number is for DoMenuCommand() stuff
-
- gHelpItem = CountMenuItems( menu );
-
- // set up the menus
-
- HsoiAdjustMenus();
-
- // draw the menu bar so all looks good :)
-
- DrawMenuBar();
- }
- else
- {
- HsoiDoError( rErrorStrings, errNoMenuBar, 0, kErrDeath );
- }
-
-
- return;
- }
-
- #pragma mark -
- #pragma mark ••• Command Handler •••
-
- /*
- * HsoiDoMenuCommand() is one of the most important functions in the shell. Here
- * is where all the menu commands are dispatched from.
- */
-
-
- void HsoiDoMenuCommand( long menuResult )
- {
- short menuID; // ID of selected menu
- short menuItem; // item number in selected menu
- Str255 daName, fontName;
- TextStyle ts;
- WindowRef window;
- WEReference we;
- Point where = { -1, -1 };
- Str255 theWords = NIL_STRING;
- RGBColor newColor = { nil, nil, nil };
-
- // menuResult is the value returned by MenuSelect(). From that, we can extract
- // which menu was selected (in the hi order bits), and which item in that menu
- // was selected (in the low order bits)
-
- menuID = HiWrd( menuResult );
- menuItem = LoWrd( menuResult );
-
- // get the front window
-
- window = FrontWindow();
-
- // get the front window's associated WE instance
-
- we = HsoiGetWindowWE( window );
-
- // now, a huge switch statement on which menu was selected.
-
- switch( menuID )
- {
- // the Apple menu.
-
- case mApple:
-
- switch( menuItem )
- {
- case iAbout: // display the about Box
- {
- HsoiDoAboutBox();
- }
- break;
-
- default: // handle AppleMenuItem/DA selection
- GetMenuItemText( GetMenuHandle( mApple ), menuItem, daName );
- OpenDeskAcc( daName );
- break;
- }
- break;
- // end case mApple
-
-
- // the File menu
-
- case mFile:
-
- switch( menuItem )
- {
- case iNew:
- HsoiCreateWindow( nil );
- break;
-
- case iOpen:
- HsoiDoOpen();
- break;
-
- case iClose:
- HsoiDoClose( closingWindow, savingAsk, window );
- break;
-
- case iSave:
-
- HsoiDoSave( window );
-
- break;
-
- case iSaveAs:
- HsoiDoSaveAs( nil, window );
-
- break;
-
- case iRevert:
- HsoiDoRevert( window );
- break;
-
- case iPageSetup:
- HsoiDoPageSetup();
- break;
-
- case iPrint:
- HsoiDoPrint( window );
- break;
-
- case iPreferences:
- HsoiDoPrefsDialog();
- break;
-
- case iQuit:
- HsoiCleanUp( savingAsk );
- break;
- }
- break;
-
- // end case mFile
-
- // the Edit menu
-
- case mEdit:
-
- // if we don't have a window up at all, there's obviously nothing to
- // edit, so just can things and leave. but just in case the menuItem
- // was iShowClipboard (in addition to window == nil), we need to let it
- // fall through (Show Clipboard could still be a valid command)
-
- if ( (window == nil) && (menuItem != iShowClipboard) )
- break;
-
- switch( menuItem )
- {
- case iUndo:
- HsoiStartVBLSpinning();
- WEUndo( we );
- HsoiStopVBLSpinning();
- break;
-
- // since pasting/copying/cutting might take a long time (like if the scrap is HUGE)
- // let's spin the cursor with my VBL cursor spinning. if we didn't
- // do this, cause WEPaste/WECut/WECopy can get intensive, the user might think
- // their computer froze up.
-
-
- case iCut:
- HsoiStartVBLSpinning();
- WECut( we );
- HsoiStopVBLSpinning();
- break;
-
- case iCopy:
- HsoiStartVBLSpinning();
- WECopy( we );
- HsoiStopVBLSpinning();
- break;
-
- case iPaste:
- HsoiStartVBLSpinning();
- //WEPaste( we );
- WEObjectsPaste( we );
- HsoiStopVBLSpinning();
- break;
-
- case iClear:
- HsoiStartVBLSpinning();
- WEDelete( we );
- HsoiStopVBLSpinning();
- break;
-
- case iSelectAll:
- WESetSelection( 0, MAXLONG, we );
- break;
-
- case iShowClipboard:
- HsoiShowClipboard();
- break;
-
- }
-
- break;
-
- // end case mEdit
-
- // this is if they select something from the Text menu. There isn't much
- // to do here since there really isn't anything on the Text menu to select
- // (the entire menu just branches off into submenus, and it's from the submenus
- // that stuff happens. So, each submenu is handled further down in this function.
-
- case mText:
-
- switch( menuItem )
- {
- case iFont:
- case iSize:
- case iStyle:
- case iJustification:
- case iColor:
- case iFeatures:
- {
- // don't do anything really...to deal with font/size/style/justification,
- // you need to deal with the associated submenu...we do that below
-
- // SysBeep(10);
- }
- break;
- }
- break;
-
- // end case mText
-
-
- // so now, let's deal with each of those Text menu submenus.
-
- case mFont:
- {
- // if we got a window, figure out the font they selected and change things.
-
- if ( window != nil )
- {
- GetMenuItemText( GetMenuHandle( mFont ), menuItem, fontName );
- GetFNum( fontName, &ts.tsFont );
- WESetStyle( weDoFont, &ts, we );
- }
-
- }
- break; // end case mFont
-
-
- case mSize:
- {
- Str255 sizeString;
- long longSize;
- short mode;
-
- if ( window != nil )
- {
- if ( menuItem <= kSizeMenuLast ) // if they picked a number
- {
- GetMenuItemText( GetMenuHandle( mSize ), menuItem, sizeString );
- StringToNum( sizeString, &longSize );
- mode = weDoSize;
- ts.tsSize = longSize;
- }
- else if ( menuItem == iSizeSmaller )
- {
- mode = weDoAddSize;
- ts.tsSize = -1;
- longSize = 5; // arbitrary...just not 0
- }
- else if ( menuItem == iSizeLarger )
- {
- mode = weDoAddSize;
- ts.tsSize = +1;
- longSize = 5; // arbitrary....just not 0
- }
- else if ( menuItem == iSizeOther )
- {
-
- longSize = HsoiDoOtherFontSize( window );
-
- if ( longSize != 0 )
- {
- ts.tsSize = longSize;
- mode = weDoSize;
- }
- }
-
- // all that stuff above went to figure out just what to do with
- // the font, and now we do it
-
- if ( longSize != 0 )
- WESetStyle( mode, &ts, we );
- }
-
-
- }
- break; // end case mSize
-
-
- case mStyle:
- {
-
- if ( window != nil )
- {
- // figure out what face we want
-
- switch ( menuItem )
- {
- case iPlain:
- ts.tsFace = 0;
- break;
-
- case iBold:
- ts.tsFace = bold;
- break;
-
- case iItalic:
- ts.tsFace = italic;
- break;
-
- case iUnderline:
- ts.tsFace = underline;
- break;
-
- case iOutline:
- ts.tsFace = outline;
- break;
-
- case iShadow:
- ts.tsFace = shadow;
- break;
-
- case iCondensed:
- ts.tsFace = condense;
- break;
-
- case iExtended:
- ts.tsFace = extend;
- break;
-
- } // end switch menuItem (within case mStyle)
-
-
- // and now set the face
-
- WESetStyle( weDoFace + weDoToggleFace, &ts, we );
-
- } // end if ( window != nil )
-
- }
- break; // end case mStyle
-
-
- case mJustification:
- {
- char alignment;
-
- if ( window != nil )
- {
- // figure out what alignment they want
-
- switch ( menuItem )
- {
- case iDefaultJust:
- alignment = weFlushDefault;
- break;
-
- case iLeftAlign:
- alignment = weFlushLeft;
- break;
-
- case iCenterAlign:
- alignment = weCenter;
- break;
-
- case iRightAlign:
- alignment = weFlushRight;
- break;
-
- case iFullAlign:
- alignment = weJustify;
- break;
-
- } // end switch( menuItem) within case mJustifiction
-
- // set the alignment mode...this automatically redraws the text
-
- WESetAlignment( alignment, we );
-
- } // end if ( window != nil )
-
-
- }
- break; // end case mJustification
-
-
- // how about neat-o colors?
-
- case mColor:
- {
- short i; // a counter variable
- TextStyle ts;
-
- if ( window == nil)
- break;
-
- if ( HsoiIsDialogWindow(window))
- break;
-
- // find the color corresponding to the chosen menu item...
-
- // we subtract 1 from the (*sColors)->numEntries cause the
- // 'mctb' resource really only has the 7 color entries. the
- // separator line and the "Other..." items are not part of
- // the 'mctb' resource
- // and the - 1 is so we can go to 0 for array happiness.
-
- for ( i = (*sColors)->numEntries - 1; i >= 0; i-- )
- {
- if ( (*sColors)->mcEntryRecs[i].mctItem == menuItem )
- {
-
- // they picked a color from the menu
-
- ts.tsColor = (*sColors)->mcEntryRecs[i].mctRGB2;
- WESetStyle( weDoColor, &ts, we );
- }
- else if ( menuItem == iColorOther )
- {
- // they picked the "Other" item
-
- short mode;
- TextStyle tempTs;
- RGBColor failed = { nil, nil, nil };
-
- // if there's a sound playing, stop it
-
- if ( SoundIsPlaying() )
- StopCurrentSound();
-
- // get the prompt string for the color picker dialog
-
- GetIndString( theWords, rGetColorStrings, strGetTextColor );
-
- // now to find the default color to display
-
- // with the advent of System 7.5 (or MacOS 7.5, whatever you want to
- // call it), there is a new system extension called the Color Picker.
- // the picker is a much more robust color wheel. The neatest thing about
- // it is that it can be a movable modal dialog! However, i've had a hard
- // time trying to find documentation on just how to use the picker
- // (but i do know the toolbox call is PickColor()). We should use the
- // new picker, but until i figure it out....
-
- // however, if the user does have the Color Picker extension installed on
- // their system and the application calls GetColor(), GetColor() will
- // fall through and will call the new picker. Of course, it'll be a
- // modal dialog...
-
- mode = weDoColor;
- WEContinuousStyle( (unsigned short *)&mode, &tempTs, we );
-
- // do the color dialog
-
- if ( GetColor( where, theWords,
- ((mode & weDoColor) != 0 ? &tempTs.tsColor : &failed ), &newColor ) )
-
- // and based on it's outcome...
-
- {
- // we have a new color, so let's set the text right
-
- ts.tsColor = newColor;
- WESetStyle( weDoColor, &ts, we );
- HsoiDoUpdate( window ); // need to force an update
- goto byebye;
- }
- else // they canceled the GetColor dialog
- {
- HsoiDoUpdate( window ); // need for force and update
- goto byebye;
- }
- } // end else if iColorOther
-
- } // end for loop
-
- }
- break; // end case mColor
-
-
- case mFeatures:
- {
- short feature, oldSetting;
-
- if (window == nil)
- break;
-
- if ( HsoiIsDialogWindow(window) )
- break;
-
- switch( menuItem )
- {
- case iTabHooks:
- {
- // install or remove our custom tab hooks
-
- if ( WEIsTabHooks( we ) == false )
- {
- // left-align the text (hooks only work with left-aligned text)
-
- WESetAlignment( weFlushLeft, we );
-
- // install them
-
- WEInstallTabHooks( we );
-
- }
- else
- {
- // remove them
-
- WERemoveTabHooks( we );
- }
-
-
- // turn the cursor into a wristwatch (this might be a nice place
- // to have a VBL spinning cursor instead...WECalText can take a while
- // to perform)
-
- SetCursor( *gWaitCursor );
-
- // recalculate the line breaks and redraw the text
-
- WECalText( we );
-
-
- }// end case iTabHooks
-
- break;
-
- // take care of other features
-
- case iAutoScroll:
- feature = weFAutoScroll;
- break;
-
- case iOutlineHilite:
- feature = weFOutlineHilite;
- break;
-
- case iReadOnly:
- feature = weFReadOnly;
- break;
-
- case iIntelligentCutAndPaste:
- feature = weFIntCutAndPaste;
- break;
-
- case iDragAndDropEditing:
- feature = weFDragAndDrop;
- break;
-
- case iOffscreenDrawing:
- feature = weFDrawOffscreen;
-
- } // end switch ( menuItem ) in case mFeatures
-
- // toggle the specified feature
-
- if ( menuItem != iTabHooks ) // don't do it for tab hooks
- oldSetting = WEFeatureFlag( feature, weBitToggle, we );
-
- }
- break; // end case mFeatures:
-
- case mDialogs:
- switch( menuItem )
- {
- case iModal:
- HsoiDoModalDialog();
- break;
-
- case iModeless:
- HsoiDoModelessDialog();
- break;
-
- case iMovable:
- HsoiDoMovableModalDialog();
- break;
- }
- break;
-
- // end case mDialogs
-
- case mWindows:
-
- switch( menuItem )
- {
- case iTileWindows:
- HsoiDoTileWindows();
- break;
-
- case iStackWindows:
- HsoiDoStackWindows();
- break;
-
- // normally, we don't care about the seperator lines cause
- // they remain disabled..but since we use a "default" to handle
- // all the windows in the menu, we need to make sure we cover
- // this one just in case something funky happens...don't want this
- // getting passed to HsoiDoSelectFromWindowsMenu(). besides, all
- // we do is break.
-
- case iWindowMenuSeperator:
- break;
-
- // and by using "default", we can handle any menu item in the window's
- // menu, no matter how many windows/menu-items there might be
-
- default:
- HsoiDoSelectFromWindowsMenu( menuItem );
- break;
-
- }
-
- break; // end case mWindows
-
- // all the sound stuff is currently partially implimented. You can create the
- // new sound objects fine, but i've run into problems in trying to get the
- // current sound to stop playing. It might be my code, it might be Kamprath's
- // code. I've tried contacting Michael about this, but so far, nothing
- // figured out.
-
-
- case mSound:
- {
-
- switch( menuItem )
- {
- // sounds...all use Michael Kamprath's WASTE Object Handler Library
- case iRecordNewSnd:
- // first, make sure no sounds are playing
- HsoiDoStop();
- // now create the new sound
- CreateNewSoundObject( we );
- break;
-
- case iPlaySnd:
- PlaySelectedSound( we );
- break;
-
- case iStopPlayingSnd:
- StopCurrentSound();
- break;
-
- // text to speech stuff
-
- case iSpeakAll:
- HsoiDoReadDoc( window );
- break;
-
- case iSpeakFromCursor:
- HsoiDoReadFromCursor( window );
- break;
-
- case iSpeakSelection:
- HsoiDoReadSelection( window );
- break;
-
- case iStopSpeaking:
- HsoiDoStop();
- break;
-
- case iPauseSpeaking:
- HsoiDoPause();
- break;
-
- case iTurnSpeechOnOff:
- HsoiDoSpeechOnOff();
- break;
-
- case iAutoHiliting:
- // this should do nothing since it's a submenu
- break;
-
- case iSpeechOptions:
- HsoiDoSpeechOptionsDialog();
- break;
-
- } // end switch(menuItem) in case mSound
- }
- break; // end case mSound
-
- case mHiliting:
- HsoiDoHiliteMenu( menuItem );
- break;
-
- // end case mHiliting
-
- case kHMHelpMenuID:
- if ( menuItem == gHelpItem )
- HsoiDoHelpStuff();
-
- break;
-
- #if HAS_DEBUG
-
- case mTestMENU:
- {
- case iTestDoTest:
- HsoiDoTest();
- break;
- }
- break;
- #endif
-
-
- }
-
- byebye: // for the goto statement
-
- HiliteMenu( 0 );
-
- return;
- }
-
-
-
- #pragma mark -
- #pragma mark ••• Menu Adjustment •••
-
- // our "public" menu adjuster routine. call this whenever you need to have the
- // menus get adjusted, and then from here, it'll dispatch and update the menus
- // accordingly
-
- void HsoiAdjustMenus( void )
- {
- WindowRef window;
- Str255 itemString;
-
- // find out what window is in front (cause the menus's appearance is based (mostly)
- // upon the front window)
-
- window = FrontWindow();
-
- // by default the Undo menu item should read "Can't Undo" and be disabled
-
- GetIndString( itemString, rUndoStrings, strCantUndo );
- SetMenuItemText( GetMenuHandle( mEdit ), iUndo, itemString );
- DisableItem( GetMenuHandle( mEdit ), iUndo );
-
- // now let's see what we should do based upon FrontWindow()
-
- if ( window == nil )
- {
- // no windows at all, so adjust accordingly
-
- HsoiAdjustMenusNoWindow( window );
- }
- else if ( gInModalState )
- {
- // now if our gInModalState boolean is set, adjust accordingly
- // (gInModalState currently is set with the Help dialog, Other Font Size dialog,
- // and movable modal progress bar)
-
- if ( (DialogRef)window == gHelpDialog )
- HsoiAdjustMenusHelpDialog( window );
- else
- HsoiAdjustMenusDialog( window );
- }
-
- #if HAS_DEBUG
-
- else if ( window == gTestWindow )
- {
- HsoiAdjustMenusTestWindow( window );
- }
-
- #endif
-
- else if ( (DialogRef)window == gModelessDialog )
- {
- HsoiAdjustMenusFindDialog( window );
- }
- else if ( (DialogRef)window == gHelpDialog )
- {
- HsoiAdjustMenusHelpDialog( window );
- }
- else
- {
- switch ( GetWindowKind( window ) )
- {
- // handle our main document window.
- // we have our own unique windowKind for our document windows, but in case
- // we get (for some strange reason) a window with a userKind, let it get
- // handled in the same way.
-
- case userKind: // (same as kApplicationWindowKind)
- case kDocumentKind:
- HsoiAdjustMenusDocumentWindow( window );
- break;
-
- // this handles "generic" dialogs (i.e. anything we don't want to
- // specifically handle ourselves)
-
- case dialogKind: // (same as kDialogWindowKind)
- HsoiAdjustMenusDialog( window );
- break;
-
- // this adjusts things when the clipboard window is in front
-
- case kClipboardKind:
- HsoiAdjustMenusClipboardWindow( window );
- break;
-
- } // end: switch ( GetWindowKind( window ) )
-
-
- } // end: else (i.e. window != nil)
-
- DrawMenuBar();
-
- return;
- }
-
- void HsoiAdjustMenusNoWindow( WindowRef window )
- {
- MenuRef menu;
- short i;
-
- // Apple Menu -- enable it all
-
- menu = GetMenuHandle( mApple );
-
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // File Menu -- not much to do with no window...
-
- menu = GetMenuHandle( mFile );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- DisableItem( menu, iClose );
- DisableItem( menu, iSave );
- DisableItem( menu, iSaveAs );
- DisableItem( menu, iRevert );
- DisableItem( menu, iPrint );
-
- // Edit Menu -- not much to do here either...
-
- menu = GetMenuHandle( mEdit );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- DisableItem( menu, iUndo );
- DisableItem( menu, iCut );
- DisableItem( menu, iCopy );
- DisableItem( menu, iPaste );
- DisableItem( menu, iClear );
- DisableItem( menu, iSelectAll );
-
- // Text Menu (and it's submenus...cause this is pretty straight forward)
- // no window, nothing to do...disable them all!
-
- DisableItem( GetMenuHandle( mText ), 0 );
- DisableItem( GetMenuHandle( mFont ), 0 );
- DisableItem( GetMenuHandle( mSize ), 0 );
- DisableItem( GetMenuHandle( mStyle ), 0 );
- DisableItem( GetMenuHandle( mJustification ), 0 );
- DisableItem( GetMenuHandle( mColor ), 0 );
- DisableItem( GetMenuHandle( mFeatures ), 0 );
-
- // Dialogs Menu
-
- menu = GetMenuHandle( mDialogs );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // Windows menu -- no windows...it's moot!
-
- DisableItem( GetMenuHandle( mWindows ), 0 );
- HsoiAdjustWindowsMenu( window );
-
- // Sound menu
-
- HsoiAdjustSoundMenu( window );
-
- // Help menu
-
- HMGetHelpMenuHandle( &menu );
-
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #if HAS_DEBUG
-
- // Test menu
-
- menu = GetMenuHandle( mTestMENU );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #endif
-
-
- return;
- }
-
- void HsoiAdjustMenusHelpDialog( WindowRef window )
- {
- // pretty much disable everything since we're in a movable modal dialog.
- // however, due to the cool stuff we can do in our help menu, some editing
- // stuff might have to be enabled
-
- // however, until i get some funkyness worked out with the help dialog's
- // filter, we'll just call our generic dialog menu adjuster
-
- HsoiAdjustMenusDialog( window );
-
- return;
- }
-
-
- // TESTING NOTE: i think i can check to make sure this is called when the help dialog
- // is up, the other font size, and/or the mmodal progress bar thing. mostly, i'm
- // curious to make sure the edit field check works
-
- void HsoiAdjustMenusDialog( WindowRef window )
- {
- MenuRef menu;
- short i;
-
- // pretty much, everything ought to be disabled. why? well hopefully this
- // function will only be called when the window/dialog is a modal or movable modal
- // dialog, and we won't need many of the editing features, plus many things just
- // shouldn't be done when a dialog is up front (e.g. opening a new document window
- // just shouldn't be done).
-
- // one fun thing we do here is check for the presence of edit text items in the
- // dialog's DITL. If there are, we can enable certain editing commands.
-
- // first, let's just disable everything...
-
- DisableItem( GetMenuHandle( mApple ), 0 );
- DisableItem( GetMenuHandle( mFile ), 0 );
- // skip the Edit menu
- DisableItem( GetMenuHandle( mText ), 0 );
- DisableItem( GetMenuHandle( mFont ), 0 );
- DisableItem( GetMenuHandle( mSize ), 0 );
- DisableItem( GetMenuHandle( mStyle ), 0 );
- DisableItem( GetMenuHandle( mJustification ), 0 );
- DisableItem( GetMenuHandle( mColor ), 0 );
- DisableItem( GetMenuHandle( mFeatures ), 0 );
- DisableItem( GetMenuHandle( mDialogs ), 0 );
- DisableItem( GetMenuHandle( mWindows ), 0 );
- HsoiAdjustWindowsMenu( window );
- HsoiAdjustSoundMenu( window );
- HMGetHelpMenuHandle( &menu );
- DisableItem( menu, 0 );
-
- #if HAS_DEBUG
-
- DisableItem( GetMenuHandle( mTestMENU ), 0 );
-
- #endif
-
- // and now, let's do our edit menu!
-
- menu = GetMenuHandle( mEdit );
-
- // let's see if the dialog has any edit fields...if so, then we can continue, else
- // we'll just disable the whole thing
-
- //•• Thinking about this some more, i wonder if this is really necessary....this
- // would be a "proper" way to check whether or not to enable the edit menu or
- // not for a dialog, but perhaps this ought to be something in the dialog's
- // filter instead of in here....
-
- if ( !gHiliting && (GetDialogKeyboardFocusItem( (DialogRef)window ) > 0) )
- {
- // long temp;
-
- // enable the whole menu
-
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // now, we know there are some commands they just can't use
-
- DisableItem( menu, iUndo );
- DisableItem( menu, iShowClipboard );
-
- // and for now (while i write this thing), let's just leave the rest
- // (cut, copy, paste, clear, select all) to the dialog manager to deal
- // with...
-
- /*
- if ( HsoiHasSelectionRange( (DialogPeek)window ) )
- {
- EnableItem( menu, iCut );
- EnableItem( menu, iCopy );
- EnableItem( menu, iClear );
- }
-
- // see if there's anything on the scrap to paste
-
- if ( GetScrap( nil, TYPE_TEXT, &temp ) )
- EnableItem( menu, iPaste );
-
- // and for giggles, just enable select all
-
- EnableItem( menu, iSelectAll );
-
-
- */
-
- }
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- DisableItem( menu, i );
-
- }// end: if ( GetDialogKeyboardFocueItem( (DialogRef)window ) >= 0 )
-
-
- return;
- }
-
-
- void HsoiAdjustMenusDocumentWindow( WindowRef window )
- {
- MenuRef menu;
- short i;
- Str255 itemString, numString, workString;
- WEActionKind actionKind;
- Boolean temp;
- long selStart, selEnd;
- TextStyle ts;
- short mode, item;
- short menuItem;
- WEReference we;
-
- // here's the fun one! document windows!!!
-
- // since we know it's a document window, there will be a WE instance associated
- // with it. let's grab it
-
- we = HsoiGetWindowWE( window );
-
- // Apple menu
-
- menu = GetMenuHandle( mApple );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // File menu
-
- menu = GetMenuHandle( mFile );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // if we have hit the max number of open document windows, we must disable New
- // and Open
-
- if ( gNumWindows >= kMaxNumberOfOpenWindows )
- {
- DisableItem( menu, iNew );
- DisableItem( menu, iOpen );
- }
-
- if ( WEGetModCount( we ) <= 0 )
- {
- DisableItem( menu, iSave );
- DisableItem( menu, iRevert );
- }
-
- // if the window is a new document, there is nothing to revert to
-
- if ( (*HsoiGetWindowDocument(window))->fileAlias == nil )
- DisableItem( menu, iRevert );
-
- // Edit menu
-
- // gotta remember read-onlys!
-
- menu = GetMenuHandle( mEdit );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // check for pastes
-
- if ( !WECanPaste( we ) )
- DisableItem( menu, iPaste );
-
- // get Undo all set right
-
- actionKind = WEGetUndoInfo( &temp, we );
-
- if ( actionKind != weAKNone )
- {
- // change the Undo menu item to "Undo/Redo" + name of action
-
- // the temp?1:0 thing is my attempt at replacing the pascal ORD() function
- // since this technique was taken from some Pascal source (perhaps it's not
- // even necessary, but it all works ok)
-
- GetIndString( itemString, rUndoStrings, 2 * actionKind + (temp ? 1 : 0) );
- SetMenuItemText( menu, iUndo, itemString );
- }
- else
- {
- DisableItem( menu, iUndo );
- }
-
- if ( WEGetTextLength( we ) <= 0 )
- DisableItem( menu, iSelectAll );
-
- WEGetSelection( &selStart, &selEnd, we );
-
- if ( selStart == selEnd )
- {
- DisableItem( menu, iCut );
- DisableItem( menu, iCopy );
- DisableItem( menu, iClear );
- }
-
- // and if we have read-only, make sure certain things are disabled
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- {
- DisableItem( menu, iUndo );
- DisableItem( menu, iCut );
- DisableItem( menu, iPaste );
- DisableItem( menu, iClear );
- }
-
- // Text menu
-
- // before we proceed, we need to determine which style attributes are continuous
- // over the current selection range (we need this information to check the
- // menus properly)
-
- mode = weDoAll; // query about all attributes
- temp = WEContinuousStyle( (unsigned short *)&mode, &ts, we );
-
- menu = GetMenuHandle( mText );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // font submenu
-
- menu = GetMenuHandle( mFont );
-
- // if the window is read-only, disable it all, else enable it all
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- {
- DisableItem( menu, 0 );
- }
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- // remove all the check marks
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- CheckItem( menu, i, false );
-
- // and if there is a continuous font over the selection range, check that item
-
- if ( (mode & weDoFont) != 0 )
- {
- GetFontName( ts.tsFont, itemString );
- CheckItem( menu, HsoiFindMenuItemText( menu, itemString ), true );
- }
-
- // Size submenu
-
- menu = GetMenuHandle( mSize );
-
- // again, if read only, disable the whole thing
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- {
- DisableItem( menu, 0 );
- }
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- // remove the check marks
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- CheckItem( menu, i, false );
-
- // NOTE! All this stuff with the font Size menu dealing with the "Other"
- // size menu item is as per Apple's "Macintosh Human Interface Guidelines"
- // (for once, I follow them) :) It all seems strange, but it's what
- // should be done to be "proper". and perhaps there might be an easier
- // way to do this, but for now, this works fine
-
- // i ought to do this same sort of thing for the Font, Style, and Color
- // menus also (put hash marks or something to indicate multiple stuff)
- // (Ok, Style sorta does this, but if there are multiple styles, we should
- // have hash marks and not check marks....
-
- // if there is a continuous font size all over the selection range,
- // check the corresponding menu item
-
- if ( (mode & weDoSize) != 0 )
- {
- NumToString( ts.tsSize, itemString );
- menuItem = HsoiFindMenuItemText( menu, itemString );
-
- // if menuItem is 0, we didn't find the item, so we'll assume that it's
- // not a "supported" font size (9, 10, 12, 14, 18, 24, 36, 48... the sizes
- // in the size menu), therefore we should check the "Other" item.
- // Furthermore, this "odd" font size should be displayed in the Other
- // item's text...try it...you'll see what I mean
-
- if ( menuItem != 0 )
- {
- CheckItem( menu, menuItem, true );
- GetIndString( itemString, rOtherSizeStrings, strOtherSizeOtherOnly );
- SetMenuItemText( menu, CountMenuItems( menu ), itemString );
- }
- else
- {
- CheckItem( menu, CountMenuItems( menu ), true );
- GetIndString( itemString, rOtherSizeStrings, strOtherSizeOtherSpace );
- GetIndString( workString, rOtherSizeStrings, strOtherSizeLeftParen );
- HsoiConcatString( itemString, workString );
- NumToString( ts.tsSize, numString );
- HsoiConcatString( itemString, numString );
- GetIndString( workString, rOtherSizeStrings, strOtherSizeRightParen );
- HsoiConcatString( itemString, workString );
-
- SetMenuItemText( menu, CountMenuItems( menu ), itemString );
- }
- }
- else // not one continuous size
- {
- GetIndString( itemString, rOtherSizeStrings, strOtherSizeMixed );
- SetMenuItemText( menu, CountMenuItems( menu ), itemString );
- CheckItem( menu, CountMenuItems( menu ), true );
- }
-
- // Style submenu
-
- menu = GetMenuHandle( mStyle );
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- CheckItem( menu, i, false );
-
- if ( (mode & weDoFace) != 0 )
- {
- if ( ts.tsFace == 0 )
- CheckItem( menu, iPlain, true );
- if ( ts.tsFace & bold )
- CheckItem( menu, iBold, true );
- if ( ts.tsFace & italic )
- CheckItem( menu, iItalic, true );
- if ( ts.tsFace & underline )
- CheckItem( menu, iUnderline, true );
- if ( ts.tsFace & outline )
- CheckItem( menu, iOutline, true );
- if ( ts.tsFace & shadow )
- CheckItem( menu, iShadow, true );
- if ( ts.tsFace & condense )
- CheckItem( menu, iCondensed, true );
- if ( ts.tsFace & extend )
- CheckItem( menu, iExtended, true );
- }
-
- // Justification submenu
-
- menu = GetMenuHandle( mJustification );
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- CheckItem( menu, i, false );
-
- switch( WEGetAlignment( we ) )
- {
- case weFlushLeft:
- item = iLeftAlign;
- break;
-
- case weFlushRight:
- item = iRightAlign;
- break;
-
- case weFlushDefault:
- item = iDefaultJust;
- break;
-
- case weCenter:
- item = iCenterAlign;
- break;
-
- case weJustify:
- item = iFullAlign;
- break;
- }
-
- // check the menu item
-
- CheckItem( menu, item, true );
-
- // Color submenu
-
- menu = GetMenuHandle( mColor );
-
- // no color quickdraw, no color menu!
-
- if ( gHasColorQD )
- {
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- // remove the check marks
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- CheckItem( menu, i, false );
-
- /* one thing to note about the color menu...
-
- the colors it picks not only to decide whether or not to check the
- menu item, but also the color it'll choose to draw text in is determined
- by the color of the menu item (so you could pick some strange shade of
- mauve in ResEdit when playing with the 'mctb' resource and you'll draw
- text in this color.)
-
- Now, if you open up a document that has a color that doesn't EXACTLY
- match the colors in the menu, the "Other" item should be checked,
- and when the color wheel is brought up, that color should be the
- "default" color in the wheel.
-
- Something that I didn't do, but probably might want to add (or you
- could add it..and it would go in HsoiAdjustMenus()) is that if
- there is another color as the default, draw the menu item text
- for "Other" in that color...sorta like how the Other font size menu
- item works...and if there were multiple/mixed colors in the selection
- range, just draw "other" in black.
-
- */
-
- if ( (mode & weDoColor) != 0 )
- {
- Boolean otherColor = true;
-
- // for reasons why we subtract 1 from the numEntries, see the above
- // color handling stuff in DoMenuCommand()
-
- for ( i = (*sColors)->numEntries - 1; i >= 0; i-- )
- {
- if ( HsoiEqualColor( &ts.tsColor, &(*sColors)->mcEntryRecs[i].mctRGB2 ) )
- {
- CheckItem( menu, (*sColors)->mcEntryRecs[i].mctItem, true );
- otherColor = false;
- }
-
- } // end for loop
-
- if ( otherColor )
- {
- // make sure there are no check marks anywhere
-
- for ( i = CountMenuItems( menu ); i >= 1; i-- )
- {
- CheckItem( menu, i, false );
- }
-
- // now check the Other menu
-
- CheckItem( menu, iColorOther, true );
- }
-
-
- }// end mode & weDoColor
-
- }
- else // no ColorQuickDraw
- DisableItem( menu, 0 );
-
-
- // Features submenu (this is getting long isn't it?)
-
- menu = GetMenuHandle( mFeatures );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // no removal of check marks here....the text of the menu items switches
- // depending on the state of the feature. You could change this to having
- // just plain old check marks, but I like this way of doing things cause
- // it is a little more informative for the user, plus it can show you how
- // to change menu item text!
-
- if ( WEIsTabHooks( we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableTabHooks );
- SetMenuItemText( menu, iTabHooks, itemString );
-
- // tab hooks only work with left alignment, so don't allow this!
-
- DisableItem( GetMenuHandle( mJustification ), 0 );
- DisableItem( GetMenuHandle( mText ), iJustification );
- }
- else
- {
- MenuRef justMenu = GetMenuHandle( mJustification );
-
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableTabHooks );
- SetMenuItemText( menu, iTabHooks, itemString );
-
- for ( i = 0; i <= CountMenuItems( justMenu ); i++ )
- EnableItem( justMenu, i );
-
- EnableItem( GetMenuHandle( mText ), iJustification );
- }
-
- if ( WEFeatureFlag( weFAutoScroll, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableAutoScroll );
- SetMenuItemText( menu, iAutoScroll, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableAutoScroll );
- SetMenuItemText( menu, iAutoScroll, itemString );
- }
-
- if ( WEFeatureFlag( weFOutlineHilite, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableOutlineHilite );
- SetMenuItemText( menu, iOutlineHilite, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableOutlineHilite );
- SetMenuItemText( menu, iOutlineHilite, itemString );
- }
-
- if ( WEFeatureFlag( weFReadOnly, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableReadOnly );
- SetMenuItemText( menu, iReadOnly, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableReadOnly );
- SetMenuItemText( menu, iReadOnly, itemString );
- }
-
-
- if ( WEFeatureFlag( weFIntCutAndPaste, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableCutAndPaste );
- SetMenuItemText( menu, iIntelligentCutAndPaste, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableCutAndPaste );
- SetMenuItemText( menu, iIntelligentCutAndPaste, itemString );
- }
-
- // if the computer doesn't support Drag and Drop, we gotta dim this
-
- if ( gHasDragAndDrop )
- {
- // make sure the item is enabled
-
- EnableItem( menu, iDragAndDropEditing );
-
- // check it
-
- if ( WEFeatureFlag( weFDragAndDrop, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableDragAndDrop );
- SetMenuItemText( menu, iDragAndDropEditing, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableDragAndDrop );
- SetMenuItemText( menu, iDragAndDropEditing, itemString );
- }
- }
- else
- {
- // no drag and drop on the computer, so disable the item
-
- DisableItem( menu, iDragAndDropEditing );
-
- // set the menu item text to say we can't drag and drop on this 'puter
-
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureCantDragAndDrop );
- SetMenuItemText( menu, iDragAndDropEditing, itemString );
- }
-
- if ( WEFeatureFlag( weFDrawOffscreen, weBitTest, we ) )
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureDisableOffscreen );
- SetMenuItemText( menu, iOffscreenDrawing, itemString );
- }
- else
- {
- GetIndString( itemString, rFeaturesMenuStrings, strFeatureEnableOffscreen );
- SetMenuItemText( menu, iOffscreenDrawing, itemString );
- }
-
-
- // Dialogs menu
-
- menu = GetMenuHandle( mDialogs );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // Windows menu
-
- menu = GetMenuHandle( mWindows );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- HsoiAdjustWindowsMenu( window );
-
- // Sound menu
-
- HsoiAdjustSoundMenu( window );
-
- // and finally!!! our Help menu
-
- HMGetHelpMenuHandle( &menu );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
-
- #if HAS_DEBUG
-
- // Test menu
-
- menu = GetMenuHandle( mTestMENU );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #endif
-
-
- // and just before we go, adjust the font size menu
-
- HsoiMaintainFontMenu();
-
- return;
- }
-
- void HsoiAdjustMenusClipboardWindow( WindowRef window )
- {
- MenuRef menu;
- short i;
-
- // similar but much simpler than HsoiAdjustMenusDocumentWindow()
-
- // Apple menu
-
- menu = GetMenuHandle( mApple );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // File menu
-
- menu = GetMenuHandle( mFile );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // disable New and Open if we've hit our max open windows
-
- if ( gNumWindows >= kMaxNumberOfOpenWindows )
- {
- DisableItem( menu, iNew );
- DisableItem( menu, iOpen );
- }
-
- DisableItem( menu, iSave );
- DisableItem( menu, iSaveAs );
- DisableItem( menu, iRevert );
- DisableItem( menu, iPrint );
-
- // Edit menu
-
- menu = GetMenuHandle( mEdit );
- EnableItem( menu, 0 );
- for ( i = CountMenuItems(menu) - 1; i >= 1; i-- )
- DisableItem( menu, i );
- EnableItem( menu, iShowClipboard );
-
- // and here's a pretty simple run to disable everything else
-
- DisableItem( GetMenuHandle( mText ), 0 );
- DisableItem( GetMenuHandle( mFont ), 0 );
- DisableItem( GetMenuHandle( mSize ), 0 );
- DisableItem( GetMenuHandle( mStyle ), 0 );
- DisableItem( GetMenuHandle( mJustification ), 0 );
- DisableItem( GetMenuHandle( mColor ), 0 );
- DisableItem( GetMenuHandle( mFeatures ), 0 );
-
- // enable the Dialogs menu'
-
- menu = GetMenuHandle( mDialogs );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- // Windows menu
-
- menu = GetMenuHandle( mWindows );
-
- if ( gNumWindows <= 0 )
- {
- DisableItem( menu, 0 );
- }
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- HsoiAdjustWindowsMenu( window );
-
- // Sound menu....since we can play sounds on the clipboard, let's make sure we set things up
-
- HsoiAdjustSoundMenu( window );
-
- // and finally!!! our Help menu
-
- HMGetHelpMenuHandle( &menu );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #if HAS_DEBUG
-
- // Test menu
-
- menu = GetMenuHandle( mTestMENU );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #endif
-
-
- return;
- }
-
- void HsoiAdjustMenusFindDialog( WindowRef window )
- {
- #pragma unused ( window )
-
- MenuRef menu;
- short i;
-
- // this is our modeless find/search dialog. since it's a modeless dialog, this
- // routine is sorta a hybrid between our document and dialog adjusters.
-
- menu = GetMenuHandle( mApple );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- menu = GetMenuHandle( mFile );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- if ( gNumWindows >= kMaxNumberOfOpenWindows )
- {
- DisableItem( menu, iNew );
- DisableItem( menu, iOpen );
- }
-
- DisableItem( menu, iSave );
- DisableItem( menu, iSaveAs );
- DisableItem( menu, iRevert );
- DisableItem( menu, iPrint );
-
- menu = GetMenuHandle( mEdit );
- EnableItem( menu, 0 );
- for ( i = CountMenuItems(menu) - 1; i >= 1; i-- )
- DisableItem( menu, i );
- EnableItem( menu, iShowClipboard );
-
- DisableItem( GetMenuHandle( mText ), 0 );
- DisableItem( GetMenuHandle( mFont ), 0 );
- DisableItem( GetMenuHandle( mSize ), 0 );
- DisableItem( GetMenuHandle( mStyle ), 0 );
- DisableItem( GetMenuHandle( mJustification ), 0 );
- DisableItem( GetMenuHandle( mColor ), 0 );
- DisableItem( GetMenuHandle( mFeatures ), 0 );
-
- menu = GetMenuHandle( mDialogs );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- menu = GetMenuHandle( mWindows );
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
-
- HsoiAdjustSoundMenu( window );
-
- HMGetHelpMenuHandle( &menu );
- if ( gHiliting )
- DisableItem( menu, i );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #if HAS_DEBUG
-
- // Test menu
-
- menu = GetMenuHandle( mTestMENU );
- if ( gHiliting )
- DisableItem( menu, 0 );
- else
- {
- for ( i = 0; i <= CountMenuItems( menu ); i++ )
- EnableItem( menu, i );
- }
-
- #endif
-
- return;
- }
-