+// Base class for user action types.
+//
+// Individual instruments can have actions associated with a mouse
+// click in a rectangular area. Current concrete classes include
+// FGAdjustAction, FGSwapAction, and FGToggleAction.
+////////////////////////////////////////////////////////////////////////
+
+class FGPanelAction
+{
+public:
+ FGPanelAction ();
+ FGPanelAction (int button, int x, int y, int w, int h);
+ virtual ~FGPanelAction ();
+
+ // Getters.
+ virtual int getButton () const { return _button; }
+ virtual int getX () const { return _x; }
+ virtual int getY () const { return _y; }
+ virtual int getWidth () const { return _w; }
+ virtual int getHeight () const { return _h; }
+
+ // Setters.
+ virtual void setButton (int button) { _button = button; }
+ virtual void setX (int x) { _x = x; }
+ virtual void setY (int y) { _y = y; }
+ virtual void setWidth (int w) { _w = w; }
+ virtual void setHeight (int h) { _h = h; }
+
+ // Check whether we're in the area.
+ virtual bool inArea (int button, int x, int y)
+ {
+ return (button == _button &&
+ x >= _x &&
+ x < _x + _w &&
+ y >= _y &&
+ y < _y + _h);
+ }
+
+ // Perform the action.
+ virtual void doAction () = 0;
+
+private:
+ int _button;
+ int _x;
+ int _y;
+ int _w;
+ int _h;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Adjustment action.
+//
+// This is an action to increase or decrease an FGFS value by a certain
+// increment within a certain range. If the wrap flag is true, the
+// value will wrap around if it goes below min or above max; otherwise,
+// it will simply stop at min or max.
+////////////////////////////////////////////////////////////////////////
+
+class FGAdjustAction : public FGPanelAction
+{
+public:
+ FGAdjustAction (int button, int x, int y, int w, int h,
+ SGValue * value, float increment,
+ float min, float max, bool wrap=false);
+ virtual ~FGAdjustAction ();
+ virtual void doAction ();
+
+private:
+ SGValue * _value;
+ float _increment;
+ float _min;
+ float _max;
+ bool _wrap;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Swap action.
+//
+// This is an action to swap two values. It's currently used in the
+// navigation radios.
+////////////////////////////////////////////////////////////////////////
+
+class FGSwapAction : public FGPanelAction
+{
+public:
+ FGSwapAction (int button, int x, int y, int w, int h,
+ SGValue * value1, SGValue * value2);
+ virtual ~FGSwapAction ();
+ virtual void doAction ();
+
+private:
+ SGValue * _value1;
+ SGValue * _value2;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Toggle action.
+//
+// This is an action to toggle a boolean value.
+////////////////////////////////////////////////////////////////////////
+
+class FGToggleAction : public FGPanelAction
+{
+public:
+ FGToggleAction (int button, int x, int y, int w, int h,
+ SGValue * value);
+ virtual ~FGToggleAction ();
+ virtual void doAction ();
+
+private:
+ SGValue * _value;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Abstract base class for a panel instrument.
+//
+// A panel instrument consists of zero or more actions, associated
+// with mouse clicks in rectangular areas. Currently, the only
+// concrete class derived from this is FGLayeredInstrument, but others
+// may show up in the future (some complex instruments could be
+// entirely hand-coded, for example).