;; Step/theme.jl

;; Copyright (C) 1999 Michele Campeotto <golia@supereva.it>

;; This theme is based on Window Maker, another window manager for X11
;; (wich is based on Apple NeXTStep), I ported it to Sawmill because I liked
;; his look'n'feel but Window Maker is'nt working well with Gnome.

;; --- Frame preferences ---------------------------------------------------

(defgroup Step-frame "Step theme options")

(defcustom Step:title-active-color (get-color "white")
  "Title active color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

(defcustom Step:title-inactive-color (get-color "black")
  "Title inactive color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

(defcustom Step:title-alignement 'center
  "Alignement of the text in the titlebar (needs a restart)"
  :group Step-frame
  :type symbol
  :options (left center right)
  :after-set after-setting-frame-option)

(defcustom Step:titlebar-active-color (get-color "black")
  "Titlebar active color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

(defcustom Step:titlebar-inactive-color (get-color "gray")
  "Titlebar inactive color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

(defcustom Step:flat-buttons t
  "Use flat buttons on titlebar"
  :group Step-frame
  :type boolean
  :after-set after-setting-frame-option)

(defcustom Step:resizebar-active-color (get-color "gray")
  "Resizebar active color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

(defcustom Step:resizebar-inactive-color (get-color "gray")
  "Resizebar inactive color"
  :group Step-frame
  :type color
  :after-set after-setting-frame-option)

;; --- Frame definition ----------------------------------------------------

(let* (
	(title-font (get-font "-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*"))
	(title-colors (lambda () (list Step:title-inactive-color Step:title-active-color)))
	(titlebar-colors (lambda () (list Step:titlebar-inactive-color Step:titlebar-active-color)))
	(resizebar-colors (lambda () (list Step:resizebar-inactive-color Step:resizebar-active-color)))
	(alignement Step:title-alignement)

	(minimize-flat (list
		(make-image "minimize-flat-inactive-t.png")
		(make-image "minimize-flat-active-t.png") nil
  		(make-image "minimize-flat-pressed.png")))

	(minimize-bevel (list
		(make-image "minimize-bevel-inactive-t.png")
		(make-image "minimize-bevel-active-t.png") nil
  		(make-image "minimize-bevel-pressed-t.png")))

	(minimize (lambda ()
		(if Step:flat-buttons minimize-flat minimize-bevel)))

	(close-flat (list
		(make-image "close-flat-inactive-t.png")
		(make-image "close-flat-active-t.png") nil
  		(make-image "close-flat-pressed.png")))

	(close-bevel (list
		(make-image "close-bevel-inactive-t.png")
		(make-image "close-bevel-active-t.png") nil
  		(make-image "close-bevel-pressed-t.png")))

	(close (lambda ()
		(if Step:flat-buttons close-flat close-bevel)))
	
	(titlebar (list
		(make-image "titlebar-inactive-t.png")
		(make-image "titlebar-active-t.png")))

	(top-left (list
		(make-image "top-left-inactive.png")
		(make-image "top-left-active.png")))

	(top-right (list
		(make-image "top-right-inactive.png")
		(make-image "top-right-active.png")))

	(border (make-image "border.png"))

	(bottom (make-image "bottom-t.png"))
	
	(bottom-left (make-image "bottom-left-t.png"))
	
	(bottom-right (make-image "bottom-right-t.png"))

;; Normal window frame
	(frame `(
	;; Minimize button
		((background . ,titlebar-colors)
		 (foreground . ,minimize)
		 (left-edge . -1)
		 (width . 24)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . iconify-button))
	;; Titlebar
		((background . ,titlebar-colors)
		 (foreground . ,title-colors)
		 (font . ,title-font)
		 (text . ,window-name)
		 (x-justify . ,alignement)
		 (y-justify . center)
		 (left-edge . 23)
		 (right-edge . 23)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
		((background . ,titlebar)
		 (left-edge . 23)
		 (right-edge . 23)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
	;; Close button
		((background . ,titlebar-colors)
		 (foreground . ,close)
		 (right-edge . -1)
		 (width . 24)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . close-button))
	;; Left border
		((background . ,border)
		 (right-edge . -1)
		 (width . 1)
		 (top-edge . 0)
		 (bottom-edge . -9)
		 (cursor . left_ptr)
		 (class . right-border))
	;;Right border
		((background . ,border)
		 (left-edge . -1)
		 (width . 1)
		 (top-edge . 0)
		 (bottom-edge . -9)
		 (cursor . left_ptr)
		 (class . left-border))
	;; Bottom left corner
		((background . ,resizebar-colors)
		 (foreground . ,bottom-left)
		 (left-edge . 0)
		 (width . 30)
		 (bottom-edge . -9)
		 (height . 9)
		 (cursor . left_ptr)
		 (class . bottom-left-corner))
	;; Bottom border
		((background . ,resizebar-colors)
		 (left-edge . 30)
		 (right-edge . 30)
		 (bottom-edge . -9)
		 (height . 9)
		 (cursor . left_ptr)
		 (class . bottom-border))
		((background . ,bottom)
		 (left-edge . 30)
		 (right-edge . 30)
		 (bottom-edge . -9)
		 (height . 9)
		 (cursor . left_ptr)
		 (class . bottom-border))
	;; Bottom right corner
		((background . ,resizebar-colors)
		 (foreground . ,bottom-right)
		 (right-edge . 0)
		 (width . 30)
		 (bottom-edge . -9)
		 (height . 9)
		 (cursor . left_ptr)
		 (class . bottom-right-corner))
	)) ;; end frame

;; Normal window shaded frame
	(shaped-frame `(
	;; Minimize button
		((background . ,titlebar-colors)
		 (foreground . ,minimize)
		 (left-edge . -1)
		 (width . 24)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . iconify-button))
	;; Titlebar
		((background . ,titlebar-colors)
		 (foreground . ,title-colors)
		 (font . ,title-font)
		 (text . ,window-name)
		 (x-justify . ,alignement)
		 (y-justify . center)
		 (left-edge . 23)
		 (right-edge . 23)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
		((background . ,titlebar)
		 (left-edge . 23)
		 (right-edge . 23)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
	;; Close button
		((background . ,titlebar-colors)
		 (foreground . ,close)
		 (right-edge . -1)
		 (width . 24)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . close-button))
	)) ;; end shaped-frame

;; Dialog window frame
	(transient-frame `(
	;; Top left
		((background . ,top-left)
		 (left-edge . -1)
		 (width . 2)
		 (top-edge . -23)
		 (cursor . left_ptr)
		 (class . title))
	;; Titlebar
		((background . ,titlebar-colors)
		 (foreground . ,title-colors)
		 (font . ,title-font)
		 (text . ,window-name)
		 (x-justify . ,alignement)
		 (y-justify . center)
		 (left-edge . 1)
		 (right-edge . 1)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
		((background . ,titlebar)
		 (left-edge . 1)
		 (right-edge . 1)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
	;; Top right
		((background . ,top-right)
		 (right-edge . -1)
		 (width . 2)
		 (top-edge . -23)
		 (cursor . left_ptr)
		 (class . title))
	;; Left border
		((background . ,border)
		 (right-edge . -1)
		 (width . 1)
		 (top-edge . 0)
		 (bottom-edge . -1)
		 (cursor . left_ptr)
		 (class . right-border))
	;;Right border
		((background . ,border)
		 (left-edge . -1)
		 (width . 1)
		 (top-edge . 0)
		 (bottom-edge . -1)
		 (cursor . left_ptr)
		 (class . left-border))
	;; Bottom border
		((background . ,border)
		 (left-edge . 0)
		 (right-edge . 0)
		 (bottom-edge . -1)
		 (height . 1)
		 (cursor . left_ptr)
		 (class . bottom-border))
	)) ;; end transient-frame

;; Dialog window shaded frame
	(shaped-transient-frame `(
	;; Top left
		((background . ,top-left)
		 (left-edge . -1)
		 (width . 2)
		 (top-edge . -23)
		 (cursor . left_ptr)
		 (class . title))
	;; Titlebar
		((background . ,titlebar-colors)
		 (foreground . ,title-colors)
		 (font . ,title-font)
		 (text . ,window-name)
		 (x-justify . ,alignement)
		 (y-justify . center)
		 (left-edge . 1)
		 (right-edge . 1)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
		((background . ,titlebar)
		 (left-edge . 1)
		 (right-edge . 1)
		 (top-edge . -23)
		 (height . 23)
		 (cursor . left_ptr)
		 (class . title))
	;; Top right
		((background . ,top-right)
		 (right-edge . -1)
		 (width . 2)
		 (top-edge . -23)
		 (cursor . left_ptr)
		 (class . title))
	)) ;; end shaped-transient-frame
	
;; Black border only frame
	(none-frame `(
	;; Top border
		((background . ,border)
		 (right-edge . -1)
		 (left-edge . -1)
		 (top-edge . -1)
		 (cursor . left_ptr)
		 (class . top-border))
	;; Left border
		((background . ,border)
		 (right-edge . -1)
		 (bottom-edge . 0)
		 (top-edge . 0)
		 (cursor . left_ptr)
		 (class . right-border))
	;;Right border
		((background . ,border)
		 (left-edge . -1)
		 (bottom-edge . 0)
		 (top-edge . 0)
		 (cursor . left_ptr)
		 (class . left-border))
	;; Bottom border
		((background . ,border)
		 (left-edge . -1)
		 (right-edge . -1)
		 (bottom-edge . -1)
		 (cursor . left_ptr)
		 (class . bottom-border))
	))) ;; end shaped-transient-frame

	(add-frame-style 'Step
		(lambda (w type)
			(cond ((eq type 'shaped)
					shaped-frame)
				((eq type 'transient)
					transient-frame)
				((eq type 'shaped-transient)
					shaped-transient-frame)
				((eq type 'unframed)
					none-frame)
				(t frame)))))
