return formObj;
}
-static JSValueRef jsXawLabelGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+static JSValueRef jsXawLabelGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef jsPropertyName, JSValueRef* exception)
{
- printf("Get:");
- size_t len = JSStringGetMaximumUTF8CStringSize(propertyName);
- char* pname = (char*)malloc(len);
+ int objectID = (int)JSObjectGetPrivate(object);
- JSStringGetUTF8CString(propertyName, pname, len);
- printf("%s\n",pname);
- free(pname);
- return JSValueMakeNumber(ctx, 1.23);
+ JSValueRef result = JSValueMakeUndefined(ctx);
+
+ size_t len = JSStringGetMaximumUTF8CStringSize(jsPropertyName);
+ char* propertyName = (char*)malloc(len);
+
+ JSStringGetUTF8CString(jsPropertyName, propertyName, len);
+
+ if(!strcmp( propertyName, "Text" ))
+ {
+ char *str;
+ Arg args[1];
+ XtSetArg(args[0],XtNlabel,(XtArgVal)&str);
+ XtGetValues(myWidgets[objectID],args,1);
+ JSStringRef mystring = JSStringCreateWithUTF8CString(str);
+ result = JSValueMakeString(ctx, mystring);
+ free(str);
+ }
+
+
+ free(propertyName);
+ return result;
}
static bool jsXawLabelSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef jsPropertyName, JSValueRef value, JSValueRef* exception)
{
if (argumentCount >= 2)
{
char widgetName[8]={'W','i','d','g','e','t','_',(char)objIDc+48};
- printf("Untitled Widget%d on %d", objIDc, parentObjectID);
+ printf("Untitled Widget%d on %d. Initializing...\n", objIDc, parentObjectID);
double widgetDirection = 0;
/********************************************************************************\
//Construct a class and create object out of it, send it back to JavaScript.
widgetObj = JSObjectMake(ctx, JSClassCreate(&classDefinition), NULL);
JSObjectSetPrivate(widgetObj, (void*)objIDc);
+ free(text);
+ text = NULL;
+
+ }else if((argumentCount == 3) && JSValueIsString(ctx, arguments[1]))
+ {//Button
+ printf("Button selected for widget %d on %d.\n", objIDc,parentObjectID);
+
+
+ classDefinition.getProperty = (JSObjectGetPropertyCallback)jsXawLabelGetProperty;
+ classDefinition.setProperty = (JSObjectSetPropertyCallback)jsXawLabelSetProperty;
+
+ /********************************************************************************\
+ Call XAW to put xwindow instance up.
+ var Widget = new xawWidget(mywindow, "Widget", 0);
+ \********************************************************************************/
+
+
+ JSStringRef jstrArg = JSValueToStringCopy(ctx, arguments[1], exception);
+ size_t len = JSStringGetMaximumUTF8CStringSize(jstrArg);
+ char* text = (char*)malloc(len);
+
+ JSStringGetUTF8CString(jstrArg, text, len);
+ JSStringRelease(jstrArg);
+
+
+ myWidgets[objIDc] = XtVaCreateManagedWidget(widgetName, commandWidgetClass, myWidgets[parentObjectID], XtNlabel, text,
+ XtNhorizDistance,50,
+ XtNvertDistance,50, NULL);
+
+ //Construct a class and create object out of it, send it back to JavaScript.
+ widgetObj = JSObjectMake(ctx, JSClassCreate(&classDefinition), NULL);
+ JSObjectSetPrivate(widgetObj, (void*)objIDc);
+ free(text);
+ text = NULL;
}else {
printf("Nothing selected for widget %d on %d.\n", objIDc,parentObjectID);
const JSObjectRef args[],
JSValueRef* jobjExp)
{
-
- //Add heap area to accomodate a new Widget
jsCallbackInfo* timeOutCallback = (jsCallbackInfo *)malloc( sizeof(jsCallbackInfo));
- if( myWidgets == NULL )//stop if empty pointer for some reason
+ if( timeOutCallback == NULL )//stop if empty pointer for some reason
{
printf( "Memory alloc failed!\n" );
return JSValueToObject(ctx, JSValueMakeNull(ctx), jobjExp);