rlm@10: ;; Copyright (c) Stephen C. Gilardi. All rights reserved. The use and rlm@10: ;; distribution terms for this software are covered by the Eclipse Public rlm@10: ;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can rlm@10: ;; be found in the file epl-v10.html at the root of this distribution. By rlm@10: ;; using this software in any fashion, you are agreeing to be bound by the rlm@10: ;; terms of this license. You must not remove this notice, or any other, rlm@10: ;; from this software. rlm@10: ;; rlm@10: ;; clojure.contrib.miglayout rlm@10: ;; rlm@10: ;; Clojure support for the MiGLayout layout manager rlm@10: ;; http://www.miglayout.com/ rlm@10: ;; rlm@10: ;; Example: rlm@10: ;; rlm@10: ;; (use '[clojure.contrib.miglayout.test :as mlt :only ()]) rlm@10: ;; (dotimes [i 5] (mlt/run-test i)) rlm@10: ;; rlm@10: ;; scgilardi (gmail) rlm@10: ;; Created 5 October 2008 rlm@10: rlm@10: (ns rlm@10: ^{:author "Stephen C. Gilardi", rlm@10: :doc "Clojure support for the MiGLayout layout manager rlm@10: http://www.miglayout.com/ rlm@10: rlm@10: Example: rlm@10: rlm@10: (use '[clojure.contrib.miglayout.test :as mlt :only ()]) rlm@10: (dotimes [i 5] (mlt/run-test i)) rlm@10: rlm@10: "} rlm@10: clojure.contrib.miglayout rlm@10: (:import javax.swing.JComponent) rlm@10: (:use clojure.contrib.miglayout.internal)) rlm@10: rlm@10: (defn miglayout rlm@10: "Adds java.awt.Components to a javax.swing.JComponent with constraints rlm@10: formatted for the MiGLayout layout manager. rlm@10: rlm@10: Arguments: container [item constraint*]* rlm@10: rlm@10: - container: the container for the specified components, its layout rlm@10: manager will be set to a new instance of MigLayout rlm@10: rlm@10: - an inline series of items and constraints--each item may be followed rlm@10: by zero or more constraints. rlm@10: rlm@10: Item: rlm@10: rlm@10: - An item is either a Component or one of the keywords :layout rlm@10: :column or :row. Constraints for a keyword item affect the entire rlm@10: layout. rlm@10: rlm@10: Constraint: string, keyword, vector, map, or set rlm@10: rlm@10: - A string specifies one or more constraints each with zero or more rlm@10: arguments. rlm@10: - A keyword specifies a single constraint without arguments rlm@10: - A vector specifies a single constraint with one or more arguments rlm@10: - A map specifies one or more constraints as keys, each mapped to a rlm@10: single argument rlm@10: - A set groups two or more constraints, each a string, keyword, rlm@10: vector, map, or set rlm@10: rlm@10: Any items marked with an \"id\" constraint will be included in a map from rlm@10: id to component attached to the container. The map can be retrieved using rlm@10: clojure.contrib.miglayout/components." rlm@10: [^JComponent container & args] rlm@10: (let [item-constraints (apply parse-item-constraints args) rlm@10: {:keys [keywords components]} item-constraints rlm@10: {:keys [layout column row]} keywords] rlm@10: (do-layout container layout column row components))) rlm@10: rlm@10: (defn components rlm@10: "Returns a map from id (a keyword) to component for all components with rlm@10: an id constraint set" rlm@10: [^JComponent container] rlm@10: (get-components container))