home *** CD-ROM | disk | FTP | other *** search
Oberon Document | 1994-06-07 | 22.3 KB | 596 lines | [oODC/obnF] |
- Documents.StdDocumentDesc
- Documents.DocumentDesc
- Containers.ViewDesc
- Views.ViewDesc
- Stores.StoreDesc
- Documents.ModelDesc
- Containers.ModelDesc
- Models.ModelDesc
- Stores.ElemDesc
- TextViews.StdViewDesc
- TextViews.ViewDesc
- TextModels.StdModelDesc
- TextModels.ModelDesc
- TextModels.AttributesDesc
- Geneva
- TextRulers.StdRulerDesc
- TextRulers.RulerDesc
- TextRulers.StdStyleDesc
- TextRulers.StyleDesc
- TextRulers.AttributesDesc
- DevCommanders.StdViewDesc
- DevCommanders.ViewDesc
- Geneva
- MODULE SamplesMacEditor; (* Sample Macintosh Application mf/od*)
- (* This Sample Text Editor shows how to use MacOberon to develop a standalone Mac Application.
- Some parts are taken from the new Inside Mac Toolbox Essentiels, so you have to lookup
- there, if you have some specific questions about the code.
- This application does NOT show how you SHOULD program to Mac, it's only intended as
- a sample for the use of MacOberon!
- Because we use the MacOberon Compiler, this application needs also at least an 68020 processor.
- Click the following commands to compile, link and launch the application:
- DevCompiler.Compile
- DevLinker.Link ":Samples:MacEditor" +SamplesMacEditor >SamplesMacEditor
- Read MakeMacApp.Doc for more information about how to create Macintosh standalone
- applications using MacOberon. ( Write.Open MakeMacApp.Doc )
- IMPORT
- SYSTEM,
- MacTypes, QuickDraw := MacQuickDraw, MemoryMgr := MacMemoryMgr, FileMgr := MacFileMgr,
- FontMgr := MacFontMgr, MenuMgr := MacMenuMgr, WindowMgr := MacWindowMgr,
- TextEdit := MacTextEdit, DialogMgr := MacDialogMgr, PrintingMgr := MacPrintingMgr,
- ControlMgr := MacControlMgr, EventMgr := MacEventMgr, DeskMgr := MacDeskMgr,
- OSUtils := MacOSUtils, GestaltMgr := MacGestaltMgr;
- CONST
- UNTAGGED = 1;
- CALLBACK = 2;
- (* Apple Menu *)
- mApple=256;
- iAbout=1;
- (* File Menu *)
- mFile=257;
- iNew=1;
- iOpen=2;
- iClose=3;
- iSave=5;
- iPageSetUp=7;
- iPrint=8;
- iQuit=10;
- (* Edit Menu *)
- mEdit=258;
- iCut=3;
- iCopy=4;
- iPaste=5;
- iClear=6;
- iSelectAll=8;
- (* Font Menus *)
- mFont=259;
- mSize=260;
- (* Alerts *)
- aAbout=1000;
- (* Controls *)
- rVScroll=128;
- DocRec = RECORD [UNTAGGED] (* Datatype for our documents *)
- data : TextEdit.TEHandle;
- vScrollBar : ControlMgr.ControlHandle;
- END;
- DocPtr = POINTER TO DocRec;
- wcount: SHORTINT; (* Application Window Number *)
- gPrint : PrintingMgr.THPrint; (* global Printhandle *)
- (***************************************************************)
- (* Two general routines for adjusting rectangles of the textwindows *)
- PROCEDURE GetTERect(window : WindowMgr.WindowPtr; VAR teRect : QuickDraw.Rect);
- BEGIN
- teRect:=window.portRect;
- QuickDraw.InsetRect(teRect, 4 ,4 );
- DEC(teRect.right, 15);
- DEC(teRect.bottom, 15);
- END GetTERect;
- PROCEDURE AdjustViewRect(docTE : TextEdit.TEHandle);
- BEGIN
- docTE.viewRect.bottom:=(((docTE.viewRect.bottom-docTE.viewRect.top) DIV docTE.lineHeight) *
- docTE.lineHeight) + docTE.viewRect.top;
- END AdjustViewRect;
- (***************************************************************)
- (* Creates and returns a new TextEdit window *)
- PROCEDURE NewWindow() : WindowMgr.WindowPtr;
- VAR
- winTitle: MacTypes.Str255;
- wbounds, tbounds: QuickDraw.Rect;
- window: WindowMgr.WindowPtr;
- text: TextEdit.TEHandle;
- newDoc : DocPtr;
- info : FontMgr.FontInfo;
- BEGIN
- wbounds.top:= QuickDraw.globals.screenBits.bounds.top+40+10*(wcount MOD 10); (* Open new window *)
- wbounds.left:=QuickDraw.globals.screenBits.bounds.left+20+10*(wcount MOD 10);
- wbounds.bottom:=QuickDraw.globals.screenBits.bounds.bottom-20;
- wbounds.right:= QuickDraw.globals.screenBits.bounds.right-50; INC(wcount);
- winTitle[0]:=3X; winTitle[1]:=23X; winTitle[2]:=CHR((wcount DIV 10) MOD 10+30H); winTitle[3]:=CHR(wcount MOD 10+30H);
- window:=WindowMgr.NewWindow(NIL, wbounds, winTitle, FALSE, 0, SYSTEM.VAL(WindowMgr.WindowPtr, -1), TRUE, 0);
- QuickDraw.SetPort(window);
- GetTERect(window, tbounds);
- text:= TextEdit.TENew(tbounds, tbounds); (* Add textedit structure and set default font *)
- text.txFont:=4; text.txSize:=9;
- QuickDraw.TextFont(4); QuickDraw.TextSize(9);
- FontMgr.GetFontInfo(info);
- text.lineHeight:=info.ascent+info.descent+info.leading;
- text.fontAscent:=info.ascent;
- AdjustViewRect(text);
- TextEdit.TEAutoView(TRUE, text);
- newDoc := SYSTEM.VAL(DocPtr, MemoryMgr.NewPtrClear(SIZE(DocRec)));
- newDoc.data:=text;
- newDoc.vScrollBar:=ControlMgr.GetNewControl(rVScroll, window); (* Add scrollbar *)
- window.refCon:=SYSTEM.VAL(LONGINT, newDoc); (* We use the window refcon to store our data pointer *)
- RETURN window
- END NewWindow;
- (***************************************************************)
- (* Routines for text scrolling and updating *)
- PROCEDURE AdjustTE(window : WindowMgr.WindowPtr);
- myDoc : DocPtr;
- BEGIN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- TextEdit.TEPinScroll( myDoc.data.viewRect.left - myDoc.data.destRect.left,
- myDoc.data.viewRect.top - myDoc.data.destRect.top -
- ControlMgr.GetCtlValue(myDoc.vScrollBar)*myDoc.data.lineHeight, myDoc.data);
- END AdjustTE;
- PROCEDURE AdjustScrollSizes(window : WindowMgr.WindowPtr);
- myDoc : DocPtr;
- teTop, teRight, teBottom : INTEGER;
- teRect : QuickDraw.Rect;
- BEGIN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- GetTERect(window, teRect);
- teTop:=window.portRect.top;
- teRight:=window.portRect.right;
- teBottom:=window.portRect.bottom;
- myDoc.data.viewRect:=teRect;
- AdjustViewRect(myDoc.data);
- ControlMgr.MoveControl(myDoc.vScrollBar, teRight-15, -1);
- ControlMgr.SizeControl(myDoc.vScrollBar, 16, (teBottom-teTop)-13);
- END AdjustScrollSizes;
- PROCEDURE AdjustScrollValues(window : WindowMgr.WindowPtr);
- VAR
- myDoc : DocPtr;
- max, lines, value : INTEGER;
- BEGIN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- lines:=myDoc.data.nLines;
- max:=lines-((myDoc.data.viewRect.bottom-myDoc.data.viewRect.top) DIV myDoc.data.lineHeight);
- IF max<0 THEN max:=0 END;
- ControlMgr.SetCtlMax(myDoc.vScrollBar, max);
- value:=(myDoc.data.viewRect.top-myDoc.data.destRect.top) DIV myDoc.data.lineHeight;
- IF value<0 THEN value:=0 END;IF value>max THEN value:=max END;
- ControlMgr.SetCtlValue(myDoc.vScrollBar, value);
- ControlMgr.ShowControl(myDoc.vScrollBar)
- END AdjustScrollValues;
- PROCEDURE AdjustScrollBars(window : WindowMgr.WindowPtr; resize : BOOLEAN);
- VAR
- myDoc : DocPtr;
- BEGIN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- myDoc.vScrollBar.contrlVis:=0X;
- IF resize THEN AdjustScrollSizes(window) END;
- AdjustScrollValues(window)
- END AdjustScrollBars;
- (***************************************************************)
- (* Use StandardGetFile to select and open a plain ascii text file *)
- PROCEDURE OpenFile;
- myTypes : FileMgr.SFTypeList;
- myReply : FileMgr.StandardFileReply;
- window : WindowMgr.WindowPtr;
- inFile : INTEGER;
- err : INTEGER;
- theSize : LONGINT;
- buffer : MacTypes.Ptr;
- myDoc : DocPtr;
- BEGIN
- myTypes[0]:=054455854H; (* TEXT *)
- FileMgr.StandardGetFile(NIL, 1, myTypes, myReply);
- IF myReply.sfGood THEN
- window:=NewWindow();
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- WindowMgr.SetWTitle(window, SYSTEM.VAL(MacTypes.Str255, myReply.sfFile.name));
- err:=FileMgr.FSpOpenDF(myReply.sfFile, 0, inFile);
- err:=FileMgr.GetEOF(inFile, theSize);
- IF theSize>7FFFH THEN theSize:=7FFFH END; (* Limitation of TextEdit, max 32768 chars *)
- err:=FileMgr.SetFPos(inFile, 1, 0);
- buffer := MemoryMgr.NewPtr(8000H);
- err:=FileMgr.FSRead(inFile, theSize, buffer);
- err:=FileMgr.FSClose(inFile);
- TextEdit.TESetText(buffer, theSize, myDoc.data);
- AdjustScrollBars(window, TRUE);
- AdjustTE(window);
- WindowMgr.ShowWindow(window);
- MemoryMgr.DisposPtr(buffer)
- END;
- END OpenFile;
- (***************************************************************)
- (* Close the front window *)
- PROCEDURE CloseWindow;
- window : WindowMgr.WindowPtr;
- myDoc : DocPtr;
- BEGIN
- window:=WindowMgr.FrontWindow();
- IF window=NIL THEN RETURN END;
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- TextEdit.TEDispose(myDoc.data);
- WindowMgr.CloseWindow(window);
- MemoryMgr.DisposPtr(SYSTEM.VAL(MacTypes.Ptr, myDoc));
- END CloseWindow;
- (***************************************************************)
- (* Save the content of the front window to a file *)
- PROCEDURE SaveWindow;
- myReply : FileMgr.StandardFileReply;
- prompt, defname : MacTypes.Str255;
- myDoc : DocPtr;
- window : WindowMgr.WindowPtr;
- myFile : INTEGER;
- err : INTEGER;
- size : LONGINT;
- BEGIN
- window:=WindowMgr.FrontWindow();
- IF window=NIL THEN RETURN END;
- MacTypes.SetStr255(prompt, 'Save file as :');
- MacTypes.SetStr255(defname, 'Untitled');
- FileMgr.StandardPutFile(prompt, defname, myReply); (* Select a filename *)
- IF myReply.sfGood THEN
- IF myReply.sfReplacing THEN err:=FileMgr.FSpDelete(myReply.sfFile) END;
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- err:=FileMgr.FSpCreate(myReply.sfFile, 045444954H, 054455854H, 0); (* Create a new file *)
- err:=FileMgr.FSpOpenDF(myReply.sfFile, 0, myFile);
- IF err=0 THEN
- (* Write the text data *)
- size:=myDoc.data.teLength;
- err:=FileMgr.FSWrite(myFile, size, SYSTEM.VAL(MacTypes.Ptr, SYSTEM.ADR(myDoc.data.hText[0])));
- err:=FileMgr.FSClose(myFile)
- END
- END
- END SaveWindow;
- (***************************************************************)
- (* Print the content of the front window *)
- PROCEDURE DoPageSetUp;
- VAR
- ignore : BOOLEAN;
- BEGIN
- PrintingMgr.PrOpen;
- ignore:=PrintingMgr.PrStlDialog(gPrint); (* Get Pagesetup *)
- PrintingMgr.PrClose
- END DoPageSetUp;
- PROCEDURE DoPrint;
- myDoc : DocPtr;
- window : WindowMgr.WindowPtr;
- pages : INTEGER;
- lines : INTEGER;
- prPort : PrintingMgr.TPPrPort;
- line,page : INTEGER;
- lh,y : INTEGER;
- BEGIN
- window:=WindowMgr.FrontWindow();
- IF window=NIL THEN RETURN END;
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- PrintingMgr.PrOpen;
- IF PrintingMgr.PrJobDialog(gPrint) THEN (* Get printing options *)
- prPort:=PrintingMgr.PrOpenDoc(gPrint, NIL, NIL);
- lines:= (prPort.portRect.bottom - prPort.portRect.top) DIV myDoc.data.lineHeight;
- pages:= myDoc.data.nLines DIV lines;
- line:=0; page:=0;
- WHILE page<=pages DO
- PrintingMgr.PrOpenPage(prPort, NIL);
- QuickDraw.TextFont(myDoc.data.txFont);
- QuickDraw.TextSize(myDoc.data.txSize);
- lh:=myDoc.data.lineHeight;
- y:=lh;
- REPEAT
- QuickDraw.MoveTo(20,y);
- QuickDraw.DrawText(SYSTEM.ADR(myDoc.data.hText[0]), myDoc.data.lineStarts[line],
- myDoc.data.lineStarts[line+1] - myDoc.data.lineStarts[line]-1);
- INC(line);
- INC(y,lh);
- UNTIL ((line>myDoc.data.nLines) OR ((line MOD lines)=0));
- PrintingMgr.PrClosePage(prPort);
- INC(page);
- END;
- PrintingMgr.PrCloseDoc(prPort);
- END;
- PrintingMgr.PrClose
- END DoPrint;
- (***************************************************************)
- (* Clickroutine for scrollbar *)
- PROCEDURE [CALLBACK] VertAction(control : ControlMgr.ControlHandle; part : INTEGER);
- scrollDistance:INTEGER;
- window : WindowMgr.WindowPtr;
- myDoc : DocPtr;
- oldSetting,max : INTEGER;
- BEGIN
- IF part#0 THEN
- window:=control.contrlOwner;
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- CASE part OF
- | ControlMgr.inUpButton,ControlMgr.inDownButton : scrollDistance:=1
- | ControlMgr.inPageUp,ControlMgr.inPageDown : scrollDistance:=10
- END;
- IF (part=ControlMgr.inDownButton) OR (part=ControlMgr
- .inPageDown) THEN scrollDistance:=-scrollDistance END;
- oldSetting:=ControlMgr.GetCtlValue(control);
- max:=ControlMgr.GetCtlMax(control);
- scrollDistance:=oldSetting-scrollDistance;
- IF scrollDistance<0 THEN scrollDistance:=0 END;
- IF scrollDistance>max THEN scrollDistance:=max END;
- ControlMgr.SetCtlValue(control,scrollDistance);
- scrollDistance:=oldSetting-scrollDistance;
- IF scrollDistance#0 THEN TextEdit.TEPinScroll(0, scrollDistance*myDoc.data.lineHeight, myDoc.data) END;
- END;
- END VertAction;
- (***************************************************************)
- (* Process the clicking into a text window *)
- PROCEDURE DoContentClick(window : WindowMgr.WindowPtr; event : EventMgr.EventRecord);
- control : ControlMgr.ControlHandle;
- value,part : INTEGER;
- myDoc : DocPtr;
- teRect : QuickDraw.Rect;
- BEGIN
- QuickDraw.SetPort(window);
- QuickDraw.GlobalToLocal(event.where);
- GetTERect(window, teRect);
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- IF ~QuickDraw.PtInRect(event.where,teRect) THEN (* Click into scrollbar? *)
- part:=ControlMgr.FindControl(event.where, window, control);
- CASE part OF
- | 0 :
- | ControlMgr.inThumb :
- value:=ControlMgr.GetCtlValue(control);
- part:=ControlMgr.TrackControl(control, event.where, NIL);
- IF part#0 THEN
- value:=value - ControlMgr.GetCtlValue(control);
- IF value#0 THEN TextEdit.TEPinScroll(0, value*myDoc.data.lineHeight, myDoc.data) END
- END
- ELSE
- part := ControlMgr.TrackControl(control, event.where, SYSTEM.VAL(MacTypes.ProcPtr, SYSTEM.ADR(VertAction)));
- END
- ELSE TextEdit.TEClick(event.where, FALSE, myDoc.data) END (* Click into window *)
- END DoContentClick;
- (***************************************************************)
- (* Process the selecting of a menuitem *)
- PROCEDURE MenuCommand(menuResult: LONGINT); (* Item has been Chosen by MenuSelect or MenuKey *)
- VAR
- menu, item: INTEGER;
- Name: MacTypes.Str255;
- daRefNum: INTEGER;
- itemHit: INTEGER;
- window: WindowMgr.WindowPtr;
- myDoc: DocPtr;
- fontID, fsize : INTEGER;
- fInfo : FontMgr.FontInfo;
- oldPort : QuickDraw.GrafPtr;
- BEGIN
- menu:=SHORT(menuResult DIV 10000H); item:=SHORT(menuResult MOD 10000H); (* Get menu and item number *)
- window:=WindowMgr.FrontWindow();
- IF window#NIL THEN myDoc:=SYSTEM.VAL(DocPtr, window.refCon) END;
- CASE menu OF
- | mApple:
- IF item=iAbout THEN itemHit:=DialogMgr.Alert(aAbout, NIL)
- ELSE
- MenuMgr.GetItem(MenuMgr.GetMHandle(mApple), item, Name);
- daRefNum:=DeskMgr.OpenDeskAcc(Name)
- END
- | mFile:
- CASE item OF
- | iNew : window:=NewWindow();AdjustScrollBars(window, TRUE);
- WindowMgr.ShowWindow(window)
- | iOpen : OpenFile;
- | iClose : CloseWindow;
- | iPageSetUp : DoPageSetUp;
- | iPrint : DoPrint;
- | iSave : SaveWindow;
- | iQuit : OSUtils.ExitToShell
- ELSE END
- | mEdit:
- IF window#NIL THEN
- CASE item OF (* We don't exchange our data with the clipboard *)
- | iCut : TextEdit.TECut(myDoc.data);
- | iCopy : TextEdit.TECopy(myDoc.data);
- | iPaste : TextEdit.TEPaste(myDoc.data);
- | iClear : TextEdit.TEDelete(myDoc.data);
- | iSelectAll : TextEdit.TESetSelect(0, 32767, myDoc.data)
- ELSE END;
- AdjustScrollBars(window, FALSE)
- END
- | mFont:
- IF window#NIL THEN
- MenuMgr.GetItem(MenuMgr.GetMHandle(mFont), item, Name);
- FontMgr.GetFNum(Name, fontID);
- QuickDraw.GetPort(oldPort);
- QuickDraw.SetPort(myDoc.data.inPort);
- QuickDraw.TextFont(fontID);
- myDoc.data.txFont:=fontID;
- AdjustScrollBars(window, TRUE);
- AdjustTE(window);
- WindowMgr.InvalRect(window.portRect);
- QuickDraw.SetPort(oldPort)
- END
- | mSize:
- IF window#NIL THEN
- CASE item OF
- | 1 : fsize:=9;
- | 2 : fsize:=10;
- | 3 : fsize:=12;
- | 4 : fsize:=18;
- | 5 : fsize:=24
- ELSE END;
- QuickDraw.GetPort(oldPort);
- QuickDraw.SetPort(myDoc.data.inPort);
- QuickDraw.TextSize(fsize);
- myDoc.data.txSize:=fsize;
- FontMgr.GetFontInfo(fInfo);
- myDoc.data.lineHeight:=fInfo.ascent+fInfo.descent+fInfo.leading;
- myDoc.data.fontAscent:=fInfo.ascent;
- AdjustScrollBars(window, TRUE);
- AdjustTE(window);
- WindowMgr.InvalRect(window.portRect);
- QuickDraw.SetPort(oldPort)
- END
- ELSE END;
- MenuMgr.HiliteMenu(0)
- END MenuCommand;
- (***************************************************************)
- (* Help routine for update *)
- PROCEDURE GetLocalUpdateRgn(window : WindowMgr.WindowPtr; localRgn : QuickDraw.RgnHandle);
- BEGIN
- QuickDraw.CopyRgn(window.updateRgn, localRgn);
- QuickDraw.OffsetRgn(localRgn, window.portPixMap.bounds.left, window.portPixMap.bounds.top)
- END GetLocalUpdateRgn;
- (***************************************************************)
- (* Handle activating or deactivating of a text window *)
- PROCEDURE DoActivate(window : WindowMgr.WindowPtr; active : BOOLEAN);
- myDoc : DocPtr;
- growRect : QuickDraw.Rect;
- BEGIN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- IF active THEN
- TextEdit.TEActivate(myDoc.data);
- myDoc.vScrollBar.contrlVis:=0FFX;
- WindowMgr.InvalRect(myDoc.vScrollBar.contrlRect);
- growRect:=window.portRect;
- growRect.left:=growRect.right-15;
- growRect.top:=growRect.bottom-15;
- WindowMgr.InvalRect(growRect);
- ELSE
- TextEdit.TEDeactivate(myDoc.data);
- ControlMgr.HideControl(myDoc.vScrollBar);
- WindowMgr.DrawGrowIcon(window)
- END
- END DoActivate;
- (***************************************************************)
- (* Main loop of our program - handles all incoming events *)
- PROCEDURE Loop();
- VAR
- gotEvent: BOOLEAN;
- event: EventMgr.EventRecord;
- window: WindowMgr.WindowPtr;
- key: INTEGER;
- newsize : LONGINT;
- myDoc : DocPtr;
- growRect, oldViewRect : QuickDraw.Rect;
- locUpdateRgn : QuickDraw.RgnHandle;
- theResult : BOOLEAN;
- BEGIN
- LOOP gotEvent:=EventMgr.WaitNextEvent(EventMgr.everyEvent, event, 0, NIL);
- CASE event.what OF
- | EventMgr.mouseDown:
- CASE WindowMgr.FindWindow(event.where, window) OF
- | WindowMgr.inMenuBar: MenuCommand(MenuMgr.MenuSelect(event.where))
- | WindowMgr.inSysWindow: DeskMgr.SystemClick(event, window)
- | WindowMgr.inContent:
- IF window # WindowMgr.FrontWindow() THEN WindowMgr.SelectWindow(window)
- ELSE DoContentClick(window, event)
- END
- | WindowMgr.inDrag: WindowMgr.DragWindow(window, event.where, QuickDraw.globals.screenBits.bounds)
- | WindowMgr.inGoAway: IF WindowMgr.TrackGoAway(window, event.where) THEN WindowMgr.CloseWindow(window) END
- | WindowMgr.inGrow:
- QuickDraw.SetPort(window);
- QuickDraw.SetRect(growRect, 64, 64, 2000, 2000);
- newsize:=WindowMgr.GrowWindow(window, event.where, growRect);
- IF newsize#0 THEN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- oldViewRect:=myDoc.data.viewRect;
- locUpdateRgn:=QuickDraw.NewRgn();
- GetLocalUpdateRgn(window, locUpdateRgn);
- WindowMgr.SizeWindow(window, SHORT(newsize MOD 10000H), SHORT(newsize DIV 10000H),TRUE);
- AdjustScrollBars(window, TRUE);
- AdjustTE(window);
- WindowMgr.InvalRect(window.portRect);
- theResult:=QuickDraw.SectRect(oldViewRect, myDoc.data.viewRect, oldViewRect);
- WindowMgr.ValidRect(oldViewRect);
- WindowMgr.InvalRgn(locUpdateRgn);
- QuickDraw.DisposeRgn(locUpdateRgn);
- END;
- | WindowMgr.inDesk, WindowMgr.inZoomIn, WindowMgr.inZoomOut:
- END;
- | EventMgr.keyDown, EventMgr.autoKey: (* check if cmdkey is pressed *)
- key:=SHORT(event.message MOD 100H);
- IF 8 IN SYSTEM.VAL(SET, LONG(event.modifiers)) THEN MenuCommand(MenuMgr.MenuKey(key))
- ELSE
- window:=WindowMgr.FrontWindow();
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- TextEdit.TEKey(key, myDoc.data); (* Enter key in text *)
- AdjustScrollBars(window, FALSE)
- END
- | EventMgr.updateEvt:
- window:=SYSTEM.VAL(WindowMgr.WindowPtr, event.message);
- IF window#NIL THEN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- WindowMgr.BeginUpdate(window);
- QuickDraw.SetPort(window);
- QuickDraw.EraseRect(window.portRect);
- ControlMgr.DrawControls(window);
- WindowMgr.DrawGrowIcon(window);
- TextEdit.TEUpdate(window.portRect, myDoc.data);
- WindowMgr.EndUpdate(window)
- END;
- | EventMgr.activateEvt: (* modifiers: bit0: 0=deactivate 1=activate *)
- window:=SYSTEM.VAL(WindowMgr.WindowPtr, event.message);
- IF window#NIL THEN DoActivate(window, ODD(event.modifiers)) END;
- | EventMgr.osEvt:
- window:=WindowMgr.FrontWindow();
- IF window#NIL THEN myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- IF SYSTEM.LSH(event.message, -24) (*MOD 100H*)=EventMgr.suspendResumeMessage THEN
- IF ODD(event.message) THEN (* Activate *)
- QuickDraw.SetPort(window); TextEdit.TEActivate(myDoc.data); QuickDraw.InitCursor
- ELSE (* Deactivate *)
- TextEdit.TEDeactivate(myDoc.data); QuickDraw.InitCursor
- END
- END
- ELSE QuickDraw.InitCursor END
- | EventMgr.nullEvent:
- window:=WindowMgr.FrontWindow();
- IF window#NIL THEN
- myDoc:=SYSTEM.VAL(DocPtr, window.refCon);
- TextEdit.TEIdle(myDoc.data)
- END
- ELSE (* Ignore Other Event Types *)
- END
- END
- END Loop;
- (***************************************************************)
- (* Initalize all menus, variables etc *)
- PROCEDURE InitMac;
- systemversion : LONGINT; res: MacTypes.OSErr;
- BEGIN
- MemoryMgr.MaxApplZone;
- MemoryMgr.MoreMasters;
- QuickDraw.InitGraf(QuickDraw.globals.thePort);
- (* The QuickDraw Globals are proper Oberon Variables *)
- FontMgr.InitFonts;
- WindowMgr.InitWindows;
- MenuMgr.InitMenus;
- TextEdit.TEInit;
- DialogMgr.InitDialogs(0);
- QuickDraw.InitCursor;
- EventMgr.FlushEvents(EventMgr.everyEvent, 0);
- res := GestaltMgr.Gestalt(GestaltMgr.SystemVersion, systemversion);
- IF (res # 0) OR (systemversion < 0700H) THEN
- OSUtils.SysBeep(1);
- OSUtils.ExitToShell
- END;
- (* Set up menus *)
- MenuMgr.SetMenuBar(MenuMgr.GetNewMBar(128));
- MenuMgr.AddResMenu(MenuMgr.GetMHandle(mApple), 44525652H);
- MenuMgr.AddResMenu(MenuMgr.GetMHandle(mFont), 464F4E54H);
- MenuMgr.DrawMenuBar;
- (* Set up print structure *)
- gPrint := SYSTEM.VAL(PrintingMgr.THPrint, MemoryMgr.NewHandle(120));
- PrintingMgr.PrOpen;
- PrintingMgr.PrintDefault(gPrint);
- PrintingMgr.PrClose
- END InitMac;
- BEGIN
- InitMac;
- Loop()
- END SamplesMacEditor.
- TextControllers.StdCtrlDesc
- TextControllers.ControllerDesc
- Containers.ControllerDesc
- Controllers.ControllerDesc
- Geneva
- Documents.ControllerDesc
-