Board Logo

Overriding icons
Tolstoy - 5/25/2006 at 02:30 AM

Is there anyway to override all of the default icons without having to specify i0,i4,i8, et cetera in the items file? I want to have a special icon for one of my items that doesn't change... but the only way I could make it work was to specify it for every single icon state, which is rather cumbersome.

Example:

['MyWindow', 0, {'tt' : 'My tooltip', 'sb':'Use Firefox dude', 'i0' : 'icons/myicon.gif', 'i4' : 'icons/myicon.gif', 'i8' : 'icons/myicon.gif', 'i12' : 'icons/myicon.gif', 'i64' : 'icons/myicon.gif', 'i68' : 'icons/myicon.gif', 'i72' : 'icons/myicon.gif', 'i76' : 'icons/myicon.gif'},

I personally would prefer something like

['MyWindow', 0, {'tt' : 'My tooltip', 'sb':'Use Firefox dude', 'i99' : 'icons/myicon.gif'},

Would be much easier! All around great product!


tigra - 5/25/2006 at 11:39 AM

here is how we approach this issue in the SCMS:

1. here we describe the supported classes and icons for each of them.

Code:

var a_iconkeys = ['name',0,4,8,12,64,68,72,76],
a_classes = [null,
['project','cl1.gif','cl1.gif','cl1.gif','cl1.gif','cl1.gif','cl1.gif','cl1.gif','cl1.gif'],
['folder','cl2.gif','cl2.gif','folderopen.gif','folderopen.gif','folderopen.gif','folderopen.gif','folderopen.gif','folderopen.gif'],
['document','cl3.gif','cl3.gif','cl3.gif','cl3.gif','cl3.gif','cl3.gif','cl3.gif','cl3.gif'],
['template','cl4.gif','cl4.gif','cl4.gif','cl4.gif','cl4.gif','cl4.gif','cl4.gif','cl4.gif'],
['script','cl5.gif','cl5.gif','cl5.gif','cl5.gif','cl5.gif','cl5.gif','cl5.gif','cl5.gif'],
['variable','cl6.gif','cl6.gif','cl6.gif','cl6.gif','cl6.gif','cl6.gif','cl6.gif','cl6.gif']
];


2. this function merges item scope settings of particular item (in this case id) with the class information
Code:

function iss (class_id, item_id, selectable) {
var iss_data = [];
for (var i = 0; i < a_iconkeys.length; i++)
iss_data['i' + a_iconkeys] = ip + a_classes[class_id];
iss_data['id'] = item_id;
iss_data['cid'] = class_id;
iss_data['sel'] = selectable;
return iss_data;
};


3. then in the items structure we just call the function providing class id and item specific data:

Code:

var TREE_ITEMS = [
['projects',0,iss(1,-1, 1),
['softcomplex',0,iss(1,1),
['index.html',0,iss(3,21),
['title',0,iss(6,22)],
...


your implementation mey be different but approach is the same: move the long and repeating stuff somewhere so you can refer it from the multiple locations.


Tolstoy - 6/14/2006 at 07:40 AM

Very cool, very powerful. Thanks!


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/