BLT hiertable questions 
Author Message
 BLT hiertable questions

Folks,

I have a few questions on the BLT hiertable.  Here's an example
application.

   blt::hiertable .h
   .h column configure treeView -text Name
   .h column insert end col1
   .h column insert end col2
   set e1 [ .h insert end entry1 ]
   .h entry configure $e1 -data "col1 foo col2 bar"
   set e2 [ .h insert end entry2 ]
   .h entry configure $e2 -data "col1 foo2 col2 xyzzy"
   .h entry configure $e2 -foreground blue
   pack .h -fill both

a. How can I change the foreground color of one cell?  Suppose I want
   the text xyzzy to be red.

b. The text for the second entry is blue.  But, when I select that
   line of the hiertable, its Name field (text "entry2") turns
   black.  How can I keep it blue even when selected?

c. I want to configure the text in the treeView (Name) column for one
   entry to be blank.  I tried a few things with no success:

   .h entry configure $e1 -data {treeView ""} ;# crashes solaris 2.4v
   .h entry configure $e1 -label "" ;# no visible effect
   .h entry configure $e1 -data {Name ""} ;# error can't find "Name"

   Any suggestions?

d. With an answer to (a), I may be able to figure this out; but given
   an existing "balloon help" / tooltip implementation, how can I
   set a tooltip for a single cell?  I want to turn the xyzzy text red
   to indicate an error of some kind, and then I want to use the tooltip
   approach to display the reason for the error.  So, I don't want to
   apply the tooltip to an entire entry or to an entire column, just
   to one cell.

Any help would be appreciated.



Fri, 03 Jun 2005 01:50:26 GMT  
 BLT hiertable questions

Quote:

> I have a few questions on the BLT hiertable.  Here's an example
> application.
>    blt::hiertable .h
>    .h column configure treeView -text Name
>    .h column insert end col1
>    .h column insert end col2
>    set e1 [ .h insert end entry1 ]
>    .h entry configure $e1 -data "col1 foo col2 bar"
>    set e2 [ .h insert end entry2 ]
>    .h entry configure $e2 -data "col1 foo2 col2 xyzzy"
>    .h entry configure $e2 -foreground blue
>    pack .h -fill both
> a. How can I change the foreground color of one cell?  Suppose I want
>    the text xyzzy to be red.

This answer is for BLT 2.4z only.  You can create a special "style"
for the cell.

    .h style text "myStyle" -foreground red
    .h style set "myStyle" "col2" $e2      

Quote:
> b. The text for the second entry is blue.  But, when I select that
>    line of the hiertable, its Name field (text "entry2") turns
>    black.  How can I keep it blue even when selected?

Selected entries are drawn using the -selectforeground and
-selectbackground colors.  There's no way to use particular colors for
specific selected entries.  Sounds like you're using selection
highlighting to mark certain entries.  You might want to use an extra
column for marking entries.  Check out the ./demos/treeview1.tcl demo
for an example of checkbox styles.

Quote:
> c. I want to configure the text in the treeView (Name) column for one
>    entry to be blank.  I tried a few things with no success:
>    .h entry configure $e1 -data {treeView ""} ;# crashes solaris 2.4v
>    .h entry configure $e1 -label "" ;# no visible effect
>    .h entry configure $e1 -data {Name ""} ;# error can't find "Name"

You can control the column label with column's -text option.

    .h column configure treeView -text ""

Quote:
> d. With an answer to (a), I may be able to figure this out; but given
>    an existing "balloon help" / tooltip implementation, how can I
>    set a tooltip for a single cell?  I want to turn the xyzzy text red
>    to indicate an error of some kind, and then I want to use the tooltip
>    approach to display the reason for the error.  So, I don't want to
>    apply the tooltip to an entire entry or to an entire column, just
>    to one cell.

This answer is again for 2.4z, but it can be done in previous versions
too.  You can bind events to the style.

    .h bind "myStyle" <Enter> {
        puts "entered entry=[.h get current], column=[.h column current]"
    }
    .h bind "myStyle" <Leave> {
        puts "left entry=[.h get current], column=[.h column current]"
    }

For previous versions, you will have to bind to hiertable widget
itself. It's more complicated since you have to handle the determine
the Enter/Leave events for yourself.

    set current " "
    bind .h <Motion> {
        set column [.h column nearest %x]
        set entry [.h get current]
        set new [list $entry $column]
        if { $current != $new }  {
            if { $current == "entry2 col2" && [llength $current] > 0 } {
                puts "left $current"
            }
            if { $new == "entry2 col2" } {
                puts "entered $new"
                set current $new
            } else {
                set current ""
            }
        }
    }  

    bind .h <Leave> {
        puts "left $current"
        set current ""
    }

Note. The "hiertable" is old name for the "treeview" widget.  The two
commands work exactly the same way.  It's okay to use "hiertable".

--gah



Sat, 04 Jun 2005 09:06:25 GMT  
 BLT hiertable questions
George,

Quote:
> > a. How can I change the foreground color of one cell?  Suppose I
> >    want the text xyzzy to be red. [...]
> > d. With an answer to (a), I may be able to figure this out; but
> >    given an existing "balloon help" / tooltip implementation, how
> >    can I set a tooltip for a single cell?
> This answer is for BLT 2.4z only.  You can create a special "style"
> for the cell. [...]

Thanks.  I will update to 2.4z and try that.

Quote:
> > b. The text for the second entry is blue.  But, when I select that
> >    line of the hiertable, its Name field (text "entry2") turns
> >    black.  How can I keep it blue even when selected?

> Selected entries are drawn using the -selectforeground and
> -selectbackground colors.  There's no way to use particular
> colors for specific selected entries.  Sounds like you're using
> selection highlighting to mark certain entries.

In the example, all of the text on the line is blue, until I
click on it.  While the rest of the cell text stays blue, that
one piece of text turns black.  Is that unavoidable?  I want all
the text on the line to stay blue regardless of whether or not
that line is selected.  If a different line is displayed in
orange text, then I want that text to stay orange regardless of
whether or not that line is selected.

Quote:
> > c. I want to configure the text in the treeView (Name) column for
> >    one entry to be blank.  I tried a few things with no success:

> You can control the column label with column's -text option.

Thanks, but I want to set the cell text for an *entry* in that column
to empty.  Is there a way to do that?




Sun, 05 Jun 2005 04:05:54 GMT  
 BLT hiertable questions
George,

Quote:
> > > a. How can I change the foreground color of one cell?  Suppose I
> > >    want the text xyzzy to be red. [...]
> > This answer is for BLT 2.4z only.  You can create a special "style"
> > for the cell. [...]
> Thanks.  I will update to 2.4z and try that.

I guess there is some "priority" used to decide which color wins.
When I set the color of a line using ".h entry configure $e1
-foreground blue", then use a style to set one of its fields red,
the blue "wins".  The red never appears.  

Is that the intended behavior?  It seems the style is "less important"
than the entry, so your suggestion doesn't work for me.  I know the
style itself works, because the text turns red when I leave off the
"entry configure -foreground blue".

Quote:
> > > b. The text for the second entry is blue.  But, when I select that
> > >    line of the hiertable, its Name field (text "entry2") turns
> > >    black.  How can I keep it blue even when selected?

> > Selected entries are drawn using the -selectforeground and
> > -selectbackground colors.  There's no way to use particular
> > colors for specific selected entries.  Sounds like you're using
> > selection highlighting to mark certain entries.

> In the example, all of the text on the line is blue, until I
> click on it.  While the rest of the cell text stays blue, that
> one piece of text turns black.  Is that unavoidable?

In 2.4z, the behavior is different; I was using 2.4v.  In 2.4z,
the entire line turns black when it is selected.  I guess I will
have to rethink my design; but at least now all the columns react
the same way.  In 2.4v the treeview column was a different color
than the other columns.

The tooltip stuff you suggested works fine; thanks!




Sun, 05 Jun 2005 12:18:57 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. blt::hiertable question

2. BLT hiertable questions

3. editing data in blt's hiertable widget

4. Problem with BLT hiertable

5. Changing background colour of BLT hiertable

6. BLT 2.4s: hiertable problems

7. BLT2.4u Hiertable core dumps

8. BLT2.4o Hiertable

9. BLT: the instruction order is surprisingly relevant ( BLT 2.4 tk 8.0.5 windows NT)

10. ANNOUNCE: BLT busy for Windows, Tk 8.0, BLT 8.0 unofficial

11. BLT Zoom Stack question

12. BLT graph question - tilting at axis labels...

 

 
Powered by phpBB® Forum Software