Use Unicode characters for bullets

The original tkoutline used text characters as the bullets ("[+]", "[-]" and " * ") and this was replaced by using images instead. The old functionality is still available via the preferences file.

Images as bullets works fine and does have the drawback that a separate command is needed to insert the images vs. inserting the rest of the text. When a node is "drawn", text based bullets are inserted and then they are replaced with an image.

Another option would be to use bullet-like unicode characters. Unlike the bullet images, unicode characters can be inserted just like normal text. Also, the forground color and size and be easily modified. One drawback to using unicode is that some systems don't have (some? all?) unicode characters available. Hopefully there is a way to automatically detect this so tkoutline could fallback gracefully to images. I wouldn't be too surprised if such automatic detection were not possible.

Here is some experimental code that can be placed in your startup script (Edit->Edit startup script). It will cause unicode characters to be used for bullets:

 # Set the preferences to not use images
 option add *Text.useBulletImages 0 user
 option add *Text.bulletFont "Courier 11" user

 # Tkoutline's current version of setNodeMargins incorrectly uses the indentString to
 # determine margin2.  This version hard-codes (ugh) the bullet used for measuring the
 # margin
 proc ::outlinewidget::setNodeMargins {win tree node} {
    set margin1 [expr ([$tree depth $node] - 1) * [font measure [option get $win bulletFont Text] "\u25bc "]]
        if {[$tree keyexists $node nobullet]} {
            set margin2 [expr $margin1 + [font measure [option get $win bulletFont Text] " "]]
        } else {
            set margin2 [expr $margin1 + [font measure [option get $win bulletFont Text] "\u25bc  "]]
            }
        $win tag configure item:$node -lmargin1 $margin1
        $win tag configure item:$node -lmargin2 $margin2
    }

 # The current version uses [+], [-], and *.  Here Unicode characters are used instead
 proc ::outlinewidget::nodeBulletToText {tree node} {
    if {![$tree isleaf $node] || [$tree keyexists $node openCmd]} {
        if {[$tree set $node expand]} {
            set bullet " \u25bc"
                set stateTags {expanded expandtext}
                } else {
                    set bullet " \u25ba"
                    set stateTags {collapsed collapsetext}
                    }
        } else {
            set bullet " \u25cf"
                set stateTags {leaf leaftext}
            }
        if {[$tree keyexists $node nobullet]} {
            set bullet ""
            }
        set bullet [list "$bullet" $stateTags]
        return $bullet
    }


Updated 13 Jan 2005, 02:32 GMT
Search - Recent Changes - 2 References - About WiKit - Go to Tkoutline - Help
Sourceforge logo