casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisplayTool.h
Go to the documentation of this file.
1 //# DisplayTool.h: base class for event-based tools in the display classes
2 //# Copyright (C) 1999,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_DISPLAYTOOL_H
29 #define TRIALDISPLAY_DISPLAYTOOL_H
30 
31 #include <casa/aips.h>
33 
34 namespace casa { //# NAMESPACE CASA - BEGIN
35 
36 // <summary>
37 // Base class for event-based tools in the display classes.
38 // </summary>
39 
40 // <use visibility=local>
41 
42 // <reviewed reviewer="Ralph Marson" date="2000/04/18" tests="tDisplayTool">
43 // </reviewed>
44 
45 // <etymology>
46 // "DisplayTool" is a base interface for "Tools" to be used in "Display"
47 // applications.
48 // <etymology>
49 
50 // <synopsis>
51 // This class is a simple base class which provides a suitable base upon
52 // which to build interactive user tools for the display classes. It
53 // simply provides a facility to setup a key to catch and respond to, and
54 // an interface to enable and disable the tool.
55 // </synopsis>
56 
57 // <example>
58 // A function to provide information about a DisplayTool might look like:
59 // <srcblock>
60 // void MyClass::printToolKey(const DisplayTool &tool) const {
61 // cout << tool.getKey() << endl;
62 // }
63 // </srcblock>
64 // </example>
65 
66 // <motivation>
67 // This class unites all key handling for display tools.
68 // </motivation>
69 
70 // <todo asof="2000/01/17">
71 // Nothing known.
72 // </todo>
73 
74  class DisplayTool {
75 
76  public:
77 
78  // Destructor.
79  virtual ~DisplayTool();
80 
81  // Switch the tool on/off. This simply registers or unregisters the
82  // event handlers.
83  // <group>
84  virtual void enable() = 0;
85  virtual void disable() = 0;
86  // </group>
87 
88  // Set/get which key to catch.
89  // <group>
90  virtual void setKey(const Display::KeySym &keysym);
91  virtual Display::KeySym getKey() const;
92  // </group>
93 
94  protected:
95 
96  // Constructor taking a key to which this tool will initially be
97  // attached, typically one of the pointer buttons.
98  explicit DisplayTool(const Display::KeySym &keysym =
100 
101  // Copy constructor - construct a new DisplayTool from
102  // <src>other</src>, using copy semantics.
103  DisplayTool(const DisplayTool &other);
104 
105  // Copy assignment using copy semantics.
106  DisplayTool &operator=(const DisplayTool &other);
107 
108  // Return the modifier mask. Some keys, specifically the mouse
109  // (pointer) buttons, have associated with them a bit mask which is
110  // used to determine if that key is currently held down. This
111  // function returns the modifier for the key of this tool, and
112  // returns 0 if the key does not have a modifier bit mask, eg. it is
113  // an alphanumeric key on the keyboard.
115  return itsKeyModifier;
116  }
117 
118  private:
119 
120  // The key to handle.
122 
123  // The modifier mask for the key.
125 
126  // Support function to choose a key modifier for the tool key.
127  void chooseKeyModifier();
128 
129  };
130 
131 
132 } //# NAMESPACE CASA - END
133 
134 #endif
virtual void setKey(const Display::KeySym &keysym)
Set/get which key to catch.
DisplayTool(const Display::KeySym &keysym=Display::K_Pointer_Button1)
Constructor taking a key to which this tool will initially be attached, typically one of the pointer...
virtual void disable()=0
virtual Display::KeySym getKey() const
DisplayTool & operator=(const DisplayTool &other)
Copy assignment using copy semantics.
Base class for event-based tools in the display classes.
Definition: DisplayTool.h:74
Display::KeyModifier itsKeyModifier
The modifier mask for the key.
Definition: DisplayTool.h:124
Display::KeyModifier keyModifiers()
Return the modifier mask.
Definition: DisplayTool.h:114
virtual void enable()=0
Switch the tool on/off.
KeyModifier
All events - modifier codes.
Definition: DisplayEnums.h:368
virtual ~DisplayTool()
Destructor.
void chooseKeyModifier()
Support function to choose a key modifier for the tool key.
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
Display::KeySym itsKeySym
The key to handle.
Definition: DisplayTool.h:121