1 jls.loader.provide('jls.win32.TreeView');
  2 
  3 jls.loader.require('jls.win32.Window');
  4 
  5 jls.win32.TreeView = jls.lang.Class.create(jls.win32.Window,
  6 {
  7     initialize : function($super, title, style, x, y, w, h, parent, id, exStyle, param) {
  8         $super(jls.win32.TreeView.CLASSNAME, title, style, x, y, w, h, parent, id, exStyle, param);
  9         this._item = new jls.lang.Struct([
 10             {name: 'hParent', type: 'Pointer'},
 11             {name: 'hInsertAfter', type: 'Pointer'},
 12             {name: 'item.mask', type: 'UnsignedInt'},
 13             {name: 'item.hItem', type: 'Pointer'},
 14             {name: 'item.state', type: 'UnsignedInt'},
 15             {name: 'item.stateMask', type: 'UnsignedInt'},
 16             {name: 'item.pszText', type: 'Pointer'},
 17             {name: 'item.cchTextMax', type: 'SignedInt'},
 18             {name: 'item.iImage', type: 'SignedInt'},
 19             {name: 'item.iSelectedImage', type: 'SignedInt'},
 20             {name: 'item.cChildren', type: 'SignedInt'},
 21             {name: 'item.lParam', type: 'Pointer'}
 22         ]);
 23         this._textBuffer = jls.lang.ByteBuffer.allocate(256);
 24     },
 25     insertItem : function(label, parent) {
 26         this._item.put('hParent', parent || jls.win32.TreeView.TVI_ROOT);
 27         this._item.put('hInsertAfter', 0);
 28         this._item.put('item.mask', jls.win32.TreeView.TVIF_TEXT | jls.win32.TreeView.TVIF_IMAGE);
 29         this._textBuffer.clear();
 30         this._textBuffer.putString(label || '');
 31         this._textBuffer.putByte(0);
 32         this._item.put('item.pszText', this._textBuffer.byteArray().pointer());
 33         this._item.put('item.cchTextMax', label.length + 1);
 34         this._item.put('item.iImage', -1);
 35         this._item.put('item.iSelectedImage', -1);
 36         this._item.put('item.cChildren', 0);
 37         this._item.put('item.lParam', 0);
 38         return this.sendMessage(jls.win32.TreeView.TVM_INSERTITEMA, 0, this._item.buffer().byteArray());
 39     }
 40 });
 41 
 42 /*
 43 typedef struct {
 44   HTREEITEM hParent;
 45   HTREEITEM hInsertAfter;
 46 #if (_WIN32_IE >= 0x0400)
 47   union {
 48     TVITEMEX itemex;
 49     TVITEM   item;
 50   } DUMMYUNIONNAME;
 51 #else 
 52   TVITEM    item;
 53 #endif 
 54 } TVINSERTSTRUCT, *LPTVINSERTSTRUCT;
 55 */
 56 /*
 57 typedef struct tagTVITEM {
 58   UINT      mask;
 59   HTREEITEM hItem;
 60   UINT      state;
 61   UINT      stateMask;
 62   LPTSTR    pszText;
 63   int       cchTextMax;
 64   int       iImage;
 65   int       iSelectedImage;
 66   int       cChildren;
 67   LPARAM    lParam;
 68 } TVITEM, *LPTVITEM;
 69 */
 70 
 71 Object.extend(jls.win32.TreeView,
 72 {
 73     TVS_HASBUTTONS           : 0x00000001,
 74     TVS_HASLINES             : 0x00000002,
 75     TVS_LINESATROOT          : 0x00000004,
 76     TVS_EDITLABELS           : 0x00000008,
 77     TVS_DISABLEDRAGDROP      : 0x00000010,
 78     TVS_SHOWSELALWAYS        : 0x00000020,
 79     TVM_INSERTITEMA          : 0x00001100,
 80     TVM_INSERTITEMW          : 0x00001132,
 81     TVM_DELETEITEM           : 0x00001101,
 82     TVM_EXPAND               : 0x00001102,
 83     TVM_GETITEMRECT          : 0x00001104,
 84     TVM_GETCOUNT             : 0x00001105,
 85     TVM_GETINDENT            : 0x00001106,
 86     TVM_SETINDENT            : 0x00001107,
 87     TVM_GETIMAGELIST         : 0x00001108,
 88     TVM_SETIMAGELIST         : 0x00001109,
 89     TVM_GETNEXTITEM          : 0x0000110a,
 90     TVM_SELECTITEM           : 0x0000110b,
 91     TVM_GETITEMA             : 0x0000110c,
 92     TVM_GETITEMW             : 0x0000113e,
 93     TVM_SETITEMA             : 0x0000110d,
 94     TVM_SETITEMW             : 0x0000113f,
 95     TVM_EDITLABELA           : 0x0000110e,
 96     TVM_EDITLABELW           : 0x00001141,
 97     TVM_GETEDITCONTROL       : 0x0000110f,
 98     TVM_GETVISIBLECOUNT      : 0x00001110,
 99     TVM_HITTEST              : 0x00001111,
100     TVM_CREATEDRAGIMAGE      : 0x00001112,
101     TVM_SORTCHILDREN         : 0x00001113,
102     TVM_ENSUREVISIBLE        : 0x00001114,
103     TVM_SORTCHILDRENCB       : 0x00001115,
104     TVM_ENDEDITLABELNOW      : 0x00001116,
105     TVM_GETISEARCHSTRINGA    : 0x00001117,
106     TVM_GETISEARCHSTRINGW    : 0x00001140,
107     TVI_ROOT                 : 0xffff0000,
108     TVI_FIRST                : 0xffff0001,
109     TVI_LAST                 : 0xffff0002,
110     TVI_SORT                 : 0xffff0003,
111     TVIF_TEXT                : 0x00000001,
112     TVIF_IMAGE               : 0x00000002,
113     TVIF_PARAM               : 0x00000004,
114     TVIF_STATE               : 0x00000008,
115     TVIF_HANDLE              : 0x00000010,
116     TVIF_SELECTEDIMAGE       : 0x00000020,
117     TVIF_CHILDREN            : 0x00000040,
118     TVIS_FOCUSED             : 0x00000001,
119     TVIS_SELECTED            : 0x00000002,
120     TVIS_CUT                 : 0x00000004,
121     TVIS_DROPHILITED         : 0x00000008,
122     TVIS_BOLD                : 0x00000010,
123     TVIS_EXPANDED            : 0x00000020,
124     TVIS_EXPANDEDONCE        : 0x00000040,
125     TVIS_OVERLAYMASK         : 0x00000f00,
126     TVIS_STATEIMAGEMASK      : 0x0000f000,
127     TVIS_USERMASK            : 0x0000f000,
128 
129     CLASSNAME: 'SysTreeView32'
130 });
131