home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WDRAG.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  7KB  |  267 lines

  1.  
  2. #ifndef _WDRAG_HPP_INCLUDED
  3. #define _WDRAG_HPP_INCLUDED
  4.  
  5. #ifndef _WNO_PRAGMA_PUSH
  6. #pragma pack(push,8);
  7. #pragma enum int;
  8. #endif
  9.  
  10. #ifndef _WPOINT_HPP_INCLUDED
  11. #   include "wpoint.hpp"
  12. #endif
  13. #ifndef _WEVENTD_HPP_INCLUDED
  14. #   include "weventd.hpp"
  15. #endif
  16. #ifndef _WSTRING_HPP_INCLUDED
  17. #   include "wstring.hpp"
  18. #endif
  19. #ifndef _WIMAGELIST_HPP_INCLUDED
  20. #   include "wimglist.hpp"
  21. #endif
  22.  
  23. class WImageList;
  24. class WWindow;
  25. class WDragInfo;
  26.  
  27. struct _wWPIUnknown;
  28. struct _wWPIDataObject;
  29.  
  30. //
  31. // WDragInfo -- This class is used for very fine control over
  32. //              drag and drop.
  33. //
  34.  
  35. class WCMCLASS WDragInfo {
  36.  
  37.   public:
  38.  
  39.         // Number of bytes in structure
  40.     
  41.         WUShort         cb;
  42.  
  43.         // If TRUE, we are in an OLE drag
  44.  
  45.         WBool           isOleDrag;
  46.  
  47.         // Pointers to the OLE objects
  48.  
  49.         const _wWPIUnknown      *oleSourceObject;
  50.         const _wWPIDataObject   *oleDataObject;
  51.  
  52.         // Feedback data
  53.         WBool           drawFeedback;
  54.         WPoint          pickPoint;
  55.         WPoint          size;
  56.  
  57.         // The drop effect as defined by the target
  58.  
  59.         WULong          dropEffect;
  60.  
  61.         // Was the escape key pressed?
  62.  
  63.         WBool           escapePressed;
  64.  
  65.         // Starting key/button state
  66.  
  67.         WULong          kbOldState;
  68.  
  69.         // Current key/button state
  70.  
  71.         WULong          kbState;
  72.  
  73.         // ItemID
  74.  
  75.         WULong          itemID;
  76.  
  77.         // Mouse positions (in absolute coordinates)
  78.  
  79.         WPoint          startPosition;    // where drag started
  80.         WPoint          currentPosition;  
  81.  
  82.         // Current drop target's window handle
  83.  
  84.         WWindow        *dragTarget;
  85.         WWindowHandle   dragTargetWindow;
  86.  
  87.         // Where the drag started
  88.  
  89.         WWindow        *dragSource;       // where drag started
  90.         WWindowHandle   dragSourceWindow;
  91.  
  92.         // User-defined data
  93.  
  94.         void           *userData;         // user-defined data
  95.  
  96.         // Imagelist to use
  97.  
  98.         WImageList     *imageList;
  99.         void           *imageData;        // reserved
  100.         WPoint          hotSpot;          // hotspot for the image
  101.         WBool           deleteImageList;  // delete when done?
  102.  
  103.   public:
  104.  
  105.         /************************************************************
  106.          * Methods
  107.          ************************************************************/
  108.  
  109.         // Prepare structure for non-OLE drag
  110.  
  111.         void Initialize( WWindow *drgsrc );
  112.  
  113.         // Update state
  114.  
  115.         void Update();
  116.  
  117.         // Prepare the image list
  118.  
  119.         WBool PrepareImageList();
  120.  
  121.         /************************************************************
  122.          * Constructors and destructors
  123.          ************************************************************/
  124.  
  125.         WDragInfo();
  126.  
  127.         ~WDragInfo();
  128. };
  129.  
  130. /* Define the various drag effects */
  131.  
  132. #define WDROPEFFECT_NONE    0x00000000
  133. #define WDROPEFFECT_COPY    0x00000001
  134. #define WDROPEFFECT_MOVE    0x00000002
  135. #define WDROPEFFECT_LINK    0x00000004
  136.  
  137. #define WDROPEFFECT_ALL     (WDROPEFFECT_COPY|WDROPEFFECT_MOVE|\
  138.                              WDROPEFFECT_LINK)
  139.  
  140. #define WDROPEFFECT_SCROLL  0x80000000
  141.  
  142. typedef unsigned long WDropEffect;
  143.  
  144. //
  145. // Event structures
  146. //
  147.  
  148. struct WCMCLASS WDragEventData : public WEventData {
  149.     WDragInfo    *draginfo;      // advanced information
  150.     WBool         delDragInfo;   // delete it or not...
  151.  
  152.     WString       tag;           // string that identifies the drag
  153.     WStringArray  strings;       // list of strings
  154.     WULongArray   items;         // list of values
  155.  
  156.     WImageList    images;        // images to display when dragging
  157.     WPoint        startPoint;    // starting x,y (screen)
  158.     WPoint        currentPoint;  // current x,y (screen)
  159.     WObject      *source;        // pointer to source object
  160.     WDropEffect   sourceOps;     // allowable op(s) from the source
  161.     WDropEffect   targetOps;     // what the target can accept
  162.     WDropEffect   currentOp;     // the current operation
  163.     WDWord        button;        // which button was pressed
  164.     WBool         escapePressed; // TRUE if user pressed escape
  165.  
  166.     void         *userData;      // user-defined data
  167.  
  168.     WDragEventData();
  169.  
  170.     ~WDragEventData();
  171. };
  172.  
  173. typedef WDragEventData WDragContinueEventData;
  174. typedef WDragEventData WDragFeedbackEventData;
  175. typedef WDragEventData WDragEnterEventData;
  176. typedef WDragEventData WDragOverEventData;
  177. typedef WDragEventData WDragLeaveEventData;
  178. typedef WDragEventData WDragDropEventData;
  179. typedef WDragEventData WDragScrollEventData;
  180.  
  181. typedef WULong WDragResult;
  182.  
  183. /* General errors */
  184.  
  185. #define WDRAG_E_OUTOFMEMORY              0x8007000EL
  186. #define WDRAG_E_INVALIDARG               0x80070057L
  187. #define WDRAG_E_UNEXPECTED               0x8000FFFFL
  188.  
  189. /* Return this from OnDragStart to let WClass to the dragging */
  190.  
  191. #define WDRAG_DEFAULT_START              0x00000001L
  192.  
  193. /* Return this from OnDragStart if you handled the drag */
  194.  
  195. #define WDRAG_HANDLED_START              0x00000002L
  196.  
  197. /* Return this from OnDragStart if the parent should handle things */
  198.  
  199. #define WDRAG_PARENT_START               0x00000004L
  200.  
  201. /* Return this from OnDragFeedback for default behaviour */
  202.  
  203. #define WDRAG_DEFAULT_FEEDBACK           0x00040102L
  204.  
  205. /* Return this from OnDragFeedback if you handled pointer setting */
  206.  
  207. #define WDRAG_HANDLED_FEEDBACK          (0x00000000L)
  208.  
  209. /* Return this from OnDragContinue if the drag should continue */
  210.  
  211. #define WDRAG_CONTINUE_DRAG             (0x00000000L)
  212.  
  213. /* Return this from OnDragContinue if a drop should occur */
  214.  
  215. #define WDRAG_DROP                       0x00040100L
  216.  
  217. /* Return this from OnDragContinue/OnDragStart to cancel the drag without dropping */
  218.  
  219. #define WDRAG_CANCEL_DRAG                0x00040101L
  220.  
  221.  
  222. /* Define the cursors */
  223.  
  224. enum WOleCursorID {
  225.     WOLE_CURCOPY,
  226.     WOLE_CURLINK,
  227.     WOLE_CURMOVE,
  228.     WOLE_CURNONE,
  229. };
  230.  
  231. /* Define identifiers for the mouse/key states */
  232.  
  233. #define WMK_NONE     0x0000
  234. #define WMK_LBUTTON  0x0001
  235. #define WMK_RBUTTON  0x0002
  236. #define WMK_SHIFT    0x0004
  237. #define WMK_CONTROL  0x0008
  238. #define WMK_MBUTTON  0x0010
  239. #define WMK_ALT      0x0020
  240.  
  241. /* Define the size of the edge zone for scrolling, in pixels */
  242.  
  243. #define WDD_DEFSCROLLINSET          11
  244.  
  245. /* Delay before scrolling begins, milliseconds */
  246.  
  247. #define WDD_DEFSCROLLDELAY          50
  248.  
  249. /* Scrolling interval, milliseconds */
  250.  
  251. #define WDD_DEFSCROLLINTERVAL       50
  252.  
  253. /* Delay before dragging starts, milliseconds */
  254.  
  255. #define WDD_DEFDRAGDELAY            200
  256.  
  257. /* Minimum distance before dragging starts, pixels */
  258.  
  259. #define WDD_DEFDRAGMINDIST          2
  260.  
  261. #ifndef _WNO_PRAGMA_PUSH
  262. #pragma enum pop;
  263. #pragma pack(pop);
  264. #endif
  265.  
  266. #endif // _WDRAG_HPP_INCLUDED
  267.