Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!labrea!Portia!Jessica!rick From: rick@Jessica.stanford.edu (Rick Wong) Newsgroups: comp.sys.mac.programmer Subject: Re: Using Textedit in Paint programs Message-ID: <3975@Portia.Stanford.EDU> Date: 19 Oct 88 02:19:19 GMT References: <900011@newton> Sender: news@Portia.Stanford.EDU Reply-To: rick@Jessica.stanford.edu (Rick Wong) Organization: Stanford University Lines: 50 In article <900011@newton> clam@newton.ncsa.uiuc.edu writes: > >I am trying to write a color paint program. I would love to know how I can >make use of TextEdit to implement the text tool in the tool palette (the 'A' >icon). Specifically: Don't bother using TextEdit. For all but the most simple applications, it inevitably forces you to kludge up your code. I hate it. Vehemently. For a paint program, which has limited text editing, it is at least as easy to write your own code for storing strings, drawing them on screen, blinking the caret, and so on. > > [1] How do I prevent existing graphics that is in the view rect of text >edit record from being erased? > Don't use TextEdit. For paint programs, you generally need at two offscreen bitmaps, one for a backup image and one to do work in. When the text changes, copy the backup image to the work bitmap, then redraw the text on top of it. Since you won't be handling much text, the speed is adequate. > [2] When the user types , how do I erase the last character >and restore the background graphics that was replaced by the character? > See [1]. > All existing paint programs seem to be able to do this quite well and >I suspect they make use of text edit since they have the blinking text caret >to prompt users to enter text. Is this true? > Any program that did text editing well wouldn't be using TextEdit (it's getting mighty hot around here . . .). MacPaint and HyperCard don't use TextEdit for painted text (try to have MacsBug break on TEIdle -- nothing happens). >Thanks in advance, >Chih-Chao Lam >lam@sumex-aim.stanford.edu Rick "Cheesy Spam Jello" Wong Courseware Authoring Tools Project, Stanford University rick@jessica.stanford.edu "Ask not what your country can do for you, but what you can do for George Bush."