home *** CD-ROM | disk | FTP | other *** search
Wrap
Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!chx400!news.unige.ch!ugun2b!cui.unige.ch!perrier Newsgroups: comp.windows.x.motif Subject: Re: Text manipulation in a Drawing Area Message-ID: <1992Aug27.092831.19156@uni2b.unige.ch> From: perrier@cih.hcuge.ch (Perrier Rene) Date: 27 Aug 92 09:28:30 +0200 Sender: perrier@cui.unige.ch (Perrier Rene) References: <9208260306.AA01932@laurie.smec.sony.com> Distribution: inet Organization: University Hospital of Geneva, Switzerland Nntp-Posting-Host: cuisund.unige.ch Lines: 54 In article <9208260306.AA01932@laurie.smec.sony.com>, lr@laurie.smec.Sony.COM writes: > I am new to Motif programming, and am trying to test different > possible applications. One application is annotation of images. > I would like to be able to place a line of text on an image. I > would then like to be able to select that text and move it to a > different location. I would be satisfied in keeping the line(s) > together and not allowing the separation of text. I'll save that > for another day. > > - I thought of creating a widget for the text and placing that over > the image, but I do not know how to make the background of the widget > transparent so that only the text shows. Is this possible? > > - Could just the text be an overlay? And what about considering the problem from an oposite view, i.e. could the image be in the background (and the text in the foreground) ? Answer is yes. You can put your image (pixmap) in the background pixmap of your Drawing Area, just keep a list of (string, position) structure in your program and in the ExposeCallback of your Drawing Area, just draw every string at its corresponding position. i.e. for(i=1, i<nbStrings;i++) XDrawString(display, XtWindow(myDrawingArea), gc, list[i].postion.x, list[i].position.y, list[i].string, strlen(list[i].string) If you need to move or erase a string you can either update your list, clear the entire window (XClearArea(dsp, w, 0, 0, 0, 0, True)) which will generate an expose event and thus call your ExposeCallback which will redraw with your list updated, either just clear the part corresponding to the string your want to erase (nicer, because less flashing, but you need to compute exactly the area you want to clear). You don't need to care about your image, because the server will do this job for you, and if you need to update your image, just XtVaSetValues(myDrawingArea, XmNbackgroundPixmap, myNewImage, NULL); XFreePixmap(dsp, myNewImage); > lr@smec.sony.com > sony medical > montvale,nj > (201)358-4988 Hope this help. Rene Perrier ##################################################################### Rene Perrier e-mail: perrier@cih.hcuge.ch Digital Imaging Group (U.I.N) Computer Science Department (C.I.H) ## ## ### # ## University Hospital of Geneva # # ## # # # 24, rue Micheli-du-Crest ## ## # # # # CH-1211 Geneve 14 # # ## # ## Switzerland ## ## ## # ## tel.: +41-22-3726268 ##### ## ### ## ## # fax : +41-22-3726198 #####################################################################