home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / motif / 5853 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  3.2 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!chx400!news.unige.ch!ugun2b!cui.unige.ch!perrier
  2. Newsgroups: comp.windows.x.motif
  3. Subject: Re: Text manipulation in a Drawing Area
  4. Message-ID: <1992Aug27.092831.19156@uni2b.unige.ch>
  5. From: perrier@cih.hcuge.ch (Perrier Rene)
  6. Date: 27 Aug 92 09:28:30 +0200
  7. Sender: perrier@cui.unige.ch (Perrier Rene)
  8. References: <9208260306.AA01932@laurie.smec.sony.com>
  9. Distribution: inet
  10. Organization: University Hospital of Geneva, Switzerland
  11. Nntp-Posting-Host: cuisund.unige.ch
  12. Lines: 54
  13.  
  14. In article <9208260306.AA01932@laurie.smec.sony.com>, lr@laurie.smec.Sony.COM writes:
  15. > I am new to Motif programming, and am trying to test different
  16. > possible applications.  One application is annotation of images.
  17. > I would like to be able to place a line of text on an image.  I
  18. > would then like to be able to select that text and move it to a 
  19. > different location.  I would be satisfied in keeping the line(s)
  20. > together and not allowing the separation of text.  I'll save that
  21. > for another day.
  22. >  - I thought of creating a widget for the text and placing that over
  23. > the image, but I do not know how to make the background of the widget
  24. > transparent so that only the text shows.  Is this possible?
  25. >  - Could just the text be an overlay? 
  26. And what about considering the problem from an oposite view, i.e. could the
  27. image be in the background (and the text in the foreground) ?
  28.  
  29. Answer is yes. You can put your image (pixmap) in the background pixmap of
  30. your Drawing Area, just keep a list of (string, position) structure in your
  31. program and in the ExposeCallback of your Drawing Area, just draw every string
  32. at its corresponding position. i.e.
  33.  
  34. for(i=1, i<nbStrings;i++)
  35.   XDrawString(display, XtWindow(myDrawingArea), gc, list[i].postion.x,
  36.               list[i].position.y, list[i].string, strlen(list[i].string)
  37.  
  38. 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).
  39.  
  40. You don't need to care about your image, because the server will do this job for
  41. you, and if you need to update your image, just
  42.  
  43. XtVaSetValues(myDrawingArea, XmNbackgroundPixmap, myNewImage, NULL);
  44. XFreePixmap(dsp, myNewImage);
  45.  
  46.  
  47. > lr@smec.sony.com
  48. > sony medical
  49. > montvale,nj
  50. > (201)358-4988
  51.  
  52. Hope this help.
  53.             Rene Perrier
  54.  
  55. #####################################################################
  56. Rene Perrier                             e-mail: perrier@cih.hcuge.ch
  57. Digital Imaging Group (U.I.N)
  58. Computer Science Department (C.I.H)     ##   ##      ###       #   ##
  59. University Hospital of Geneva            #   #       ##       # #  #
  60. 24, rue Micheli-du-Crest                ##  ##       #        # # #
  61. CH-1211 Geneve 14                       #   #       ##       #  ##
  62. Switzerland                            ##  ##      ##       #   ##
  63. tel.: +41-22-3726268                   #####  ##  ###  ##  ##   #
  64. fax : +41-22-3726198
  65. #####################################################################
  66.