home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / HORIZ_DR.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  6.7 KB  |  175 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. import sub_arctic.lib.sub_arctic_error;
  5. import sub_arctic.output.loaded_image;
  6. import sub_arctic.output.drawable;
  7. import sub_arctic.input.pressable;
  8. import sub_arctic.input.move_draggable;
  9. import sub_arctic.input.event;
  10. import sub_arctic.input.user_info_holder;
  11. import sub_arctic.input.pick_collector;
  12. import sub_arctic.input.callback_object;
  13. import java.awt.Point;
  14.  
  15. /** 
  16.  * This class provides a container for dragging that is limited to changes
  17.  * in x only.  You can put any subtree inside it to make that subtree 
  18.  * draggable.  The container handles the pick process correctly so that it 
  19.  * only initiates a drag if you actually click over an object inside the an 
  20.  * object in the sub-tree (not simply anywhere inside the bounds of the 
  21.  * container).  The container will "shrink-wrap" around the objects it 
  22.  * contains, and can optionally draw a bounding rectangle as drag feedback.
  23.  *
  24.  * @author Scott Hudson
  25.  */
  26. public class horiz_drag_container extends drag_container {
  27.  
  28.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  29.  
  30.   /** 
  31.    * Full constructor.  
  32.    *
  33.    * @param int             x              initial x position of the container.
  34.    * @param int             y              initial y position of the container.
  35.    * @param boolean         do_bb_feedback whether we do bounding box feedback.
  36.    * @param callback_object cbo            object to make callbacks to.
  37.    */
  38.   public horiz_drag_container(
  39.     int x, int y, boolean do_bb_feedback, callback_object cbo) 
  40. {
  41.       super(x,y,do_bb_feedback,cbo);
  42.     }
  43.  
  44.    //had:
  45.    //* @exception general
  46.  
  47.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  48.  
  49.   /** 
  50.    * Nearly full constructor.  This provides a null callback.
  51.    *
  52.    * @param int     x              initial x position of the container.
  53.    * @param int     y              initial y position of the container.
  54.    * @param boolean do_bb_feedback whether we do bounding box feedback.
  55.    */
  56.   public horiz_drag_container(int x, int y, boolean do_bb_feedback) 
  57. {
  58.       super(x,y,do_bb_feedback);
  59.     }
  60.  
  61.    //had:
  62.    //* @exception general
  63.  
  64.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  65.  
  66.   /** 
  67.    * Handle the start of a drag to the object.  
  68.    * @param event evt   the event "causing" the start of the drag.
  69.    * @param int    x_pos     x position of new position (in parent's coords).
  70.    * @param int    y_pos     y position of new position (in parent's coords).
  71.    * @param int    grab_x    x position where we started the drag (in local 
  72.    *                         coords).
  73.    * @param int    grab_y    y position where we started the drag (in local 
  74.    *                         coords).
  75.    * @param Object user_info information provided when this object requested 
  76.    *                         focus.
  77.    * @return boolean indicating whether the input was consumed (in this case it
  78.    *                 always is).
  79.    */
  80.   public boolean drag_start(
  81.     event evt, 
  82.     int x_pos, int y_pos, 
  83.     int grab_x, int grab_y, 
  84.     Object user_info)
  85.     {
  86.       /* modify the move so there is no y component, then let super class go */
  87.       return super.drag_start(evt, x_pos, y(), grab_x, grab_y, user_info);
  88.     }
  89.  
  90.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  91.  
  92.   /** 
  93.    * Handle a movement during a drag.  Here we just set our position to 
  94.    * follow the event location and do the move callback. 
  95.    *
  96.    * @param event evt   the event "causing" the start of the drag.
  97.    * @param int    x_pos     x position of new position (in parent's coords).
  98.    * @param int    y_pos     y position of new position (in parent's coords).
  99.    * @param int    start_x   x position where we started the drag (in parent's
  100.    *                         coords).
  101.    * @param int    start_y   y position where we started the drag (in parent's
  102.    *                         coords).
  103.    * @param int    grab_x    x position where we started the grab (in local 
  104.    *                         coords).
  105.    * @param int    grab_y    y position where we started the grab (in local 
  106.    *                         coords).
  107.    * @param Object user_info information provided when this object requested 
  108.    *                         focus.
  109.    * @return boolean indicating whether the input was consumed (in this case it
  110.    *                 always is).
  111.    */
  112.   public boolean drag_feedback(
  113.     event evt, 
  114.     int x_pos, int y_pos, 
  115.     int st_x, int st_y, 
  116.     int grab_x, int grab_y, 
  117.     Object user_info)
  118.     {
  119.       /* modify the move so there is no y component, then let super class go */
  120.       return super.drag_feedback(evt, x_pos, y(), st_x, st_y, grab_x, grab_y, 
  121.                                    user_info);
  122.     }
  123.  
  124.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  125.  
  126.   /** 
  127.    * Handle input corresponding to the end of a drag.  
  128.    *
  129.    * @param event evt   the event "causing" the start of the drag.
  130.    * @param int    x_pos     x position of new position (in parent's coords).
  131.    * @param int    y_pos     y position of new position (in parent's coords).
  132.    * @param int    start_x   x position where we started the drag (in parent's
  133.    *                         coords).
  134.    * @param int    start_y   y position where we started the drag (in parent's
  135.    *                         coords).
  136.    * @param int    grab_x    x position where we started the grab (in local 
  137.    *                         coords).
  138.    * @param int    grab_y    y position where we started the grab (in local 
  139.    *                         coords).
  140.    * @param Object user_info information provided when this object requested 
  141.    *                         focus.
  142.    * @return boolean indicating whether the input was consumed (in this case it
  143.    *                 always is).
  144.    */
  145.   public boolean drag_end(
  146.     event evt, 
  147.     int x_pos, int y_pos, 
  148.     int st_x, int st_y, 
  149.     int grab_x, int grab_y, 
  150.     Object user_info)
  151.     {
  152.       /* modify the move so there is no y component, then let super class go */
  153.       return super.drag_end(evt, x_pos, y(), st_x, st_y, grab_x, grab_y, 
  154.                                    user_info);
  155.     }
  156.  
  157.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  158. }
  159. /*=========================== COPYRIGHT NOTICE ===========================
  160.  
  161. This file is part of the subArctic user interface toolkit.
  162.  
  163. Copyright (c) 1996 Scott Hudson and Ian Smith
  164. All rights reserved.
  165.  
  166. The subArctic system is freely available for most uses under the terms
  167. and conditions described in 
  168.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  169. and appearing in full in the lib/interactor.java source file.
  170.  
  171. The current release and additional information about this software can be 
  172. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  173.  
  174. ========================================================================*/
  175.