casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DisplayTool.h
Go to the documentation of this file.
00001 //# DisplayTool.h: base class for event-based tools in the display classes
00002 //# Copyright (C) 1999,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //# 
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //# 
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //# 
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //# 
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //# 
00026 //# $Id$
00027 
00028 #ifndef TRIALDISPLAY_DISPLAYTOOL_H
00029 #define TRIALDISPLAY_DISPLAYTOOL_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/Display/DisplayEnums.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary>
00037 // Base class for event-based tools in the display classes.
00038 // </summary>
00039 
00040 // <use visibility=local>
00041 
00042 // <reviewed reviewer="Ralph Marson" date="2000/04/18" tests="tDisplayTool">
00043 // </reviewed>
00044 
00045 // <etymology>
00046 // "DisplayTool" is a base interface for "Tools" to be used in "Display"
00047 // applications.
00048 // <etymology>
00049 
00050 // <synopsis>
00051 // This class is a simple base class which provides a suitable base upon
00052 // which to build interactive user tools for the display classes.  It
00053 // simply provides a facility to setup a key to catch and respond to, and
00054 // an interface to enable and disable the tool.
00055 // </synopsis>
00056 
00057 // <example>
00058 // A function to provide information about a DisplayTool might look like:
00059 // <srcblock>
00060 // void MyClass::printToolKey(const DisplayTool &tool) const {
00061 //     cout << tool.getKey() << endl;
00062 // }
00063 // </srcblock>
00064 // </example>
00065 
00066 // <motivation>
00067 // This class unites all key handling for display tools.
00068 // </motivation>
00069 
00070 // <todo asof="2000/01/17">
00071 // Nothing known.
00072 // </todo>
00073 
00074 class DisplayTool {
00075 
00076  public:
00077 
00078   // Destructor.
00079   virtual ~DisplayTool();
00080 
00081   // Switch the tool on/off.  This simply registers or unregisters the
00082   // event handlers.
00083   // <group>
00084   virtual void enable() = 0;
00085   virtual void disable() = 0;
00086   // </group>
00087   
00088   // Set/get which key to catch.
00089   // <group>
00090   virtual void setKey(const Display::KeySym &keysym);
00091   virtual Display::KeySym getKey() const;
00092   // </group>
00093 
00094  protected:
00095 
00096   // Constructor taking a key to which this tool will initially be
00097   // attached, typically one of the pointer buttons.
00098   explicit DisplayTool(const Display::KeySym &keysym = 
00099                        Display::K_Pointer_Button1);
00100 
00101   // Copy constructor - construct a new DisplayTool from
00102   // <src>other</src>, using copy semantics.
00103   DisplayTool(const DisplayTool &other);
00104 
00105   // Copy assignment using copy semantics.
00106   DisplayTool &operator=(const DisplayTool &other);
00107 
00108   // Return the modifier mask.  Some keys, specifically the mouse
00109   // (pointer) buttons, have associated with them a bit mask which is
00110   // used to determine if that key is currently held down.  This
00111   // function returns the modifier for the key of this tool, and
00112   // returns 0 if the key does not have a modifier bit mask, eg. it is
00113   // an alphanumeric key on the keyboard.
00114   Display::KeyModifier keyModifiers()
00115     { return itsKeyModifier; }
00116 
00117  private:
00118 
00119   // The key to handle.
00120   Display::KeySym itsKeySym;
00121 
00122   // The modifier mask for the key.
00123   Display::KeyModifier itsKeyModifier;
00124 
00125   // Support function to choose a key modifier for the tool key.
00126   void chooseKeyModifier();
00127 
00128 };
00129 
00130 
00131 } //# NAMESPACE CASA - END
00132 
00133 #endif