Mercurial > lasercutter
comparison src/clojure/contrib/miglayout.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:35cf337adfcf | 10:ef7dbbd6452c |
---|---|
1 ;; Copyright (c) Stephen C. Gilardi. All rights reserved. The use and | |
2 ;; distribution terms for this software are covered by the Eclipse Public | |
3 ;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can | |
4 ;; be found in the file epl-v10.html at the root of this distribution. By | |
5 ;; using this software in any fashion, you are agreeing to be bound by the | |
6 ;; terms of this license. You must not remove this notice, or any other, | |
7 ;; from this software. | |
8 ;; | |
9 ;; clojure.contrib.miglayout | |
10 ;; | |
11 ;; Clojure support for the MiGLayout layout manager | |
12 ;; http://www.miglayout.com/ | |
13 ;; | |
14 ;; Example: | |
15 ;; | |
16 ;; (use '[clojure.contrib.miglayout.test :as mlt :only ()]) | |
17 ;; (dotimes [i 5] (mlt/run-test i)) | |
18 ;; | |
19 ;; scgilardi (gmail) | |
20 ;; Created 5 October 2008 | |
21 | |
22 (ns | |
23 ^{:author "Stephen C. Gilardi", | |
24 :doc "Clojure support for the MiGLayout layout manager | |
25 http://www.miglayout.com/ | |
26 | |
27 Example: | |
28 | |
29 (use '[clojure.contrib.miglayout.test :as mlt :only ()]) | |
30 (dotimes [i 5] (mlt/run-test i)) | |
31 | |
32 "} | |
33 clojure.contrib.miglayout | |
34 (:import javax.swing.JComponent) | |
35 (:use clojure.contrib.miglayout.internal)) | |
36 | |
37 (defn miglayout | |
38 "Adds java.awt.Components to a javax.swing.JComponent with constraints | |
39 formatted for the MiGLayout layout manager. | |
40 | |
41 Arguments: container [item constraint*]* | |
42 | |
43 - container: the container for the specified components, its layout | |
44 manager will be set to a new instance of MigLayout | |
45 | |
46 - an inline series of items and constraints--each item may be followed | |
47 by zero or more constraints. | |
48 | |
49 Item: | |
50 | |
51 - An item is either a Component or one of the keywords :layout | |
52 :column or :row. Constraints for a keyword item affect the entire | |
53 layout. | |
54 | |
55 Constraint: string, keyword, vector, map, or set | |
56 | |
57 - A string specifies one or more constraints each with zero or more | |
58 arguments. | |
59 - A keyword specifies a single constraint without arguments | |
60 - A vector specifies a single constraint with one or more arguments | |
61 - A map specifies one or more constraints as keys, each mapped to a | |
62 single argument | |
63 - A set groups two or more constraints, each a string, keyword, | |
64 vector, map, or set | |
65 | |
66 Any items marked with an \"id\" constraint will be included in a map from | |
67 id to component attached to the container. The map can be retrieved using | |
68 clojure.contrib.miglayout/components." | |
69 [^JComponent container & args] | |
70 (let [item-constraints (apply parse-item-constraints args) | |
71 {:keys [keywords components]} item-constraints | |
72 {:keys [layout column row]} keywords] | |
73 (do-layout container layout column row components))) | |
74 | |
75 (defn components | |
76 "Returns a map from id (a keyword) to component for all components with | |
77 an id constraint set" | |
78 [^JComponent container] | |
79 (get-components container)) |