Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanup whitespace

  • Loading branch information...
commit 072ac4038a37253040bcd6b7f82e6fda12c3b419 1 parent 7222337
@daveray authored
View
10 src/seesaw/core.clj
@@ -2432,12 +2432,12 @@
(defn- paint-option-handler [^java.awt.Component c v]
(cond
- (nil? v) (do
+ (nil? v) (do
(update-proxy c {"paintComponent" nil})
(.repaint c))
(fn? v) (paint-option-handler c {:after v})
- (map? v) (do
- (put-meta! c paint-property v)
+ (map? v) (do
+ (put-meta! c paint-property v)
(update-proxy c {"paintComponent" paint-component-impl})
(.repaint c))
:else (illegal-argument "Expect map or function for :paint property")))
@@ -2447,8 +2447,8 @@
Macro that generates a paintable widget, i.e. a widget that can be drawn on
by client code. target is a Swing class literal indicating the type that will
- be constructed.
-
+ be constructed.
+
All other options will be passed along to the given Seesaw widget
as usual and will be applied to the generated class.
View
204 src/seesaw/selector.clj
@@ -2,7 +2,7 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
@@ -11,7 +11,7 @@
(ns seesaw.selector
"Seesaw selector support, based largely upon enlive-html.
https://github.com/cgrand/enlive
-
+
There's no need to ever directly require this namespace. Use (seesaw.core/select)!"
(:require [seesaw.util :as ssu])
(:require [clojure.zip :as z]))
@@ -30,9 +30,9 @@
(defprotocol Tag
(tag-name [this]))
-(defn id-of
+(defn id-of
"Retrieve the id of a widget. Use (seesaw.core/id-of)."
- [w]
+ [w]
(id-of* w))
(defn id-of!
@@ -47,7 +47,7 @@
"Retrieve the classes of a widget as a set of strings"
(class-of* w))
-(defn class-of!
+(defn class-of!
"INTERNAL USE ONLY."
[w classes]
(class-of!* w classes))
@@ -55,7 +55,7 @@
(defn id-selector? [s]
(.startsWith (name s) "#"))
-(defn- mapknit
+(defn- mapknit
([f coll]
(mapknit f coll nil))
([f coll etc]
@@ -64,13 +64,13 @@
(f (first coll) (mapknit f (rest coll) etc))
etc))))
-(defn- iterate-while
+(defn- iterate-while
([f x]
- (lazy-seq (when x (cons x (iterate-while f (f x))))))
+ (lazy-seq (when x (cons x (iterate-while f (f x))))))
([f x pred]
- (lazy-seq (when (pred x) (cons x (iterate-while f (f x) pred))))))
-
-
+ (lazy-seq (when (pred x) (cons x (iterate-while f (f x) pred))))))
+
+
;; utilities
(defn- node? [x]
@@ -79,12 +79,12 @@
(defn- as-nodes [node-or-nodes]
(if (node? node-or-nodes)
- [node-or-nodes]
+ [node-or-nodes]
node-or-nodes))
(defn- flatten-nodes-coll [x]
(letfn [(flat* [x stack]
- (if (node? x)
+ (if (node? x)
(cons x (when (seq stack) (flat (peek stack) (pop stack))))
(if-let [[x & xs] (seq x)]
(recur x (conj stack xs))
@@ -97,7 +97,7 @@
(defn- flatmap [f node-or-nodes]
(flatten-nodes-coll (map f (as-nodes node-or-nodes))))
-(defn- attr-values
+(defn- attr-values
"Returns the whitespace-separated values of the specified attr as a set or nil."
[node attr]
(when-let [v (-> node :attrs (get attr))]
@@ -108,22 +108,22 @@
(z/zipper (constantly true) ssu/children identity root))
;; predicates utils
-(defn- zip-pred
+(defn- zip-pred
"Turns a predicate function on elements locs into a predicate-step usable in selectors."
[f]
#(and (z/branch? %) (f %)))
-(defn- pred
+(defn- pred
"Turns a predicate function on elements into a predicate-step usable in selectors."
[f]
(zip-pred #(f (z/node %))))
-(defn- text-pred
+(defn- text-pred
"Turns a predicate function on strings (text nodes) into a predicate-step usable in selectors."
[f]
#(let [n (z/node %)] (and (string? n) (f n))))
-(defn- re-pred
+(defn- re-pred
"Turns a predicate function on strings (text nodes) into a predicate-step usable in selectors."
[re]
(text-pred #(re-matches re %)))
@@ -133,14 +133,14 @@
;; core predicates
(def ^{:private true} any (pred (constantly true)))
-(defn- tag=
+(defn- tag=
"Selector predicate, :foo is as short-hand for (tag= :foo)."
[expected-tag-name]
- (pred
- (fn [v]
+ (pred
+ (fn [v]
(= (if (satisfies? Tag v)
(tag-name v)
- (.getSimpleName (class v)))
+ (.getSimpleName (class v)))
expected-tag-name))))
(defn- id=
@@ -162,12 +162,12 @@
"Selector predicate, tests if the specified whitespace-seperated attribute contains the specified values. See CSS ~="
[attr & values]
(pred #(when-let [v (attr-values % attr)] (every? v values))))
-
-(defn- has-class
+
+(defn- has-class
"Selector predicate, :.foo.bar. Looks for widgets with (:class #{:foo :bar})"
[& classes]
(pred #(when-let [v (class-of %)] (every? v classes))))
-
+
;; selector syntax
(defn- intersection [preds]
(condp = (count preds)
@@ -187,16 +187,16 @@
(def ^{:private true} segment-regex #"^<([\w.!]+)>(.*)")
-(defn- split-segments
- [^String s]
- (if-let [[_ ^String class-name & more] (re-matches segment-regex s)]
+(defn- split-segments
+ [^String s]
+ (if-let [[_ ^String class-name & more] (re-matches segment-regex s)]
(if (.endsWith class-name "!")
(cons (str "+" (subs class-name 0 (dec (count class-name)))) (remove empty? more))
(cons (str "*" class-name) (remove empty? more)))
(seq (.split s "(?=[#.])"))))
-(def ^{:private true} compile-keyword
- (memoize
+(def ^{:private true} compile-keyword
+ (memoize
(fn [kw]
(if (= :> kw)
:>
@@ -215,15 +215,15 @@
(conj preds (loose-type= (subs segment 1)))
preds)))) preds segments)]
(if (seq preds) (intersection preds) any))))))
-
+
(defn- compile-step [step]
(cond
(string? step) (compile-keyword (keyword step))
- (keyword? step) (compile-keyword step)
+ (keyword? step) (compile-keyword step)
(set? step) (union (map compile-step step))
(vector? step) (intersection (map compile-step step))
- :else step))
-
+ :else step))
+
(defn- compile-chain [chain]
(map compile-step chain))
@@ -248,12 +248,12 @@
(fn [^Number n]
(loop [n n s (set init) [chains & etc] chains-seq]
(cond
- (odd? n) (recur (bit-shift-right n 1) (into s chains) etc)
+ (odd? n) (recur (bit-shift-right n 1) (into s chains) etc)
(zero? n) s
:else (recur (bit-shift-right n 1) s etc)))))
(defn- make-state [chains]
- (let [derivations
+ (let [derivations
(reduce
(fn [derivations chain]
(cond
@@ -263,7 +263,7 @@
(next chain)
(let [pred (first chain)]
(-> derivations
- (assoc nil (conj (derivations nil) chain))
+ (assoc nil (conj (derivations nil) chain))
(assoc pred (conj (derivations pred) (next chain)))))
:else
(assoc derivations :accepts (first chain)))) {} chains)
@@ -286,7 +286,7 @@
(def ^{:private true} memoized-automaton* (memoize automaton*))
(def ^{:private true} memoized-lockstep-automaton* (memoize lockstep-automaton*))
-
+
(defn- automaton [selector]
((if (cacheable? selector) memoized-automaton* automaton*) selector))
@@ -303,56 +303,56 @@
(not (fragment-selector? selector)))
(defn- static-selector? [selector]
- (or (keyword? selector)
+ (or (keyword? selector)
(and (coll? selector) (every? static-selector? selector))))
-;; core
-
+;; core
+
(defn- children-locs [loc]
(iterate-while z/right (z/down loc)))
(defn- zip-select-nodes* [locs state]
- (letfn [(select1 [loc previous-state]
+ (letfn [(select1 [loc previous-state]
(when-let [state (step previous-state loc)]
(let [descendants (mapcat #(select1 % state) (children-locs loc))]
(if (accept-key state) (cons loc descendants) descendants))))]
(mapcat #(select1 % state) locs)))
-
+
(defn- select-nodes* [nodes selector]
(let [state (automaton selector)]
- (map z/node (zip-select-nodes* (map swing-zipper nodes) state))))
-
+ (map z/node (zip-select-nodes* (map swing-zipper nodes) state))))
+
(defn- zip-select-fragments* [locs state-from state-to]
- (letfn [(select1 [locs previous-state-from previous-state-to]
+ (letfn [(select1 [locs previous-state-from previous-state-to]
(when (and previous-state-from previous-state-to)
(let [states-from (map #(step previous-state-from %) locs)
states-to (map #(step previous-state-to %) locs)
descendants (reduce into []
- (map #(select1 (children-locs %1) %2 %3)
+ (map #(select1 (children-locs %1) %2 %3)
locs states-from states-to))]
- (loop [fragments descendants fragment nil
+ (loop [fragments descendants fragment nil
locs locs states-from states-from states-to states-to]
(if-let [[loc & etc] (seq locs)]
(if fragment
(let [fragment (conj fragment loc)]
(if (accept-key (first states-to))
- (recur (conj fragments fragment) nil etc
+ (recur (conj fragments fragment) nil etc
(rest states-from) (rest states-to))
- (recur fragments fragment etc
+ (recur fragments fragment etc
(rest states-from) (rest states-to))))
(if (accept-key (first states-from))
(recur fragments [] locs states-from states-to)
- (recur fragments nil etc
+ (recur fragments nil etc
(rest states-from) (rest states-to))))
fragments)))))]
(select1 locs state-from state-to)))
-
+
(defn- select-fragments* [nodes selector]
- (let [[selector-from selector-to] (first selector)
+ (let [[selector-from selector-to] (first selector)
state-from (automaton selector-from)
state-to (automaton selector-to)]
- (map #(map z/node %)
- (zip-select-fragments* (map swing-zipper nodes) state-from state-to))))
+ (map #(map z/node %)
+ (zip-select-fragments* (map swing-zipper nodes) state-from state-to))))
(defn select
"*USE seesaw.core/select*
@@ -360,36 +360,36 @@
[node-or-nodes selector]
(let [nodes (as-nodes node-or-nodes)]
(if (node-selector? selector)
- (select-nodes* nodes selector)
+ (select-nodes* nodes selector)
(select-fragments* nodes selector))))
-
-(defn- zip-select
+
+(defn- zip-select
"Returns the seq of locs matched by the specified selector."
[locs selector]
(if (node-selector? selector)
- (apply zip-select-nodes* locs selector)
+ (apply zip-select-nodes* locs selector)
(apply zip-select-fragments* locs selector)))
-
+
;; other predicates
-(defn- attr?
+(defn- attr?
"Selector predicate, tests if the specified attributes are present."
[& kws]
(pred #(every? (-> % :attrs keys set) kws)))
-
+
(defn- every?+ [pred & colls]
- (every? #(apply pred %) (apply map vector colls)))
+ (every? #(apply pred %) (apply map vector colls)))
-(defn- multi-attr-pred
+(defn- multi-attr-pred
[single-attr-pred]
(fn [& kvs]
(let [ks (take-nth 2 kvs)
vs (take-nth 2 (rest kvs))]
(pred #(when-let [attrs (:attrs %)]
- (every?+ single-attr-pred (map attrs ks) vs))))))
+ (every?+ single-attr-pred (map attrs ks) vs))))))
(def ^{:private true
- :doc "Selector predicate, tests if the specified attributes have the specified values."}
- attr=
+ :doc "Selector predicate, tests if the specified attributes have the specified values."}
+ attr=
(multi-attr-pred =))
(defn- starts-with? [^String s ^String prefix]
@@ -402,34 +402,34 @@
(and s (<= 0 (.indexOf s substring))))
(def ^{:private true
- :doc "Selector predicate, tests if the specified attributes start with the specified values. See CSS ^= ."}
+ :doc "Selector predicate, tests if the specified attributes start with the specified values. See CSS ^= ."}
attr-starts
(multi-attr-pred starts-with?))
(def ^{:private true
- :doc "Selector predicate, tests if the specified attributes end with the specified values. See CSS $= ."}
+ :doc "Selector predicate, tests if the specified attributes end with the specified values. See CSS $= ."}
attr-ends
(multi-attr-pred ends-with?))
(def ^{:private true
- :doc "Selector predicate, tests if the specified attributes contain the specified values. See CSS *= ."}
+ :doc "Selector predicate, tests if the specified attributes contain the specified values. See CSS *= ."}
attr-contains
(multi-attr-pred contains-substring?))
(defn- is-first-segment? [^String s ^String segment]
- (and s
+ (and s
(.startsWith s segment)
(= \- (.charAt s (count segment)))))
-
+
(def ^{:private true
:doc "Selector predicate, tests if the specified attributes start with the specified values. See CSS |= ."}
- attr|=
+ attr|=
(multi-attr-pred is-first-segment?))
-(def ^{:private true} root
+(def ^{:private true} root
(zip-pred #(-> % z/up nil?)))
-(defn- nth?
+(defn- nth?
[f a b]
(if (zero? a)
;#(= (-> (filter xml/tag? (f %)) count inc) b)
@@ -459,21 +459,21 @@
"Selector step, tests if the node has an+b-1 siblings of the same type (tag name) on its left. See CSS :nth-of-type."
([b] (nth-of-type 0 b))
([a b] (zip-pred (nth? (filter-of-type z/lefts) a b))))
-
+
(defn- nth-last-of-type
"Selector step, tests if the node has an+b-1 siblings of the same type (tag name) on its right. See CSS :nth-last-of-type."
([b] (nth-last-of-type 0 b))
([a b] (zip-pred (nth? (filter-of-type z/rights) a b))))
-(def ^{:private true} first-child (nth-child 1))
-
-(def ^{:private true} last-child (nth-last-child 1))
-
-(def ^{:private true} first-of-type (nth-of-type 1))
-
-(def ^{:private true} last-of-type (nth-last-of-type 1))
+(def ^{:private true} first-child (nth-child 1))
+
+(def ^{:private true} last-child (nth-last-child 1))
-(def ^{:private true} only-child (intersection [first-child last-child]))
+(def ^{:private true} first-of-type (nth-of-type 1))
+
+(def ^{:private true} last-of-type (nth-last-of-type 1))
+
+(def ^{:private true} only-child (intersection [first-child last-child]))
(def ^{:private true} only-of-type (intersection [first-of-type last-of-type]))
@@ -486,19 +486,19 @@
(defn- select? [node-or-nodes selector]
(-> node-or-nodes as-nodes (select selector) seq boolean))
-(defn- has
- "Selector predicate, matches elements which contain at least one element that
- matches the specified selector. See jQuery's :has"
+(defn- has
+ "Selector predicate, matches elements which contain at least one element that
+ matches the specified selector. See jQuery's :has"
[selector]
(pred #(select? (:content %) selector)))
-
+
(defn- but-node
- "Selector predicate, matches nodes which are rejected by the specified selector-step. See CSS :not"
+ "Selector predicate, matches nodes which are rejected by the specified selector-step. See CSS :not"
[selector-step]
(complement (compile-step selector-step)))
(defn- but
- "Selector predicate, matches elements which are rejected by the specified selector-step. See CSS :not"
+ "Selector predicate, matches elements which are rejected by the specified selector-step. See CSS :not"
[selector-step]
(intersection [any (but-node selector-step)]))
@@ -512,7 +512,7 @@
(let [selector [:> selector-step]]
;#(select? (filter xml/tag? (z/lefts %)) selector)))
#(select? (filter (constantly true) (z/lefts %)) selector)))
-
+
(defn- right [selector-step]
(let [selector [:> selector-step]]
;#(when-let [sibling (first (filter xml/tag? (z/rights %)))]
@@ -523,7 +523,7 @@
(let [selector [:> selector-step]]
;#(select? (filter xml/tag? (z/rights %)) selector)))
#(select? (filter (constantly true) (z/rights %)) selector)))
-
+
(def ^{:private true} any-node (constantly true))
(def ^{:private true} this-node [:> any-node])
@@ -532,31 +532,31 @@
;; screen-scraping utils
(defn- text
- "Returns the text value of a node."
+ "Returns the text value of a node."
{:tag String}
[node]
(cond
(string? node) node
- ;(xml/tag? node) (apply str (map text (:content node)))
+ ;(xml/tag? node) (apply str (map text (:content node)))
:else ""))
-
+
(defn- texts
- "Returns the text value of a nodes collection."
+ "Returns the text value of a nodes collection."
{:tag String}
[nodes]
(map text nodes))
;(defmacro let-select
- ;"For each node or fragment, performs a subselect and bind it to a local,
+ ;"For each node or fragment, performs a subselect and bind it to a local,
;then evaluates body.
- ;bindings is a vector of binding forms and selectors."
+ ;bindings is a vector of binding forms and selectors."
;[nodes-or-fragments bindings & body]
;(let [node-or-fragment (gensym "node-or-fragment__")
- ;bindings
- ;(map (fn [f x] (f x))
+ ;bindings
+ ;(map (fn [f x] (f x))
;(cycle [identity (fn [spec] `(select ~node-or-fragment ~spec))])
- ;bindings)]
- ;`(map (fn [~node-or-fragment]
+ ;bindings)]
+ ;`(map (fn [~node-or-fragment]
;(let [~@bindings]
;~@body)) ~nodes-or-fragments)))
View
202 src/seesaw/swingx.clj
@@ -2,16 +2,16 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns ^{:doc "SwingX integration. Unfortunately, SwingX is hosted on java.net which means
- it looks abandoned most of the time. Downloads are here
+ it looks abandoned most of the time. Downloads are here
http://java.net/downloads/swingx/releases/1.6/
-
+
This is an incomplete wrapper. If something's missing that you want, just ask."
:author "Dave Ray"}
seesaw.swingx
@@ -27,7 +27,7 @@
ConfigIcon get-icon* set-icon*
config config!]]
[seesaw.layout :only [default-items-option box-layout grid-layout]]
- [seesaw.options :only [option-map bean-option apply-options
+ [seesaw.options :only [option-map bean-option apply-options
default-option resource-option around-option]]
[seesaw.widget-options :only [widget-option-provider]])
(:import [org.jdesktop.swingx.decorator
@@ -45,7 +45,7 @@
HighlightPredicate$TypeHighlightPredicate]))
;*******************************************************************************
-; Highlighter Predicates
+; Highlighter Predicates
(def p-built-in
(constant-map HighlightPredicate
@@ -79,11 +79,11 @@
(boolean (f renderer adapter)))))
(defn p-and [& args]
- (HighlightPredicate$AndHighlightPredicate.
+ (HighlightPredicate$AndHighlightPredicate.
(map to-p args)))
(defn p-or [& args]
- (HighlightPredicate$OrHighlightPredicate.
+ (HighlightPredicate$OrHighlightPredicate.
(map to-p args)))
(defn p-not [p]
@@ -108,7 +108,7 @@
(HighlightPredicate$DepthHighlightPredicate. (int-array depths)))
(defn p-pattern [pattern & {:keys [test-column highlight-column]}]
- (org.jdesktop.swingx.decorator.PatternPredicate.
+ (org.jdesktop.swingx.decorator.PatternPredicate.
pattern
(or test-column -1)
(or highlight-column -1)))
@@ -117,12 +117,12 @@
; Highlighters
(defn hl-color
- [& {:keys [foreground background
+ [& {:keys [foreground background
selected-background selected-foreground]}]
- (fn self
+ (fn self
([] (self :always))
- ([p]
- (org.jdesktop.swingx.decorator.ColorHighlighter.
+ ([p]
+ (org.jdesktop.swingx.decorator.ColorHighlighter.
(to-p p)
(seesaw.color/to-color background)
(seesaw.color/to-color foreground)
@@ -131,18 +131,18 @@
(defn hl-icon
[i]
- (fn self
+ (fn self
([] (self :always))
- ([p]
- (org.jdesktop.swingx.decorator.IconHighlighter.
+ ([p]
+ (org.jdesktop.swingx.decorator.IconHighlighter.
(to-p p)
(icon i)))))
(defn hl-shade
[]
- (fn self
+ (fn self
([] (self :always))
- ([p]
+ ([p]
(org.jdesktop.swingx.decorator.ShadingColorHighlighter.
(to-p p)))))
@@ -150,13 +150,13 @@
[& {:keys [background lines-per-stripe]}]
(cond
(and background lines-per-stripe)
- (HighlighterFactory/createSimpleStriping
+ (HighlighterFactory/createSimpleStriping
(seesaw.color/to-color background) lines-per-stripe)
- background
+ background
(HighlighterFactory/createSimpleStriping (seesaw.color/to-color background))
- lines-per-stripe
+ lines-per-stripe
(HighlighterFactory/createSimpleStriping lines-per-stripe)
- :else
+ :else
(HighlighterFactory/createSimpleStriping)))
(defn ^Highlighter to-highlighter [v]
@@ -167,7 +167,7 @@
(= :simple-striping v) (hl-simple-striping)
:else (illegal-argument "Don't know how to make highlighter from %s" v)))
-(defprotocol HighlighterHost
+(defprotocol HighlighterHost
(get-highlighters* [this])
(set-highlighters* [this hs])
(add-highlighter* [this h])
@@ -220,9 +220,9 @@
(widget-option-provider org.jdesktop.swingx.JXButton button-x-options)
(defn button-x
- "Creates a org.jdesktop.swingx.JXButton which is an improved (button) that
+ "Creates a org.jdesktop.swingx.JXButton which is an improved (button) that
supports painters. Supports these additional options:
-
+
:foreground-painter The foreground painter
:background-painter The background painter
@@ -240,7 +240,7 @@
(apply-options (construct org.jdesktop.swingx.JXButton) args))
;*******************************************************************************
-; XLabel
+; XLabel
(def label-x-options
(merge
@@ -255,9 +255,9 @@
(widget-option-provider org.jdesktop.swingx.JXLabel label-x-options)
(defn label-x
- "Creates a org.jdesktop.swingx.JXLabel which is an improved (label) that
+ "Creates a org.jdesktop.swingx.JXLabel which is an improved (label) that
supports wrapped text, rotation, etc. Additional options:
-
+
:wrap-lines? When true, text is wrapped to fit
:text-rotation Rotation of text in radians
@@ -276,7 +276,7 @@
(apply-options (construct org.jdesktop.swingx.JXLabel) args))
;*******************************************************************************
-; BusyLabel
+; BusyLabel
(def busy-label-options
(merge
@@ -289,9 +289,9 @@
(defn busy-label
"Creates a org.jdesktop.swingx.JXBusyLabel which is a label that shows
- 'busy' status with a spinner, kind of like an indeterminate progress bar.
+ 'busy' status with a spinner, kind of like an indeterminate progress bar.
Additional options:
-
+
:busy? Whether busy status should be shown or not. Defaults to false.
Examples:
@@ -308,7 +308,7 @@
(apply-options (construct org.jdesktop.swingx.JXBusyLabel) args))
;*******************************************************************************
-; Hyperlink
+; Hyperlink
(def hyperlink-options
(merge
button-options
@@ -317,13 +317,13 @@
(widget-option-provider org.jdesktop.swingx.JXHyperlink hyperlink-options)
-(defn hyperlink
+(defn hyperlink
"Constuct an org.jdesktop.swingx.JXHyperlink which is a button that looks like
a link and opens its URI in the system browser. In addition to all the options of
a button, supports:
-
+
:uri A string, java.net.URL, or java.net.URI with the URI to open
-
+
Examples:
(hyperlink :text \"Click Me\" :uri \"http://google.com\")
@@ -339,9 +339,9 @@
; TaskPane
(extend-protocol ConfigIcon
- org.jdesktop.swingx.JXTaskPane
+ org.jdesktop.swingx.JXTaskPane
(get-icon* [this] (.getIcon this))
- (set-icon* [this v]
+ (set-icon* [this v]
(.setIcon this (icon v))))
(def task-pane-options
@@ -363,65 +363,65 @@
(doseq [^javax.swing.Action a actions]
(.add c a)))))))
-(widget-option-provider
- org.jdesktop.swingx.JXTaskPane
+(widget-option-provider
+ org.jdesktop.swingx.JXTaskPane
task-pane-options)
(defn task-pane
"Create a org.jdesktop.swingx.JXTaskPane which is a collapsable component with a title
and icon. It is generally used as an item inside a task-pane-container. Supports the
- following additional options
-
+ following additional options
+
:resource Get icon and title from a resource
:icon The icon
:title The pane's title
:animated? True if collapse is animated
:collapsed? True if the pane should be collapsed
- :scroll-on-expand? If true, when expanded, it's container will scroll the pane into
+ :scroll-on-expand? If true, when expanded, it's container will scroll the pane into
view
- :special? If true, the pane will be displayed in a 'special' way depending on
+ :special? If true, the pane will be displayed in a 'special' way depending on
look and feel
- The pane can be populated with the standard :items option, which just takes a
+ The pane can be populated with the standard :items option, which just takes a
sequence of widgets. Additionally, the :actions option takes a sequence of
- action objects and makes hyper-links out of them.
+ action objects and makes hyper-links out of them.
See:
(seesaw.swingx/task-pane-options)
(seesaw.swingx/task-pane-container)
"
[& args]
- (apply-options
- (construct org.jdesktop.swingx.JXTaskPane)
+ (apply-options
+ (construct org.jdesktop.swingx.JXTaskPane)
args))
(def task-pane-container-options
(merge
default-options
(option-map
- (default-option
+ (default-option
:items
- #(doseq [^org.jdesktop.swingx.JXTaskPane p %2]
+ #(doseq [^org.jdesktop.swingx.JXTaskPane p %2]
(.add ^org.jdesktop.swingx.JXTaskPaneContainer %1 p))))))
-(widget-option-provider
- org.jdesktop.swingx.JXTaskPaneContainer
+(widget-option-provider
+ org.jdesktop.swingx.JXTaskPaneContainer
task-pane-container-options)
(defn task-pane-container
"Creates a container for task panes. Supports the following additional
- options:
-
+ options:
+
:items Sequence of task-panes to display
-
+
Examples:
- (task-pane-container
- :items [(task-pane :title \"First\"
- :actions [(action :name \"HI\")
+ (task-pane-container
+ :items [(task-pane :title \"First\"
+ :actions [(action :name \"HI\")
(action :name \"BYE\")])
- (task-pane :title \"Second\"
- :actions [(action :name \"HI\")
+ (task-pane :title \"Second\"
+ :actions [(action :name \"HI\")
(action :name \"BYE\")])
(task-pane :title \"Third\" :special? true :collapsed? true
:items [(button :text \"YEP\")])])
@@ -430,8 +430,8 @@
(seesaw.swingx/task-pane)
"
[& args]
- (apply-options
- (construct org.jdesktop.swingx.JXTaskPaneContainer)
+ (apply-options
+ (construct org.jdesktop.swingx.JXTaskPaneContainer)
args))
;*******************************************************************************
@@ -442,17 +442,17 @@
button-options
{:selection (:background button-options)}))
-(widget-option-provider
+(widget-option-provider
org.jdesktop.swingx.JXColorSelectionButton
color-selection-button-options)
-(defn color-selection-button
+(defn color-selection-button
"Creates a color selection button. In addition to normal button options,
supports:
-
+
:selection A color value. See (seesaw.color/to-color)
- The currently selected color canbe retrieved with (seesaw.core/selection).
+ The currently selected color canbe retrieved with (seesaw.core/selection).
Examples:
@@ -460,7 +460,7 @@
(selection! b java.awt.Color/RED)
- (listen b :selection
+ (listen b :selection
(fn [e]
(println \"Selected color changed to \")))
@@ -469,8 +469,8 @@
(seesaw.color/color)
"
[& args]
- (apply-options
- (construct org.jdesktop.swingx.JXColorSelectionButton)
+ (apply-options
+ (construct org.jdesktop.swingx.JXColorSelectionButton)
args))
; Extend selection and selection event stuff for color button.
@@ -480,7 +480,7 @@
(get-selection [this] [(config this :selection)])
(set-selection [this [v]] (config! this :selection v)))
-(defmethod listen-for-named-event
+(defmethod listen-for-named-event
[org.jdesktop.swingx.JXColorSelectionButton :selection]
[this event-name event-fn]
(listen-to-property this "background" event-fn))
@@ -495,7 +495,7 @@
(def header-options
(merge
- default-options
+ default-options
(option-map
(bean-option :title org.jdesktop.swingx.JXHeader resource)
(default-option :icon set-icon* get-icon*)
@@ -503,40 +503,40 @@
(widget-option-provider org.jdesktop.swingx.JXHeader header-options)
-(defn header
+(defn header
"Creates a header which consists of a title, description (supports basic HTML)
and an icon. Additional options:
-
+
:title The title. May be a resource.
:description The description. Supports basic HTML (3.2). May be a resource.
:icon The icon. May be a resource.
Examples:
- (header :title \"This is a title\"
- :description \"<html>A <b>description</b> with some
- <i>italics</i></html>\"
+ (header :title \"This is a title\"
+ :description \"<html>A <b>description</b> with some
+ <i>italics</i></html>\"
:icon \"http://url/to/icon.png\")
See:
(seesaw.swingx/header-options)
"
[& args]
- (apply-options
- (construct org.jdesktop.swingx.JXHeader)
+ (apply-options
+ (construct org.jdesktop.swingx.JXHeader)
args))
;*******************************************************************************
; JXList
-(def ^ {:private true} sort-order-table
- { :ascending javax.swing.SortOrder/ASCENDING
+(def ^ {:private true} sort-order-table
+ { :ascending javax.swing.SortOrder/ASCENDING
:descending javax.swing.SortOrder/DESCENDING})
; Override view/model index conversion so that the default selection
; handler from JList will work.
(extend-protocol ViewModelIndexConversion
- org.jdesktop.swingx.JXList
+ org.jdesktop.swingx.JXList
(index-to-model [this index] (.convertIndexToModel this index))
(index-to-view [this index] (.convertIndexToView this index)))
@@ -549,13 +549,13 @@
(option-map
; When the model is changed, make sure the sort order is preserved
; Otherwise, it doesn't look like :sort-with is working.
- (default-option :model
+ (default-option :model
(fn [c v]
(let [old (.getSortOrder c)]
((:setter (:model listbox-options)) c v)
(.setSortOrder c old)))
(:getter (:model listbox-options)))
-
+
(bean-option :sort-order org.jdesktop.swingx.JXList sort-order-table)
(default-option :sort-with
@@ -572,16 +572,16 @@
"Create a JXList which is basically an improved (seesaw.core/listbox).
Additional capabilities include sorting, searching, and highlighting.
Beyond listbox, has the following additional options:
-
+
:sort-with A comparator (like <, >, etc) used to sort the items in the
model.
:sort-order :ascending or descending
:highlighters A list of highlighters
-
- By default, ctrl/cmd-F is bound to the search function.
+
+ By default, ctrl/cmd-F is bound to the search function.
Examples:
-
+
See:
(seesaw.core/listbox)
"
@@ -604,28 +604,28 @@
(bean-option :title org.jdesktop.swingx.JXTitledPanel resource)
(bean-option [:title-color :title-foreground] org.jdesktop.swingx.JXTitledPanel seesaw.color/to-color)
(bean-option [:content :content-container] org.jdesktop.swingx.JXTitledPanel make-widget)
- (bean-option :right-decoration org.jdesktop.swingx.JXTitledPanel make-widget)
+ (bean-option :right-decoration org.jdesktop.swingx.JXTitledPanel make-widget)
(bean-option :left-decoration org.jdesktop.swingx.JXTitledPanel make-widget))))
-(widget-option-provider
- org.jdesktop.swingx.JXTitledPanel
+(widget-option-provider
+ org.jdesktop.swingx.JXTitledPanel
titled-panel-options)
-(defn titled-panel
+(defn titled-panel
"Creates a panel with a title and content. Has the following properties:
:content The content widget. Passed through (seesaw.core/to-widget)
:title The text of the title. May be a resource.
:title-color Text color. Passed through (seesaw.color/to-color). May
be resource.
- :left-decoration Decoration widget on left of title.
+ :left-decoration Decoration widget on left of title.
:right-decoration Decoration widget on right of title.
:resource Set :title and :title-color from a resource bundle
:painter Painter used on the title
Examples:
-
- (titled-panel :title \"Error\"
+
+ (titled-panel :title \"Error\"
:title-color :red
:content (label-x :wrap-lines? true
:text \"An error occurred!\"))
@@ -635,7 +635,7 @@
"
[& args]
(apply-options
- (construct org.jdesktop.swingx.JXTitledPanel)
+ (construct org.jdesktop.swingx.JXTitledPanel)
args))
;*******************************************************************************
@@ -655,13 +655,13 @@
"Create a JXTree which is basically an improved (seesaw.core/tree).
Additional capabilities include searching, and highlighting.
Beyond tree, has the following additional options:
-
+
:highlighters A list of highlighters
- By default, ctrl/cmd-F is bound to the search function.
+ By default, ctrl/cmd-F is bound to the search function.
Examples:
-
+
See:
(seesaw.core/tree-options)
(seesaw.core/tree)
@@ -670,7 +670,7 @@
(apply-options
(doto (construct org.jdesktop.swingx.JXTree)
(.setRolloverEnabled true))
- args))
+ args))
;*******************************************************************************
; JXTable
@@ -697,10 +697,10 @@
:column-margin Set margin between cells in pixels
:highlighters A list of highlighters
- By default, ctrl/cmd-F is bound to the search function.
+ By default, ctrl/cmd-F is bound to the search function.
Examples:
-
+
See:
(seesaw.core/table-options)
(seesaw.core/table)
@@ -710,7 +710,7 @@
(doto (construct org.jdesktop.swingx.JXTable)
(.setRolloverEnabled true)
(.setColumnControlVisible true))
- args))
+ args))
;*******************************************************************************
@@ -744,7 +744,7 @@
(defn vertical-panel-x [& opts]
(abstract-panel-x (box-layout :vertical) opts))
-(defn grid-panel-x
+(defn grid-panel-x
[& {:keys [rows columns] :as opts}]
(abstract-panel-x (grid-layout rows columns) opts))
View
6 test/seesaw/test/examples/paintable.clj
@@ -2,7 +2,7 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
@@ -12,7 +12,7 @@
(:use [seesaw core graphics]
seesaw.test.examples.example))
-(defn draw-a-red-x
+(defn draw-a-red-x
"Draw a red X on a widget with the given graphics context"
[c g]
(let [w (width c)
@@ -24,7 +24,7 @@
(line (- w d) d d (- h d)) line-style)))
(defn content []
- (flow-panel
+ (flow-panel
:border 5
:items [
(label :text "I'm a good label!" :font "ARIAL-BOLD-40" :foreground "#00AA00")
View
16 test/seesaw/test/examples/xyz_panel.clj
@@ -2,7 +2,7 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
@@ -25,15 +25,15 @@
(defn make-label
[text]
- (doto
+ (doto
; Instead of a boring label, make the label rounded with
; some custom drawing. Use the before paint hook to draw
; under the label's text.
(label
:border 5
- :text text
+ :text text
:location [(rand-int 300) (rand-int 300)]
- :paint {
+ :paint {
:before (fn [c g]
(draw g (rounded-rect 3 3 (- (width c) 6) (- (height c) 6) 9)
(style :foreground "#FFFFaa"
@@ -53,9 +53,9 @@
(defn make-panel []
(xyz-panel
:paint draw-grid
- :id :xyz
+ :id :xyz
:background "#222222"
- :items (conj
+ :items (conj
(map (comp movable make-label) ["Agent Cooper" "Big Ed" "Leland Palmer"])
(doto (border-panel
:border (line-border :top 15 :color "#AAFFFF")
@@ -65,8 +65,8 @@
movable))))
(defexample []
- (frame
- :title "Seesaw xyz-panel example"
+ (frame
+ :title "Seesaw xyz-panel example"
:content (border-panel
:vgap 5
:north "Demonstration of an xyz-panel with draggable widgets. Try dragging one!"
View
12 test/seesaw/test/selector.clj
@@ -2,7 +2,7 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
@@ -36,7 +36,7 @@
(it "should find a widget by Java class name"
(let [c (proxy [javax.swing.JLabel] [])
d (core/label)
- b (core/toggle)
+ b (core/toggle)
p (core/flow-panel :items [c d b])
f (core/frame :title "select by type" :content p)]
(expect (= [d] (select f [:JLabel])))
@@ -45,14 +45,14 @@
(it "should find a widget by class name"
(let [c (proxy [javax.swing.JLabel] [])
d (core/label :class :foo)
- b (core/toggle :class #{:foo :bar})
+ b (core/toggle :class #{:foo :bar})
p (core/flow-panel :items [c d b])
f (core/frame :title "select by class" :content p)]
(expect (= [d b] (select f [:.foo])))
(expect (= [b] (seq (select f [".bar"]))))))
(it "should find all descendants of a widget"
- (let [c (proxy [javax.swing.JLabel] [])
+ (let [c (proxy [javax.swing.JLabel] [])
d (core/label)
b (core/toggle)
p2 (core/flow-panel :items [c])
@@ -61,7 +61,7 @@
(expect (= #{c d b p2} (apply hash-set (select f [:#p :*]))))))
(it "should find direct children of a widget"
- (let [c (proxy [javax.swing.JLabel] [])
+ (let [c (proxy [javax.swing.JLabel] [])
d (core/label)
b (core/toggle)
p2 (core/flow-panel :items [c])
@@ -84,7 +84,7 @@
(let [m (core/menu-item :id :my-menu :text "my-menu")
f (core/frame :title "select menu item"
:menubar (core/menubar :items [(core/menu :text "File" :items [(core/menu :text "Nested" :items [m])])]))]
- (expect (= [m] (select f [:#my-menu])))))
+ (expect (= [m] (select f [:#my-menu])))))
(it "should select all of the components in a tree with :*"
(let [a (core/label) b (core/text) c (core/label)
Please sign in to comment.
Something went wrong with that request. Please try again.