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

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!att-out!cbfsb!mmc
  3. From: mmc@att.com (Michael J. McLennan)
  4. Subject: New "drag&drop" facility for TCL/Tk
  5. Message-ID: <1992Nov18.204441.24601@cbfsb.cb.att.com>
  6. Originator: news@cbnewsg.cb.att.com
  7. Sender: news@cbfsb.cb.att.com
  8. Nntp-Posting-Host: gewurtz.cnet.att.com
  9. Reply-To: michael.mclennan@att.com
  10. Organization: AT&T Bell Laboratories
  11. X-Newsreader: TIN [version 1.1 PL6]
  12. Date: Wed, 18 Nov 1992 20:44:41 GMT
  13. Lines: 177
  14.  
  15. All of the recent discussion about a drag-and-drop facility for TCL/Tk
  16. prompted me to polish up a facility that I developed a little while
  17. back.  It is now publicly available on barkley.berkeley.edu in the
  18. usual tcl/extensions directory.
  19.  
  20. This facility was not meant to imitate or integrate with any existing
  21. drag-and-drop protocol (so spare me your flames!).  Rather, it was
  22. designed in the mindset of TCL/Tk.  Any of the usual Tk widgets can
  23. be registered as sources or targets for drag-and-drop, and TCL commands
  24. are used to implement the transfer and interpretation of data.
  25.  
  26. When I originally started working on it, I imagined that it would be
  27. useful for transferring data between applications.  Since I started
  28. playing around with it, however, I see much more potential for transfers
  29. within a single application--just dragging a list item into an entry
  30. widget, or dragging the value from one scale widget to another.
  31.  
  32. Following is the README giving more detailed information...
  33.  
  34. Enjoy!
  35. --Michael
  36.  
  37. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38.  Michael J. McLennan 2C-226    [   [ [   [  [[   E-mail: alux2!mmc@att.com
  39.  AT&T Bell Laboratories        [[ [[ [[ [[ [      Phone: (215) 770-2842
  40.  1247 S Cedar Crest Blvd    [[ [ [ [ [ [ [  [[[     FAX: (215) 770-3843
  41.  Allentown, PA  18103          [   [ [   [       
  42. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  43.  
  44. ------------------------------------------------------------------------
  45.   Version 1.0 of the drag&drop facility has been made available for
  46.   anonymous ftp:
  47.    
  48.       SOURCE: barkley.berkeley.edu [128.32.142.237]
  49.         FILE: pub/tcl/extensions/dragdrop-1.0.tar.Z
  50.  
  51.   Please send comments or suggestions to michael.mclennan@att.com.
  52. ------------------------------------------------------------------------
  53.  
  54. ========================================================================
  55.                 Copyright 1992 by AT&T Bell Laboratories
  56. ========================================================================
  57. Permission to use, copy, modify, and distribute this software and its
  58. documentation for any purpose and without fee is hereby granted,
  59. provided that the above copyright notice appear in all copies and that
  60. both that the copyright notice and warranty disclaimer appear in
  61. supporting documentation, and that the names of AT&T Bell Laboratories
  62. any of their entities not be used in advertising or publicity
  63. pertaining to distribution of the software without specific, written
  64. prior permission.
  65.  
  66. AT&T disclaims all warranties with regard to this software, including
  67. all implied warranties of merchantability and fitness.  In no event
  68. shall AT&T be liable for any special, indirect or consequential
  69. damages or any damages whatsoever resulting from loss of use, data or
  70. profits, whether in an action of contract, negligence or other
  71. tortuous action, arising out of or in connection with the use or
  72. performance of this software.
  73. ========================================================================
  74.  
  75.  
  76. Implementation Notes:
  77.  
  78. This drag&drop facility provides a graphical paradigm for coordinating
  79. "send" commands between related TCL/Tk applications.  It was written
  80. to operate in the spirit of TCL/Tk, and not necessarily to imitate
  81. other drag-and-drop protocols.
  82.  
  83.  
  84. GETTING THE DISTRIBUTION:
  85.  
  86.  - FTP the distribution from barkley.berkeley.edu:
  87.  
  88.      ftp barkley.berkeley.edu
  89.      cd
  90.      binary
  91.      get dragdrop-1.0.tar.Z
  92.      quit
  93.  
  94.  - untar the distribution file:
  95.  
  96.      zcat dragdrop-1.0.tar.Z | tar -xvf -
  97.  
  98. This will create a directory "dragdrop-1.0" with the subdirectory
  99. "demos".
  100.  
  101.  
  102. MAKING A NEW WISH:
  103.  
  104. Update the first few lines of the given Makefile to use the proper
  105. paths for your local installation of TCL/Tk.  Note that the Makefile
  106. references the source directories for TCL/Tk, as well as the usual
  107. libraries.  Build a new wish (called "dish" to avoid any conflict
  108. with your usual wish) that will contain the drag&drop facility:
  109.  
  110.     make
  111.  
  112.  
  113. UPDATING YOUR APPLICATION:
  114.  
  115. To add this facility to your application, simply add the following
  116. command when initializing new interpreters:
  117.  
  118.     extern void Tk_AddDragDropCmd
  119.         _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin));
  120.  
  121.     main(argc,argv)
  122.         int argc;
  123.         char **argv;
  124.     {
  125.         Tcl_Interp *interp;  /* main interpreter */
  126.         Tk_Window w;         /* main application window */
  127.  
  128.         interp = Tcl_CreateInterp();
  129.             .
  130.             .  usual set-up stuff
  131.             .
  132.         w = Tk_CreateMainWindow(interp, display, name);
  133.             .
  134.             .  usual set-up stuff
  135.             .
  136.         Tk_AddDragDropCmd(interp,w);
  137.  
  138.             .
  139.             .  finish set-up and enter main loop
  140.             .
  141.     }
  142.  
  143. The usual "main.c" file used for wish has been updated with these
  144. changes, and is included in this distribution.
  145.  
  146.  
  147. RUNNING THE DEMO:
  148.  
  149. The "palette" demo provided in the "demos" directory illustrates the
  150. basic concepts of the drag&drop facility.  You may drag and drop
  151. between the widgets of a single application, or between multiple
  152. palette applications.  Once you have created the "dish" application
  153. which recognizes the drag&drop command, you can invoke the palette
  154. application as:
  155.  
  156.     dish -f demos/palette
  157.  
  158. This brings up a window with three sliders controlling the RGB values
  159. of a sample color; as you move the sliders, the color sample changes.
  160.  
  161.   - If you click with the third mouse button on one of the sliders,
  162.     a token window with the numerical value of the slider will appear.
  163.     This token window can then be "dropped" on another slider (or on
  164.     the color sample next to the slider) to change its value.
  165.  
  166.   - If you click with the third mouse button on the color sample, a
  167.     token window with the color value will appear.  This color can
  168.     be dropped on the "Foreground" and "Background" targets to change
  169.     the color scheme for the entire application.  It can also be
  170.     dropped on the color sample in another application to transfer
  171.     the RGB values.  Finally, it can be dropped on a slider (or on
  172.     the color sample next to the slider); in this case, the appropriate
  173.     color component (red, green, or blue) is extracted from the color
  174.     and used to set the slider value.
  175.  
  176.   - If you try to drop a number value (from the slider) on the
  177.     "Foreground" or "Background" targets, it will be rejected.
  178.  
  179. Notice that a particular widget can be configured to handle more than
  180. one kind of data.  For instance, the slider (and its associated
  181. color sample) will accept either a number value or a color value.
  182.  
  183. Notice also that a single kind of data can be handled differently by
  184. different targets.  A single mechanism is used to transmit RGB color
  185. values, for example, but the "Foreground" and "Background" targets
  186. do very different things with the data.
  187.  
  188. Please experiment with this facility and send me your comments.
  189.  
  190. --Michael
  191. ------------------------------------------------------------------------
  192.