home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Icon / c / StartDrag < prev    next >
Encoding:
Text File  |  1993-04-11  |  1.7 KB  |  54 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Icon.StartDrag.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (31 Mar 1992)
  14.     Purpose: Starts the drag operation of any icon (i.e. file icon)
  15. */
  16.  
  17.  
  18. #include "Wimp.h"
  19. #include "WimpSWIS.h"
  20. #include "Screen.h"
  21.  
  22.  
  23. /*  Note: Use Icon_StartSolidDrag() or DragASprite_DragIcon() to start
  24.  *  dragging an icon with DragASprite
  25.  */
  26.  
  27. extern void Icon_StartDrag(window_handle window, icon_handle icon)
  28. {
  29.   icon_block   istate;
  30.   window_state wstate;
  31.   drag_block   drag;
  32.   int          left, top;
  33.  
  34.   Wimp_GetWindowState(window, &wstate);
  35.   Wimp_GetIconState(window, icon, &istate);
  36.   left = wstate.openblock.screenrect.min.x - wstate.openblock.scroll.x;
  37.   top  = wstate.openblock.screenrect.max.y - wstate.openblock.scroll.y;
  38.  
  39.   drag.window = window;
  40.   drag.type   = drag_FIXEDBOX;
  41.  
  42.   drag.screenrect.min.x = left + istate.workarearect.min.x;
  43.   drag.screenrect.max.x = left + istate.workarearect.max.x;
  44.   drag.screenrect.min.y = top  + istate.workarearect.min.y;
  45.   drag.screenrect.max.y = top  + istate.workarearect.max.y;
  46.  
  47.   Screen_CacheModeInfo();
  48.   drag.parent.min.x = 0;
  49.   drag.parent.min.y = 0;
  50.   drag.parent.max   = screen_size;
  51.  
  52.   Wimp_DragBox(&drag);
  53. }
  54.