home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / tcl / 1883 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.7 KB  |  43 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!caen!spencer
  3. From: spencer@med.umich.edu (Spencer W. Thomas)
  4. Subject: Re: Scrollable buttons?
  5. Message-ID: <SPENCER.92Nov19031842@guraldi.med.umich.edu>
  6. Date: Thu, 19 Nov 92 03:18:42 EST
  7. Organization: University of Michigan
  8. In-Reply-To: trones@dxcern.cern.ch's message of Tue, 17 Nov 1992 10:26:54 GMT
  9. References: <1992Nov17.102654.15449@dxcern.cern.ch>
  10. Nntp-Posting-Host: guraldi.itn.med.umich.edu
  11. Lines: 30
  12.  
  13. I'm putting windows on (in?) a canvas for an application I'm writing.
  14. It's not trivial, but it's not too hard, either.  
  15.  
  16. - Use winfo reqheight/reqwidth to figure out how big the window will
  17.   be.  Then you can use whatever placement algorithm you want.  I just
  18.   place my windows in rows, with a "return" whenever a window
  19.   threatens to overrun the (current) right edge of the canvas (as
  20.   determined by 'winfo width <canvas>').
  21.  
  22. - After placing all the windows, make sure the scrolling region is big
  23.   enough. 
  24.  
  25. - All events inside the window go to the window, NOT the canvas.  This
  26.   is a pain if you want to be able to drag the windows.  I use code
  27.   like this:
  28.  
  29.     bind $w <3> "itemStartDrag $theCanvas \[expr %x+\[winfo x $w]]\
  30.                     \[expr %y+\[winfo y $w]]";
  31.     bind $w <B3-Motion> "itemDrag $theCanvas \
  32.                     \[expr %x+\[winfo x $w]]\
  33.                     \[expr %y+\[winfo y $w]] $tag";
  34.     bind $f <Any-Enter> "itemEnter $theCanvas $field";
  35.     bind $f <Any-Leave> "itemLeave $theCanvas";
  36.   where $w is the window name, and $tag is a tag for the window.
  37.   itemEnter for a window "raises" it (in relief).
  38.  
  39. --
  40. =Spencer W. Thomas         |  Info Tech and Networking, B1911 CFOB, 0704
  41.    "Genome Informatician"    |  Univ of Michigan, Ann Arbor, MI 48109
  42. Spencer.W.Thomas@med.umich.edu    |  313-747-2778, FAX 313-764-4133
  43.