VTK
dox/Widgets/vtkWidgetEventTranslator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkWidgetEventTranslator.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00035 #ifndef __vtkWidgetEventTranslator_h
00036 #define __vtkWidgetEventTranslator_h
00037 
00038 #include "vtkObject.h"
00039 
00040 // Support PIMPL encapsulation of internal STL map
00041 class vtkEventMap;
00042 class vtkRenderWindowInteractor;
00043 class vtkCallbackCommand;
00044 class vtkEvent;
00045 class vtkAbstractWidget;
00046 
00047 
00048 // This is a lightweight class that should be used internally by the widgets
00049 class VTK_WIDGETS_EXPORT vtkWidgetEventTranslator : public vtkObject
00050 {
00051 public:
00053   static vtkWidgetEventTranslator *New();
00054 
00056 
00057   vtkTypeMacro(vtkWidgetEventTranslator,vtkObject);
00058   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00062 
00065   void SetTranslation(unsigned long VTKEvent, unsigned long widgetEvent);
00066   void SetTranslation(const char *VTKEvent, const char *widgetEvent);
00067   void SetTranslation(unsigned long VTKEvent, int modifier, char keyCode,
00068                       int repeatCount, const char* keySym, unsigned long widgetEvent);
00069   void SetTranslation(vtkEvent *VTKevent, unsigned long widgetEvent);
00071   
00073 
00076   unsigned long GetTranslation(unsigned long VTKEvent);
00077   const char *GetTranslation(const char *VTKEvent);
00078   unsigned long GetTranslation(unsigned long VTKEvent, int modifier, char keyCode,
00079                                int repeatCount, char* keySym);
00080   unsigned long GetTranslation(vtkEvent *VTKEvent);
00082 
00084 
00086   int RemoveTranslation( unsigned long VTKEvent,
00087                          int modifier,    char keyCode,
00088                          int repeatCount, char* keySym);
00089   int RemoveTranslation( vtkEvent *e );
00090   int RemoveTranslation(unsigned long VTKEvent);
00091   int RemoveTranslation(const char *VTKEvent);
00093   
00096   void ClearEvents();
00097   
00098 //BTX
00100 
00101   void AddEventsToParent(vtkAbstractWidget*, vtkCallbackCommand*, float priority);
00102   void AddEventsToInteractor(vtkRenderWindowInteractor*, vtkCallbackCommand*, 
00103                              float priority);
00104 //ETX
00106   
00107 protected:
00108   // Constructors/destructors made public for widgets to use
00109   vtkWidgetEventTranslator();
00110   ~vtkWidgetEventTranslator();
00111 
00112   // Map VTK events to widget events
00113   vtkEventMap *EventMap;
00114   
00115   // Used for performance reasons to avoid object construction/deletion
00116   vtkEvent *Event;
00117   
00118 private:
00119   vtkWidgetEventTranslator(const vtkWidgetEventTranslator&);  //Not implemented
00120   void operator=(const vtkWidgetEventTranslator&);  //Not implemented
00121 
00122 };
00123 
00124 #endif /* __vtkWidgetEventTranslator_h */
00125