; Ice/theme.jl

;; Ice Sawfish theme
;;
;; A quick Eazel theme to be used for the demo stations at Linux World 2000.
;;
;; Design and Graphics by Arlo Rose
;; Implemented by Kenny Graunke and Josh Barrow
;; Based off of the "Eazel" Sawfish theme.
;;
;; © 2000 Eazel, Inc.


(let*
    ;; Update window title pixel length
    ((title-width
      (lambda (w)
	(let
            ((w-width (car (window-dimensions w))))
	  (max 0 (min (- w-width 100) (text-width (window-name w)
                                                  (get-font          "-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1")))))))
     
     ;; ********* TITLE-BAR *********
     ;; 3x18
     (titlebar-left-edge-images (list (make-image "i-titlebar-left-edge.png")
                                      (make-image "titlebar-left-edge.png")))
     
     ;; 20x18
     (titlebar-textbg-images (list (make-image "i-titlebar-textbg.png")
                                   (make-image "titlebar-textbg.png")))
     
     ;; 67x18
     (titlebar-main-ice-scale-images (list (make-image "i-titlebar-main-ice-scale.png")
                                           (make-image "titlebar-main-ice-scale.png")))
     
     ;; 13x18
     (titlebar-left-ice-images (list (make-image "i-titlebar-left-ice.png")
                                     (make-image "titlebar-left-ice.png")))     
     ;; 14x18
     (iconify-images (list (make-image "i-min.png")
                           (make-image "min.png") nil
                           (make-image "p-min.png")))
     
     ;; 14x18
     (maximize-images (list (make-image "i-max.png")
                            (make-image "max.png") nil
                            (make-image "p-max.png")))
     
     ;; 13x18
     (close-images (list (make-image "i-close.png")
                         (make-image "close.png") nil
                         (make-image "p-close.png")))
     
     ;; 5x18
     (titlebar-right-edge-images (list (make-image "i-titlebar-right-edge.png")
                                       (make-image "titlebar-right-edge.png")))
     
     ;; ********** TOP-BORDER **********
     
     ;; 20x5
     (top-left-corner-images (list (make-image "i-top-left-corner.png")
                                   (make-image "top-left-corner.png")))
     
     ;; 16x5
     (top-repeat-images (list (make-image "i-top-repeat.png")
                              (make-image "top-repeat.png")))
     
     ;; 26x6
     (top-right-corner-images (list (make-image "i-top-right-corner.png")
                                    (make-image "top-right-corner.png")))
     
     ;; *********** LEFT-BORDER ***********
     
     ;; 6x16
     (left-repeat-images (list (make-image "i-left-repeat.png")
                               (make-image "left-repeat.png")))
     
     ;; ********** RIGHT-BORDER ***********
     
     ;; 5x16
     (right-repeat-images (list (make-image "i-right-repeat.png")
                                (make-image "right-repeat.png")))
     
     ;; ********** BOTTOM-BORDER **********
     
     ;; 29x6
     (bottom-left-corner-images (list (make-image "i-bottom-left-corner.png")
                                      (make-image "bottom-left-corner.png")))
     
     ;; 16x6
     (bottom-repeat-images (list (make-image "i-bottom-repeat.png")
                                 (make-image "bottom-repeat.png")))
     
     ;; 26x6
     (bottom-right-corner-images (list (make-image "i-bottom-right-corner.png")
                                       (make-image "bottom-right-corner.png")))
     
     (frame `(
	      ;; **TITLE-BAR**
              ;; top left corner
              ((background . ,titlebar-left-edge-images)
	       (left-edge . -5)
	       (top-edge . -23)
	       (class . top-left-corner))
              
              ;; close button
	      ((background . ,close-images)
	       (left-edge . -2)
	       (top-edge . -23)
	       (class . close-button))
              
	      ;; left text bumper
              ((background . ,titlebar-left-ice-images)
	       (top-edge . -23)
               (left-edge . 11)
               ;(right-edge . ,(lambda (w) (+ (title-width w) 71)))
               (class . title))
              
              ;; window title
              ((background . ,titlebar-textbg-images)
	       (foreground . "black")
               (text . ,window-name)
               (x-justify . center)
	       (y-justify . center)          
	       (font . "-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1")
               (top-edge . -23)
               (left-edge . 24)
               (width . ,title-width)
               (class . title))
              
              ;; ice stretch
	      ((background . ,titlebar-main-ice-scale-images)
	       (top-edge . -23)
               (left-edge . ,(lambda (w) (+ (title-width w) 24)))
               (right-edge . 27)
	       (class . title))
              
	      ;; minimize button
              ((background . ,iconify-images)
               (right-edge . 13)
               (top-edge . -23)
               (class . iconify-button))
              
	      ;; maximize button
	      ((background . ,maximize-images)
	       (right-edge . -1)
	       (top-edge . -23)
	       (class . maximize-button))
	      
	      ;; top right corner
	      ((background . ,titlebar-right-edge-images)		
	       (right-edge . -6)
	       (top-edge . -23)
	       (class . top-right-corner))
	      
	      
              
              
	      
	      ;; **TOP-BORDER**
              ;; top left corner (top border half)
              ((background . ,top-left-corner-images)
               (left-edge . -5)
               (top-edge . -4)
               (class . top-left-corner))
              
              ;; top stretch
              ((background . ,top-repeat-images)
               (left-edge . 15)
               (right-edge . 20)
               (top-edge . -4)
               (class . top-border))
              
              ;; top right corner (top border half)
              ((background . ,top-right-corner-images)
               (right-edge . -6)
               (top-edge . -4)
               (class . top-right-corner))
              
              
	      
	      ;; **LEFT-BORDER**
	      ;; left top corner (left border half)
	      ((background . ,left-repeat-images)
	       (left-edge . -5)
	       (top-edge . 0)
	       (height . 20)
	       (class . top-left-corner))
	      
	      ;; left border stretch
	      ((background . ,left-repeat-images)
	       (left-edge . -5)
	       (top-edge . 20)
	       (bottom-edge . 20)
	       (class . left-border))
	      
	      ;; left bottom corner (left border half)
	      ((background . ,left-repeat-images)
	       (left-edge . -5)
	       (bottom-edge . 0)
	       (height . 20)
	       (class . bottom-left-corner))
              
              
              
	      
	      ;; **BOTTOM-BORDER**
	      ;; bottom left grow
	      ((background . ,bottom-left-corner-images)
	       (left-edge . -5)
	       (bottom-edge . -6)
	       (class . bottom-left-corner))
	      
	      ;; bottom stretch
	      ((background . ,bottom-repeat-images)
	       (left-edge . 15)
	       (right-edge . 20)
	       (bottom-edge . -6)
	       (class . bottom-border))
	      
	      ;; bottom right grow
	      ((background . ,bottom-right-corner-images)
	       (right-edge . -6)
	       (bottom-edge . -6)
	       (class . bottom-right-corner))
              
              
              
              
	      ;; **RIGHT-BORDER**
	      ;; top right corner (right border half)
	      ((background . ,right-repeat-images)
	       (right-edge . -6)
	       (top-edge . 0)
	       (height . 20)
	       (class . top-right-corner))
              
	      ;; right stretch
	      ((background . ,right-repeat-images)
	       (right-edge . -6)
	       (top-edge . 20)
	       (bottom-edge . 20)
	       (class . right-border))
	      
	      ;; bottom right corner (right border half)
	      ((background . ,right-repeat-images)
	       (right-edge . -6)
	       (bottom-edge . 0)
	       (height . 20)
	       (class . bottom-right-corner))))
     
     (shaped-frame `(
                     ;; **TITLE-BAR**
                     ;; top left corner
                     ((background . ,titlebar-left-edge-images)
                      (left-edge . -5)
                      (top-edge . -23)
                      (class . top-left-corner))
                     
                     ;; close button
                     ((background . ,close-images)
                      (left-edge . -2)
                      (top-edge . -23)
                      (class . close-button))
                     
	             ;; left text bumper
                     ((background . ,titlebar-left-ice-images)
                      (top-edge . -23)
                      (left-edge . 11)
                      ;(right-edge . ,(lambda (w) (+ (title-width w) 71)))
                      (class . title))
                     
                     ;; window title
                     ((background . ,titlebar-textbg-images)
                      (foreground . "black")
                      (text . ,window-name)
                      (x-justify . center)
                      (y-justify . center)          
                      (font . "-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1")
                      (top-edge . -23)
                      (left-edge . 24)
                      (width . ,title-width)
                      (class . title))
                     
                     ;; ice stretch
                     ((background . ,titlebar-main-ice-scale-images)
                      (top-edge . -23)
                      (left-edge . ,(lambda (w) (+ (title-width w) 24)))
                      (right-edge . 27)
                      (class . title))
                     
	             ;; minimize button
                     ((background . ,iconify-images)
                      (right-edge . 13)
                      (top-edge . -23)
                      (class . iconify-button))
                     
	             ;; maximize button
                     ((background . ,maximize-images)
                      (right-edge . -1)
                      (top-edge . -23)
                      (class . maximize-button))
                     
 	             ;; top right corner
                     ((background . ,titlebar-right-edge-images)		
                      (right-edge . -6)
                      (top-edge . -23)
                      (class . top-right-corner))

                     ;; bottom shadow, part I
                     ((background . "black")
                      (height . 1)
                      (top-edge . -4)
                      (left-edge . -5)
                      (right-edge . -6)
                      (class . title))
                     
                     ;; bottom shadow, part II
                     ((background . "black")
                      (height . 1)
                      (top-edge . -3)
                      (left-edge . -3)
                      (right-edge . -6)
                      (class . title)))))
  
  (add-frame-style 'Ice
		   (lambda (w type)
		     (case type
		       ((default) frame)
		       ((transient) frame)
		       ((shaped) shaped-frame)
		       ((shaped-transient) shaped-frame))))
  (call-after-property-changed
   'WM_NAME (lambda ()
              (rebuild-frames-with-style 'Ice))))
