API for miglayout
(master branch)
by
Stephen C. Gilardi
Usage:
(ns your-namespace
(:require clojure.contrib.miglayout))
Overview
Clojure support for the MiGLayout layout manager
http://www.miglayout.com/
Example:
(use '[clojure.contrib.miglayout.test :as mlt :only ()])
(dotimes [i 5] (mlt/run-test i))
Public Variables and Functions
components
function
Usage: (components container)
Returns a map from id (a keyword) to component for all components with
an id constraint set
miglayout
function
Usage: (miglayout container & args)
Adds java.awt.Components to a javax.swing.JComponent with constraints
formatted for the MiGLayout layout manager.
Arguments: container [item constraint*]*
- container: the container for the specified components, its layout
manager will be set to a new instance of MigLayout
- an inline series of items and constraints--each item may be followed
by zero or more constraints.
Item:
- An item is either a Component or one of the keywords :layout
:column or :row. Constraints for a keyword item affect the entire
layout.
Constraint: string, keyword, vector, map, or set
- A string specifies one or more constraints each with zero or more
arguments.
- A keyword specifies a single constraint without arguments
- A vector specifies a single constraint with one or more arguments
- A map specifies one or more constraints as keys, each mapped to a
single argument
- A set groups two or more constraints, each a string, keyword,
vector, map, or set
Any items marked with an "id" constraint will be included in a map from
id to component attached to the container. The map can be retrieved using
clojure.contrib.miglayout/components.
miglayout.example
converter-ui
function
Usage: (converter-ui)
Lays out and shows a Temperature Converter UI
fahrenheit
function
Usage: (fahrenheit celsius)
Converts a Celsius temperature to Fahrenheit. Input and output are
strings. Returns "input?" if the input can't be parsed as a Double.
main
function
Usage: (main)
Invokes converter-ui in the AWT Event thread
miglayout.internal
add-components
function
Usage: (add-components container components)
Adds components with constraints to a container
component?
function
Usage: (component? x)
Returns true if x is a java.awt.Component
constraint?
function
Usage: (constraint? x)
Returns true if x is not a keyword-item or component
do-layout
function
Usage: (do-layout container layout column row components)
Attaches a MigLayout layout manager to container and adds components
with constraints
function
Usage: (format-constraint c)
Returns a vector of vectors representing one or more constraints
separated by commas. Constraints may be specified in Clojure using
strings, keywords, vectors, maps, and/or sets.
function
Usage: (format-constraints & constraints)
Returns a string representing all the constraints for one keyword-item
or component formatted for miglayout.
get-components
function
Usage: (get-components container)
Returns a map from id to component for all components with an id
parse-component-constraint
function
Usage: (parse-component-constraint constraint)
Parses a component constraint string returning a CC object
parse-item-constraints
function
Usage: (parse-item-constraints & args)
Iterates over args and builds a map containing values associated with
:keywords and :components. The value for :keywords is a map from keyword
items to constraints strings. The value for :components is a vector of
vectors each associating a component with its constraints string.