mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-18 15:41:05 +00:00
Update gtk.js
This commit is contained in:
parent
eb5f585588
commit
a6fc2347a0
58
lib/gtk.js
58
lib/gtk.js
|
@ -34,31 +34,13 @@ var GTKCreateWidget = function(widget) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Table":
|
case "Table":
|
||||||
// attach sub widgets to table widget
|
|
||||||
var subWidgets = widget.attachedWidgets;
|
|
||||||
var countSubWidgets = subWidgets.length;
|
|
||||||
while (countSubWidgets > 0) {
|
|
||||||
commands.push([
|
|
||||||
"gtk_table_attach_defaults",
|
|
||||||
widget.widgetID,
|
|
||||||
subWidgets[i].widget.widgetID,
|
|
||||||
subWidgets[i].left,
|
|
||||||
subWidgets[i].right,
|
|
||||||
subWidgets[i].top,
|
|
||||||
subWidgets[i].bottom
|
|
||||||
]);
|
|
||||||
|
|
||||||
countSubWidgets--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create table widget
|
|
||||||
commands.push([
|
commands.push([
|
||||||
"gtk_table_new",
|
"gtk_table_new",
|
||||||
widget.rows,
|
widget.rows,
|
||||||
widget.columns,
|
widget.columns,
|
||||||
widget.homogeneous
|
widget.homogeneous
|
||||||
]);
|
]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Button":
|
case "Button":
|
||||||
|
@ -94,12 +76,8 @@ var GTKCreateWidget = function(widget) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get widgetID from first command
|
|
||||||
widgetID = GTKExecCommand(commands.pop());
|
|
||||||
|
|
||||||
// execute next commands
|
|
||||||
while (commands.length > 0) {
|
while (commands.length > 0) {
|
||||||
GTKExecCommand(commands.pop());
|
widgetID = GTKExecCommand(commands.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
return widgetID;
|
return widgetID;
|
||||||
|
@ -113,7 +91,7 @@ var GTKExecCommand = function(command) {
|
||||||
var term = command[i];
|
var term = command[i];
|
||||||
|
|
||||||
if (typeof(term) == "number") {
|
if (typeof(term) == "number") {
|
||||||
_command.push(term == 0 ? '0' : command[i]);
|
_command.push(term == 0 ? '0' : term);
|
||||||
} else if (typeof(term) == "boolean") {
|
} else if (typeof(term) == "boolean") {
|
||||||
_command.push(!term ? '0' : '1');
|
_command.push(!term ? '0' : '1');
|
||||||
} else if (typeof(term) == "string") {
|
} else if (typeof(term) == "string") {
|
||||||
|
@ -172,13 +150,17 @@ var Table = function() {
|
||||||
this.attachedWidgets = [];
|
this.attachedWidgets = [];
|
||||||
|
|
||||||
this.attach = function(widget, left, right, top, bottom) {
|
this.attach = function(widget, left, right, top, bottom) {
|
||||||
this.attachedWidgets.push({
|
this.attachedWidgets.push(widget);
|
||||||
"widget": widget,
|
|
||||||
"left": left,
|
return GTKExecCommand([
|
||||||
"right": right,
|
"gtk_table_attach_defaults",
|
||||||
"top": top,
|
this.widgetID,
|
||||||
"bottom": bottom
|
widget.widgetID,
|
||||||
});
|
left,
|
||||||
|
right,
|
||||||
|
top,
|
||||||
|
bottom
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Table.prototype = new GTKWidget();
|
Table.prototype = new GTKWidget();
|
||||||
|
@ -271,7 +253,7 @@ TextBox.prototype = new GTKWidget();
|
||||||
TextBox.prototype.constructor = TextBox;
|
TextBox.prototype.constructor = TextBox;
|
||||||
|
|
||||||
// GTKWait
|
// GTKWait
|
||||||
var GTKWait = function() {
|
var GTKWait = function(callback) {
|
||||||
var even;
|
var even;
|
||||||
|
|
||||||
GTKInit();
|
GTKInit();
|
||||||
|
@ -285,9 +267,19 @@ var GTKWait = function() {
|
||||||
if (even in GTKWidgets) {
|
if (even in GTKWidgets) {
|
||||||
GTKWidgets[even].onEventTriggered();
|
GTKWidgets[even].onEventTriggered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof(callback) == "function") {
|
||||||
|
callback(even);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GTKExit();
|
GTKExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.Window = Window;
|
||||||
|
exports.Table = Table;
|
||||||
|
exports.Button = Button;
|
||||||
|
exports.Entry = Entry;
|
||||||
|
exports.RadioBox = RadioBox;
|
||||||
|
exports.TextBox = TextBox;
|
||||||
exports.wait = GTKWait;
|
exports.wait = GTKWait;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user