appletmenu.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletmenu.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include <iac.h>
00008 #include "appletinternal.h"
00009 #include "appletcardops.h"
00010 #include "appletops.h"
00011 #include "appletmenuops.h"
00012 #include "appletmenu.h"
00013 #include "appletwindowmenu.h"
00014 #include "appletmain.h"
00015 
00016 #ifndef cutCmd
00017 #define cutCmd      3
00018 #define copyCmd     4
00019 #define pasteCmd    5
00020 #define clearCmd    6
00021 #endif
00022 
00023 MenuHandle hdlapplemenu, hdlfilemenu, hdleditmenu;
00024 
00025 MenuHandle hdlfontmenu, hdlsizemenu, hdlstylemenu, hdljustifymenu;
00026 
00027 
00028 
00029 void dialogmenuenabler (boolean flbeforedialog) {
00030     
00031     /*
00032     call before puting up a dialog. we disable all menus except the
00033     Edit menu.
00034     
00035     then call after the dialog is finished, and we re-enable all the
00036     menus.
00037     */
00038     
00039     if (flbeforedialog) {
00040         
00041         disableallmenus ();
00042         
00043         enablemenuitem (hdleditmenu, 0);
00044         
00045         disableallmenuitems (hdleditmenu);
00046         
00047         enablemenuitem (hdleditmenu, cutitem);
00048         
00049         enablemenuitem (hdleditmenu, copyitem);
00050         
00051         enablemenuitem (hdleditmenu, pasteitem);
00052         
00053         enablemenuitem (hdleditmenu, clearitem);
00054         }
00055     else 
00056         enableallmenus ();
00057         
00058     DrawMenuBar ();
00059     } /*dialogmenuenabler*/
00060     
00061     
00062 static boolean fontmenuchecker (MenuHandle hmenu, short itemnumber) {
00063 
00064     boolean fl;
00065     bigstring bs;
00066     short fontnum;
00067     
00068     getmenuitem (hmenu, itemnumber, bs);
00069     
00070     GetFNum (bs, &fontnum);
00071     
00072     fl = (fontnum == (**app.appwindow).selectioninfo.fontnum);
00073     
00074     checkmenuitem (hmenu, itemnumber, fl);
00075     
00076     enablemenuitem (hmenu, itemnumber);
00077         
00078     return (true);
00079     } /*fontmenuchecker*/
00080     
00081     
00082 static boolean sizemenuchecker (MenuHandle hmenu, short itemnumber) {
00083     
00084     short checkeditem;
00085     short fontsize;
00086     short itemsize;
00087     short style;
00088     short fontnum;
00089     
00090     fontsize = (**app.appwindow).selectioninfo.fontsize;
00091     
00092     switch (fontsize) {
00093         
00094         case -1: /*no consistent size across selection*/
00095             checkmenuitem (hmenu, itemnumber, false);
00096             
00097             goto L1; /*skip to determining if it's a real font or not*/
00098         
00099         case 9:
00100             checkeditem = point9item;
00101             
00102             break;
00103             
00104         case 10:
00105             checkeditem = point10item;
00106             
00107             break;
00108             
00109         case 12:
00110             checkeditem = point12item;
00111             
00112             break;
00113             
00114         case 14:
00115             checkeditem = point14item;
00116             
00117             break;
00118             
00119         case 18:
00120             checkeditem = point18item;
00121             
00122             break;
00123             
00124         case 24:
00125             checkeditem = point24item;
00126             
00127             break;
00128             
00129         case 36:
00130             checkeditem = point36item;
00131             
00132             break;
00133             
00134         case 48:
00135             checkeditem = point48item;
00136             
00137             break;
00138             
00139         case 72:
00140             checkeditem = point72item;
00141             
00142             break;
00143             
00144         default:
00145             checkeditem = pointcustomitem;
00146             
00147             break;
00148         } /*switch*/
00149     
00150     checkmenuitem (hmenu, itemnumber, itemnumber == checkeditem);
00151     
00152     L1:
00153     
00154     fontnum = (**app.appwindow).selectioninfo.fontnum;
00155     
00156     if (fontnum == -1) { /*no consistent font across selection*/
00157         
00158         stylemenuitem (hmenu, itemnumber, 0); /*plain*/
00159         
00160         return (true);
00161         }
00162     
00163     itemsize = -1;
00164     
00165     switch (itemnumber) {
00166         
00167         case point9item:
00168             itemsize = 9;
00169             
00170             break;
00171             
00172         case point10item:
00173             itemsize = 10;
00174             
00175             break;
00176             
00177         case point12item:
00178             itemsize = 12;
00179             
00180             break;
00181             
00182         case point14item:
00183             itemsize = 14;
00184             
00185             break;
00186             
00187         case point18item:
00188             itemsize = 18;
00189             
00190             break;
00191             
00192         case point24item:
00193             itemsize = 24;
00194             
00195             break;
00196             
00197         case point36item:
00198             itemsize = 36;
00199             
00200             break;
00201             
00202         case point48item:
00203             itemsize = 48;
00204             
00205             break;
00206             
00207         case point72item:
00208             itemsize = 72;
00209             
00210             break;
00211             
00212         } /*switch*/
00213     
00214     style = 0;
00215     
00216     if (itemsize != -1)
00217         if (RealFont (fontnum, itemsize))
00218             style = outline;
00219         
00220     stylemenuitem (hmenu, itemnumber, style);
00221         
00222     return (true);
00223     } /*sizemenuchecker*/
00224     
00225     
00226 static boolean stylemenuchecker (MenuHandle hmenu, short itemnumber) {
00227     
00228     boolean flchecked = false;
00229     tyselectioninfo x = (**app.appwindow).selectioninfo;
00230     
00231     switch (itemnumber) {
00232         
00233         case plainitem:
00234             flchecked = x.flplain;
00235             
00236             break;
00237             
00238         case bolditem:
00239             flchecked = x.flbold;
00240             
00241             break;
00242             
00243         case italicitem:
00244             flchecked = x.flitalic;
00245             
00246             break;
00247             
00248         case underlineitem:
00249             flchecked = x.flunderline;
00250             
00251             break;
00252             
00253         case outlineitem:
00254             flchecked = x.floutline;
00255             
00256             break;
00257             
00258         case shadowitem:
00259             flchecked = x.flshadow;
00260             
00261             break;
00262 
00263         } /*switch*/
00264     
00265     checkmenuitem (hmenu, itemnumber, flchecked);
00266     
00267     return (true);
00268     } /*stylemenuchecker*/
00269     
00270 
00271 static boolean justifymenuchecker (MenuHandle hmenu, short itemnumber) {
00272     
00273     tyjustification justification = (**app.appwindow).selectioninfo.justification;
00274     short checkeditem = -1;
00275     
00276     switch (justification) {
00277         
00278         case leftjustified:
00279             checkeditem = leftjustifyitem;
00280             
00281             break;
00282             
00283         case centerjustified:
00284             checkeditem = centerjustifyitem;
00285             
00286             break;
00287             
00288         case rightjustified:
00289             checkeditem = rightjustifyitem;
00290             
00291             break;
00292             
00293         case fulljustified:
00294             checkeditem = fulljustifyitem;
00295             
00296             break;
00297             
00298         case unknownjustification:
00299             checkmenuitem (hmenu, itemnumber, false);
00300             
00301             return (true);
00302             
00303         } /*switch*/
00304     
00305     checkmenuitem (hmenu, itemnumber, itemnumber == checkeditem);
00306     
00307     return (true);
00308     } /*justifymenuchecker*/
00309 
00310 
00311 static void checkfontsizestyle (void) {
00312     
00313     hdlappwindow hw = app.appwindow;
00314     tyselectioninfo x;
00315     
00316     if (hw == nil) /*no windows open*/
00317         return;
00318     
00319     x = (**hw).selectioninfo;
00320     
00321     if (!x.fldirty) /*nothing to do*/
00322         return;
00323     
00324     appprecallback ();
00325     
00326     (*app.setselectioninfocallback) ();
00327     
00328     apppostcallback ();
00329     
00330     x = (**hw).selectioninfo; /*get updated flags*/
00331     
00332     if (x.flcansetfont)
00333         visitonemenu (fontmenu, &fontmenuchecker);
00334     
00335     if (x.flcansetsize)
00336         visitonemenu (sizemenu, &sizemenuchecker);
00337     
00338     if (x.flcansetstyle)
00339         visitonemenu (stylemenu, &stylemenuchecker);
00340         
00341     if (x.flcansetjust)
00342         visitonemenu (justifymenu, &justifymenuchecker);
00343     } /*checkfontsizestyle*/
00344 
00345 
00346 void adjustmenus (void) {
00347     
00348     hdlappwindow ha = app.appwindow;
00349     boolean flappwindow = ha != nil;
00350     boolean flanywindow = FrontWindow () != nil;
00351     MenuHandle hmenu;
00352     boolean flchanges = false;
00353     boolean flsavable = true; 
00354     tyselectioninfo x;
00355     bigstring bsundo;
00356     boolean flenabled;
00357     
00358     if (app.haswindowmenu) 
00359         adjustwindowmenu ();
00360     
00361     if (flappwindow) {
00362     
00363         flsavable = !(**ha).notsaveable;
00364         
00365         flchanges = (**ha).flmadechanges;
00366         }
00367     
00368     hmenu = hdlfilemenu;
00369     
00370     if (hmenu != nil) {
00371     
00372         setmenuitemenable (hmenu, newitem, flsavable);
00373         
00374         setmenuitemenable (hmenu, openitem, true);
00375         
00376         setmenuitemenable (hmenu, closeitem, flanywindow);
00377         
00378         setmenuitemenable (hmenu, saveitem, flchanges && flsavable);
00379         
00380         setmenuitemenable (hmenu, saveasitem, flappwindow && flsavable);
00381         
00382         setmenuitemenable (hmenu, revertitem, flchanges && flsavable && ((**ha).fnum != 0));
00383         
00384         enablemenuitem (hmenu, pagesetupitem);
00385         
00386         setmenuitemenable (hmenu, printitem, flappwindow);
00387         
00388         enablemenuitem (hmenu, quititem);
00389         }
00390     
00391     hmenu = hdleditmenu;
00392     
00393     if (hmenu != nil) {
00394         
00395         if (getundomenuitem (bsundo, &flenabled)) {
00396             
00397             setmenuitem (hmenu, undoitem, bsundo);
00398             
00399             setmenuitemenable (hmenu, undoitem, flenabled);
00400             }
00401         
00402         if (flappwindow) {
00403              
00404             checkfontsizestyle ();
00405             
00406             x = (**app.appwindow).selectioninfo;
00407             }
00408         else
00409             clearbytes (&x, longsizeof (x)); /*set all flags to 0*/
00410         
00411         setmenuitemenable (hmenu, fontitem, x.flcansetfont);
00412         
00413         setmenuitemenable (hmenu, sizeitem, x.flcansetsize);
00414         
00415         setmenuitemenable (hmenu, styleitem, x.flcansetstyle);
00416         
00417         setmenuitemenable (hmenu, justifyitem, x.flcansetjust);
00418     
00419         if (x.flcansetsize) {
00420         
00421             hmenu = hdlsizemenu;
00422             
00423             enablemenuitem (hmenu, point9item);
00424             
00425             enablemenuitem (hmenu, point10item);
00426             
00427             enablemenuitem (hmenu, point12item);
00428             
00429             enablemenuitem (hmenu, point14item);
00430             
00431             enablemenuitem (hmenu, point18item);
00432             
00433             enablemenuitem (hmenu, point24item);
00434             
00435             enablemenuitem (hmenu, point36item);
00436             
00437             enablemenuitem (hmenu, point48item);
00438             
00439             enablemenuitem (hmenu, point72item);
00440             
00441             /*
00442             enablemenuitem (hmenu, pointupitem);
00443             
00444             enablemenuitem (hmenu, pointdownitem);
00445             */
00446             
00447             enablemenuitem (hmenu, pointcustomitem);
00448             }
00449         
00450         if (x.flcansetstyle) {
00451     
00452             hmenu = hdlstylemenu;
00453             
00454             enablemenuitem (hmenu, plainitem);
00455             
00456             enablemenuitem (hmenu, bolditem);
00457             
00458             enablemenuitem (hmenu, italicitem);
00459             
00460             enablemenuitem (hmenu, underlineitem);
00461             
00462             enablemenuitem (hmenu, outlineitem);
00463             
00464             enablemenuitem (hmenu, shadowitem);
00465             }
00466             
00467         if (x.flcansetjust) {
00468         
00469             hmenu = hdljustifymenu;
00470             
00471             enablemenuitem (hmenu, leftjustifyitem);
00472         
00473             enablemenuitem (hmenu, centerjustifyitem);
00474         
00475             enablemenuitem (hmenu, rightjustifyitem);
00476         
00477             enablemenuitem (hmenu, fulljustifyitem);
00478             }
00479         } /*Edit menu*/
00480     } /*adjustmenus*/
00481 
00482 
00483 static hdlcard aboutcard = nil;
00484 
00485 
00486 static void aboutfilter (EventRecord *ev) {
00487     
00488     #ifdef appRunsCards
00489         
00490         switch ((*ev).what) {
00491             
00492             case iowaInitEvent: 
00493                 aboutcard = (hdlcard) (*ev).message;
00494                 
00495                 break;
00496                 
00497             case iowaCloseEvent:
00498                 currentcard = (hdlcard) (*ev).message; 
00499                 
00500                 appsavedialoginfo (129); /*remember window position*/
00501                 
00502                 aboutcard = nil;
00503                     
00504                 break;
00505             
00506             } /*switch*/
00507         
00508     #endif
00509     } /*aboutfilter*/
00510     
00511 
00512 static void openaboutwindow (void) {
00513     
00514     #ifdef appRunsCards
00515         
00516         appprecallback ();
00517         
00518         if (aboutcard == nil)
00519             appopencardresource (129, aboutfilter);
00520         else
00521             appcardtofront (aboutcard); 
00522 
00523         apppostcallback ();
00524         
00525     #endif
00526     } /*openaboutwindow*/
00527 
00528 
00529 static void undocommand (void) {
00530     
00531     short ixaction;
00532     
00533     appprecallback (); 
00534     
00535     if (getredoaction (&ixaction))
00536         redolastaction (true);
00537     else
00538         undolastaction (true);
00539     
00540     apppostcallback ();
00541     } /*undocommand*/
00542 
00543 
00544 static boolean pushscrap (Handle h, OSType type) {
00545 
00546     OSErr ec;
00547     
00548     if (h == nil)
00549         return (true);
00550         
00551     lockhandle (h);
00552     
00553     ec = PutScrap (GetHandleSize (h), type, *h);
00554     
00555     unlockhandle (h);
00556     
00557     if (ec != noErr) {
00558     
00559         alertdialog ("\pError copying to clipboard.");
00560         
00561         return (false);
00562         }
00563         
00564     return (true);
00565     } /*pushscrap*/
00566     
00567     
00568 void appcopycommand (void) {
00569     
00570     /*
00571     DW 9/1/93: changed name, it's called from Clay Basket, to implement the
00572     Copy Alias command.
00573     */
00574 
00575     Handle appscrap = nil, textscrap = nil, pictscrap = nil;
00576     boolean flhavescrap = false;
00577     boolean fl;
00578     
00579     #ifdef appRunsCards
00580     
00581         if (cardEditCommand (copyCmd)) /*command was consumed by a shared window*/
00582             return;
00583     
00584     #endif
00585     
00586     appprecallback ();
00587     
00588     fl = (*app.copycallback) (&appscrap);
00589     
00590     apppostcallback ();
00591     
00592     if (fl) {
00593         
00594         if (app.commanderror)
00595             return;
00596             
00597         flhavescrap = true;
00598         }
00599     
00600     appprecallback ();
00601     
00602     (*app.gettextcallback) (&textscrap); /*textscrap is nil if it failed*/
00603     
00604     apppostcallback ();
00605     
00606     if (textscrap != nil)
00607         flhavescrap = true;
00608 
00609     appprecallback ();
00610     
00611     (*app.getpictcallback) (&pictscrap); /*pictscrap is nil if it failed*/
00612     
00613     apppostcallback ();
00614     
00615     if (pictscrap != nil)
00616         flhavescrap = true;
00617 
00618     if (!flhavescrap) {
00619         
00620         alertdialog ("\pNothing to copy.");
00621         
00622         return;
00623         }
00624         
00625     ZeroScrap ();
00626     
00627     if (!pushscrap (appscrap, app.creator)) /*error message already set/displayed*/
00628         return;
00629     
00630     if (!pushscrap (textscrap, 'TEXT')) 
00631         return;
00632     
00633     pushscrap (pictscrap, 'PICT');
00634     } /*appcopycommand*/
00635     
00636     
00637 static void clearcommand (void) {
00638     
00639     #ifdef appRunsCards
00640     
00641         if (cardEditCommand (clearCmd)) /*command was consumed by a shared window*/
00642             return;
00643             
00644     #endif
00645         
00646     appprecallback ();
00647     
00648     (*app.clearcallback) ();
00649     
00650     apppostcallback ();
00651     } /*clearcommand*/
00652     
00653     
00654 static void pastecommand (void) {
00655     
00656     Handle hscrap;
00657     long offset, ctbytes;
00658     
00659     #ifdef appRunsCards
00660         
00661         if (cardEditCommand (pasteCmd)) /*command was consumed by a shared window*/
00662             return;
00663     
00664     #endif
00665     
00666     hscrap = appnewhandle (0);
00667     
00668     ctbytes = GetScrap (hscrap, app.creator, &offset);
00669     
00670     if (ctbytes > 0) {
00671         
00672         boolean fl;
00673         
00674         appprecallback ();
00675         
00676         fl = (*app.pastecallback) (hscrap);
00677         
00678         apppostcallback ();
00679     
00680         if (fl) {
00681             
00682             DisposeHandle (hscrap);
00683             
00684             return;
00685             }
00686             
00687         DisposeHandle (hscrap);
00688             
00689         hscrap = appnewhandle (0);
00690         }
00691     
00692     ctbytes = GetScrap (hscrap, 'PICT', &offset);
00693     
00694     if (ctbytes > 0) {
00695         
00696         boolean fl;
00697         
00698         appprecallback ();
00699         
00700         fl = (*app.putpictcallback) (hscrap);
00701         
00702         apppostcallback ();
00703         
00704         if (fl)
00705             return;
00706             
00707         DisposeHandle (hscrap); /*app didn't want the PICT*/
00708         
00709         hscrap = appnewhandle (0);
00710         }
00711         
00712     ctbytes = GetScrap (hscrap, 'TEXT', &offset);
00713     
00714     if (ctbytes > 0) {
00715     
00716         boolean fl;
00717         
00718         appprecallback ();
00719         
00720         fl = (*app.puttextcallback) (hscrap);
00721         
00722         apppostcallback ();
00723         
00724         if (fl)
00725             return;
00726             
00727         DisposeHandle (hscrap);
00728             
00729         hscrap = appnewhandle (0);
00730         }
00731     
00732     if (hscrap != nil)
00733         DisposeHandle (hscrap); 
00734     } /*pastecommand*/
00735     
00736     
00737 static void cutcommand (void) {
00738     
00739     #ifdef appRunsCards
00740     
00741         if (cardEditCommand (cutCmd)) /*command was consumed by a shared window*/
00742             return;
00743     
00744     #endif
00745         
00746     appcopycommand ();
00747     
00748     if (app.commanderror)
00749         return;
00750 
00751     clearcommand ();
00752     } /*cutcommand*/
00753     
00754     
00755 static void UpdateSharedMenus (void) {
00756 
00757     AppleEvent event, reply;
00758     AEAddressDesc adr; 
00759     ProcessSerialNumber psn;
00760 
00761     psn.highLongOfPSN = 0;
00762 
00763     psn.lowLongOfPSN = kCurrentProcess;
00764 
00765     AECreateDesc (typeProcessSerialNumber, (Ptr) &psn, sizeof (psn), &adr);
00766     
00767     AECreateAppleEvent ('BARC', 'updm', &adr, kAutoGenerateReturnID, kAnyTransactionID, &event);
00768     
00769     AEDisposeDesc (&adr);
00770 
00771     AESend (&event, &reply, kAEWaitReply, kAENormalPriority, kNoTimeOut, (AEIdleUPP) nil, nil);
00772     
00773     AEDisposeDesc (&event); 
00774     
00775     AEDisposeDesc (&reply);
00776     } /*UpdateSharedMenus*/
00777 
00778 
00779 static void testmenus (void) {
00780     
00781     deletemenu (applemenu);
00782     
00783     deletemenu (filemenu);
00784     
00785     deletemenu (editmenu);
00786     
00787     deletemenu (fontmenu);
00788     
00789     deletemenu (sizemenu);
00790     
00791     deletemenu (stylemenu);
00792     
00793     deletemenu (justifymenu);
00794     
00795     deletemenu (windowmenu);
00796     
00797     DisposeSharedMenus ();
00798     
00799     initmenus ();
00800     
00801     UpdateSharedMenus ();
00802     } /*testmenus*/
00803     
00804 
00805 void handlemenu (long codeword) {
00806     
00807     hdlappwindow ha = app.appwindow;
00808     short idmenu, iditem;
00809     boolean fl;
00810     
00811     /*
00812     if (shiftkeydown ()) {
00813         
00814         testmenus ();
00815         
00816         return;
00817         }
00818     */
00819     iditem = LoWord (codeword);
00820 
00821     if (iditem <= 0)    
00822         goto exit;
00823      
00824     idmenu = HiWord (codeword); 
00825     
00826     if (SharedMenuHit (idmenu, iditem)) 
00827         goto exit;
00828     
00829     appprecallback (); 
00830     
00831     fl = (*app.menucallback) (idmenu, iditem);
00832     
00833     apppostcallback ();
00834     
00835     if (fl) /*consumed by the app*/
00836         goto exit;
00837     
00838     switch (idmenu) {
00839    
00840         case applemenu: 
00841             switch (iditem) {
00842             
00843                 case aboutitem:
00844                     openaboutwindow ();
00845                     
00846                     break;
00847                     
00848                 default: {
00849                 
00850                     bigstring bs;
00851                     
00852                     GetItem (hdlapplemenu, iditem, bs);
00853           
00854                     OpenDeskAcc (bs);
00855                     
00856                     break;
00857                     }
00858                 } /*switch*/
00859             
00860             break; /*apple menu*/
00861 
00862         case filemenu: 
00863             switch (iditem) {
00864             
00865                 case newitem: 
00866                     newuntitledappwindow (true);
00867                     
00868                     break;
00869                     
00870                 case openitem:
00871                     openfrontwindow ();
00872                     
00873                     break;
00874                 
00875                 case closeitem:
00876                     if (optionkeydown ())
00877                         closeallwindows ();
00878                     else 
00879                         closefrontwindow ();
00880                     
00881                     break;
00882                 
00883                 case saveitem: 
00884                     savefrontwindow ();
00885                     
00886                     break;
00887                     
00888                 case saveasitem:
00889                     saveasfrontwindow ();
00890                     
00891                     break;
00892                     
00893                 case revertitem:
00894                     revertfrontwindow ();
00895                     
00896                     break;
00897                     
00898                 case pagesetupitem: 
00899                     pagesetup ();
00900                     
00901                     break;
00902                 
00903                 case printitem:
00904                     printappwindow (ha, true);
00905                     
00906                     break;
00907                     
00908                 case quititem:
00909                     exitmainloop ();
00910                     
00911                     break;
00912                 } /*switch*/
00913             
00914             break; /*file menu*/ 
00915             
00916         case editmenu: 
00917             switch (iditem) {
00918                 
00919                 case undoitem:
00920                     undocommand ();
00921                     
00922                     break;
00923                     
00924                 case cutitem:
00925                     cutcommand ();
00926                     
00927                     break;
00928                     
00929                 case copyitem:
00930                     appcopycommand ();
00931                     
00932                     break;
00933                     
00934                 case pasteitem:
00935                     pastecommand ();
00936                     
00937                     break;
00938                     
00939                 case clearitem:
00940                     clearcommand ();
00941                     
00942                     break;
00943                     
00944                 case selectallitem:
00945                     selectallcommand ();
00946                     
00947                     break;
00948                 } /*switch*/
00949                 
00950             break; /*edit menu*/
00951             
00952         case windowmenu:
00953             selectwindowmenu (iditem);
00954 
00955             break; /*window menu*/
00956             
00957         case fontmenu: {
00958             bigstring bs;
00959             
00960             getmenuitem (hdlfontmenu, iditem, bs);
00961             
00962             appsetfont (bs);
00963             
00964             break;
00965             } /*font menu*/
00966             
00967         case sizemenu: {
00968             short size = (**ha).selectioninfo.fontsize;
00969             
00970             switch (iditem) {
00971                 
00972                 case point9item:
00973                     size = 9; break;
00974                     
00975                 case point10item:
00976                     size = 10; break;
00977                     
00978                 case point12item:
00979                     size = 12; break;
00980                     
00981                 case point14item:
00982                     size = 14; break;
00983                     
00984                 case point18item:
00985                     size = 18; break;
00986                     
00987                 case point24item:
00988                     size = 24; break;
00989                     
00990                 case point36item:
00991                     size = 36; break;
00992                     
00993                 case point48item:
00994                     size = 48; break;
00995                     
00996                 case point72item:
00997                     size = 72; break;
00998                     
00999                 case pointupitem:
01000                     size++;
01001                     
01002                     break;
01003                     
01004                 case pointdownitem:
01005                     size--;
01006                     
01007                     if (size < 1)
01008                         size = 1;
01009                         
01010                     break;
01011                     
01012                 case pointcustomitem: {
01013                     bigstring bs;
01014                     long num;
01015                     
01016                     NumToString (size, bs);
01017                     
01018                     if (!askdialog ("\pCustom font size:", bs))
01019                         goto exit;
01020                     
01021                     StringToNum (bs, &num); /*no protection against non-numeric chars*/
01022                     
01023                     size = (short) num;
01024                     
01025                     break;
01026                     }
01027                 } /*switch*/
01028                 
01029             if (size != 0) 
01030                 appsetfontsize (size);
01031                                 
01032             break;
01033             } /*size menu*/
01034             
01035         case stylemenu: {
01036             tyselectioninfo x = (**ha).selectioninfo;
01037             
01038             clearbytes (&x, longsizeof (x)); /*init all fields to zero*/
01039             
01040             x.flplain = false; /*it's off unless plain was selected*/
01041             
01042             switch (iditem) {
01043                 
01044                 case plainitem:
01045                     x.flplain = true;
01046                     
01047                     break;
01048                     
01049                 case bolditem:
01050                     x.flbold = true;
01051                     
01052                     break;
01053                     
01054                 case italicitem:
01055                     x.flitalic = true;
01056                     
01057                     break;
01058                     
01059                 case underlineitem:
01060                     x.flunderline = true;
01061                     
01062                     break;
01063                     
01064                 case outlineitem:
01065                     x.floutline = true;
01066                     
01067                     break;
01068                     
01069                 case shadowitem:
01070                     x.flshadow = true;
01071                     
01072                     break;
01073                 } /*switch*/
01074             
01075             setselectionstyleinfo (&x, true); /*pack into bits of x.fontstyle*/
01076     
01077             (**ha).selectioninfo = x;
01078             
01079             appprecallback (); 
01080             
01081             (*app.setstylecallback) ();
01082             
01083             apppostcallback ();
01084             
01085             (**ha).selectioninfo.fldirty = true;
01086             
01087             break;
01088             } /*style menu*/
01089             
01090         case justifymenu: {
01091             tyjustification justification = unknownjustification;
01092             
01093             switch (iditem) {
01094                 
01095                 case leftjustifyitem:
01096                     justification = leftjustified;
01097                     
01098                     break;
01099                     
01100                 case centerjustifyitem:
01101                     justification = centerjustified;
01102                     
01103                     break;
01104                     
01105                 case rightjustifyitem:
01106                     justification = rightjustified;
01107                     
01108                     break;
01109                     
01110                 case fulljustifyitem:
01111                     justification = fulljustified;
01112                     
01113                     break;
01114                     
01115                 } /*switch*/
01116                 
01117             if (justification != unknownjustification) {
01118                 
01119                 (**ha).selectioninfo.justification = justification;
01120                 
01121                 appprecallback (); 
01122                 
01123                 (*app.setjustifycallback) ();
01124                 
01125                 apppostcallback ();
01126                 
01127                 (**ha).selectioninfo.fldirty = true;
01128                 }
01129                 
01130             break;
01131             } /*justify menu*/
01132         
01133         case extendedmenu: { /*special key on the extended keyboard*/
01134             switch (iditem) {
01135                 
01136                 case helpitem:
01137                     openaboutwindow ();
01138                     
01139                     break;
01140                 
01141                 case homeitem:
01142                     appprecallback (); (*app.scrollcallback) (down, false, infinity); apppostcallback ();
01143                     
01144                     break;
01145                 
01146                 case enditem:
01147                     appprecallback (); (*app.scrollcallback) (up, false, infinity); apppostcallback ();
01148                     
01149                     break;
01150                 
01151                 case pageupitem:
01152                     appprecallback (); (*app.scrollcallback) (down, true, 1); apppostcallback ();
01153                     
01154                     break;
01155                 
01156                 case pagedownitem:
01157                     appprecallback (); (*app.scrollcallback) (up, true, 1); apppostcallback ();
01158                     
01159                     break;
01160                 } /*switch*/
01161             } /*extended menu*/
01162         
01163         } /*switching on which menu was invoked*/
01164         
01165     exit:
01166     
01167     HiliteMenu (0);
01168     } /*handlemenu*/
01169     
01170     
01171 boolean flipcustommenu (hdlappwindow appwindow, boolean flactivate) {
01172     
01173     /*
01174     DW 8/19/93: add call with appwindow == nil, flactivate == false.
01175     
01176     DW 10/8/93: insert menu after the Window menu.
01177     */
01178     
01179     static MenuHandle hdlcustommenu = nil;
01180     static short idcustommenu;
01181     boolean fldraw = false;
01182     
01183     if (hdlcustommenu != nil) {
01184         
01185         deletemenu (idcustommenu);
01186         
01187         hdlcustommenu = nil;
01188         
01189         fldraw = true;
01190         }
01191         
01192     if (flactivate) {
01193         
01194         idcustommenu = (**appwindow).idmenu;
01195         
01196         if (idcustommenu != 0) {
01197             
01198             installmenubefore (idcustommenu, windowmenu, &hdlcustommenu);
01199             
01200             fldraw = true;
01201             }
01202         }
01203         
01204     if (fldraw)
01205         DrawMenuBar ();
01206     
01207     return (true);
01208     } /*flipcustommenu*/
01209     
01210     
01211 void disableeditmenuitems (void) { /*DW 11/17/95*/ 
01212     
01213     disablemenuitem (hdleditmenu, undoitem);
01214     
01215     disablemenuitem (hdleditmenu, cutitem);
01216     
01217     disablemenuitem (hdleditmenu, copyitem);
01218     
01219     disablemenuitem (hdleditmenu, pasteitem);
01220     
01221     disablemenuitem (hdleditmenu, clearitem);
01222     
01223     disablemenuitem (hdleditmenu, selectallitem);
01224     
01225     disablemenuitem (hdleditmenu, fontitem);
01226     
01227     disablemenuitem (hdleditmenu, sizeitem);
01228     
01229     disablemenuitem (hdleditmenu, styleitem);
01230     
01231     disablemenuitem (hdleditmenu, justifyitem);
01232     } /*disableeditmenuitems*/
01233 
01234 
01235 void initmenus (void) {
01236 
01237     installmenu (applemenu, &hdlapplemenu);
01238     
01239     if (hdlapplemenu != nil)
01240         AddResMenu (hdlapplemenu, 'DRVR');
01241     
01242     installmenu (filemenu, &hdlfilemenu);
01243     
01244     installmenu (editmenu, &hdleditmenu);
01245     
01246     (*app.insertmenucallback) ();
01247     
01248     installhierarchicmenu (fontmenu, &hdlfontmenu);
01249     
01250     if (hdlfontmenu != nil)
01251         AddResMenu (hdlfontmenu, 'FONT');
01252     
01253     installhierarchicmenu (sizemenu, &hdlsizemenu);
01254     
01255     installhierarchicmenu (stylemenu, &hdlstylemenu);
01256     
01257     installhierarchicmenu (justifymenu, &hdljustifymenu);
01258     
01259     initwindowmenu (); /*window menu is last menu*/
01260     
01261     DrawMenuBar ();
01262     } /*initmenus*/
01263     
01264     
01265     
01266 
01267 

Generated on Wed May 31 18:19:43 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6