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.


['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.


var a_iconkeys = ['name',0,4,8,12,64,68,72,76],
a_classes = [null,

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

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:


var TREE_ITEMS = [
['projects',0,iss(1,-1, 1),

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!

Back to forum: