• Main Page
  • Classes
  • Files
  • Directories
  • File List
  • File Members

vtkKWDragAndDropTargetSet.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWDragAndDropTargetSet.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 // .NAME vtkKWDragAndDropTargetSet - a set of drag and drop targets
00015 // .SECTION Description
00016 // This class is a container for a set of drag and drop targets.
00017 // It provides methods to set drag and drop callbacks between a *single*
00018 // source and one or more targets. 
00019 // This is *not* a general drag and drop framework, where DnD types would
00020 // be created and objects would register themselves as source and/or sinks
00021 // for any of those types. This is a simpler framework to perform specific
00022 // DnD actions between a know source and known targets.
00023 // An instance of this class is available in vtkKWWidget and can be used
00024 // to register DnD actions between that vtkKWWidget source and some targets.
00025 // .SECTION See Also
00026 // vtkKWWidget
00027 
00028 #ifndef __vtkKWDragAndDropTargetSet_h
00029 #define __vtkKWDragAndDropTargetSet_h
00030 
00031 #include "vtkKWObject.h"
00032 
00033 class vtkKWWidget;
00034 class vtkKWDragAndDropTargetSetInternals;
00035 
00036 class KWWidgets_EXPORT vtkKWDragAndDropTargetSet : public vtkKWObject
00037 {
00038 public:
00039   static vtkKWDragAndDropTargetSet* New();
00040   vtkTypeRevisionMacro(vtkKWDragAndDropTargetSet,vtkKWObject);
00041   void PrintSelf(ostream& os, vtkIndent indent);
00042 
00043   // Description:
00044   // Enable/disable Drag and Drop between all the source and targets.
00045   virtual void SetEnable(int);
00046   vtkBooleanMacro(Enable, int);
00047   vtkGetMacro(Enable, int);
00048 
00049   // Description:
00050   // Set/Get the Drag and Drop source widget. This is the widget that the
00051   // the Drag and Drop originates from.
00052   // Make sure you have called SetApplication(..) on the instance before.
00053   virtual void SetSource(vtkKWWidget*);
00054   vtkGetObjectMacro(Source, vtkKWWidget);
00055 
00056   // Description:
00057   // Set/Get the optional Drag and Drop source anchor widget. This is the 
00058   // actual widget that the user drags and drops (i.e. the actual widget the
00059   // user starts the interaction with). It NULL, it defaults to the
00060   // Source widget automatically. The anchor widget is a convenient way to 
00061   // specify that a sub-part of the Source widget is to be dragged & dropped, 
00062   // not the whole Source widget. 
00063   // Make sure you have called SetApplication(..) on the instance before.
00064   virtual void SetSourceAnchor(vtkKWWidget*);
00065   vtkGetObjectMacro(SourceAnchor, vtkKWWidget);
00066 
00067   // Description:
00068   // Add/Query/Remove a Drag & Drop target. 
00069   virtual int AddTarget(vtkKWWidget *target);
00070   virtual int RemoveTarget(vtkKWWidget *target);
00071   virtual int HasTarget(vtkKWWidget *target);
00072   virtual int GetNumberOfTargets();
00073 
00074   // Description:
00075   // Set a Drag & Drop target callbacks/commands.
00076   // If the target has not been added yet, it will be added automatically.
00077   // The StartCommand of all targets is called when Drag & Drop starts.
00078   // The PerformCommand of all targets is called while Drag & Drop is 
00079   // performed.
00080   // The EndCommand of all targets that contain the drop coordinates is called
00081   // when Drag & Drop ends.
00082   // The 'object' argument is the object that will have the method called on
00083   // it. The 'method' argument is the name of the method to be called and any
00084   // arguments in string form. If the object is NULL, the method is still
00085   // evaluated as a simple command. 
00086   // The following parameters are also passed to the commands:
00087   // - absolute/screen (x,y) mouse coordinates: int, int
00088   // - the Source widget: vtkKWWidget*
00089   // - the SourceAnchor widget: vtkKWWidget* (same as Source widget most of
00090   // the times)
00091   // Additionally, EndCommand is passed a 5th parameter:
00092   // - the target: vtkKWWidget*
00093   virtual int SetTargetStartCommand(
00094     vtkKWWidget *target, vtkObject *object, const char *method);
00095   virtual int SetTargetPerformCommand(
00096     vtkKWWidget *target, vtkObject *object, const char *method);
00097   virtual int SetTargetEndCommand(
00098     vtkKWWidget *target, vtkObject *object, const char *method);
00099 
00100   // Description:
00101   // Independent of any targets, the following commands can be set:
00102   // The StartCommand is called when Drag & Drop starts.
00103   // The PerformCommand is called while Drag & Drop is performed.
00104   // The EndCommand is called when Drag & Drop ends.
00105   // The 'object' argument is the object that will have the method called on
00106   // it. The 'method' argument is the name of the method to be called and any
00107   // arguments in string form. If the object is NULL, the method is still
00108   // evaluated as a simple command. 
00109   // The following parameters are also passed to the commands:
00110   // - absolute/screen (x,y) mouse coordinates: int, int
00111   // None of them is called if Enable is false.
00112   // StartCommand and PerformCommand are called *before* any target's
00113   // corresponding command. EndCommand is called *after* any target's
00114   // EndCommand.
00115   virtual void SetStartCommand(vtkObject *object, const char *method);
00116   virtual void SetPerformCommand(vtkObject *object, const char *method);
00117   virtual void SetEndCommand(vtkObject *object, const char *method);
00118 
00119   // Description:
00120   // Callbacks. Internal, do not use.
00121   virtual void StartCallback(int x, int y);
00122   virtual void PerformCallback(int x, int y);
00123   virtual void EndCallback(int x, int y);
00124 
00125 protected:
00126   vtkKWDragAndDropTargetSet();
00127   ~vtkKWDragAndDropTargetSet();
00128 
00129   // Drag and Drop
00130 
00131   //BTX
00132 
00133   class TargetSlot
00134   {
00135   public:
00136     vtkKWWidget *Target;
00137     char *StartCommand;
00138     char *PerformCommand;
00139     char *EndCommand;
00140 
00141     void SetStartCommand(const char*);
00142     void SetEndCommand(const char*);
00143     void SetPerformCommand(const char*);
00144 
00145     TargetSlot();
00146     ~TargetSlot();
00147   };
00148 
00149   // PIMPL Encapsulation for STL containers
00150 
00151   vtkKWDragAndDropTargetSetInternals *Internals;
00152   friend class vtkKWDragAndDropTargetSetInternals;
00153 
00154   TargetSlot* GetTarget(vtkKWWidget *target);
00155 
00156   //ETX
00157 
00158   int Enable;
00159 
00160   vtkKWWidget *SourceAnchor;
00161   vtkKWWidget *Source;
00162 
00163   char *StartCommand;
00164   char *PerformCommand;
00165   char *EndCommand;
00166   virtual void InvokeCommandWithCoordinates(const char *command, int x, int y);
00167   virtual void InvokeStartCommand(int x, int y);
00168   virtual void InvokePerformCommand(int x, int y);
00169   virtual void InvokeEndCommand(int x, int y);
00170 
00171   virtual void AddBindings();
00172   virtual void RemoveBindings();
00173   virtual void DeleteAllTargets();
00174 
00175 private:
00176   
00177   vtkKWDragAndDropTargetSet(const vtkKWDragAndDropTargetSet&); // Not implemented
00178   void operator=(const vtkKWDragAndDropTargetSet&); // Not implemented
00179 };
00180 
00181 #endif

Generated on Sat Dec 11 2010 02:07:57 for KWWidgets by  doxygen 1.7.2