Clojure Seesaw 写一个Outlookbar

outlook 左侧的设计挺好,不确定这种设计是不是从outlook开始的,想到这样的设计的时候,很自然的想到outlook,姑且叫它outlook bar吧!

在学习Clojure和Seesaw,就写了一个,放在这里,有谁需要,随便拿去:

 

(ns com.gui
  (:use [seesaw core]))


(defn outlook-bar
  "Create a simple outlook bar.
   args: coll is a vector like this:
         [{:index 0, :btn-text 'first-button', :content (button :text 'this is first content.')},
         {:index 1, :btn-text 'second-button', :content (button :text 'this is second content.')}]
   return a outlook bar panel
   "
  ([coll]
    (outlook-bar (border-panel) coll (-> coll first :index )))
  ([bar coll index]
    (let [top (take (inc index) coll),
          center (nth coll index),
          bottom (drop (inc index) coll),
          composer (fn [item] (action :name (:btn-text item),
                                :handler (fn [e] (outlook-bar bar coll (:index item)))))]
      (doto bar (.removeAll))
      (config! bar
        :north (grid-panel
                 :rows (count top),
                 :columns 1,
                 :items (map composer top)),
        :center (scrollable (:content center)),
        :south (grid-panel
                 :rows (count bottom),
                 :columns 1,
                 :items (map composer bottom)))
      (doto bar (.revalidate) (.repaint)))))


; ====================   test outlook-bar =======================
;(def nav
;  [{:index 0 :btn-text "first", :content (text "this is first content.")},
;   {:index 1 :btn-text "second", :content (label :text "this is second content.")},
;   {:index 2 :btn-text "third", :content (button :text "this is third content.")}
;   ])
;
;(defn olb []
;  (-> (frame :title "Hello world!", :content (outlook-bar nav),
;        :on-close :dispose )
;    pack!
;    show!))
;
;(olb)

; ====================   test outlook-bar =======================

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值