KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWDragAndDropTargetSet.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWDragAndDropTargetSet.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWDragAndDropTargetSet - a set of drag and drop targets
15 // .SECTION Description
16 // This class is a container for a set of drag and drop targets.
17 // It provides methods to set drag and drop callbacks between a *single*
18 // source and one or more targets.
19 // This is *not* a general drag and drop framework, where DnD types would
20 // be created and objects would register themselves as source and/or sinks
21 // for any of those types. This is a simpler framework to perform specific
22 // DnD actions between a know source and known targets.
23 // An instance of this class is available in vtkKWWidget and can be used
24 // to register DnD actions between that vtkKWWidget source and some targets.
25 // .SECTION See Also
26 // vtkKWWidget
27 
28 #ifndef __vtkKWDragAndDropTargetSet_h
29 #define __vtkKWDragAndDropTargetSet_h
30 
31 #include "vtkKWObject.h"
32 
33 class vtkKWWidget;
34 class vtkKWDragAndDropTargetSetInternals;
35 
37 {
38 public:
40  vtkTypeRevisionMacro(vtkKWDragAndDropTargetSet,vtkKWObject);
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
43  // Description:
44  // Enable/disable Drag and Drop between all the source and targets.
45  virtual void SetEnable(int);
46  vtkBooleanMacro(Enable, int);
47  vtkGetMacro(Enable, int);
48 
49  // Description:
50  // Set/Get the Drag and Drop source widget. This is the widget that the
51  // the Drag and Drop originates from.
52  // Make sure you have called SetApplication(..) on the instance before.
53  virtual void SetSource(vtkKWWidget*);
54  vtkGetObjectMacro(Source, vtkKWWidget);
55 
56  // Description:
57  // Set/Get the optional Drag and Drop source anchor widget. This is the
58  // actual widget that the user drags and drops (i.e. the actual widget the
59  // user starts the interaction with). It NULL, it defaults to the
60  // Source widget automatically. The anchor widget is a convenient way to
61  // specify that a sub-part of the Source widget is to be dragged & dropped,
62  // not the whole Source widget.
63  // Make sure you have called SetApplication(..) on the instance before.
64  virtual void SetSourceAnchor(vtkKWWidget*);
65  vtkGetObjectMacro(SourceAnchor, vtkKWWidget);
66 
67  // Description:
68  // Add/Query/Remove a Drag & Drop target.
69  virtual int AddTarget(vtkKWWidget *target);
70  virtual int RemoveTarget(vtkKWWidget *target);
71  virtual int HasTarget(vtkKWWidget *target);
72  virtual int GetNumberOfTargets();
73 
74  // Description:
75  // Set a Drag & Drop target callbacks/commands.
76  // If the target has not been added yet, it will be added automatically.
77  // The StartCommand of all targets is called when Drag & Drop starts.
78  // The PerformCommand of all targets is called while Drag & Drop is
79  // performed.
80  // The EndCommand of all targets that contain the drop coordinates is called
81  // when Drag & Drop ends.
82  // The 'object' argument is the object that will have the method called on
83  // it. The 'method' argument is the name of the method to be called and any
84  // arguments in string form. If the object is NULL, the method is still
85  // evaluated as a simple command.
86  // The following parameters are also passed to the commands:
87  // - absolute/screen (x,y) mouse coordinates: int, int
88  // - the Source widget: vtkKWWidget*
89  // - the SourceAnchor widget: vtkKWWidget* (same as Source widget most of
90  // the times)
91  // Additionally, EndCommand is passed a 5th parameter:
92  // - the target: vtkKWWidget*
93  virtual int SetTargetStartCommand(
94  vtkKWWidget *target, vtkObject *object, const char *method);
95  virtual int SetTargetPerformCommand(
96  vtkKWWidget *target, vtkObject *object, const char *method);
97  virtual int SetTargetEndCommand(
98  vtkKWWidget *target, vtkObject *object, const char *method);
99 
100  // Description:
101  // Independent of any targets, the following commands can be set:
102  // The StartCommand is called when Drag & Drop starts.
103  // The PerformCommand is called while Drag & Drop is performed.
104  // The EndCommand is called when Drag & Drop ends.
105  // The 'object' argument is the object that will have the method called on
106  // it. The 'method' argument is the name of the method to be called and any
107  // arguments in string form. If the object is NULL, the method is still
108  // evaluated as a simple command.
109  // The following parameters are also passed to the commands:
110  // - absolute/screen (x,y) mouse coordinates: int, int
111  // None of them is called if Enable is false.
112  // StartCommand and PerformCommand are called *before* any target's
113  // corresponding command. EndCommand is called *after* any target's
114  // EndCommand.
115  virtual void SetStartCommand(vtkObject *object, const char *method);
116  virtual void SetPerformCommand(vtkObject *object, const char *method);
117  virtual void SetEndCommand(vtkObject *object, const char *method);
118 
119  // Description:
120  // Callbacks. Internal, do not use.
121  virtual void StartCallback(int x, int y);
122  virtual void PerformCallback(int x, int y);
123  virtual void EndCallback(int x, int y);
124 
125 protected:
128 
129  // Drag and Drop
130 
131  //BTX
132 
134  {
135  public:
139  char *EndCommand;
140 
141  void SetStartCommand(const char*);
142  void SetEndCommand(const char*);
143  void SetPerformCommand(const char*);
144 
145  TargetSlot();
146  ~TargetSlot();
147  };
148 
149  // PIMPL Encapsulation for STL containers
150 
151  vtkKWDragAndDropTargetSetInternals *Internals;
152  friend class vtkKWDragAndDropTargetSetInternals;
153 
154  TargetSlot* GetTarget(vtkKWWidget *target);
155 
156  //ETX
157 
158  int Enable;
159 
162 
165  char *EndCommand;
166  virtual void InvokeCommandWithCoordinates(const char *command, int x, int y);
167  virtual void InvokeStartCommand(int x, int y);
168  virtual void InvokePerformCommand(int x, int y);
169  virtual void InvokeEndCommand(int x, int y);
170 
171  virtual void AddBindings();
172  virtual void RemoveBindings();
173  virtual void DeleteAllTargets();
174 
175 private:
176 
177  vtkKWDragAndDropTargetSet(const vtkKWDragAndDropTargetSet&); // Not implemented
178  void operator=(const vtkKWDragAndDropTargetSet&); // Not implemented
179 };
180 
181 #endif