Gradient Header Panel

In many modern applications you'll find a gradient header panel bearing a title, some text and an icon on a gradient.

In Swing applications this widget became popular due to the excellent work of Karsten Lentzsch (http://www.jgoodies.com ).

Below you'll find soon a snit widget providing this widget in pure tcl. It is based on the gradient work of George Peter Staplin.

--- 26th. August 2005. I enhanced the code a bit. When the color resolution of the used display is too low (read != 32bit) to paint a smooth gradient, a plain background using bg0 is painted. This avoids unpleasent strips.

Author Carsten Zerbst

gradientpanel.png

 #
 # Gradient Panel
 # 
 # a clone of Karsten Lentzsch GradientPanel in Tcl
 # using the canvas and the gradient code found in 
 # tclers wiki. It is implemented using Snit as pure tcl  
 # megawidget.
 #
 #
 # Links: 
 # Karsten Lentzsch www.jgoodies.com
 # Snit: http://www.wjduquette.com/snit/
 # Gradient: https://wiki.tcl-lang.org/6100
 #
 # Author: Carsten Zerbst [email protected]
 #
 package require snit
 package require Tk
 package require Img

 package provide gradientpanel 0.1

 snit::widgetadaptor gradientpanel {
    option -font 
    option -text 
    option -title 
    option -bg0 -default white 
    option -bg1 
    option -fg -default black
    option -icon 

    constructor { args } {
        # Create a canvas widget
        installhull [ canvas $self]
        
        $self configure -height 125
        $self configurelist $args
        
        # if nothing set, determine gradient color
        if {[string length [$self cget -bg1]] == 0} {
            # try to determine new end color
            frame $self.dummyframe 
            $self configure -bg1 [ $self.dummyframe cget -bg]
            destroy $self.dummyframe                                         
        }        
        # same for font
        if {[string length [$self cget -font]] == 0} {
            label $self.dummylabel
            $self configure -font [ $self.dummylabel cget -font]
            destroy $self.dummylabel
        }        
        
        $self _drawText
        $self _drawGradient
        bind $win <Configure> [list $self _drawGradient ]
    }

    # this delegates some methods to be able to manipulate 
    # the canvas context
    delegate method * to hull 
    delegate option * to hull
    
    # use to draw the text
    method _drawText { } {
        
        set font [$self cget -font ]
        $self delete text
        $self create text 30 30 -text [$self cget -title]  -anchor w \
            -font $font -fill [$self cget -fg] -tag [list text title] 
        set y 50
        if {[llength $font] > 2} {
            set messagefont [lreplace $font 2 2 normal]
        } else {
            set messagefont $font
        }
        foreach tok [split [$self cget -text] \n] {
            $self create text 40 $y -text $tok -anchor w \
                -font $messagefont -fill [$self cget -fg] \
                -tag [list text message]
            incr y 18
        }
    }
    
    # used to redraw the gradient and icon after resize
    method _drawGradient { } {
        
        $self delete gradient
        
        set width  [winfo width $win]
        set height [winfo height $win]
        set max $width; 
        
        if {[catch {winfo rgb $self [ $self cget -bg0 ]} color1]} {
            puts stderr $color1
            return -code error "Invalid color [ $self cget -bg0 ]"
        }
        
        if {[catch {winfo rgb $self [ $self cget -bg1 ]} color2]} {
            return -code error "Invalid color [ $self cget -bg1 ]"
        }
        
                # Check color resolution. Low color resolution results in stripes
        # instead of a smooth gradient. In this case we better use only
        # bg0 as background
        if {[lindex [ winfo rgb $self #010000 ] 0] != 257 } {

            $win create rectangle  0 0 $width $height -tags gradient -fill [ $self cget -bg0 ]

        } else {

            foreach {r1 g1 b1} $color1 break
            foreach {r2 g2 b2} $color2 break
            set rRange [expr $r2.0 - $r1]
            set gRange [expr $g2.0 - $g1]
            set bRange [expr $b2.0 - $b1]
            
            set rRatio [expr $rRange / $max]
            set gRatio [expr $gRange / $max]
            set bRatio [expr $bRange / $max]
            
            
            for {set i 0} {$i < $max} {incr i  } {
                set nR [expr int( $r1 + ($rRatio * $i) )]
                set nG [expr int( $g1 + ($gRatio * $i) )]
                set nB [expr int( $b1 + ($bRatio * $i) )]
                
                set col [format {%4.4x} $nR]
                append col [format {%4.4x} $nG]
                append col [format {%4.4x} $nB]
                
                $win create line $i 0 $i $height -tags gradient -fill #${col} 
                
            }
        }
        $self lower gradient

        # draw icon
        $self delete icon
        set icon [$self cget -icon] 
        if {[string length $icon ] > 0} {
            set distance 10    
            set xmin [expr [lindex [$win bbox text] 2] + $distance]                         
            set width [ winfo width $self]
            set x [expr $width - [image width $icon ]]                         
            if { $xmin  > $x } {
                set x $xmin
            }
            set y [ winfo height $self]
            
            $self create image $x $y -image $icon -anchor sw -tag icon
            
        }
    }
 }


A simple example looks like this


 package require Tk
 if {[catch {package require gradientpanel}]} {
     source gradientpanel.tcl
 }

 set bild "R0lGODlhnAB9AOcAAP39/f7+/v////n5+fDw8Ofn5+jo6Obm5vf398rKytTU
 1NPT09HR0bm5ucDAwMLCwry8vOvr66CgoF1dXUlJSUVFRWpqanV1dY2NjZeX
 l39/f4uLi7+/v+3t7dDQ0GxsbDIyMjU1NVBQUJmZmU1NTVtbW09PT1hYWG1t
 ba6urvz8/PHx8enp6eDg4Nra2s7Ozpqamjs7O0FBQYSEhHd3d0dHRz4+PkRE
 REhISEpKSlNTU3BwcK2trcHBwc/Pz7u7u7CwsD09PVZWVl5eXk5OTkxMTEND
 Q1dXV35+fjo6Ojk5OVJSUnFxcW5ubrW1tZycnJOTk4qKipubm319fVxcXEtL
 S4mJiVlZWTY2NjAwMC8vLy4uLjExMUBAQGNjY76+vtvb29zc3N7e3tjY2MvL
 y6ysrHZ2dl9fX8nJyTQ0NFpaWmZmZmtra6Ojo+zs7O7u7uTk5KWlpZSUlIGB
 gWlpaWBgYHJycq+vr4WFhYyMjIODg9fX19nZ2erq6tbW1rKysqSkpHp6eo+P
 j+Xl5eHh4aurq4CAgLGxsaioqIeHh0JCQnx8fJiYmO/v7/Pz8/X19d3d3czM
 zMTExM3NzY6OjkZGRlVVVZWVldLS0vr6+vj4+PT09MjIyKenp3Nzc3R0dHl5
 eePj4+Li4tXV1bS0tKGhoWdnZ29vb5+fn8fHx6qqqpaWlp2dnWhoaIKCglRU
 VFFRUWJiYmRkZJCQkLq6ujw8PD8/P2VlZbOzs6ampqmpqXh4eHt7e4aGhmFh
 YTg4ODc3NzMzM7a2tsXFxZ6enoiIiJKSkpGRkb29vbe3t6Kiori4uN/f38PD
 w/Ly8sbGxi0tLSwsLCgoKCUlJSYmJioqKisrKycnJykpKSMjIyEhISAgICIi
 IiQkJB4eHh8fH///////////////////////////////////////////////
 ////////////////////////////////////////////////////////////
 /////////////////////yH5BAEKAP8ALAAAAACcAH0AAAj+AP8JHEi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PgukYhA+xBCFSXAADiADWigEIEAFYmA+QbgE0bgEFjuGJ9iAGdCD
 DcgAVjiayWkXUpAEDigDXCiDO+ABYegEcwEFJCAeX3CWVtCARdCDRECCKTiv
 JoiFWLAANriAQFiEC/CEDbiE07D+AJwoCzooARIYgjVQBBKIBRvxgiM4AVkY
 gjM4BSoQBEmYs0+wgyiowMMIBQb4gWZIMVXQBQlgBSkwhlnIAJAjF9m4hESY
 Axy7BKSRAoTaBT0oAwd4gDsQhhTAhUlUBiiwglaoPR75BAvAPCQQHSvghS60
 gF04qg+wA3PjhUWAAmOggUZTNZpqhTpQA9jrAktgg13AFyogAlmIhVtgghLA
 gGRwhV2AGziMQ8PwgB94gARwgDboBP9gBTnAgBFoNufrhctJwRm4HMkxBjyI
 gg/jASdwACfIEATChTbYMDaYAzOgAjXwJl7oBSS4BQ2Igik4g1agg09Yghug
 A0/4BDMyMIQpOIYRwAM2aAUdoIPQ+4BbOANfkIUK2BbfaAIqqAJf0CMUKIFe
 WIZeSIRT8C6OCAgAOw=="


 #
 # Example code
 #
 proc example { } {
    #set m1 [ image create photo -file möwe.png]
    set m1 [ image create photo -data $::bild]
    set text [join [list "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." \
                        "Pellentesque at tortor. Morbi ac wisi imperdiet enim" \
                        "mattis egestas. Sed ac"] \n]
    
    set title "Lorem Ipsum"
    set gp [ gradientpanel create .test -text $text -title $title -icon $m1 ]
    
    label .rest -text "The Rest of Your Panel"
    
    grid $gp -sticky ew
    grid .rest -sticky nesw
    
    grid columnconfigure . 0 -weight 1
    grid rowconfigure . 1 -weight 1
    
    wm geometry . 600x300
 } 

 example

escargo 10 Aug 2005 - Added code to _drawText for cases where the font name is less than 3 elements; modified the example so that if the page is processed by wish-reaper the single file becomes executable.


schlenk - How about adding this widget to tklib?

One minor suggestion: add an option -titlefont to configure the font for the title indepentently from the rest of the text