[Zope] Changing tree icon colors

Martijn Pieters mj@antraciet.nl
Wed, 07 Jul 1999 13:47:08 +0200


>Note that I did not implement the 'childless_decoration' attribute. This 
>is a quick patch...

I used my lunchbreak to add this as well, because it looked ugly without:

Example:
<!--#tree opened_decoration="/HelpSys/hs_obook" 
closed_decoration="/HelpSys/hs_cbook" 
childless_decoration="/HelpSys/hs_dnode"-->
Here the plus and minus symbols are replaced by the help system opened and 
closed book icons. Nodes without children are displayed with the helpsystem 
document icon.

This is a new patch, _replacing_ the previous one I posted (you did keep a 
copy of the old version, didn't you?).

Again, I'll post this patch to the Collector.

Patch against 1.10.3:
*** TreeTag.py  Wed Jul  7 13:22:59 1999
--- TreeTag.py  Wed Jul  7 13:23:30 1999
***************
*** 99,104 ****
--- 99,107 ----
   tplus=tbl[:ord('+')]+'-'+tbl[ord('+')+1:]
   tminus=tbl[:ord('-')]+'+'+tbl[ord('-')+1:]

+ plus_icon = '/p_/pl'
+ minus_icon = '/p_/mi'
+
   class Tree:
       name='tree'
       blockContinuations=()
***************
*** 112,120 ****
                             branches=None, branches_expr=None,
                             sort=None, reverse=1, skip_unauthorized=1,
                             id=None, single=1, url=None,
!                           # opened_decoration=None,
!                           # closed_decoration=None,
!                           # childless_decoration=None,
                             assume_children=1)
           has_key=args.has_key

--- 115,123 ----
                             branches=None, branches_expr=None,
                             sort=None, reverse=1, skip_unauthorized=1,
                             id=None, single=1, url=None,
!                           opened_decoration=None,
!                           closed_decoration=None,
!                           childless_decoration=None,
                             assume_children=1)
           has_key=args.has_key

***************
*** 132,137 ****
--- 135,144 ----

           if not has_key('id'): args['id']='tpId'
           if not has_key('url'): args['url']='tpURL'
+         if not has_key('opened_decoration'):
+             args['opened_decoration']=minus_icon
+         if not has_key('closed_decoration'):
+             args['closed_decoration']=plus_icon
           if not has_key('childless_decoration'):
               args['childless_decoration']=''

***************
*** 377,397 ****
               script=md['SCRIPT_NAME']
               if exp:
                   treeData['tree-item-expanded']=1
                   output('<A NAME="%s">'
                          '<A HREF="%s?tree-c=%s#%s">'
!                        '<IMG SRC="%s/p_/mi" BORDER=0></A></A>' %
!                        (id, root_url, s, id, script))
               else:
                   output('<A NAME="%s">'
                          '<A HREF="%s?tree-e=%s#%s">'
!                        '<IMG SRC="%s/p_/pl" BORDER=0></A></A>' %
!                        (id, root_url, s, id, script))
               output('</TD>\n')

           else:
               if level > 2: output('<TD COLSPAN="%s"></TD>' % level)
               elif level > 0: output('<TD></TD>' * level)
!             output('<TD WIDTH="16"></TD>\n')


           # add item text
--- 385,415 ----
               script=md['SCRIPT_NAME']
               if exp:
                   treeData['tree-item-expanded']=1
+                 if have_arg('opened_decoration'):
+                     icon=args['opened_decoration']
+                 else: icon=minus_icon
                   output('<A NAME="%s">'
                          '<A HREF="%s?tree-c=%s#%s">'
!                        '<IMG SRC="%s%s" BORDER=0></A></A>' %
!                        (id, root_url, s, id, script, icon))
               else:
+                 if have_arg('closed_decoration'):
+                     icon=args['closed_decoration']
+                 else: icon=plus_icon
                   output('<A NAME="%s">'
                          '<A HREF="%s?tree-e=%s#%s">'
!                        '<IMG SRC="%s%s" BORDER=0></A></A>' %
!                        (id, root_url, s, id, script, icon))
               output('</TD>\n')

           else:
               if level > 2: output('<TD COLSPAN="%s"></TD>' % level)
               elif level > 0: output('<TD></TD>' * level)
!             if have_arg('childless_decoration') and 
args['childless_decoration']:
!                 output('<TD WIDTH="16"><IMG SRC="%s%s"></TD>\n' %
!                        (md['SCRIPT_NAME'], args['childless_decoration']))
!             else:
!                 output('<TD WIDTH="16"></TD>\n')


           # add item text
***************
*** 648,656 ****
       return r


- #icoSpace='<IMG SRC="Blank_icon" BORDER="0">'
- #icoPlus ='<IMG SRC="Plus_icon" BORDER="0">'
- #icoMinus='<IMG SRC="Minus_icon" BORDER="0">'



--- 666,671 ----


--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------