# include "config.h"
#endif
-#include <Input/input.hxx>
+#include <simgear/structure/SGBinding.hxx>
#include <Scripting/NasalSys.hxx>
#include <Main/fg_os.hxx>
enum format_type { f_INVALID, f_INT, f_LONG, f_FLOAT, f_DOUBLE, f_STRING };
static const int FORMAT_BUFSIZE = 255;
+static const int RESIZE_MARGIN = 7;
+
/**
* Makes sure the format matches '%[ -+#]?\d*(\.\d*)?(l?[df]|s)', with
if ((ret = getActiveInputField(obj)))
return ret;
- if (object->getType() & PUCLASS_INPUT && ((puInput *)object)->isAcceptingInput())
+ if (object->getType() & (PUCLASS_INPUT|PUCLASS_LARGEINPUT)
+ && ((puInput *)object)->isAcceptingInput())
return object;
return 0;
_resizing = 0;
if (!global_drag && _resizable) {
- int hmargin = global_resize ? _dlgW / 3 : 10;
- int vmargin = global_resize ? _dlgH / 3 : 10;
+ int hmargin = global_resize ? _dlgW / 3 : RESIZE_MARGIN;
+ int vmargin = global_resize ? _dlgH / 3 : RESIZE_MARGIN;
if (y - _dlgY < vmargin)
_resizing |= BOTTOM;
static void
copy_to_pui (SGPropertyNode *node, puObject *object)
{
+ using namespace simgear;
GUIInfo *info = (GUIInfo *)object->getUserData();
if (!info) {
SG_LOG(SG_GENERAL, SG_ALERT, "dialog: widget without GUIInfo!");
}
switch (node->getType()) {
- case SGPropertyNode::BOOL:
- case SGPropertyNode::INT:
- case SGPropertyNode::LONG:
+ case props::BOOL:
+ case props::INT:
+ case props::LONG:
object->setValue(node->getIntValue());
break;
- case SGPropertyNode::FLOAT:
- case SGPropertyNode::DOUBLE:
+ case props::FLOAT:
+ case props::DOUBLE:
object->setValue(node->getFloatValue());
break;
default:
static void
copy_from_pui (puObject *object, SGPropertyNode *node)
{
+ using namespace simgear;
// puText objects are immutable, so should not be copied out
if (object->getType() & PUCLASS_TEXT)
return;
switch (node->getType()) {
- case SGPropertyNode::BOOL:
- case SGPropertyNode::INT:
- case SGPropertyNode::LONG:
+ case props::BOOL:
+ case props::INT:
+ case props::LONG:
node->setIntValue(object->getIntegerValue());
break;
- case SGPropertyNode::FLOAT:
- case SGPropertyNode::DOUBLE:
+ case props::FLOAT:
+ case props::DOUBLE:
node->setFloatValue(object->getFloatValue());
break;
default:
if (open) {
const char *s = open->getStringValue();
FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
- nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props);
+ if (nas)
+ nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props);
}
}
display(props);
_props->setIntValue("lasty", y);
FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
- if (_nasal_close) {
- const char *s = _nasal_close->getStringValue();
- nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
+ if (nas) {
+ if (_nasal_close) {
+ const char *s = _nasal_close->getStringValue();
+ nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
+ }
+ nas->deleteModule(_module.c_str());
}
- nas->deleteModule(_module.c_str());
puDeleteObject(_object);
object->setLabelFont(*_font);
}
+ string type = props->getName();
+ if (type == "input" && props->getBoolValue("live"))
+ object->setDownCallback(action_callback);
+
+ if (type == "text") {
+ const char *format = props->getStringValue("format", 0);
+ if (format) {
+ info->fmt_type = validate_format(format);
+ if (info->fmt_type != f_INVALID)
+ info->format = format;
+ else
+ SG_LOG(SG_GENERAL, SG_ALERT, "DIALOG: invalid <format> '"
+ << format << '\'');
+ }
+ }
+
if (props->hasValue("property")) {
const char *name = props->getStringValue("name");
if (name == 0)
}
object->setCallback(action_callback);
}
-
- string type = props->getName();
- if (type == "input" && props->getBoolValue("live"))
- object->setDownCallback(action_callback);
-
- if (type == "text") {
- const char *format = props->getStringValue("format", 0);
- if (format) {
- info->fmt_type = validate_format(format);
- if (info->fmt_type != f_INVALID)
- info->format = format;
- else
- SG_LOG(SG_GENERAL, SG_ALERT, "DIALOG: invalid <format> '"
- << format << '\'');
- }
- }
}
void
key = toupper(key);
if (mod & CTRL)
key = toupper(key) - '@';
- if (mod & ALT)
+ /* if (mod & ALT)
; // Alt not propagated to the gui
+ */
} else {
for (char *t = s; *t; t++)
*t = tolower(*t);