Mercurial > lasercutter
view 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 |
line wrap: on
line source
1 ;; Copyright (c) Stephen C. Gilardi. All rights reserved. The use and2 ;; distribution terms for this software are covered by the Eclipse Public3 ;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can4 ;; be found in the file epl-v10.html at the root of this distribution. By5 ;; using this software in any fashion, you are agreeing to be bound by the6 ;; terms of this license. You must not remove this notice, or any other,7 ;; from this software.8 ;;9 ;; clojure.contrib.miglayout10 ;;11 ;; Clojure support for the MiGLayout layout manager12 ;; 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 200822 (ns23 ^{:author "Stephen C. Gilardi",24 :doc "Clojure support for the MiGLayout layout manager25 http://www.miglayout.com/27 Example:29 (use '[clojure.contrib.miglayout.test :as mlt :only ()])30 (dotimes [i 5] (mlt/run-test i))32 "}33 clojure.contrib.miglayout34 (:import javax.swing.JComponent)35 (:use clojure.contrib.miglayout.internal))37 (defn miglayout38 "Adds java.awt.Components to a javax.swing.JComponent with constraints39 formatted for the MiGLayout layout manager.41 Arguments: container [item constraint*]*43 - container: the container for the specified components, its layout44 manager will be set to a new instance of MigLayout46 - an inline series of items and constraints--each item may be followed47 by zero or more constraints.49 Item:51 - An item is either a Component or one of the keywords :layout52 :column or :row. Constraints for a keyword item affect the entire53 layout.55 Constraint: string, keyword, vector, map, or set57 - A string specifies one or more constraints each with zero or more58 arguments.59 - A keyword specifies a single constraint without arguments60 - A vector specifies a single constraint with one or more arguments61 - A map specifies one or more constraints as keys, each mapped to a62 single argument63 - A set groups two or more constraints, each a string, keyword,64 vector, map, or set66 Any items marked with an \"id\" constraint will be included in a map from67 id to component attached to the container. The map can be retrieved using68 clojure.contrib.miglayout/components."69 [^JComponent container & args]70 (let [item-constraints (apply parse-item-constraints args)71 {:keys [keywords components]} item-constraints72 {:keys [layout column row]} keywords]73 (do-layout container layout column row components)))75 (defn components76 "Returns a map from id (a keyword) to component for all components with77 an id constraint set"78 [^JComponent container]79 (get-components container))