home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / dragdrop.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.2 KB  |  100 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  
  18.    dragdrop.h --- Very simplistic drag and drop support.
  19.    Created: Terry Weissman <terry@netscape.com>, 22-Aug-95.
  20.  */
  21.  
  22. #ifndef __xfe_dragdrop_h_
  23. #define __xfe_dragdrop_h_
  24.  
  25.  
  26. typedef enum {
  27.   FE_DND_NONE,            /* Deliberate 'no dragging' value. */
  28.   FE_DND_MAIL_MESSAGE,
  29.   FE_DND_MAIL_FOLDER,
  30.   FE_DND_NEWS_MESSAGE,
  31.   FE_DND_NEWS_FOLDER,
  32.   FE_DND_BOOKMARK,
  33.   FE_DND_URL,
  34.   FE_DND_COLUMN,
  35.   FE_DND_ADDRESSBOOK,
  36.   FE_DND_HISTORY,
  37.   FE_DND_LDAP_ENTRY,
  38.   FE_DND_BOOKS_DIRECTORIES
  39. } fe_dnd_Type;
  40.  
  41.  
  42.  
  43. /* Tells a drop site what kind of event is happening to it. _START means that a
  44.    new drag option has appeared.  _DRAG means that it is being moved around.
  45.    _DROP means that it has potentially dropped on this site.  _END means that
  46.    the drag is all done. */
  47. typedef enum {
  48.   FE_DND_START,
  49.   FE_DND_DRAG,
  50.   FE_DND_DROP,
  51.   FE_DND_END
  52. } fe_dnd_Event;
  53.  
  54. typedef struct fe_dnd_Source fe_dnd_Source;
  55.  
  56. /* messages sent from the drop site back to the source. */
  57. typedef enum {
  58.   FE_DND_MESSAGE_COPY,
  59.   FE_DND_MESSAGE_MOVE,
  60.   FE_DND_MESSAGE_DELETE
  61. } fe_dnd_Message;
  62.  
  63. typedef void (*fe_dnd_SourceDropFunc)(fe_dnd_Source *source, fe_dnd_Message, void *closure);
  64.  
  65. struct fe_dnd_Source {
  66.   Widget widget;        /* Toplevel widget to drag around. */
  67.   int hotx;            /* Where in the widget the cursor should */
  68.   int hoty;            /* "stick". */
  69.   fe_dnd_Type type;        /* Type of thing being dragged. */
  70.   void* closure;        /* Type-specific data about the thing being
  71.                    dragged. */
  72.   fe_dnd_SourceDropFunc func;    /* a way for the drop site to tell the source to do some operation. */
  73. };
  74.  
  75.  
  76. typedef void (*fe_dnd_DropFunc)(Widget dropw, void* closure, fe_dnd_Event,
  77.                 fe_dnd_Source*, XEvent* event);
  78.  
  79. XP_BEGIN_PROTOS
  80.  
  81. /* Register the given widget as a drop site. */
  82. extern void fe_dnd_CreateDrop(Widget w, fe_dnd_DropFunc func, void* closure);
  83.  
  84. /* Inform the D&D internals that a drag is starting or dragging or dropping or
  85.    finishing.  This will call the callback functions on all the drop sites,
  86.    which have to decide for themselves if the given drag event applies.  The
  87.    only trimming done is that _DROP events are not given to a widget unless
  88.    the mouse is over that widget.
  89.  
  90.    Note that it is entirely up to the caller to create the source struct before
  91.    calling this, and to destroy the source struct (and its widget) when
  92.    done. */
  93. extern void fe_dnd_DoDrag(fe_dnd_Source* source, XEvent* event,
  94.               fe_dnd_Event type);
  95.  
  96.  
  97. XP_END_PROTOS
  98.  
  99. #endif /* __xfe_dragdrop_h_ */
  100.