# mytheme.tcl - Copyright (C) 2005 Jelco Huijser jelco@user.sourceforge.net
# Based on sriv.tcl by Pat Thoyts <patthoyts@users.sourceforge.net>
# Images loosely based on the Mac OS X Aluminum Alloytheme  
# mytheme.tcl,v 0.1 2005/08/18 Jelco Huijser
#
#

namespace eval tile::theme::mytheme {

    package provide tile::theme::mytheme 1.0

    set imgdir [file join [file dirname [info script]] mytheme]
    array set I [tile::LoadImages $imgdir *.gif]

    array set colors {
        -frame          "#e7eaf0"
        -lighter        "#f9f6f6"
        -window         "#f9f6f6"
        -selectbg       "#f5f8fe"
        -selectfg       "#000000"
        -disabledfg     "#888a8d"
        -disabledbg     "#e7eaf0"
    }

    style theme create mytheme -settings {

        style default . \
            -borderwidth        1 \
            -background         $colors(-frame) \
            -fieldbackground    $colors(-window) \
            -troughcolor        $colors(-lighter) \
            -selectbackground   $colors(-selectbg) \
            -selectforeground   $colors(-selectfg) \
            -disabledbackground $colors(-disabledbg) \
            -disabledforeground $colors(-disabledfg) \
            ;
        style map . -foreground [list disabled $colors(-disabledfg)]

        ## Buttons.
        #
        style default TButton -padding "7 0"
        style layout TButton {
            Button.button -children {
                Button.focus -children {
                    Button.padding -children {
                        Button.label
                    }
                }
            }
        }

        style element create button image $I(button-n) \
            -map [list pressed $I(button-p)  active $I(button-h)] \
            -border 7 -sticky ew

        style element create Checkbutton.indicator image $I(check-nu) \
            -width 24 -sticky w -map [list \
                {!disabled active selected} $I(check-hc) \
                {!disabled active} $I(check-hu) \
                {!disabled selected} $I(check-nc) ]

        style element create Radiobutton.indicator image $I(radio-nu) \
            -width 24 -sticky w -map [list \
                {!disabled active selected} $I(radio-hc) \
                {!disabled active} $I(radio-hu) \
                selected $I(radio-nc) ]

        style default TMenubutton -relief raised -padding {9 2}

        ## Toolbar buttons.
        #
        style default Toolbutton \
            -width 0 -relief flat -borderwidth 1 -padding 4 \
            -background $colors(-frame) -foreground #000000 ;
        style map Toolbutton -background [list active $colors(-selectbg) disabled $colors(-disabledbg)]
        style map Toolbutton -foreground [list active $colors(-selectfg) disabled $colors(-disabledfg)]
        style map Toolbutton -relief {
            disabled    flat
            selected    sunken
            pressed     sunken
            active      raised
        }

        ## Entry widgets.
        #
        style default TEntry \
            -selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
        style default TCombobox \
            -selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
        style default TButton -padding {5 0} -font {Helvetica -12 bold}

        ## Notebooks.
        #
    style element create tab image $I(tab-n) \
        -map [list selected $I(tab-p) active $I(tab-s) disabled $I(tab-hide-n) ] \
        -border {10 6 10 2} -height 12

#       style default TNotebook.Tab -padding {4 2 4 2}
#       style map TNotebook.Tab \
#           -background \
#               [list selected $colors(-frame) active $colors(-lighter)] \
#           -padding [list selected {4 4 4 2}]

        ## Scrollbars.
        #
        style layout Vertical.TScrollbar {
            Scrollbar.trough -children {
                Scrollbar.uparrow -side top
                Scrollbar.downarrow -side bottom
                Scrollbar.uparrow -side bottom
                Vertical.Scrollbar.thumb -side top -expand true -sticky ns
            }
        }

        style layout Horizontal.TScrollbar {
            Scrollbar.trough -children {
                Scrollbar.leftarrow -side left
                Scrollbar.rightarrow -side right
                Scrollbar.leftarrow -side right
                Horizontal.Scrollbar.thumb -side left -expand true -sticky we
            }
        }

        style element create Horizontal.Scrollbar.thumb image $I(sb-thumb) \
            -map [list {pressed !disabled} $I(sb-thumb-p)] -border 11 -padding "12 1"

        style element create Vertical.Scrollbar.thumb image $I(sb-vthumb) \
            -map [list {pressed !disabled} $I(sb-vthumb-p)] -border 11 -padding "1 12"

        foreach dir {up down left right} {
            style element create ${dir}arrow image $I(arrow${dir}) \
                -map [list \
                    disabled $I(arrow${dir}) \
                    pressed $I(arrow${dir}-p) \
                    active $I(arrow${dir}-h)] \
                -border 1 -sticky {}
        }

        ## Scales.
        #
        style element create Scale.slider \
            image $I(slider) -map [list {pressed !disabled} $I(slider-p)]

        style element create Vertical.Scale.slider \
            image $I(vslider-p) -map [list {pressed !disabled} $I(vslider-p)]

        style element create Horizontal.Progress.bar \
            image $I(sb-thumb) -border 2
        style element create Vertical.Progress.bar \
            image $I(sb-vthumb) -border 2

        ## Treeview
        #
        style theme settings mytheme {
        style map Item -foreground [list selected #FFFFFF]
        style default Row -background "#EEEEEE"
        style default Heading -borderwidth 1 -relief raised -font TkTextFont
        style default Item -justify left
        style map Heading -relief {
            pressed sunken
        }
        style map Row -background {
            selected    #3c9bf7
            focus       #ccccff
            alternate   #FFFFFF
        }
        style map Cell -foreground {
            selected    #FFFFFF
        }
    }

    }
}