+/**
+ * Return true if the panel is visible.
+ */
+bool
+FGPanel::getVisibility () const
+{
+ return _visibility->getBoolValue();
+}
+
+
+/**
+ * Set the panel's background texture.
+ */
+void
+FGPanel::setBackground (ssgTexture * texture)
+{
+ _bg = texture;
+}
+
+/**
+ * Set the panel's multiple background textures.
+ */
+void
+FGPanel::setMultiBackground (ssgTexture * texture, int idx)
+{
+ _bg = 0;
+ _mbg[idx] = texture;
+}
+
+/**
+ * Set the panel's x-offset.
+ */
+void
+FGPanel::setXOffset (int offset)
+{
+ if (offset <= 0 && offset >= -_width + WIN_W)
+ _x_offset->setIntValue( offset );
+}
+
+
+/**
+ * Set the panel's y-offset.
+ */
+void
+FGPanel::setYOffset (int offset)
+{
+ if (offset <= 0 && offset >= -_height)
+ _y_offset->setIntValue( offset );
+}
+
+/**
+ * Handle a mouse action in panel-local (not screen) coordinates.
+ * Used by the 3D panel code in Model/panelnode.cxx, in situations
+ * where the panel doesn't control its own screen location.
+ */
+bool
+FGPanel::doLocalMouseAction(int button, int updown, int x, int y)
+{
+ // Note a released button and return
+ if (updown == 1) {
+ if (_mouseInstrument != 0)
+ _mouseInstrument->doMouseAction(_mouseButton, 1, _mouseX, _mouseY);
+ _mouseDown = false;
+ _mouseInstrument = 0;
+ return false;
+ }
+
+ // Search for a matching instrument.
+ for (int i = 0; i < (int)_instruments.size(); i++) {
+ FGPanelInstrument *inst = _instruments[i];
+ int ix = inst->getXPos();
+ int iy = inst->getYPos();
+ int iw = inst->getWidth() / 2;
+ int ih = inst->getHeight() / 2;
+ if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) {
+ _mouseDown = true;
+ _mouseDelay = 20;
+ _mouseInstrument = inst;
+ _mouseButton = button;
+ _mouseX = x - ix;
+ _mouseY = y - iy;
+ // Always do the action once.
+ return _mouseInstrument->doMouseAction(_mouseButton, 0,
+ _mouseX, _mouseY);
+ }
+ }
+ return false;
+}
+
+/**
+ * Perform a mouse action.
+ */
+bool
+FGPanel::doMouseAction (int button, int updown, int x, int y)
+{
+ // FIXME: this same code appears in update()
+ int xsize = _xsize_node->getIntValue();
+ int ysize = _ysize_node->getIntValue();
+ float aspect_adjust = get_aspect_adjust(xsize, ysize);
+
+ // Scale for the real window size.
+ if (aspect_adjust < 1.0) {
+ x = int(((float)x / xsize) * WIN_W * aspect_adjust);
+ y = int(WIN_H - ((float(y) / ysize) * WIN_H));
+ } else {
+ x = int(((float)x / xsize) * WIN_W);
+ y = int((WIN_H - ((float(y) / ysize) * WIN_H)) / aspect_adjust);
+ }
+
+ // Adjust for offsets.
+ x -= _x_offset->getIntValue();
+ y -= _y_offset->getIntValue();
+
+ // Having fixed up the coordinates, fall through to the local
+ // coordinate handler.
+ return doLocalMouseAction(button, updown, x, y);
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////.
+// Implementation of FGPanelAction.
+////////////////////////////////////////////////////////////////////////
+
+FGPanelAction::FGPanelAction ()
+{
+}