net.miginfocom.swt
Class MigLayout

java.lang.Object
  extended by Layout
      extended by net.miginfocom.swt.MigLayout
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public final class MigLayout
extends Layout
implements java.io.Externalizable

A very flexbile layout manager.

Read the documentation that came with this layout manager for information on usage.


Constructor Summary
MigLayout()
          Constructor with no constraints.
MigLayout(LC layoutConstraints)
          Constructor.
MigLayout(LC layoutConstraints, AC colConstraints)
          Constructor.
MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)
          Constructor.
MigLayout(java.lang.String layoutConstraints)
          Constructor.
MigLayout(java.lang.String layoutConstraints, java.lang.String colConstraints)
          Constructor.
MigLayout(java.lang.String layoutConstraints, java.lang.String colConstraints, java.lang.String rowConstraints)
          Constructor.
 
Method Summary
 void addLayoutCallback(LayoutCallback callback)
          Adds the callback function that will be called at different stages of the layout cylce.
protected  Point computeSize(Composite parent, int wHint, int hHint, boolean flushCache)
           
protected  boolean flushCache(Control control)
           
 java.lang.Object getColumnConstraints()
          Returns the column layout constraints either as a String or AC.
 java.lang.Object getComponentConstraints(Control comp)
          Returns the component constraints as a String representation.
 float getLayoutAlignmentX(Composite parent)
           
 float getLayoutAlignmentY(Composite parent)
           
 java.lang.Object getLayoutConstraints()
          Returns layout constraints eighter as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints(Object).
 java.lang.Object getRowConstraints()
          Returns the row layout constraints as a String representation.
 boolean isManagingComponent(Control c)
          Returns if this layout manager is currently managing this component.
protected  void layout(Composite parent, boolean flushCache)
           
 void readExternal(java.io.ObjectInput in)
           
 void removeLayoutCallback(LayoutCallback callback)
          Removes the callback if it exists.
 void setColumnConstraints(java.lang.Object constr)
          Sets the column layout constraints for the layout manager instance as a String.
 void setComponentConstraints(Control comp, java.lang.Object constr)
          Sets the component constraint for the component that already must be handleded by this layout manager.
 void setLayoutConstraints(java.lang.Object s)
          Sets the layout constraints for the layout manager instance as a String.
 void setRowConstraints(java.lang.Object constr)
          Sets the row layout constraints for the layout manager instance as a String.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MigLayout

public MigLayout()
Constructor with no constraints.


MigLayout

public MigLayout(java.lang.String layoutConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as "".

MigLayout

public MigLayout(java.lang.String layoutConstraints,
                 java.lang.String colConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as "".
colConstraints - The constraints for the columns in the grid. null will be treated as "".

MigLayout

public MigLayout(java.lang.String layoutConstraints,
                 java.lang.String colConstraints,
                 java.lang.String rowConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as "".
colConstraints - The constraints for the columns in the grid. null will be treated as "".
rowConstraints - The constraints for the rows in the grid. null will be treated as "".

MigLayout

public MigLayout(LC layoutConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as an empty cosntraint.

MigLayout

public MigLayout(LC layoutConstraints,
                 AC colConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as an empty cosntraint.
colConstraints - The constraints for the columns in the grid. null will be treated as an empty constraint.

MigLayout

public MigLayout(LC layoutConstraints,
                 AC colConstraints,
                 AC rowConstraints)
Constructor.

Parameters:
layoutConstraints - The constraints that concern the whole layout. null will be treated as an empty cosntraint.
colConstraints - The constraints for the columns in the grid. null will be treated as an empty constraint.
rowConstraints - The constraints for the rows in the grid. null will be treated as an empty constraint.
Method Detail

getLayoutConstraints

public java.lang.Object getLayoutConstraints()
Returns layout constraints eighter as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints(Object).

Returns:
The layout constraints eighter as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints(Object). Never null.

setLayoutConstraints

public void setLayoutConstraints(java.lang.Object s)
Sets the layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters:
s - The layout constraints as a String representation. null is converted to "" for storage.
Throws:
java.lang.RuntimeException - if the constaint was not valid.

getColumnConstraints

public java.lang.Object getColumnConstraints()
Returns the column layout constraints either as a String or AC.

Returns:
The column constraints eighter as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints(Object). Never null.

setColumnConstraints

public void setColumnConstraints(java.lang.Object constr)
Sets the column layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters:
constr - The column layout constraints as a String representation. null is converted to "" for storage.
Throws:
java.lang.RuntimeException - if the constaint was not valid.

getRowConstraints

public java.lang.Object getRowConstraints()
Returns the row layout constraints as a String representation. This string is the exact string as set with setRowConstraints(Object) or sent into the constructor.

See the class JavaDocs for information on how this string is formatted.

Returns:
The row layout constraints as a String representation. Never null.

setRowConstraints

public void setRowConstraints(java.lang.Object constr)
Sets the row layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters:
constr - The row layout constraints as a String representation. null is converted to "" for storage.
Throws:
java.lang.RuntimeException - if the constaint was not valid.

getComponentConstraints

public java.lang.Object getComponentConstraints(Control comp)
Returns the component constraints as a String representation. This string is the exact string as set with #setComponentConstraints(java.awt.Component, Object) or set when adding the component to the parent component.

See the class JavaDocs for information on how this string is formatted.

Parameters:
comp - The component to return the constraints for.
Returns:
The component constraints as a String representation ir null if the component is not registered with this layout manager. The returned values is wither a String or a CC depending on what constraint was sent in when the component was added. May be null.

setComponentConstraints

public void setComponentConstraints(Control comp,
                                    java.lang.Object constr)
Sets the component constraint for the component that already must be handleded by this layout manager.

See the class JavaDocs for information on how this string is formatted.

Parameters:
constr - The component constraints as a String or CC. null is ok.
comp - The component to set the constraints for.
Throws:
java.lang.RuntimeException - if the constaint was not valid.
java.lang.IllegalArgumentException - If the component is not handlering the component.

isManagingComponent

public boolean isManagingComponent(Control c)
Returns if this layout manager is currently managing this component.

Parameters:
c - The component to check. If null then false will be returned.
Returns:
If this layout manager is currently managing this component.

addLayoutCallback

public void addLayoutCallback(LayoutCallback callback)
Adds the callback function that will be called at different stages of the layout cylce.

Parameters:
callback - The callback. Not null.

removeLayoutCallback

public void removeLayoutCallback(LayoutCallback callback)
Removes the callback if it exists.

Parameters:
callback - The callback. May be null.

getLayoutAlignmentX

public float getLayoutAlignmentX(Composite parent)

getLayoutAlignmentY

public float getLayoutAlignmentY(Composite parent)

computeSize

protected Point computeSize(Composite parent,
                            int wHint,
                            int hHint,
                            boolean flushCache)

layout

protected void layout(Composite parent,
                      boolean flushCache)

flushCache

protected boolean flushCache(Control control)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException


Copyright © 2006 MiG InfoCom AB. All Rights Reserved.