#include "puList.hxx"
#include "AirportList.hxx"
+int fgPopup::checkHit(int button, int updown, int x, int y)
+{
+ int result = puPopup::checkHit(button, updown, x, y);
+
+ // This is annoying. We would really want a true result from the
+ // superclass to indicate "handled by child object", but all it
+ // tells us is that the pointer is inside the dialog. So do the
+ // intersection test (again) to make sure we don't start a drag
+ // when inside controls. A further weirdness: plib inserts a
+ // "ghost" child which covers the whole control. (?) Skip it.
+ if(!result) return result;
+ puObject* child = getFirstChild();
+ if(child) child = child->getNextObject();
+ while(child) {
+ int cx, cy, cw, ch;
+ child->getAbsolutePosition(&cx, &cy);
+ child->getSize(&cw, &ch);
+ if(x >= cx && x < cx + cw && y >= cy && y < cy + ch)
+ return result;
+ child = child->getNextObject();
+ }
+
+ // Finally, handle the mouse event
+ if(updown == PU_DOWN) {
+ int px, py;
+ getPosition(&px, &py);
+ _dragging = true;
+ _dX = px - x;
+ _dY = py - y;
+ } else if(updown == PU_DRAG && _dragging) {
+ setPosition(x + _dX, y + _dY);
+ } else {
+ _dragging = false;
+ }
+ return 1;
+}
\f
////////////////////////////////////////////////////////////////////////
if (props->getBoolValue("modal", false))
dialog = new puDialogBox(x, y);
else
- dialog = new puPopup(x, y);
+ dialog = new fgPopup(x, y);
setupGroup(dialog, props, width, height, true);
return dialog;
} else if (type == "group") {
vector<char **> _char_arrays;
};
+//
+// Custom subclass of puPopup to implement "draggable" windows in the
+// interface. Note that this is a subclass of puPopup, not
+// puDialogBox. Sadly, PUI (mis)uses subclassing to implement a
+// boolean property: modality. That means that we can't implement
+// dragging of both puPopup windows and puDialogBoxes with the same
+// code. Rather than duplicate code, I've chosen to implement only
+// "non-modal dragability" here. Modal dialog boxes (like the exit
+// confirmation) are not draggable.
+//
+class fgPopup : public puPopup {
+public:
+ fgPopup(int x, int y) : puPopup(x, y) { _dragging = false; }
+ int checkHit(int b, int up, int x, int y);
+private:
+ bool _dragging;
+ int _dX, _dY;
+};
+
#endif // __DIALOG_HXX
*/
fgPropPicker::fgPropPicker ( int x, int y, int w, int h, int arrows,
- const char *dir, const char *title ) : puDialogBox ( x,y )
+ const char *dir, const char *title ) : fgPopup ( x,y )
{
puFont LegendFont, LabelFont;
puGetDefaultFonts ( &LegendFont, &LabelFont );
FG_POP_PUI_DIALOG( prop_edit );
}
-fgPropEdit::fgPropEdit ( const char *name, const char *value, char *proppath ) : puDialogBox ( 0, 0 )
+fgPropEdit::fgPropEdit ( const char *name, const char *value, char *proppath ) : fgPopup ( 0, 0 )
{
puFont LegendFont, LabelFont;
#include <stdio.h>
#include "gui.h"
+#include "dialog.hxx"
#include <simgear/props/props.hxx>
void prop_pickerInit();
class fgPropEdit ;
class fgPropPicker :
- public puDialogBox,
+ public fgPopup,
public SGPropertyChangeListener
{
virtual void valueChanged (SGPropertyNode * node);
} ;
-class fgPropEdit : public puDialogBox
+class fgPropEdit : public fgPopup
{
static void fgPropEditHandleCancel ( puObject *b ) ;