1 jls.loader.provide('jls.win32.DeviceContext'); 2 3 jls.loader.requireLibrary('jls_win32'); 4 5 jls.loader.require('jls.win32.Window'); 6 jls.loader.require('jls.win32.Font'); 7 jls.loader.require('jls.win32.Pen'); 8 jls.loader.require('jls.win32.Brush'); 9 10 jls.win32.DeviceContext = jls.lang.Class.create( 11 { 12 initialize : function(window) { 13 if (! (window instanceof jls.win32.Window)) { 14 throw new jls.lang.Exception('Invalid window argument type (' + (typeof window) + ')'); 15 } 16 this._no = new _native.win32.DeviceContext(window._no); 17 }, 18 drawText : function(text, left, top, right, bottom, count, flags) { 19 this._no.drawText(text, left, top, right, bottom, count || -1, flags || jls.win32.DeviceContext.DT_LEFT); 20 return this; 21 }, 22 /*setDIBits : function(buffer, width, height, left, top, topDown) { 23 this._no.setDIBits(buffer._barray, width, height, left, top, topDown); 24 return this; 25 },*/ 26 setDIBits : function(img, left, top) { 27 this._no.setDIBits(img.getBuffer().byteArray(), img.getWidth(), img.getHeight(), 28 left, top, img.getOrientation() == jls.util.Image.BOTTOM_LEFT); 29 return this; 30 }, 31 /*stretchDIBits : function(buffer, width, height, destWidth, destHeight, topDown) { 32 this._no.stretchDIBits(buffer._barray, width, height, destWidth, destHeight, topDown); 33 return this; 34 },*/ 35 stretchDIBits : function(img, width, height) { 36 this._no.stretchDIBits(img.getBuffer().byteArray(), img.getWidth(), img.getHeight(), 37 width, height, img.getOrientation() == jls.util.Image.BOTTOM_LEFT); 38 return this; 39 }, 40 selectObject : function(obj) { 41 if (! ((obj instanceof jls.win32.Font) || (obj instanceof jls.win32.Brush) || (obj instanceof jls.win32.Pen))) { 42 throw new jls.lang.Exception('Invalid Object argument type (' + (typeof obj) + ')'); 43 } 44 this._no.selectObject(obj._no); 45 return this; 46 }, 47 setBkMode : function(transparent) { 48 this._no.setBkMode(transparent); 49 return this; 50 }, 51 setTextColor : function(r, g, b) { 52 this._no.setTextColor(r, g, b); 53 return this; 54 }, 55 setBkColor : function(r, g, b) { 56 this._no.setBkColor(r, g, b); 57 return this; 58 }, 59 rectangle : function(left, top, right, bottom, width, height) { 60 this._no.rectangle(left, top, right, bottom, width, height); 61 return this; 62 }, 63 ellipse : function(left, top, right, bottom, width, height) { 64 this._no.ellipse(left, top, right, bottom, width, height); 65 return this; 66 }, 67 fillRect : function(left, top, right, bottom, brush) { 68 this._no.fillRect(left, top, right, bottom, brush._no); 69 return this; 70 }, 71 release : function() { 72 this._no.release(); 73 this._no = null; 74 return this; 75 } 76 }); 77 78 /*Object.extend(jls.win32.DeviceContext, 79 { 80 _nop : null, 81 nop : function() { 82 } 83 });*/ 84 85 Object.inheritConstants(jls.win32.DeviceContext, _native.win32.DeviceContext); 86