From 2e280aa78f2ce474ac3a9254eaf353087c0994a6 Mon Sep 17 00:00:00 2001 From: sidorares Date: Mon, 25 Jul 2011 13:42:42 +1000 Subject: [PATCH] drawing requests wrappers, set/get title, 'handle' helper --- test/wndwrap.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/wndwrap.js b/test/wndwrap.js index 436598d..456b5ea 100644 --- a/test/wndwrap.js +++ b/test/wndwrap.js @@ -23,12 +23,32 @@ GraphicContext.prototype.noop = function() //testing triggering gc creation } -GraphicContext.prototype.drawText = function(x, y, text) +GraphicContext.prototype.rectangles = function(x, y, xyWHpoints) +{ + this.xclient.PolyFillRectangle(this.win.id, this.id, xyWHpoints); +} + +GraphicContext.prototype.text = function(x, y, text) { - //console.log([0, this.win.id, this.id, x, y, [text]]); this.xclient.PolyText8(this.win.id, this.id, x, y, [text]); } +GraphicContext.prototype.polyLine = function(points, opts) +{ + var coordinateMode = 0; + if (opts && opts.coordinateMode === 'previous') + coordinateMode = 1; + this.xclient.PolyLine(coordinateMode, this.win.id, this.id, points); +} + +GraphicContext.prototype.points = function(points, opts) +{ + var coordinateMode = 0; + if (opts && opts.coordinateMode === 'previous') + coordinateMode = 1; + this.xclient.PolyPoint(coordinateMode, this.win.id, this.id, points); +} + function Window(parent, x, y, w, h) { if (parent.constructor && parent.constructor.name == 'XClient') @@ -118,4 +138,10 @@ Window.prototype.unmap = function() { this.xclient.UnmapWindow(this.id); } +Window.prototype.handle = function(handlers) { + for (var eventName in handlers) { + this.on(eventName, handlers[eventName]); + } +} + module.exports = Window; \ No newline at end of file