论坛首页 编程语言技术论坛

Clojure Seesaw 写一个Outlookbar

浏览 1566 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-03-05  

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

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

 

(ns winnertel.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 =======================

 

   发表时间:2013-03-12  
试了下,费了点周折以后跑起来了,很酷!
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics