TweetFollow Us on Twitter

Object Shell 2
Volume Number:6
Issue Number:9
Column Tag:MacOOPs!

Related Info: Window Manager QuickDraw TextEdit

Object Shell, Part II

By Dr. Christian Stratowa, Vienna, Austria

Part 2: Application-specific Units

Let me start the second part of my article once again with a statement, this time with the first sentence of the TMLetter: “Apple is giving notice to Macintosh developers that object-oriented programming (OOP) will become the only way to write Mac software.” I really hope this statement does not mean that in the future Apple will force programmers to use MacApp. Although I don’t have MacApp yet, from what I have seen in the different articles published in MacTutor, I have the feeling that I won’t like it. Once upon a time...Apple has started the computer revolution by giving people the freedom of personal computing. Now that Apple seems more and more to adopt IBM-like behaviour let me say: “Freedom to the programmers to adopt their own programming style and to use the language of their choice!” Programming is still an esthetic art and having a uniform user interface (which is surely of great benefit to the users) does not necessarily mean to have to adopt a uniform programming style.

Last time I have presented the general part of our shell program, which needs not be changed when you want to use ObjectShell for your own purposes. So let’s now talk about the units specific to our demo application.

Adding your own menus

Unit MyMenus allows us to attach all menus specific to our application. Here we make use of Apple’s new “Hierarchical Menus” feature, where any menu item can be defined as submenu. So we define an object TSubMenu, whose method Create inserts a submenu (see IM V-236). In our program we make use of this feature not only in menu “Text” where Font, Size, Style and Justification are arranged as submenus, and in “Color” with submenus TForeCMenu and TBackCMenu, but we do also define item “New” of our standard “File” menu as submenu to be able to create “NewText” or “NewPict” documents. We can do this by creating submenu TNewMenu without having to change any code in our unit StdMenus. Every submenu item can itself be another submenu, although Apple states that only one level of hierarchical menus should be used. In our demo program we create another submenu level by defining TNewPictMenu and TNewTextMenu to let the user choose the window type. Normally you would delete this level.

We can open windows containing either TEXT or PICT documents which use different menus. For this we want to change the appearance of the menubar depending on the type of window becoming Frontwindow. Therefore procedure SetMyMenuBar, which is called from DoActivate every time a window will be activated, does change the whole MenuBar by calling SwitchMenus. When no window is in front, all but the three standard menus will be deleted from the menubar. In the case Frontwindow is a desk acessory I decided for demonstration purposes to disable the application-specific menus only although we could have also deleted them in this case. (I have put the necessary call to SwitchMenus in parenthesis.) Procedure SwitchMenus does insert or delete the necessary menus by calling DoInsertMenu. This procedure requires parameter vMenuHdl besides vRsrcID, because it is not possible to call GetMenuHandle(vRsrcID), when a menu is not installed in the menulist.

When a userwindow becomes activated, we want the current menu settings to be marked, e.g. for text the current Font, Size, Style and Align menu items should be indicated with a checkmark. This is pretty straight foreward. For text procedure SwitchMenus calls CheckFontMenu, CheckSizeMenu etc. Procedure CheckFontMenu does for example get the current font from the GrafPort (thePort^.txFont) and does call SetCheckMark if vFontName equals vCurrentFont. It has also to call OutlineFontSize for every RealFont in the System. Procedure CheckStyleMenu is a little more tricky, because Apple has decided to define Style as set of type StyleItem [see IM I-152]. Together with style “Plain” there exist eight style items, therefore I have decided to use the bits of one byte for the style setting. For this purpose I defined a field variable fMyHdl of type Handle in TDocument. All procedure CheckStyleMenu has to do is to set the corresponding bits. (Because a Handle is defined as ^^SignedByte the initial setting “Plain” is: fMyHdl^^:= -128.) Similarly, when we select or unselect a style item, TStyleMenu.Choose sets or clears the corresponding bit.

For graphics we have only to call SetCheckMark every time a graphics window becomes activated or the user selects an item from the “Graphics” menu or one of the “Color” submenus. (To save some space in this article, I have decided not to colorize the “Color” submenu items. With new ResEdit 1.3 (one.three!) it is much too easy to do, anyway.)

Documents - What the Mac is Made for

So far we have learned how to deal with Mac specific stuff, but every computer is built for one purpose only - to process our documents.

As mentioned earlier, our program can handle text and graphics. In unit MyDocuments we define subclasses TTextDocument and TPictDocument. The document type itself is then set in TWindow.DoNew in the already known manner. However, creating a new document this way does have its disadvantages, too: We have to place every field, which has to be set from outside the object, in ancestor class TDocument. Let us take textedit record’s handle fTextHdl as an example. This is clearly a field variable, which does only belong to subclass TTextDocument. But if we define it there the compiler will generate an error message in method Choose of our submenus, where we have set e.g. fTextHdl^^.txFont. Isn’t this a limitation of the ObjectPascal compiler? (You will probably say objects should be encapsulated and fields not changed from outside directly.)

Since we are already talking about text let’s have a closer look.

Typewriter’s Mac

Before creating a new fTextHdl for our textedit record in DoNew we have to define its view rectangle fViewRect and destination rectangle fDocRect. These two rectangles have also to be set in our Update routine, otherwise you will be in trouble when for example selecting text with TEClick. You may be wondering why we declare field fViewRect in addition to fViewRgn. This is necessary to be able to inset fViewRect by kTextMargin. Insetting fViewRgn would lead to strange looking results in the case you want to place some controls within your window and use a background color other than white.

Typing itself is handled in method KeyPress. In this routine we inform the user when the number of characters in the text exceeds MaxInt during typing by displaying a dialog box.

Every time we SetColor or change Font, Size, Style or Justification of our text method ReDraw does the necessary calculations before calling TECalText and invalidating fViewRgn to force an update event.

The World of QuickDraw

Our graphics example shows how to deal with the following features:

• selecting the desired shape from menu “Graphics”

• clicking anywhere within fViewRgn to determine where the shape should be drawn

• popping up a dialog box for setting the shape parameters every time you click the mouse button within the view region

• changing fore and background color any time you want

This time we create every shape in DoNew as a distinct object oOvals, oSpirals, together with its connected oDialog box. Only after having clicked the mouse button in fViewRgn we are setting the choosen shape equal to oShape to be able to use field oShape in the other methods.

Method ClickInDoc does first call DoDialog to allow the user to set the shape parameters and then calls self.ReDraw. But keep in mind that the user could have scrolled fDocRect before clicking in the view region to position the draw origin, so you have to adjust field oShape.fPt accordingly first. When the dialog window has been closed all needed update and activate events are generated automatically. In our case automatically updating is not necessary, because the whole view region will be redrawn anyhow since we clip to fViewRgn and call Update ourselves, so we call ValidRgn(fViewRgn) first to prevent redrawing the part of fViewRgn covered by the dialog box twice.

The actual drawing is done in method ReDraw using QuickDraw’s picture record. QuickDraw lets you save a sequence of drawing commands between calls OpenPicture and ClosePicture and “play them back” later with a single procedure call [IM I-158]. To be compatible with MacDraw we have to embed picture comments picDwgBeg and picDwgEnd. PicComments, which do not have an effect on the displayed image, are used to apply additional information when pictures are transmitted from one application to another. Here we use also PicGrpBeg and PicGrpEnd to group our QuickDraw calls together to act like one object. Our application supports scrolling, therefore we have first to limit drawing to region vClipRect within the portRect of QuickDraw. Otherwise offsetting the picture rectangle just one pixel to the right or bottom will set the clipping rectangle to the empty rectangle and the whole picture gets clipped (see IM I-190 and MT 4/86 p.57).

There are three ways to redraw pictures, when we scroll or resize the drawing window:

1, We could store the picture as an offscreen bitmap. This would allow fast scrolling but uses lots of RAM, especially when drawing in color with new 32bit ColorQuickDraw.

2, We could recalculate our drawing for every update event like MacDraw does. This approach is unacceptable in the case our drawing contains e.g. a graph obtained from a set of differential equations, or a Mandelbrot fractal, where calculation times easily exceed one hour. In that case recalculating the picture should not be done for saving and printing our documents either.

3, We could calculate our drawing only once and define it as QuickDraw picture, then redraw it when necessary with procedure DrawPicture. This approach should also be used for saving and printing.

In my example I use the third possibility which seems to me to be the best one. However, to be able to change the color of our drawing every time we select a different color from the Color menu, we have to define our picture in method ReDraw instead of method ClickInDoc, an approach not possible for long calculation times. (For more information about pictures and picComments see MT 4/86 p.56, MT 10/87 p.66 and MT 6/88 p.40.)

Mac’s Way to Communicate

As mentioned earlier, before drawing our picture we put up a dialog box to get all of the shape parameters we need. Object TDialog contains variable fDlogItems, which determines the size of string array fStr, the array of editable text fields fStr itself, and a boolean flag fDFlag as field variables. Array fStr stores the parameters we input so that the next time we select the dialog box our new parameter settings will be displayed. The flag field is set to TRUE when we press OK after setting the dialog parameters or to FALSE when we cancel the dialog, in which case the default values are displayed the next time the dialog box is called. Fig.5 shows the dialog box, which will be displayed after calling oOvals.DoDialog. As you can see it does not only contain editable text fields but also a popup menu, which I have implemented so that you can see how Apple’s demo example (Macintosh developer technical sample code disk) works in a real application. It is pretty straight foreward, you only have to take care to preserve the old grafport in filterfunction MyFilter before setting the grafport to vDPtr.

Method DoDialog does first call CenterMyDialog to make sure the dialog box will be centered for every screen size used. This is always possible because records DialogTemplate and AlertTemplate contain field boundsRect, which stores the global coordinates of the Dialog or Alert window [see IM I-423]. After determining dialog’s width and height procedure CenterDialogBox calculates the new TopLeft position of boundsRect. Before allowing the changed resource being purged from the heap CenterMyDialog has to call SetResPurge, so that the resource data can be written out to the resource file.

The parameters stored in array fStr when the user presses the OK button, are converted to numbers in method TShape.Create. I did not implement error checking in case the user types a non-numeric entry in the dialog.

Cut, Copy and Paste

Our application does implement the Edit menu. This is pretty straight forward for text, where we can use the editing routines from TextEdit. The only difference to other people’s code is that after calling TECut or TECopy we transfer the content of TextEdit’s private scrap immediately to the desk scrap. By doing this we need not take care to transfer the private scrap when another window gets activated or when running under MultiFinder. (Apple’s new TextEdit routines TECut and TECopy write both text and its associated style information directly to the desk scrap, anyhow. [IM V-267]) Before pasting we check first if the desk scrap contains text and if the length of the current text plus the text to be pasted does not exceed MaxInt in which case we put up an alert box informing the user. In method ApplTask we enable menu items Cut and Copy only when text is selected, and Paste only when the scrap is not empty.

Setting up editing for pictures is a little more complicated. We have to know exactly when to dispose of vScrapHdl we have created before, and when to call KillPicture. For menu items Cut and Copy we have to set vScrapHdl to nil before disposing it, for menu item Paste we are not allowed to dispose of vScrapHdl because it has been converted before to type PicHandle. At the end of method Edit we have to call self.Update if the content of our document has changed. In our demo application we have implemented the Edit menu mainly to be able to paste pictures into other applications like MacDraw. Pasting a picture within our program, although possible, does not give you any advantage, in contrast you are not able to change the color afterwards.

Saving and Opening Files

Once we have typed text or played around with different shapes we want to store our work to disk. This is done with TWindow function Saved. When we have choosen “Save as...” from the File menu (vSaveAs) or want to save a document the first time (vNewFile), we call the standard file dialog. If vReply is good we do first check for DuplicateFileName and then create a new file. DuplicateFileName makes recursive calls to nextWindow to check if a window with title vFileName is already open. If this is the case we rename the old window “Untitled”, delete its file and set flag fChanged of the old document to TRUE. This forces the program to ask the user if s/he wants to save the old document before closing it. In any case we open the file, call oDocument.DoSave, and close the file.

For text we set the file position to the start of the file and use TextEdit record handle hText to write text into the file. (Remember to lock the handle before dereferencing it.)

In the case of our drawings we have first to write a 512 byte blank header to disk before we can write our QuickDraw picture document into the file. This will enable MacDraw to open our PICT file and use its default settings.

Opening documents is done similarly. We call the standard file dialog and if vReply is good and the file is not already open, we create a new window by calling DoNew. We open then the file in window’s method DoOpen, call oDocument.DoOpen, set the new window title, force an update event, and close the file.

When opening a text file we check first if vFileSize is not larger than allowed by TextEdit before reading in the text. We set the caret to the end of our document and scroll the text to the bottom.

Because we have saved our picture as a MacDraw document we have to set the file position to 512 bytes from start before reading in the picture. In this way we are also able to open MacDraw documents saved as PICT documents. To be able to do this we have to set fDocRect equal to the picture frame otherwise the MacDraw document would be displayed with distortion.

Using the File Manager to save and open files involves a lot of error checking, so we embed most of its routines in our boolean function OSError, which displays an error message when an error has occured. It would be good programming style and helpful to the user if the dialog box would not only show the error ID number but a description of the error, too. In order to save space in this article we describe only the errors “Duplicate File name” and “File already open”, in all other cases we display vErrNr only.

When closing a file whose document field fChanged has been set to TRUE, an alert box pops up asking the user to save the document before closing it. When the user presses “Cancel” the flag gQuitting will be set to FALSE. This is important in case “Quit” was choosen from the File menu, because procedure DoQuit will then discontinue closing further windows and not set flag gDone.

When the last application window will be closed or vNextWindow is a desk accessory gCloseFlag will enable us to SetMyMenuBar.

Making Hardcopies

Although some people have promised us a paperless world with the advent of computers quite the opposite became true. To enable our user to waste paper too we support printing text and graphics.

Printing a document using the Printing Manager involves a lot of opening and closing stuff. At first we have to open the printer resource file and the Printer Driver (PrOpen) in procedure DoPrint called from the standard File menu. Then we validate our print record, put up the standard printing dialog box and pass control to oWindow.DoPrint before calling PrClose. In unit StdWindows we open the printing grafport after having saved our current grafport. We DisplayPrintDialog to enable the user to cancel the printing process. In case of draft printing the actual printing is done in TDocument.DoPrint, where each page is opened, printed and closed separately. In the other cases each page is prepared for printing only once by drawing into the printing port and writing it to disk as part of a spool file. The actual printing is then done in TWindow.DoPrint by calling PrPicFile. This procedure images and prints a spool file containing a previously spooled document.

While this time printing graphics is easy by simply calling DrawPicture, you only have to reset vDocRect in case the user has scrolled the picture before choosing ‘Print’, printing text involves more work. First we calculate the bounding rectangle our edit record will use for wrapping text by insetting vPageRect. Then we create a new TextEdit record which will draw into the printing port, determine vPageHeight, and copy the text handle and text length from the active window’s main edit record fTextHdl into our new one, vTextHdl. After wrapping the text to vPageRect we open each page separately and draw our text by calling TEUpdate. Before closing the page we have to offset our text so that the next part of our document can be drawn on the following page. When done we dispose of the edit record, but first we have to clear its text handle hText to nil. Otherwise we would automatically deallocate the text while our window still needs it (MR 3-168).

Multifinder Support

Trying to support Multifinder was pretty hard because the only information I have until now comes from two articles in MacTutor (MT 11/87 and 2/88), which I didn’t quite understand, so I had to play around to get the code right. And this is how I think Multifinder is working: When you switch between different applications under Multifinder, the application which comes to the front gets activated. Multifinder will not only feed an activate event to the proper window, but will also post a resume/suspend event in the event queue (App4Evt). When you have set in resource ‘SIZE’, that your application supports resume/suspend events then you should not use these activation events (is this true?) but handle the necessary activations yourself. Since App4Evt is an application defined event type, then depending on the state of gEvent.message, which, for activate events, is a pointer to the window effected, you have to set the activate/deactivate flag yourself. Therefore, in procedure DoMFEvent we are forcing an activate/deactivate event by setting the activeFlag bit of the EventRecord field gEvent.modifiers. This field is an integer, therefore we have to set/clear bit 15 (because the bit-numbering convention of the toolbox is the reverse of the one generally used on the 68000 processor). Then when FrontWindow is ours we call oWindow.Activate as usual. This code does now really work. To see, that it is also necessary, delete all code in procedure DoMFEvent and recompile the program. When you open now the program under Multifinder then at first sight you won’t see any difference. But when you look carefully you will see, that after switching between programs our grow box and scroll bars will not be activated properly.

Although set up for mouse moved events, we are not supporting this feature of MultiFinder and have therefore set gMouseRgn to nil. I have only one monitor so I could not test if the necessary region arithmetics would be ok on multiple monitors.

A Personal Outlook

Now that I have finished to outline a typical shell program for the Mac, which I hope some of you may find useful, let me take the opportunity to make some personal remarks about the future of computers, Apple computers, and programming.

It seems clear to me that object-oriented programming will be the software-approach of the future. However, I don’t think that MacApp will have a bright future, because first it does restrict programmer’s thinking too much, and second it is limited to the Mac only. (Besides that I don’t see any advantage in learning more than 500 MacApp procedures over learning more than 500 ROM calls.) The way of the future seems to lie more in GAOOP - graphic assisted object-oriented programming, a way outlined in Steve Jobs’s NextStep, and to a more limited content also in HyperCard. Maybe Smalltalk will finally get the attention it deserves, although for some strange reason Apple has never promoted it officially. Using Smalltalk scientists at Canon’s European research center have recently developed a visual programming language, called VPL, which enables nonspecialists to manipulate images on a computer screen. I have the feeling that Apple is more and more loosing ground.

Talking about Apple - what is the difference between IBM and Apple? Most people would probably agree that IBM became world’s largest computer company not because of innovative products but (at least partly) because of its known customer service, a word that does not even exist at Apple. At mainframe times customer service and compatability to existing operating systems was more important than staying at the edge of technology. In contrast to IBM, Apple became a billion dollar company due to only two innovative products, the Apple II and the Macintosh. For personal computers of today innovation and userfriendliness is more important than compatibility to existing systems (even if this system is UNIX). This will be even more important tomorrow.

What is the hardware approach of the future, and where will Apple be? Sun and HP have already come out with RISC machines, even Atari has recently presented an innovative computer, the Atari Transputer Workstation. Meanwhile Apple has presented a third Mac II clone (IIci) without graphics processor. (How can a company claiming to make one of the best graphics computers, still design its hardware without at least one graphics processor?) Maybe Apple is already too large to be innovative. I think Apple will only survive if it will be the first to present the power of an old Cray 1 on the desktop at the cost of a Mac II. Where are the NeXT Jobs at Apple? (Note added in proof (Oct89): On a trip to New York I had the possibility to get a demonstration of the NeXT cube. I am really sorry for Apple but after having seen and heard(!) the NeXT in action I have almost lost all interest in working with or programming the Mac. If I would have the money I would buy one immediately. Forget the Mac, join the NeXT! - or at least get a demonstration yourself.)

Be it RISC or transputer or another processor technology, the real hardware innovation of the near future will be parallel processing, which will stay with us forever (!), because this is how our brain works. Neural network design will also become more and more important. In the farther future optical computing will give parallel processing a completely new meaning. And then will come the quantum computer, which may at last be able to think. I guess I’ll better stop here!

Continued in next frame

Volume Number:6
Issue Number:9
Column Tag:MacOOPs!

Related Info: Window Manager QuickDraw TextEdit

Object Shell, Part II (code)

By Dr. Christian Stratowa, Vienna, Austria

Listing: MyMenus.p

UNIT MyMenus;
{****************************************}
INTERFACE
 USES
 MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, MacPrint, ObjIntf, 
GlobalStuff, StdWindows, StdMenus, MyDocuments;
 TYPE
 TSubMenu = OBJECT(TMenu)
 PROCEDURE Create(vRsrcID: Integer);
 override;
 END;
 TNewMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TNewPictMenu = OBJECT(TNewMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TNewTextMenu = OBJECT(TNewMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TGraphMenu = OBJECT(TMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TColorMenu = OBJECT(TMenu)
 END;
 TForeCMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TBackCMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TTextMenu = OBJECT(TMenu)
 END;
 TFontMenu = OBJECT(TSubMenu)
 PROCEDURE Create(vRsrcID: Integer);
 override;
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TSizeMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TStyleMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 TJustMenu = OBJECT(TSubMenu)
 PROCEDURE Choose(vItem: Integer);
 override;
 END;
 VAR
 oNewMenu: TNewMenu;
 oNewPictMenu: TNewPictMenu;
 oNewTextMenu: TNewTextMenu;
 oGraphMenu: TGraphMenu;
 oColorMenu: TColorMenu;
 oForeCMenu: TForeCMenu;
 oBackCMenu: TBackCMenu;
 oTextMenu: TTextMenu;
 oFontMenu: TFontMenu;
 oSizeMenu: TSizeMenu;
 oStyleMenu: TStyleMenu;
 oJustMenu: TJustMenu;

 PROCEDURE InitMyMenus;
 PROCEDURE ClickInMyMenus(vMenu,vItem: Integer);
 PROCEDURE SetMyMenuItems;
 PROCEDURE SetMyMenuBar;
 PROCEDURE DisposeMyMenus;

{****************************************}
IMPLEMENTATION

PROCEDURE SetCheckMark(vMenuHdl: MenuHandle; vItem: Integer);
 VAR
 vMaxMItem: Integer;
 i: Integer;
BEGIN
 vMaxMItem:= CountMItems(vMenuHdl);
 FOR i:= 1 TO vMaxMItem DO
 CheckItem(vMenuHdl, i, (i = vItem));
END;  {SetCheckMark}

{----------------------------------------}
PROCEDURE OutlineFontSize(vFontNumber: Integer);
 VAR
 vSizeMenu: MenuHandle;
 vSizeName: Str255;
 vSizeNumber: LongInt;
 i: Integer;
BEGIN
 vSizeMenu:= oSizeMenu.fMenuHdl;
 FOR i:= 1 TO CountMItems(vSizeMenu) DO
 BEGIN
 GetItem(vSizeMenu, i, vSizeName);
 StringToNum(vSizeName, vSizeNumber);
 IF RealFont(vFontNumber, vSizeNumber) THEN
 SetItemStyle(vSizeMenu, i, [Outline])
 ELSE
 SetItemStyle(vSizeMenu, i, []);
 END;
END;  {OutlineFontSize}

{----------------------------------------}
PROCEDURE CheckFontMenu(vMenuHdl: MenuHandle);
 VAR
 vMaxMItem: Integer;
 vFontName: Str255;
 vFontNumber: Integer;
 vCurrentFont: Str255;
 i: Integer;
BEGIN
 vMaxMItem := CountMItems(vMenuHdl);
 GetFontName(thePort^.txFont, vCurrentFont);
 FOR i:= 1 TO vMaxMItem DO
 BEGIN
 GetItem(vMenuHdl, i, vFontName);
 IF vFontName = vCurrentFont THEN
 BEGIN
 SetCheckMark(vMenuHdl, i);
 GetFNum(vFontName, vFontNumber);
 OutlineFontSize(vFontNumber);
 leave;
 END;
 END;
END;  {CheckFontMenu}

{----------------------------------------}
PROCEDURE CheckSizeMenu (vMenuHdl: MenuHandle);
 VAR
 vMaxMItem: Integer;
 vSizeName: Str255;
 vSizeNumber: LongInt;
 vCurrentSize: Integer;
 i: Integer;
BEGIN
 vMaxMItem:= CountMItems(vMenuHdl);
 vCurrentSize:= thePort^.txSize;
 FOR i:= 1 TO vMaxMItem DO
 BEGIN
 GetItem(vMenuHdl, i, vSizeName);
 StringToNum(vSizeName, vSizeNumber);
 IF LoWord(vSizeNumber) = vCurrentSize THEN
 BEGIN
 SetCheckMark(vMenuHdl, i);
 leave;
 END;
 END;
END;  {CheckSizeMenu}

{----------------------------------------}
PROCEDURE CheckStyleMenu(vMenuHdl: MenuHandle);
 VAR
 i: Integer;
 vStylePtr: Ptr;
BEGIN
 vStylePtr:= oWindow.oDocument.fMyHdl^;
 FOR i:= kPlain TO kExtend DO
 CheckItem(vMenuHdl,i, BitTst(vStylePtr,i - 1))
END;  {CheckStyleMenu}

{----------------------------------------}
PROCEDURE CheckJustMenu(vMenuHdl: MenuHandle);
 VAR
 vJust: Integer;
 vItem: Integer;
BEGIN
 vJust:= oWindow.oDocument.fTextHdl^^.just;
 CASE vJust OF
 teJustLeft: 
 vItem:= kLeft;
 teJustCenter: 
 vItem:= kCenter;
 OTHERWISE
 vItem:= kRight;
 END;
 SetCheckMark(vMenuHdl, vItem);
END;  {CheckJustMenu}

{----------------------------------------}
PROCEDURE SwitchMenus(vPictFlag,vTextFlag: BOOLEAN);

 PROCEDURE DoInsertMenu(vMenuHdl: MenuHandle;
 vRsrcID: Integer; vFlag: BOOLEAN);
 BEGIN
 IF vFlag THEN
 InsertMenu(vMenuHdl, 0)
 ELSE
 DeleteMenu(vRsrcID);
 END; {DoInsertMenu}

{-  -  -  -  -  -  -  -  -  -  -  -  -  -}
BEGIN
 IF vPictFlag = FALSE THEN
 BEGIN
 DoInsertMenu(oGraphMenu.fMenuHdl, kGraphID, vPictFlag);
 DoInsertMenu(oColorMenu.fMenuHdl, kColorID, vPictFlag);
 DoInsertMenu(oTextMenu.fMenuHdl, kTextID, vTextFlag);
 DoInsertMenu(oColorMenu.fMenuHdl, kColorID, vTextFlag);

 IF vTextFlag = TRUE THEN
 BEGIN
 CheckFontMenu(oFontMenu.fMenuHdl);
 CheckSizeMenu(oSizeMenu.fMenuHdl);
 CheckStyleMenu(oStyleMenu.fMenuHdl);
 CheckJustMenu(oJustMenu.fMenuHdl);
 WITH oWindow.oDocument DO
 BEGIN
 SetCheckMark(oForeCMenu.fMenuHdl, fForeC);
 SetCheckMark(oBackCMenu.fMenuHdl, fBackC);
 END;
 END;
 END
 ELSE
 BEGIN
 DoInsertMenu(oTextMenu.fMenuHdl, kTextID, vTextFlag);
 DoInsertMenu(oColorMenu.fMenuHdl, kColorID, vTextFlag);
 DoInsertMenu(oGraphMenu.fMenuHdl, kGraphID, vPictFlag);
 DoInsertMenu(oColorMenu.fMenuHdl, kColorID, vPictFlag);
 WITH oWindow.oDocument DO
 BEGIN
 SetCheckMark(oGraphMenu.fMenuHdl, fShapeID);
 SetCheckMark(oForeCMenu.fMenuHdl, fForeC);
 SetCheckMark(oBackCMenu.fMenuHdl, fBackC);
 END;
 END;
END;  {SwitchMenus}

{========================================}
PROCEDURE InitMyMenus;
BEGIN
 New(oNewMenu);
 oNewMenu.Create(kNewID);
 New(oNewPictMenu);
 oNewPictMenu.Create(kNewPictID);
 New(oNewTextMenu);
 oNewTextMenu.Create(kNewTextID);
 New(oGraphMenu);
 oGraphMenu.Create(kGraphID);
 New(oColorMenu);
 oColorMenu.Create(kColorID);
 New(oForeCMenu);
 oForeCMenu.Create(kForeCID);
 New(oBackCMenu);
 oBackCMenu.Create(kBackCID);
 New(oTextMenu);
 oTextMenu.Create(kTextID);
 New(oFontMenu);
 oFontMenu.Create(kFontID);
 New(oSizeMenu);
 oSizeMenu.Create(kSizeID);
 New(oStyleMenu);
 oStyleMenu.Create(kStyleID);
 New(oJustMenu);
 oJustMenu.Create(kJustID);
 SwitchMenus(FALSE, FALSE);
END;  {InitMyMenus}

{========================================}
PROCEDURE ClickInMyMenus(vMenu,vItem: Integer);
BEGIN
 CASE vMenu OF
 kNewPictID: 
 oNewPictMenu.Choose(vItem);
 kNewTextID: 
 oNewTextMenu.Choose(vItem);
 kGraphID: 
 oGraphMenu.Choose(vItem);
 kForeCID: 
 oForeCMenu.Choose(vItem);
 kBackCID: 
 oBackCMenu.Choose(vItem);
 kFontID: 
 oFontMenu.Choose(vItem);
 kSizeID: 
 oSizeMenu.Choose(vItem);
 kStyleID: 
 oStyleMenu.Choose(vItem);
 kJustID: 
 oJustMenu.Choose(vItem);
 OTHERWISE
 END;
END;  {ClickInMyMenus}

{========================================}
PROCEDURE SetMyMenuItems;
 VAR
 vFrontWFlag: BOOLEAN;
 vUserWFlag: BOOLEAN;
BEGIN
 vFrontWFlag:= (FrontWindow <> NIL);
 vUserWFlag := IsAppWindow(FrontWindow);
{Enable/disable items of MyMenus}
END;  {SetMyMenuItems}

{========================================}
PROCEDURE SetMyMenuBar;
 VAR
 vFrontWFlag: BOOLEAN;
 vUserWFlag: BOOLEAN;
 vDocType: OSType;
BEGIN
 vFrontWFlag:= (FrontWindow <> NIL);
 vUserWFlag := IsAppWindow(FrontWindow);

 IF NOT vFrontWFlag THEN
 SwitchMenus(FALSE, FALSE);

 IF vUserWFlag THEN
 BEGIN
 oWindow:= TWindow(GetWRefCon(FrontWindow));
 vDocType:= oWindow.oDocument.fDocType;
 IF vDocType = kPictDoc THEN
 SwitchMenus(TRUE, FALSE)
 ELSE IF vDocType = kTextDoc THEN
 SwitchMenus(FALSE, TRUE);
 END
 ELSE
{SwitchMenus(FALSE, FALSE)};

 SetEnable(kEditID, 0, vFrontWFlag);
 SetEnable(kGraphID, 0, vUserWFlag);
 SetEnable(kTextID, 0, vUserWFlag);
 SetEnable(kColorID, 0, vUserWFlag);
 DrawMenuBar;
END;  {SetMyMenuBar}

{========================================}
PROCEDURE DisposeMyMenus;
BEGIN
 oNewMenu.Free;
 oNewPictMenu.Free;
 oNewTextMenu.Free;
 oGraphMenu.Free;
 oColorMenu.Free;
 oForeCMenu.Free;
 oBackCMenu.Free;
 oTextMenu.Free;
 oFontMenu.Free;
 oSizeMenu.Free;
 oStyleMenu.Free;
 oJustMenu.Free;
END;  {DisposeMyMenus}

{========================================}
PROCEDURE TSubMenu.Create(vRsrcID: Integer);
BEGIN
 HLock(Handle(Self));
 fMenuHdl:= GetMenu(vRsrcID);
 InsertMenu(fMenuHdl, -1);
 HUnlock(Handle(Self));
END; {Create}

{========================================}
PROCEDURE TNewMenu.Choose(vItem: Integer);
BEGIN
{for TML create tempvariable}
 CASE vItem OF
 kNoGrow: 
 New(TWindow(oWindow));
 kGrow: 
 New(TGrowWindow(oWindow));
 kHScroll..kScroll: 
 New(TScrollWindow(oWindow));
 kHScrollZoom..kScrollZoom: 
 IF BitTst(Ptr(ROM85), 0) THEN
 New(TScrollWindow(oWindow))
 ELSE
 New(TScrollZoomWindow(oWindow));
 OTHERWISE
 END;
 oWindow.fWKind:= vItem;
END; {Choose}

{----------------------------------------}
PROCEDURE TNewPictMenu.Choose(vItem: Integer);
BEGIN
 INHERITED Choose(vItem);
 oWindow.DoNew(kPictDoc);
 ShowWindow(oWindow.fWPtr);

 SetCheckMark(oForeCMenu.fMenuHdl, kBlack);
 SetCheckMark(oBackCMenu.fMenuHdl, kWhite);
END; {Choose}

{----------------------------------------}
PROCEDURE TNewTextMenu.Choose(vItem: Integer);
BEGIN
 INHERITED Choose(vItem);
 oWindow.DoNew(kTextDoc);
 ShowWindow(oWindow.fWPtr);

 CheckFontMenu(oFontMenu.fMenuHdl);
 CheckSizeMenu(oSizeMenu.fMenuHdl);
 CheckStyleMenu(oStyleMenu.fMenuHdl);
 SetCheckMark(oJustMenu.fMenuHdl, kLeft);
 SetCheckMark(oForeCMenu.fMenuHdl, kBlack);
 SetCheckMark(oBackCMenu.fMenuHdl, kWhite);
END; {Choose}

{========================================}
PROCEDURE TGraphMenu.Choose(vItem: Integer);
BEGIN
 oWindow := TWindow(GetWRefCon(FrontWindow));
 oWindow.oDocument.fShapeID:= vItem;

 SetCheckMark(fMenuHdl, vItem);
END; {Choose}

{========================================}
PROCEDURE TForeCMenu.Choose(vItem: Integer);
BEGIN
 oWindow:= TWindow(GetWRefCon(FrontWindow));
 oWindow.oDocument.fForeC:= vItem;
 oWindow.ReDrawContent;

 SetCheckMark(fMenuHdl, vItem);
END; {Choose}

{----------------------------------------}
PROCEDURE TBackCMenu.Choose(vItem: Integer);
BEGIN
 oWindow:= TWindow(GetWRefCon(FrontWindow));
 oWindow.oDocument.fBackC:= vItem;
 oWindow.ReDrawContent;

 SetCheckMark(fMenuHdl, vItem);
END; {Choose}

{========================================}
PROCEDURE TFontMenu.Create(vRsrcID: Integer);
BEGIN
 HLock(Handle(Self));
 fMenuHdl:= GetMenu(vRsrcID);
 AddResMenu(fMenuHdl, ‘FONT’);
 InsertMenu(fMenuHdl, -1);
 HUnlock(Handle(Self));
END; {Create}

{----------------------------------------}
PROCEDURE TFontMenu.Choose(vItem: Integer);
 VAR
 vFontName: Str255;
 vFontNumber: Integer;
BEGIN
 GetItem(fMenuHdl, vItem, vFontName);
 GetFNum(vFontName, vFontNumber);
 TextFont(vFontNumber);

 oWindow:= TWindow(GetWRefCon(FrontWindow));
 oWindow.oDocument.fTextHdl^^.txFont:= vFontNumber;
 oWindow.ReDrawContent;

 SetCheckMark(fMenuHdl, vItem);
 OutlineFontSize(vFontNumber);
END; {Choose}

{========================================}
PROCEDURE TSizeMenu.Choose (vItem: Integer);
 VAR
 vSizeName: Str255;
 vSizeNumber: LongInt;
BEGIN
 GetItem(fMenuHdl, vItem, vSizeName);
 StringToNum(vSizeName, vSizeNumber);
 TextSize(LoWord(vSizeNumber));

 oWindow:= TWindow(GetWRefCon(FrontWindow));
 oWindow.oDocument.fTextHdl^^.txSize:= LoWord(vSizeNumber);
 oWindow.ReDrawContent;

 SetCheckMark(fMenuHdl, vItem);
END; {Choose}

{========================================}
PROCEDURE TStyleMenu.Choose(vItem: Integer);
 VAR
 vStyle: Style;
 vStylePtr: Ptr;
BEGIN
 oWindow:= TWindow(GetWRefCon(FrontWindow));
 WITH oWindow.oDocument DO
 BEGIN
 vStylePtr:= fMyHdl^;
 vStyle:= [];
 CASE vItem OF
 kPlain: 
 BEGIN
 TextFace([]);
 fMyHdl^^:= -128;
 END;
 kBold: 
 vStyle:= [Bold];
 kItalic: 
 vStyle:= [Italic];
 kUnderline: 
 vStyle:= [Underline];
 kOutline: 
 vStyle:= [Outline];
 kShadow: 
 vStyle:= [Shadow];
 kCondense: 
 vStyle:= [Condense];
 kExtend: 
 vStyle:= [Extend];
 OTHERWISE
 END;

 IF (vStyle <= thePort^.txFace) 
 AND (vItem <> kPlain) THEN
 BEGIN
 TextFace(thePort^.txFace - vStyle);
 BitClr(vStylePtr, vItem - 1);
 END
 ELSE
 BEGIN
 TextFace(thePort^.txFace + vStyle);
 BitClr(vStylePtr, kPlain - 1);
 BitSet(vStylePtr, vItem - 1);
 END;

 fTextHdl^^.txFace:= thePort^.txFace;
 fMyHdl^^:= vStylePtr^;
 END;
 oWindow.ReDrawContent;

 CheckStyleMenu(fMenuHdl);
END; {Choose}

{========================================}
PROCEDURE TJustMenu.Choose(vItem: Integer);
 VAR
 vJust: Integer;
BEGIN
 oWindow:= TWindow(GetWRefCon(FrontWindow));
 CASE vItem OF
 kLeft: 
 vJust:= teJustLeft;
 kCenter: 
 vJust:= teJustCenter;
 kRight: 
 vJust:= teJustRight;
 OTHERWISE
 END;
 oWindow.oDocument.fTextHdl^^.just:= vJust;
 oWindow.ReDrawContent;

 SetCheckMark(fMenuHdl, vItem);
END; {Choose}

END. {unit MyMenus}
{****************************************}

Listing:  MyDocuments.p

UNIT MyDocuments;
{****************************************}
INTERFACE
 USES
 MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, MacPrint, ObjIntf, 
GlobalStuff, MyDialogs, MyShapes;

 TYPE
 TDocument = OBJECT(TObject)
 fDocType: OSType;
 fVolNum: Integer;
 fFileNum: Integer;
 fChanged: BOOLEAN;
 fViewRgn: RgnHandle;
 fViewRect: Rect;
 fDocRect: Rect;
 fTextHdl: TEHandle;
 fPictHdl: PicHandle;
 fMyHdl: Handle;
 fForeC: Integer;
 fBackC: Integer;
 fShapeID: Integer;
 PROCEDURE DoNew;
 PROCEDURE DoOpen(vVolNum,vFileNum: Integer);
 PROCEDURE DoSave(vFileNum: Integer);
 PROCEDURE DoPrint(vPrPort: TPPrPort);
 PROCEDURE ApplTask;
 PROCEDURE ClickInDoc(vPt: Point);
 PROCEDURE KeyPress(vChar: CHAR);
 PROCEDURE ReDraw;
 PROCEDURE Update;
 PROCEDURE Activate;
 PROCEDURE Edit(vItem: Integer);
 END;
 TTextDocument = OBJECT(TDocument)
 PROCEDURE DoNew;
 override;
 PROCEDURE DoOpen(vVolNum,vFileNum: Integer);
 override;
 PROCEDURE DoSave(vFileNum: Integer);
 override;
 PROCEDURE DoPrint(vPrPort: TPPrPort);
 override;
 PROCEDURE ApplTask;
 override;
 PROCEDURE ClickInDoc(vPt: Point);
 override;
 PROCEDURE KeyPress(vChar: CHAR);
 override;
 PROCEDURE ReDraw;
 override;
 PROCEDURE Update;
 override;
 PROCEDURE Activate;
 override;
 PROCEDURE Edit(vItem: Integer);
 override;
 PROCEDURE Free;
 override;
 END;
 TPictDocument = OBJECT(TDocument)
 oOvals: TOvals;
 oSpirals: TSpirals;
 oShape: TShape;
 PROCEDURE DoNew;
 override;
 PROCEDURE DoOpen(vVolNum,vFileNum: Integer);
 override;
 PROCEDURE DoSave(vFileNum: Integer);
 override;
 PROCEDURE DoPrint(vPrPort: TPPrPort);
 override;
 PROCEDURE ApplTask;
 override;
 PROCEDURE ClickInDoc(vPt: Point);
 override;
 PROCEDURE ReDraw;
 override;
 PROCEDURE Update;
 override;
 PROCEDURE Edit(vItem: Integer);
 override;
 PROCEDURE Free;
 override;
 END;

{****************************************}
IMPLEMENTATION

FUNCTION SetColor(vColor: Integer): LongInt;
BEGIN
 CASE vColor OF
 kBlack: 
 SetColor:= blackColor;
 kWhite: 
 SetColor:= whiteColor;
 kRed: 
 SetColor:= redColor;
 kGreen: 
 SetColor:= greenColor;
 kBlue: 
 SetColor:= blueColor;
 kCyan: 
 SetColor:= cyanColor;
 kMagenta: 
 SetColor:= magentaColor;
 kYellow: 
 SetColor:= yellowColor;
 END;
END;  {SetColor}

{----------------------------------------}
PROCEDURE TDocument.DoNew;
BEGIN
 fVolNum:= 0;
 fFileNum:= 0;
 fChanged:= FALSE;
 fTextHdl:= NIL;
 fPictHdl:= NIL;
 fMyHdl:= NIL;
END; {DoNew}

{----------------------------------------}
PROCEDURE TDocument.DoOpen(vVolNum,vFileNum: Integer);
BEGIN
END; {DoOpen}
{----------------------------------------}
PROCEDURE TDocument.DoSave(vFileNum: Integer);
BEGIN
END; {DoSave}
{----------------------------------------}
PROCEDURE TDocument.DoPrint(vPrPort: TPPrPort);
BEGIN
END; {DoPrint}
{----------------------------------------}
PROCEDURE TDocument.ApplTask;
BEGIN
END; {ApplTask}
{----------------------------------------}
PROCEDURE TDocument.ClickInDoc(vPt: Point);
BEGIN
END; {ClickInDoc}
{----------------------------------------}
PROCEDURE TDocument.KeyPress(vChar: CHAR);
BEGIN
END; {KeyPress}
{----------------------------------------}
PROCEDURE TDocument.ReDraw;
BEGIN
END; {ReDraw}
{----------------------------------------}
PROCEDURE TDocument.Update;
BEGIN
END; {Update}
{----------------------------------------}
PROCEDURE TDocument.Activate;
BEGIN
END; {Activate}
{----------------------------------------}
PROCEDURE TDocument.Edit(vItem: Integer);
BEGIN
END; {Edit}

{========================================}
PROCEDURE TTextDocument.DoNew;
 VAR
 vColumnWidth: Integer;
 vViewRect: Rect;
BEGIN
 INHERITED DoNew;
 vColumnWidth:= 6 * 72;
 vViewRect := fViewRect;
 InsetRect(vViewRect, kTextMargin, 0);
 fViewRect := vViewRect;
 fDocRect:= fViewRect;
 fDocRect.right:= vColumnWidth;
 fTextHdl:= TENew(fDocRect, fViewRect);
 fDocType:= ‘TEXT’;
 TextSize(12);
 fTextHdl^^.txSize:= thePort^.txSize;
 TextFace([]);
 fMyHdl:= NewHandle($2);
 fMyHdl^^:= -128;
 fForeC:= kBlack;
 fBackC:= kWhite;
END; {DoNew}

{----------------------------------------}
PROCEDURE TTextDocument.DoOpen(vVolNum,
 vFileNum: Integer);
 VAR
 vFileSize: LongInt;
 vHdl: Handle;
 vDocRect: Rect;
BEGIN
 IF OSError(GetEOF(vFileNum, vFileSize)) THEN
 Exit(DoOpen);
 IF OSError(SetFPos(vFileNum, FSFromStart, 0)) THEN
 Exit(DoOpen);

 IF vFileSize > MaxInt THEN
 BEGIN
 CenterMyDialog(‘ALRT’, kSizeErrID);
 IF StopAlert(kSizeErrID, NIL) = OK THEN
 Exit(DoOpen);
 END;

 SetHandleSize(fTextHdl^^.hText, vFileSize);
 IF OSError(MemError) THEN
 Exit(DoOpen);

 vHdl:= fTextHdl^^.hText;
 MoveHHi(vHdl);
 HLock(vHdl);
 IF OSError(FSRead(vFileNum, vFileSize, vHdl^)) THEN
 BEGIN
 HUnlock(vHdl);
 Exit(DoOpen);
 END;
 HUnlock(vHdl);

 fTextHdl^^.teLength:= vFileSize;
 TECalText(fTextHdl);
 TESetSelect(MaxInt, MaxInt, fTextHdl);
 WITH fDocRect, fTextHdl^^ DO
 BEGIN
 bottom:= top + nLines * lineHeight;
 vDocRect := fDocRect;
 OffsetRect(vDocRect, 0, bottom);
 fDocRect := vDocRect;
 END;

 fVolNum:= vVolNum;
 fFileNum:= vFileNum;
 fChanged:= FALSE;
END; {DoOpen}

{----------------------------------------}
PROCEDURE TTextDocument.DoSave(vFileNum: Integer);
 VAR
 vFileSize: LongInt;
 vHdl: Handle;
BEGIN
 IF OSError(SetFPos(vFileNum, FSFromStart, 0)) THEN
 Exit(DoSave);
 vFileSize:= fTextHdl^^.teLength;

 vHdl:= fTextHdl^^.hText;
 MoveHHi(vHdl);
 HLock(vHdl);
 IF OSError(FSWrite(vFileNum, vFileSize, vHdl^)) THEN
 BEGIN
 HUnlock(vHdl);
 Exit(DoSave);
 END;
 HUnlock(vHdl);

 fFileNum:= vFileNum;
 fChanged:= FALSE;
END; {DoSave}

{----------------------------------------}
PROCEDURE TTextDocument.DoPrint(vPrPort: TPPrPort);
 VAR
 vHMargin, vVMargin: Integer;
 vPageRect: Rect;
 vTextHdl: TEHandle;
 vPageSize: Integer;
 vPageHeight: Integer;
 vDocSize: Integer;
 vNumCopies: Integer;
 i: Integer;
BEGIN
 WITH fTextHdl^^ DO
 BEGIN
 TextFont(txFont);
 TextSize(txSize);
 TextFace(txFace);
 END;

 WITH gPrintHdl^^.prInfo DO
 BEGIN
 vHMargin:= ROUND(kPrintMargin * iHRes);
 vVMargin:= ROUND(kPrintMargin * iVRes);
 vPageRect:= rPage;
 InsetRect(vPageRect, vHMargin, vVMargin);
 END;

 vTextHdl := TENew(vPageRect, vPageRect);
 WITH vTextHdl^^, viewRect DO
 BEGIN
 vPageSize:= (bottom - top) DIV lineHeight;
 vPageHeight:= vPageSize * lineHeight;
 bottom:= top + vPageHeight;
 destRect:= viewRect;
 DisposHandle(hText);
 hText:= fTextHdl^^.hText;
 teLength:= fTextHdl^^.teLength;
 END;

 SetCursor(gWatch);
 TECalText(vTextHdl);
 SetCursor(arrow);

 WITH gPrintHdl^^.prJob DO
 IF bJDocLoop = BDraftLoop THEN
 vNumCopies:= iCopies
 ELSE
 vNumCopies:= 1;

 MoveHHi(Handle(vTextHdl));
 HLock(Handle(vTextHdl));
 WITH vTextHdl^^ DO
 FOR i:= 1 TO vNumCopies DO
 BEGIN
 vDocSize:= nLines;
 WHILE vDocSize > 0 DO
 BEGIN
 PrOpenPage(vPrPort, NIL);
 IF OSError(PrError) THEN
 leave;
 TEUpdate(viewRect, vTextHdl);
 OffsetRect(destRect, 0, -vPageHeight);
 PrClosePage(vPrPort);
 IF OSError(PrError) THEN
 leave;
 vDocSize:= vDocSize - vPageSize;
 END;
 END;
 vTextHdl^^.hText:= NIL;
 HUnlock(Handle(vTextHdl));

 TEDispose(vTextHdl);
END; {DoPrint}

{----------------------------------------}
PROCEDURE TTextDocument.ApplTask;
 VAR
 vPt: Point;
 vCopyFlag: BOOLEAN;
 vPasteFlag: BOOLEAN;
BEGIN
 TEIdle(fTextHdl);

 GetMouse(vPt);
 IF PtInRgn(vPt, fViewRgn) THEN
 SetCursor(gIBeam)
 ELSE
 SetCursor(arrow);

 WITH fTextHdl^^ DO
 vCopyFlag:= (selStart <> selEnd);
 vPasteFlag:= (TEGetScrapLen <> 0);
 SetEnable(kEditID, kCut, vCopyFlag);
 SetEnable(kEditID, kCopy, vCopyFlag);
 SetEnable(kEditID, kPaste, vPasteFlag);
END; {ApplTask}

{----------------------------------------}
PROCEDURE TTextDocument.ClickInDoc(vPt: Point);
 VAR
 vShift: BOOLEAN;
BEGIN
 vShift:= (BitAnd(gEvent.modifiers, ShiftKey)= ShiftKey);
 TEClick(vPt, vShift, fTextHdl);
END; {ClickInDoc}

{----------------------------------------}
PROCEDURE TTextDocument.KeyPress(vChar: CHAR);
BEGIN
 IF fTextHdl <> NIL THEN
 BEGIN
 IF (fTextHdl^^.teLength = MaxInt) 
 AND (vChar <> Chr(kBS)) THEN
 BEGIN
 CenterMyDialog(‘ALRT’, kSizeErrID);
 IF StopAlert(kSizeErrID, NIL) = OK THEN
 Exit(KeyPress);
 END;

 TEKey(vChar, fTextHdl);
 WITH fDocRect, fTextHdl^^ DO
 bottom:= top + lineHeight * nLines;
 fChanged:= TRUE;
 END;
END; {KeyPress}

{----------------------------------------}
PROCEDURE TTextDocument.ReDraw;
 VAR
 vFontInfo: FontInfo;
 vViewRect: Rect;
BEGIN
 vViewRect:= fViewRect;
 InsetRect(vViewRect, kTextMargin, 0);
 fViewRect:= vViewRect;
 ForeColor(SetColor(fForeC));
 BackColor(SetColor(fBackC));

 GetFontInfo(vFontInfo);
 WITH fTextHdl^^, vFontInfo, fDocRect DO
 BEGIN
 fontAscent:= ascent;
 lineHeight:= ascent + descent + leading;
 bottom:= top + nLines * lineHeight;
 END;

 TECalText(fTextHdl);
 InvalRgn(fViewRgn);
END; {ReDraw}

{----------------------------------------}
PROCEDURE TTextDocument.Update;
BEGIN
 WITH fTextHdl^^ DO
 BEGIN
 viewRect:= fViewRect;
 destRect:= fDocRect;
 TEUpdate(viewRect, fTextHdl);
 END;
END; {Update}

{----------------------------------------}
PROCEDURE TTextDocument.Activate;
BEGIN
 IF fTextHdl <> NIL THEN
 IF BitAnd(gEvent.modifiers, activeFlag) <> 0 THEN
 TEActivate(fTextHdl)
 ELSE
 TEDeActivate(fTextHdl);
END; {Activate}

{----------------------------------------}
PROCEDURE TTextDocument.Edit(vItem: Integer);
 VAR
 vOffset: LongInt;
BEGIN
 CASE vItem OF
 kUndo: 
 ;
 kCut: 
 BEGIN
 TECut(fTextHdl);
 IF OSError(ZeroScrap) THEN
 Exit(Edit);
 IF OSError(TEToScrap) THEN
 Exit(Edit);
 END;
 kCopy: 
 BEGIN
 TECopy(fTextHdl);
 IF OSError(ZeroScrap) THEN
 Exit(Edit);
 IF OSError(TEToScrap) THEN
 Exit(Edit);
 END;
 kPaste: 
 BEGIN
 IF GetScrap(NIL, ‘TEXT’, vOffset) > 0 THEN
 IF OSError(TEFromScrap) THEN
 Exit(Edit);
 IF (fTextHdl^^.teLength + TEGetScrapLen > MaxInt) THEN
 BEGIN
 CenterMyDialog(‘ALRT’, kSizeErrID);
 IF StopAlert(kSizeErrID, NIL) = OK THEN
 Exit(Edit);
 END;
 TEPaste(fTextHdl);
 END;
 kClear: 
 TEDelete(fTextHdl);
 OTHERWISE
 END;

 IF vItem <> kCopy THEN
 fChanged:= TRUE;
 WITH fDocRect, fTextHdl^^ DO
 bottom:= top + lineHeight * nLines;
END; {Edit}

{----------------------------------------}
PROCEDURE TTextDocument.Free;
BEGIN
 IF fMyHdl <> NIL THEN
 DisposHandle(fMyHdl);
 TEDispose(fTextHdl);
 INHERITED Free;
END; {Free}

{========================================}
PROCEDURE TPictDocument.DoNew;
BEGIN
 INHERITED DoNew;
 oOvals:= NIL;
 oSpirals:= NIL;
 oShape:= NIL;

 IF gPrintHdl <> NIL THEN
 fDocRect:= gPrintHdl^^.prInfo.rPage
 ELSE
 fDocRect:= thePort^.portRect;

 fDocType:= ‘PICT’;
 fForeC:= kBlack;
 fBackC:= kWhite;
 fShapeID:= 0;

 New(oOvals);
 New(oOvals.oDialog);
 oOvals.oDialog.Init(5, 1, kPopUPID1, FALSE);

 New(oSpirals);
 New(oSpirals.oDialog);
 oSpirals.oDialog.Init(3, 0, 0, FALSE);
END; {DoNew}

{----------------------------------------}
PROCEDURE TPictDocument.DoOpen(vVolNum, vFileNum: Integer);
 VAR
 vFileSize: LongInt;
 vHdl: Handle;
BEGIN
 IF OSError(GetEOF(vFileNum, vFileSize)) THEN
 Exit(DoOpen);
 IF OSError(SetFPos(vFileNum, FSFromStart, kPictHeader)) THEN
 Exit(DoOpen);
 vFileSize:= vFileSize - kPictHeader;

 vHdl:= NewHandle(vFileSize);
 MoveHHi(vHdl);
 HLock(vHdl);
 IF OSError(FSRead(vFileNum, vFileSize, vHdl^)) THEN
 BEGIN
 HUnlock(vHdl);
 DisposHandle(vHdl);
 Exit(DoOpen);
 END;
 HUnlock(vHdl);

 fPictHdl:= PicHandle(vHdl);
 fDocRect:= fPictHdl^^.picFrame;
 fVolNum:= vVolNum;
 fFileNum:= vFileNum;
 fChanged:= FALSE;
END; {DoOpen}

{----------------------------------------}
FUNCTION NewClearPtr(logicalSize: LongInt): Ptr;
INLINE
 $201F, {move.l (a7)+, d0}
 $A31E, {_NewPtr, CLEAR}
 $2E88; {move.l a0, (a7)}

{-  -  -  -  -  -  -  -  -  -  -  -  -  -}
PROCEDURE TPictDocument.DoSave(vFileNum: Integer);
 VAR
 vFileSize: LongInt;
 vClearPtr: Ptr;
 vHdl: Handle;
BEGIN
 IF fPictHdl = NIL THEN
 Exit(DoSave);
 IF OSError(SetFPos(vFileNum, FSFromStart, 0)) THEN
 Exit(DoSave);
 vFileSize:= kPictHeader;

 vClearPtr:= NewClearPtr(vFileSize);
 IF OSError(FSWrite(vFileNum, vFileSize, vClearPtr))
 THEN BEGIN
 DisposPtr(vClearPtr);
 Exit(DoSave);
 END;
 DisposPtr(vClearPtr);

 vHdl:= Handle(fPictHdl);
 vFileSize:= GetHandleSize(vHdl);
 MoveHHi(vHdl);
 HLock(vHdl);
 IF OSError(FSWrite(vFileNum, vFileSize, vHdl^)) THEN
 BEGIN
 HUnlock(vHdl);
 Exit(DoSave);
 END;
 HUnlock(vHdl);

 fFileNum:= vFileNum;
 fChanged:= FALSE;
END; {DoSave}

{----------------------------------------}
PROCEDURE TPictDocument.DoPrint(vPrPort: TPPrPort);
 VAR
 vPageRect: Rect;
 vDocRect: Rect;
 vNumCopies: Integer;
 i: Integer;
BEGIN
 WITH gPrintHdl^^.prJob DO
 IF bJDocLoop = BDraftLoop THEN
 vNumCopies:= iCopies
 ELSE
 vNumCopies:= 1;

 FOR i:= 1 TO vNumCopies DO
 BEGIN
 PrOpenPage(vPrPort, NIL);
 IF OSError(PrError) THEN
 Exit(DoPrint);
 vDocRect := fDocRect;
 WITH fDocRect DO
 OffsetRect(vDocRect, -left, -top);
 DrawPicture(fPictHdl, vDocRect);
 PrClosePage(vPrPort);
 IF OSError(PrError) THEN
 END;
END; {DoPrint}

{----------------------------------------}
PROCEDURE TPictDocument.ApplTask;
 VAR
 vPt: Point;
 vCopyFlag: BOOLEAN;
 vPasteFlag: BOOLEAN;
BEGIN
 GetMouse(vPt);
 IF PtInRgn(vPt, fViewRgn) THEN
 SetCursor(gCross)
 ELSE
 SetCursor(arrow);

 vCopyFlag:= TRUE;
 vPasteFlag:= (InfoScrap^.scrapSize > 0);
 SetEnable(kEditID, kCut, vCopyFlag);
 SetEnable(kEditID, kCopy, vCopyFlag);
 SetEnable(kEditID, kPaste, vPasteFlag);
END; {ApplTask}

{----------------------------------------}
PROCEDURE TPictDocument.ClickInDoc(vPt: Point);
BEGIN
 CASE fShapeID OF
 kOvals: 
 oShape:= oOvals;
 kSpirals: 
 oShape:= oSpirals;
 OTHERWISE
 Exit(ClickInDoc);
 END;

 WITH oShape DO
 BEGIN
 fPt.h:= vPt.h - fDocRect.left;
 fPt.v:= vPt.v - fDocRect.top;
 oDialog.DoDialog(2000 + fShapeID);
 IF oDialog.fDFlag = FALSE THEN
 Exit(ClickInDoc);
 END;

 self.ReDraw;
 ValidRgn(fViewRgn);
 SetClip(fViewRgn);
 EraseRgn(fViewRgn);
 self.Update;
 ClipRect(thePort^.portRect);
END; {ClickInDoc}

{----------------------------------------}
PROCEDURE TPictDocument.ReDraw;
 CONST
 PicDwgBeg = 130;
 PicDwgEnd = 131;
 PicGrpBeg = 140;
 PicGrpEnd = 141;
 VAR
 vPt: Point;
 vClipRect: Rect;
BEGIN
 IF oShape <> NIL THEN
 BEGIN
 ForeColor(SetColor(fForeC));
 BackColor(SetColor(fBackC));

 WITH oShape DO
 BEGIN
 vPt.h:= fPt.h + fDocRect.left;
 vPt.v:= fPt.v + fDocRect.top;
 END;

 SetRect(vClipRect,-10000,-10000,10000,10000);
 ClipRect(vClipRect);

 IF fPictHdl <> NIL THEN
 KillPicture(fPictHdl);
 fPictHdl:= OpenPicture(fDocRect);
 PicComment(PicDwgBeg, 0, NIL);
 PicComment(PicGrpBeg, 0, NIL);
 oShape.Create(vPt);
 PicComment(PicGrpEnd, 0, NIL);
 PicComment(PicDwgEnd, 0, NIL);
 ClosePicture;

 fDocRect:= fPictHdl^^.picFrame;
 fChanged:= TRUE;
 END;

 IF fPictHdl <> NIL THEN
 InvalRgn(fViewRgn);
END; {ReDraw}

{----------------------------------------}
PROCEDURE TPictDocument.Update;
BEGIN
 IF fPictHdl <> NIL THEN
 DrawPicture(fPictHdl, fDocRect);
END; {Update}

{----------------------------------------}
PROCEDURE TPictDocument.Edit (vItem: Integer);
 VAR
 vLength: LongInt;
 vErr: OSErr;
 vOffset: LongInt;
 vScrapHdl: Handle;
BEGIN
 CASE vItem OF
 kUndo: 
 ;
 kCut: 
 BEGIN
 vScrapHdl:= NewHandle(0);
 vScrapHdl:= Handle(fPictHdl);
 IF vScrapHdl <> NIL THEN
 IF NOT OSError(ZeroScrap) THEN
 BEGIN
 vLength:= GetHandleSize(vScrapHdl);
 MoveHHi(vScrapHdl);
 HLock(vScrapHdl);
 vErr:= PutScrap(vLength, ‘PICT’, vScrapHdl^);
 HUnlock(vScrapHdl);
 IF oShape <> NIL THEN
 oShape:= NIL;
 IF fPictHdl <> NIL THEN
 BEGIN
 KillPicture(fPictHdl);
 fPictHdl:= NIL;
 END;
 END;
 vScrapHdl:= NIL;
 DisposHandle(vScrapHdl);
 END;
 kCopy: 
 BEGIN
 vScrapHdl:= NewHandle(0);
 vScrapHdl:= Handle(fPictHdl);
 IF NOT OSError(ZeroScrap) THEN
 IF vScrapHdl <> NIL THEN
 BEGIN
 vLength:= GetHandleSize(vScrapHdl);
 MoveHHi(vScrapHdl);
 HLock(vScrapHdl);
 vErr:= PutScrap(vLength, ‘PICT’, vScrapHdl^);
 HUnlock(vScrapHdl);
 END;
 vScrapHdl:= NIL;
 DisposHandle(vScrapHdl);
 END;
 kPaste: 
 BEGIN
 vScrapHdl:= NewHandle(0);
 vLength:= GetScrap(vScrapHdl, ‘PICT’, vOffset);
 IF vLength > 0 THEN
 BEGIN
 IF fPictHdl <> NIL THEN
 BEGIN
 KillPicture(fPictHdl);
 fPictHdl:= NIL;
 END;
 fPictHdl:= PicHandle(vScrapHdl);
 fDocRect:= fPictHdl^^.picFrame;
 END;
 END;
 kClear: 
 BEGIN
 IF oShape <> NIL THEN
 oShape:= NIL;
 IF fPictHdl <> NIL THEN
 BEGIN
 KillPicture(fPictHdl);
 fPictHdl:= NIL;
 END;
 END;
 OTHERWISE
 END;

 IF vItem <> kCopy THEN
 BEGIN
 SetClip(fViewRgn);
 EraseRgn(fViewRgn);
 self.Update;
 ClipRect(thePort^.portRect);
 fChanged:= TRUE;
 END;
END; {Edit}

{----------------------------------------}
PROCEDURE TPictDocument.Free;
BEGIN
 IF oOvals <> NIL THEN
 oOvals.Free;
 IF oSpirals <> NIL THEN
 oSpirals.Free;
 IF fPictHdl <> NIL THEN
 KillPicture(fPictHdl);
 INHERITED Free;
END; {Free}

END.  {unit MyDocuments}
{***********************************}

Listing:  MyShapes.p

UNIT MyShapes;
{****************************************}
INTERFACE
 USES
 MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, MacPrint, ObjIntf, 
GlobalStuff, MyDialogs;
 TYPE
 TShape = OBJECT(TObject)
 fPt: Point;
 oDialog: TDialog;
 PROCEDURE Create(vPt: Point);
 PROCEDURE Free;
 override;
 END;
 TOvals = OBJECT(TShape)
 PROCEDURE Create(vPt: Point);
 override;
 END;
 TSpirals = OBJECT(TShape)
 PROCEDURE Create(vPt: Point);
 override;
 END;

{****************************************}
IMPLEMENTATION

PROCEDURE TShape.Create(vPt: Point);
BEGIN
END; {Create}

{----------------------------------------}
PROCEDURE TShape.Free;
BEGIN
 IF oDialog <> NIL THEN
 oDialog.Free;
 INHERITED Free;
END; {Free}

{========================================}
PROCEDURE TOvals.Create(vPt: Point);
 VAR
 vItem: Integer;
 i: Integer;
 vRect: Rect;
 vMax: LongInt;
 vHSize, vVSize: LongInt;
 vHDelta, vVDelta: LongInt;
BEGIN
 MoveTo(vPt.h, vPt.v);
 WITH oDialog DO
 BEGIN
 StringToNum(fStr[1], vMax);
 StringToNum(fStr[2], vHSize);
 StringToNum(fStr[3], vVSize);
 StringToNum(fStr[4], vHDelta);
 StringToNum(fStr[5], vVDelta);
 END;
 vItem := oDialog.fPopItem;

 WITH vPt DO
 SetRect(vRect,h-vHSize,v-vVSize,
 h+vHSize,v+vVSize);
 IF vMax > 0 THEN
 FOR i:= 1 TO vMax DO
 BEGIN
 CASE vItem OF
 kFrameOval: 
 FrameOval(vRect);
 kInvertOval: 
 InvertOval(vRect);
 kFrameRect: 
 FrameRect(vRect);
 kInvertRect: 
 InvertRect(vRect);
 OTHERWISE
 END;
 InsetRect(vRect, vHDelta, vVDelta);
 END;
END; {Create}

{========================================}
PROCEDURE TSpirals.Create(vPt: Point);
 VAR
 i, j: Integer;
 x, y, z: LongInt;
 dH, dV, dX: LongInt;
 vMax: LongInt;
BEGIN
 MoveTo(vPt.h, vPt.v);
 WITH oDialog DO
 BEGIN
 StringToNum(fStr[1], dH);
 StringToNum(fStr[2], dV);
 StringToNum(fStr[3], vMax);
 END;
 x:= 0;
 y:= 1;
 z:= -1;
 IF vMax > 0 THEN
 REPEAT
 x:= x + 1;
 IF odd(x) THEN
 y:= -y;
 IF odd(x + 1) THEN
 z:= -z;
 dV:= dV * y * z;
 dH:= dH * z * y;
 Line(dH, dV);
 dX:= dH + 2 * y;
 dH:= dV + 2 * z;
 dV:= dX;
 UNTIL x = vMax;
END; {Create}

END. {unit MyShapes}
{****************************************}
Listing:  MyDialogs.p

UNIT MyDialogs;
{****************************************}
INTERFACE
 USES
 MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, MacPrint, ObjIntf, 
GlobalStuff;
 TYPE
 TDialog = OBJECT(TObject)
 fDlogItems: Integer;
 fDFlag: BOOLEAN;
 fPopMenus: Integer;
 fPopUpID: Integer;
 fPopItem: Integer;
 fStr: ARRAY[1..kMaxEditItems] OF Str255;
 PROCEDURE Init (vDlogItems, vPopMenus,
 vPopUpID: Integer; vDFlag: BOOLEAN);
 PROCEDURE DoDialog(vDialogID: Integer);
 END;

{****************************************}
IMPLEMENTATION
 CONST
 cPromptItem = 3;
 cPopUpItem = 4;
 cFirstEditItem = 5;
 VAR
 uItemType: Integer;
 uItemHdl: Handle;
 uItemRect: Rect;
 uPopUpRect: Rect;
 uPromptRect: Rect;
 uPopUpID: Integer;
 uPopMenuHdl: MenuHandle;
 uMarkedItem: Integer;

{========================================}
PROCEDURE TDialog.Init (vDlogItems, vPopMenus,
 vPopUpID: Integer; vDFlag: BOOLEAN);
BEGIN
 fDlogItems:= vDlogItems;
 fPopMenus:= vPopMenus;
 fPopUpID:= vPopUpID;
 fPopItem:= 1;
 fDFlag:= vDFlag;
END;  {Init}

{========================================}
PROCEDURE OutlineOK(vDPtr: DialogPtr);
 VAR
 vSavePort: GrafPtr;
BEGIN
 GetPort(vSavePort);
 SetPort(vDPtr);
 GetDItem(vDPtr,OK,uItemType,uItemHdl,uItemRect);
 IF uItemHdl <> NIL THEN
 BEGIN
 PenSize(3, 3);
 InsetRect(uItemRect, -4, -4);
 FrameRoundRect(uItemRect, 16, 16);
 PenSize(1, 1);
 END;
 SetPort(vSavePort);
END; {OutlineOK}

{-  -  -  -  -  -  -  -  -  -  -  -  -  -}
PROCEDURE DrawPopUp (vDPtr: DialogPtr; vItem: Integer);
 CONST
 cLeftSlop = 5;
 cRightSlop = 3;
 cBotSlop = 7;
 VAR
 vRect: Rect;
 vItemText: Str255;
 vWidth, vNewWidth, vNewLength: Integer;
BEGIN
 GetItem(uPopMenuHdl, uMarkedItem, vItemText);
 vRect:= uPopUpRect;
 WITH vRect DO
 BEGIN
 InsetRect(vRect, -1, -1);
 vWidth:= (right - left) - (cLeftSlop + cRightSlop);
 vNewWidth:= StringWidth(vItemText);
 IF vNewWidth > vWidth THEN
 BEGIN
 vNewLength:= LENGTH(vItemText);
 vWidth:= vWidth - CharWidth(‘ ’);

 REPEAT
 vNewWidth:= vNewWidth -CharWidth(vItemText[vNewLength]);
 Delete(vItemText, vNewLength, 1);
 vNewLength:= PRED(vNewLength);
 UNTIL (vNewWidth <= vWidth) OR (LENGTH(vItemText) = 0);

 vNewLength:= SUCC(vNewLength);
 Insert(‘ ’, vItemText, vNewLength);
 END;

 FrameRect(vRect);
 MoveTo(right, top + 2);
 LineTo(right, bottom);
 LineTo(left + 2, bottom);

 MoveTo(left + cLeftSlop, bottom - cBotSlop);
 DrawString(vItemText);
 END;
END; {DrawPopUp}

{-  -  -  -  -  -  -  -  -  -  -  -  -  -}
FUNCTION MyFilter (vDPtr: DialogPtr;
 VAR vEvent: EventRecord;
 VAR vItemHit: Integer): BOOLEAN;
 VAR
 vSavePort: GrafPtr;
 vMousePt, vPopLoc: Point;
 vNewItem: Integer;
 vResult: LongInt;
BEGIN
 vItemHit:= 0;
 MyFilter:= FALSE;
 GetPort(vSavePort);
 SetPort(vDPtr);

 CASE vEvent.what OF
 keyDown: 
 BEGIN
 IF (vEvent.message MOD 256) IN [kCR, kEnter]
 THEN BEGIN
 GetDItem(vDPtr, OK, uItemType, uItemHdl, uItemRect);
 HiliteControl(ControlHandle(uItemHdl), 1);
 Delay(3, vResult);

 MyFilter:= TRUE;
 vItemHit:= OK;
 END;
 END;
 mouseDown: 
 BEGIN
 vMousePt:= vEvent.where;
 GlobalToLocal(vMousePt);

 IF (FindDItem(vDPtr, vMousePt)+1)= cPopUpItem
 THEN BEGIN
 InvertRect(uPromptRect);
 InsertMenu(uPopMenuHdl, -1);
 vPopLoc:= uPopUpRect.topLeft;
 LocalToGlobal(vPopLoc);
 CalcMenuSize(uPopMenuHdl);
 WITH vPopLoc DO
 vResult:= PopUpMenuSelect(uPopMenuHdl, v, h, uMarkedItem);
 InvertRect(uPromptRect);
 DeleteMenu(uPopUpID);

 IF vResult <> 0 THEN
 BEGIN
 vNewItem:= LoWord(vResult);

 IF vNewItem <> uMarkedItem THEN
 BEGIN
 SetItemMark(uPopMenuHdl, uMarkedItem, ‘ ‘);
 SetItemMark(uPopMenuHdl, vNewItem, CHR(checkMark));
 uMarkedItem:= vNewItem;
 EraseRect(uPopUpRect);
 DrawPopUp(vDPtr, cPopUpItem);

 MyFilter:= TRUE;
 vItemHit:= cPopUpItem;
 END;
 END;
 END;
 END;
 OTHERWISE
 END;
 SetPort(vSavePort);
END; {MyFilter}

{-  -  -  -  -  -  -  -  -  -  -  -  -  -}
PROCEDURE TDialog.DoDialog (vDialogID: Integer);
 VAR
 vDPtr: DialogPtr;
 vItem, vItemNum: Integer;
 vStr: Str255;
BEGIN
 CenterMyDialog(‘DLOG’, vDialogID);
 vDPtr:= GetNewDialog(vDialogID, NIL, POINTER(-1));
 IF vDPtr = NIL THEN
 Exit(DoDialog);

 IF fDFlag THEN
 FOR vItem:= 1 TO fDlogItems DO
 BEGIN
 vItemNum:= vItem + cFirstEditItem - 1;
 GetDItem(vDPtr, vItemNum, uItemType, uItemHdl, uItemRect);
 SetIText(uItemHdl, fStr[vItem]);
 END;

 OutlineOK(vDPtr);
 GetDItem(vDPtr, cFirstEditItem, uItemType, uItemHdl, uItemRect);
 SelIText(vDPtr, cFirstEditItem, 0, maxInt);

 CASE fPopMenus OF
 0: 
 REPEAT
 ModalDialog(NIL, vItemNum)
 UNTIL (vItemNum IN [OK, Cancel]);
 1: 
 BEGIN
 uPopUpID:= fPopUpID;
 uPopMenuHdl:= GetMenu(fPopUpID);
 SetItemMark(uPopMenuHdl, fPopItem, CHR(checkMark));
 uMarkedItem:= fPopItem;

 GetDItem(vDPtr, cPopUpItem, uItemType, uItemHdl, uPopUpRect);
 SetDItem(vDPtr, cPopUpItem, uItemType, @DrawPopUp, uPopUpRect);
 GetDItem(vDPtr, cPromptItem, uItemType, uItemHdl, uPromptRect);

 REPEAT
 ModalDialog(@MyFilter, vItemNum);
 CASE vItemNum OF
 cPopUpItem: 
 BEGIN
 fPopItem:= uMarkedItem;
 END;
 OTHERWISE
 END;
 UNTIL (vItemNum IN [OK, Cancel]);

 ReleaseResource(Handle(uPopMenuHdl));
 END;
 OTHERWISE
 END;

 CASE vItemNum OF
 OK: 
 BEGIN
 FOR vItem:= 1 TO fDlogItems DO
 BEGIN
 vItemNum:= vItem + cFirstEditItem - 1;
 GetDItem(vDPtr, vItemNum, uItemType, uItemHdl, uItemRect);
 GetIText(uItemHdl, vStr);
 fStr[vItem]:= vStr;
 END;
 fDFlag:= TRUE;
 END;
 Cancel: 
 BEGIN
 fPopItem:= 1;
 fDFlag:= FALSE;
 END;
 OTHERWISE
 END;

 DisposDialog(vDPtr);
END; {DoDialog}

END. {unit MyDialogs}
{****************************************}
Listing:  ResourceFile.r

resource ‘ALRT’ (1000) {
 {80, 58, 224, 366},
 100,
 { /* array: 4 elements */
 /* [1] */
 OK, visible, silent,
 /* [2] */
 OK, visible, silent,
 /* [3] */
 OK, visible, silent,
 /* [4] */
 OK, visible, silent
 }
};
resource ‘ALRT’ (1001) {
 {82, 78, 164, 464},
 1001,
 { /* array: 4 elements */
 /* [1] */
 OK, visible, sound1,
 /* [2] */
 OK, visible, sound1,
 /* [3] */
 OK, visible, sound1,
 /* [4] */
 OK, visible, sound1
 }
};
resource ‘ALRT’ (1003) {
 {64, 68, 188, 348},
 1003,
 { /* array: 4 elements */
 /* [1] */
 OK, visible, sound1,
 /* [2] */
 OK, visible, sound1,
 /* [3] */
 OK, visible, sound1,
 /* [4] */
 OK, visible, sound1
 }
};
resource ‘ALRT’ (1002) {
 {94, 84, 170, 370},
 1002,
 { /* array: 4 elements */
 /* [1] */
 OK, visible, sound1,
 /* [2] */
 OK, visible, sound1,
 /* [3] */
 OK, visible, sound1,
 /* [4] */
 OK, visible, sound1
 }
};
resource ‘DITL’ (100, purgeable) {
 { /* array DITLarray: 2 elements */
 /* [1] */
 {109, 45, 129, 104},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {30, 40, 87, 268},
 StaticText {
 disabled,
 “           ObjectShell Program\n         “
 “        Version 1.0\n Copyright by  ^0”
 }
 }
};
resource ‘DITL’ (1001) {
 { /* array DITLarray: 3 elements */
 /* [1] */
 {50, 296, 71, 358},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {40, 104, 70, 260},
 StaticText {
 disabled,
 “Error number: ^0”
 },
 /* [3] */
 {8, 104, 32, 360},
 StaticText {
 disabled,
 “^1”
 }
 }
};
resource ‘DITL’ (1002) {
 { /* array DITLarray: 2 elements */
 /* [1] */
 {45, 84, 66, 144},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {7, 84, 36, 274},
 StaticText {
 disabled,
 “Text too long for TextEdit”
 }
 }
};
resource ‘DITL’ (1003) {
 { /* array DITLarray: 4 elements */
 /* [1] */
 {81, 31, 101, 91},
 Button {
 enabled,
 “Yes”
 },
 /* [2] */
 {80, 184, 100, 244},
 Button {
 enabled,
 “cancel”
 },
 /* [3] */
 {13, 31, 60, 227},
 StaticText {
 disabled,
 “Do you want to save changes to \”^0\”?”
 },
 /* [4] */
 {80, 107, 100, 167},
 Button {
 enabled,
 “No”
 }
 }
};
resource ‘DITL’ (2000) {
 { /* array DITLarray: 1 elements */
 /* [1] */
 {19, 25, 80, 245},
 StaticText {
 disabled,
 “Printing in Progress...\nTo stop printing”
 “, hold down the\n\0x11-Key and type period(.)”
 “.”
 }
 }
};
resource ‘DITL’ (2001) {
 { /* array DITLarray: 14 elements */
 /* [1] */
 {216, 24, 236, 84},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {216, 104, 236, 164},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {20, 110, 36, 213},
 StaticText {
 disabled,
 “Kind of Shape”
 },
 /* [4] */
 {20, 214, 38, 295},
 UserItem {
 enabled
 },
 /* [5] */
 {56, 272, 77, 332},
 EditText {
 enabled,
 “38”
 },
 /* [6] */
 {96, 272, 118, 332},
 EditText {
 enabled,
 “150”
 },
 /* [7] */
 {128, 272, 148, 332},
 EditText {
 enabled,
 “150”
 },
 /* [8] */
 {168, 272, 188, 332},
 EditText {
 enabled,
 “4”
 },
 /* [9] */
 {198, 272, 218, 332},
 EditText {
 enabled,
 “0”
 },
 /* [10] */
 {56, 136, 80, 256},
 StaticText {
 disabled,
 “Number of Shapes”
 },
 /* [11] */
 {96, 24, 120, 256},
 StaticText {
 disabled,
 “Starting Size of Shapes: horizontal”
 },
 /* [12] */
 {127, 185, 147, 245},
 StaticText {
 disabled,
 “vertical”
 },
 /* [13] */
 {168, 32, 192, 264},
 StaticText {
 disabled,
 “Pixels to inset Shapes: horizontal”
 },
 /* [14] */
 {198, 185, 218, 245},
 StaticText {
 disabled,
 “vertical”
 }
 }
};
resource ‘DITL’ (2002) {
 { /* array DITLarray: 8 elements */
 /* [1] */
 {179, 26, 199, 86},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {180, 110, 200, 170},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {24, 56, 48, 208},
 StaticText {
 disabled,
 “Length of Initial Line”
 },
 /* [4] */
 {72, 80, 96, 208},
 StaticText {
 disabled,
 “Vertical Deviation”
 },
 /* [5] */
 {24, 224, 44, 284},
 EditText {
 enabled,
 “150”
 },
 /* [6] */
 {72, 224, 92, 284},
 EditText {
 enabled,
 “150”
 },
 /* [7] */
 {128, 224, 148, 284},
 EditText {
 enabled,
 “150”
 },
 /* [8] */
 {128, 88, 152, 208},
 StaticText {
 disabled,
 “Number of Lines”
 }
 }
};
resource ‘MENU’ (1) {
 1,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 apple,
 { /* array: 2 elements */
 /* [1] */
 “About ObjectShell..”, noIcon, “”, “”, plain,
 /* [2] */
 “-”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (2) {
 2,
 textMenuProc,
 0x7FFFFDB7,
 enabled,
 “ File”,
 { /* array: 11 elements */
 /* [1] */
 “New”, noIcon, hierarchicalMenu, “\0x15”, plain,
 /* [2] */
 “Open”, noIcon, “O”, “”, plain,
 /* [3] */
 “Close”, noIcon, “”, “”, plain,
 /* [4] */
 “-”, noIcon, “”, “”, plain,
 /* [5] */
 “Save”, noIcon, “S”, “”, plain,
 /* [6] */
 “Save As... “, noIcon, “”, “”, plain,
 /* [7] */
 “-”, noIcon, “”, “”, plain,
 /* [8] */
 “Page Setup...”, noIcon, “”, “”, plain,
 /* [9] */
 “Print”, noIcon, “P”, “”, plain,
 /* [10] */
 “-”, noIcon, “”, “”, plain,
 /* [11] */
 “Quit “, noIcon, “Q”, “”, plain
 }
};
resource ‘MENU’ (3) {
 3,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 “Edit”,
 { /* array: 6 elements */
 /* [1] */
 “Undo “, noIcon, “Z”, “”, plain,
 /* [2] */
 “-”, noIcon, “”, “”, plain,
 /* [3] */
 “Cut “, noIcon, “X”, “”, plain,
 /* [4] */
 “Copy “, noIcon, “C”, “”, plain,
 /* [5] */
 “Paste “, noIcon, “V”, “”, plain,
 /* [6] */
 “Clear”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (21) {
 21,
 textMenuProc,
 allEnabled,
 enabled,
 “New”,
 { /* array: 2 elements */
 /* [1] */
 “TextWindow”, noIcon, hierarchicalMenu, “‘“, plain,
 /* [2] */
 “PictWindow”, noIcon, hierarchicalMenu, “””, plain
 }
};
resource ‘MENU’ (4) {
 4,
 textMenuProc,
 allEnabled,
 enabled,
 “Graphics”,
 { /* array: 3 elements */
 /* [1] */
 “Ovals”, noIcon, “”, “”, plain,
 /* [2] */
 “Spirals”, noIcon, “”, “”, plain,
 }
};
resource ‘MENU’ (5) {
 5,
 textMenuProc,
 allEnabled,
 enabled,
 “Color”,
 { /* array: 2 elements */
 /* [1] */
 “ForeColor “, noIcon, hierarchicalMenu, “3”, plain,
 /* [2] */
 “BackColor”, noIcon, hierarchicalMenu, “4”, plain
 }
};
resource ‘MENU’ (51) {
 51,
 textMenuProc,
 allEnabled,
 enabled,
 “ForeColor”,
 { /* array: 8 elements */
 /* [1] */
 “Black”, noIcon, “”, “”, plain,
 /* [2] */
 “White”, noIcon, “”, “”, plain,
 /* [3] */
 “Red”, noIcon, “”, “”, plain,
 /* [4] */
 “Green”, noIcon, “”, “”, plain,
 /* [5] */
 “Blue”, noIcon, “”, “”, plain,
 /* [6] */
 “Cyan”, noIcon, “”, “”, plain,
 /* [7] */
 “Magenta”, noIcon, “”, “”, plain,
 /* [8] */
 “Yellow”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (52) {
 52,
 textMenuProc,
 allEnabled,
 enabled,
 “BackColor”,
 { /* array: 8 elements */
 /* [1] */
 “Black”, noIcon, “”, “”, plain,
 /* [2] */
 “White”, noIcon, “”, “”, plain,
 /* [3] */
 “Red”, noIcon, “”, “”, plain,
 /* [4] */
 “Green”, noIcon, “”, “”, plain,
 /* [5] */
 “Blue”, noIcon, “”, “”, plain,
 /* [6] */
 “Cyan”, noIcon, “”, “”, plain,
 /* [7] */
 “Magenta”, noIcon, “”, “”, plain,
 /* [8] */
 “Yellow”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (6) {
 6,
 textMenuProc,
 allEnabled,
 enabled,
 “Text”,
 { /* array: 4 elements */
 /* [1] */
 “Font”, noIcon, hierarchicalMenu, “=”, plain,
 /* [2] */
 “Size”, noIcon, hierarchicalMenu, “>”, plain,
 /* [3] */
 “Style”, noIcon, hierarchicalMenu, “?”, plain,
 /* [4] */
 “Align\0x00”, noIcon, hierarchicalMenu, “@”, plain
 }
};
resource ‘MENU’ (61) {
 61,
 textMenuProc,
 allEnabled,
 enabled,
 “Font”,
 { /* array: 0 elements */
 }
};
resource ‘MENU’ (62) {
 62,
 textMenuProc,
 allEnabled,
 enabled,
 “Size”,
 { /* array: 9 elements */
 “9”, noIcon, “”, “”, plain,
 “10”, noIcon, “”, “”, plain,
 “12”, noIcon, “”, “”, plain,
 “14”, noIcon, “”, “”, plain,
 “18”, noIcon, “”, “”, plain,
 “24”, noIcon, “”, “”, plain,
 “36”, noIcon, “”, “”, plain,
 “48”, noIcon, “”, “”, plain,
 “72”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (211) {
 211,
 textMenuProc,
 allEnabled,
 enabled,
 “PictWindow”,
 { /* array: 8 elements */
 /* [1] */
 “NoGrowWindow”, noIcon, “”, “”, plain,
 /* [2] */
 “GrowWindow”, noIcon, “”, “”, plain,
 /* [3] */
 “HScrollWindow”, noIcon, “”, “”, plain,
 /* [4] */
 “VScrollWindow”, noIcon, “”, “”, plain,
 /* [5] */
 “ScrollWindow”, noIcon, “”, “”, plain,
 /* [6] */
 “HScrollZoomWindow”, noIcon, “”, “”, plain,
 /* [7] */
 “VScrollZoomWindow”, noIcon, “”, “”, plain,
 /* [8] */
 “ScrollZoomWindow”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (212) {
 212,
 textMenuProc,
 allEnabled,
 enabled,
 “TextWindow”,
 { /* array: 8 elements */
 /* [1] */
 “NoGrowWindow”, noIcon, “”, “”, plain,
 /* [2] */
 “GrowWindow”, noIcon, “”, “”, plain,
 /* [3] */
 “HScrollWindow”, noIcon, “”, “”, plain,
 /* [4] */
 “VScrollWindow”, noIcon, “”, “”, plain,
 /* [5] */
 “ScrollWindow”, noIcon, “”, “”, plain,
 /* [6] */
 “HScrollZoomWindow”, noIcon, “”, “”, plain,
 /* [7] */
 “VScrollZoomWindow”, noIcon, “”, “”, plain,
 /* [8] */
 “ScrollZoomWindow”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (63) {
 63,
 textMenuProc,
 allEnabled,
 enabled,
 “Style”,
 { /* array: 8 elements */
 /* [1] */
 “Plain”, noIcon, “”, “”, plain,
 /* [2] */
 “Bold”, noIcon, “B”, “”, 1,
 /* [3] */
 “Italic”, noIcon, “I”, “”, 2,
 /* [4] */
 “Underline”, noIcon, “U”, “”, 4,
 /* [5] */
 “Outline”, noIcon, “”, “”, 8,
 /* [6] */
 “Shadow”, noIcon, “T”, “”, 16,
 /* [7] */
 “Condense”, noIcon, “”, “”, plain,
 /* [8] */
 “Extend”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (64) {
 64,
 textMenuProc,
 allEnabled,
 enabled,
 “Align”,
 { /* array: 3 elements */
 /* [1] */
 “Left”, noIcon, “”, “”, plain,
 /* [2] */
 “Middle”, noIcon, “”, “”, plain,
 /* [3] */
 “Right”, noIcon, “”, “”, plain
 }
};
resource ‘MENU’ (10) {
 10,
 textMenuProc,
 allEnabled,
 enabled,
 “PopupMenu”,
 { /* array: 4 elements */
 /* [1] */
 “FrameOval”, noIcon, “”, “”, plain,
 /* [2] */
 “InvertOval”, noIcon, “”, “”, plain,
 /* [3] */
 “FrameRectangle”, noIcon, “”, “”, plain,
 /* [4] */
 “InvertRectangle”, noIcon, “”, “”, plain
 }
};
resource ‘STR#’ (1000) {
 { /* array StringArray: 2 elements */
 /* [1] */
 “Untitled”,
 /* [2] */
 “Save current document as:”
 }
};
resource ‘STR#’ (1001) {
 { /* array StringArray: 2 elements */
 /* [1] */
 “Duplicate file name”,
 /* [2] */
 “File already open”
 }
};
resource ‘DLOG’ (2000, purgeable) {
 {72, 66, 174, 334},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 2000,
 “New Dialog”
};
resource ‘DLOG’ (2001, purgeable) {
 {46, 44, 312, 406},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 2001,
 “New Dialog”
};
resource ‘DLOG’ (2002, purgeable) {
 {40, 40, 252, 360},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 2002,
 “New Dialog”
};
resource ‘BNDL’ (1001) {
 ‘CSOS’,
 0,
 { /* array TypeArray: 2 elements */
 /* [1] */
 ‘ICN#’,
 { /* array IDArray: 3 elements */
 0, 1001,
 1, 1002,
 2, 1003
 },
 /* [2] */
 ‘FREF’,
 { /* array IDArray: 3 elements */
 0, 1001,
 1, 1002,
 2, 1003
 }
 }
};
resource ‘FREF’ (1001) {
 ‘APPL’,
 0,
 “”
};
resource ‘FREF’ (1002) {
 ‘TEXT’,
 1,
 “”
};
resource ‘FREF’ (1003) {
 ‘PICT’,
 2,
 “”
};
resource ‘ICN#’ (1001, “CSOS APPL”, purgeable) {
 { /* array: 2 elements */
 /* [1] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0800 0080 0FFF FF80 0800 0080 0FFF FF80"
 $”0800 0080 0FFF FF80 7800 00F0 8000 0008"
 $”8000 0008 99C5 CDC8 A525 1088 A5C5 9088"
 $”A525 1088 99CD CC88 8000 0008 FFFF FFF8"
 $”8000 0008 8757 4408 8854 4408 8676 4408"
 $”8154 4408 8E57 7708 8000 0008 FFFF FFF8"
 $”8000 0008 FFFF FFF8 8000 0008 7FFF FFF0",
 /* [2] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0FFF FF80 0FFF FF80 0FFF FF80 0FFF FF80"
 $”0FFF FF80 0FFF FF80 7FFF FFF0 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 7FFF FFF0"
 }
};
resource ‘ICN#’ (1002, “CSOS TEXT”, purgeable) {
 { /* array: 2 elements */
 /* [1] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0800 0080 0FFF FF80 0800 0080 0FFF FF80"
 $”0800 0080 0FFF FF80 0800 0080 7FFF FFF0"
 $”8000 0008 99C5 CDC8 A525 1088 A5C5 9088"
 $”A525 1088 99CD CC88 8000 0008 FFFF FFF8"
 $”8000 0008 81DD 5C08 8090 8808 8098 8808"
 $”8090 8808 809D 4808 8000 0008 7FFF FFF0"
 $”0800 0080 0FFF FF80 0800 0080 07FF FF”,
 /* [2] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0FFF FF80 0FFF FF80 0FFF FF80 0FFF FF80"
 $”0FFF FF80 0FFF FF80 0FFF FF80 7FFF FFF0"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 7FFF FFF0"
 $”0FFF FF80 0FFF FF80 0FFF FF80 07FF FF”
 }
};
resource ‘ICN#’ (1003, “CSOS PICT”, purgeable) {
 { /* array: 2 elements */
 /* [1] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0800 0080 0FFF FF80 0800 0080 0FFF FF80"
 $”0800 0080 0FFF FF80 0800 0080 7FFF FFF0"
 $”8000 0008 99C5 CDC8 A525 1088 A5C5 9088"
 $”A525 1088 99CD CC88 8000 0008 FFFF FFF8"
 $”8000 0008 81C9 B808 812A 1008 81CA 1008"
 $”810A 1008 8109 9008 8000 0008 7FFF FFF0"
 $”0800 0080 0FFF FF80 0800 0080 07FF FF”,
 /* [2] */
 $”0000 0000 0000 0000 0000 0000 07FF FF00"
 $”0FFF FF80 0FFF FF80 0FFF FF80 0FFF FF80"
 $”0FFF FF80 0FFF FF80 0FFF FF80 7FFF FFF0"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
 $”FFFF FFF8 FFFF FFF8 FFFF FFF8 7FFF FFF0"
 $”0FFF FF80 0FFF FF80 0FFF FF80 07FF FF”
 }
};
data ‘CSOS’ (0) {
 $”19A9 2031 3938 3920 4368 7269 7374 6961"
 $”6E20 5374 7261 746F 7761"
};
resource ‘SIZE’ (-1) {
 dontSaveScreen,
 acceptSuspendResumeEvents,
 enableOptionSwitch,
 cannotBackground,
 multiFinderAware,
 131072,
 81920
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »

Price Scanner via MacPrices.net

Amazon is offering a $100 discount on every M...
Amazon is offering a $100 instant discount on each configuration of Apple’s new 13″ M3 MacBook Air, in Midnight, this weekend. These are the lowest prices currently available for new 13″ M3 MacBook... Read more
You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.