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

vtkKWKeyBindingsManager.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    vtkKWKeyBindingsManager.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 vtkKWKeyBindingsManager - a keyboard shortcut manager.
00015 // .SECTION Description
00016 // This class is basically a manager that acts as a container for a set of
00017 // key bindings.
00018 // Any object that define a key binding can register it here. 
00019 // This manager can be queried later on to list all key bindings, for example.
00020 // This class does not support reassigning key bindings yet.
00021 // .SECTION See Also
00022 // vtkKWKeyBindingsWidget
00023 
00024 
00025 #ifndef __vtkKWKeyBindingsManager_h
00026 #define __vtkKWKeyBindingsManager_h
00027 
00028 #include "vtkKWObject.h"
00029 
00030 class vtkKWKeyBindingsManagerInternals;
00031 class vtkKWEventMap;
00032 
00033 class KWWidgets_EXPORT vtkKWKeyBindingsManager : public vtkKWObject
00034 {
00035 public:
00036   static vtkKWKeyBindingsManager* New();
00037   vtkTypeRevisionMacro(vtkKWKeyBindingsManager,vtkKWObject);
00038   void PrintSelf(ostream& os, vtkIndent indent);
00039 
00040   // Description:
00041   // Add or set or remove a key binding. Setting a key binding will remove any
00042   // items that were previously associated to that specific binding.
00043   // 'target' is generally a pointer to the class that set up this binding.
00044   // 'binding' is the binding itself, in a Tk event form (say, <KeyPress-p>)
00045   // 'callback_object' and 'callback_command' define the callback associated
00046   //     to this binding. The 'object' argument is the object that will have 
00047   //     the 'command' (method) called on it. The 'method' argument is the 
00048   //     name of the method to be called and any arguments in string form.
00049   //     If the 'object' is NULL, the method is still evaluated as a 
00050   //     simple Tcl command. 
00051   //     simple Tcl command. 
00052   // 'context' is a string in plain English (or preferably localized) that
00053   // explains in which context this key binding is valid. For example: 
00054   // "Any 2D View", or "Any Main Window". It usually is a simple/short
00055   // description of the class setting the binding (i.e. the 'target'). 
00056   // 'description' is a string in plain English (or preferably localized) that
00057   // explains what that binding does. For example: "Reset the camera".
00058   virtual void AddKeyBinding(
00059     vtkObject *target, 
00060     const char *binding, 
00061     vtkObject *callback_object = NULL, 
00062     const char *callback_command = NULL,
00063     const char *context = NULL,
00064     const char *description = NULL);
00065   virtual void SetKeyBinding(
00066     vtkObject *target, 
00067     const char *binding, 
00068     vtkObject *callback_object = NULL, 
00069     const char *callback_command = NULL,
00070     const char *context = NULL,
00071     const char *description = NULL);
00072   virtual void RemoveKeyBinding(
00073     vtkObject *target, 
00074     const char *binding = NULL, 
00075     vtkObject *callback_object = NULL, 
00076     const char *callback_command = NULL);
00077   
00078   // Description:
00079   // Query the key bindings. While a little convoluted, this is the fastest
00080   // way to query the internal bindings: iterate over the targets, then
00081   // iterate over the bindings for each target, then iterate over the callback
00082   // objects for each binding, then iterate over the key bindings entries 
00083   // themselves for each callback objet; for each entry (given a target, 
00084   // binding, callback object and index), you can retrieve the callback
00085   // command, context and description.
00086   // See vtkKWKeyBindingsWidget.cxx for an example.
00087   virtual int GetNumberOfTargets();
00088   virtual vtkObject* GetNthTarget(int idx);
00089   virtual int GetNumberOfBindings(vtkObject *target);
00090   virtual const char* GetNthBinding(vtkObject *target, int idx);
00091   virtual int GetNumberOfCallbackObjects(
00092     vtkObject *target, const char *binding);
00093   virtual vtkObject* GetNthCallbackObject(
00094     vtkObject *target, const char *binding, int idx);
00095   virtual int GetNumberOfKeyBindings(
00096     vtkObject *target, const char *binding, vtkObject *callback_object);
00097   virtual const char* GetNthCallbackCommand(
00098     vtkObject *target, const char *binding,vtkObject *callback_object,int idx);
00099   virtual const char* GetNthContext(
00100     vtkObject *target, const char *binding,vtkObject *callback_object,int idx);
00101   virtual const char* GetNthDescription(
00102     vtkObject *target, const char *binding,vtkObject *callback_object,int idx);
00103 
00104   // Description:
00105   // Convenience method that can be used to add all the key and keysym
00106   // bindings found in a vtkKWEventMap.
00107   virtual void SetKeyBindingsFromEventMap(vtkKWEventMap *map);
00108 
00109   // Description:
00110   // Get a "pretty" representation of a binding (remove trailing <>, Key-,
00111   // KeyPress-, translate some keysyms, change - into +, uppercase the key).
00112   virtual const char* GetPrettyBinding(const char *binding);
00113 
00114   // Description:
00115   // Get a "pretty" representation of a context (if the context is a single
00116   // word, i.e. maybe a class name, remove the usual prefixes, and separate
00117   // each words).
00118   virtual const char* GetPrettyContext(const char *context);
00119 
00120 protected:
00121   vtkKWKeyBindingsManager();
00122   ~vtkKWKeyBindingsManager();
00123 
00124   //BTX
00125   // PIMPL Encapsulation for STL containers
00126   vtkKWKeyBindingsManagerInternals *Internals;
00127   //ETX
00128 
00129   // Description:
00130   // Processes the events that are passed through CallbackCommand (or others).
00131   // Subclasses can oberride this method to process their own events, but
00132   // should call the superclass too.
00133   virtual void ProcessCallbackCommandEvents(
00134     vtkObject *caller, unsigned long event, void *calldata);
00135   
00136 private:
00137   
00138   vtkKWKeyBindingsManager(const vtkKWKeyBindingsManager&); // Not implemented
00139   void operator=(const vtkKWKeyBindingsManager&); // Not implemented
00140 };
00141 
00142 #endif
00143 

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