java.lang.Object
org.eclipse.swt.widgets.Layout
net.miginfocom.swt.MigLayout
- All Implemented Interfaces:
Externalizable,Serializable
A very flexible layout manager.
Read the documentation that came with this layout manager for information on usage.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContainerWrapperprivate ArrayList<LayoutCallback> private final Map<ComponentWrapper, CC> private ObjectHold the serializable text representation of the constraints.private ACprivate longprivate Timerprivate Gridprivate intprivate intprivate ObjectHold the serializable text representation of the constraints.private LCprivate ObjectHold the serializable text representation of the constraints.private ACThe component to String or CC constraints mappings. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with no constraints.Constructor.Constructor.Constructor.Constructor.Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutCallback(LayoutCallback callback) Adds the callback function that will be called at different stages of the layout cycle.private voidcheckCache(org.eclipse.swt.widgets.Composite parent) Check if something has changed and if so recreate it to the cached objects.private voidcheckConstrMap(org.eclipse.swt.widgets.Composite parent) Checks so all components in ccMap actually exist in the parent's collection.private ContainerWrappercheckParent(org.eclipse.swt.widgets.Composite parent) protected org.eclipse.swt.graphics.PointcomputeSize(org.eclipse.swt.widgets.Composite parent, int wHint, int hHint, boolean flushCache) protected booleanflushCache(org.eclipse.swt.widgets.Control control) Returns the column layout constraints either as aStringorAC.Returns a shallow copy of the constraints map.private booleangetDebug()Returns the current debugging state.private intReturns the debug millis.floatgetLayoutAlignmentX(org.eclipse.swt.widgets.Composite parent) floatgetLayoutAlignmentY(org.eclipse.swt.widgets.Composite parent) Returns layout constraints either as aStringorLCdepending what was sent in to the constructor or set withsetLayoutConstraints(Object).Returns the row layout constraints as a String representation.booleanisManagingComponent(org.eclipse.swt.widgets.Control c) Returns if this layout manager is currently managing this component.protected voidlayout(org.eclipse.swt.widgets.Composite parent, boolean flushCache) voidprivate ObjectvoidremoveLayoutCallback(LayoutCallback callback) Removes the callback if it exists.voidsetColumnConstraints(Object constr) Sets the column layout constraints for the layout manager instance as a String.private voidsetComponentConstraintsImpl(org.eclipse.swt.widgets.Control comp, Object constr, boolean noCheck) Sets the component constraint for the component that already must be handled by this layout manager.voidsetConstraintMap(Map<org.eclipse.swt.widgets.Control, Object> map) Sets the constraints map.private voidsetDebug(ComponentWrapper parentW, boolean b) Sets the debugging state for this layout manager instance.voidSets the layout constraints for the layout manager instance as a String.voidsetRowConstraints(Object constr) Sets the row layout constraints for the layout manager instance as a String.void
-
Field Details
-
scrConstrMap
The component to String or CC constraints mappings. -
layoutConstraints
Hold the serializable text representation of the constraints. -
colConstraints
Hold the serializable text representation of the constraints. -
rowConstraints
Hold the serializable text representation of the constraints. -
cacheParentW
-
ccMap
-
lc
-
colSpecs
-
rowSpecs
-
grid
-
debugTimer
-
curDelay
private transient long curDelay -
lastModCount
private transient int lastModCount -
lastHash
private transient int lastHash -
callbackList
-
-
Constructor Details
-
MigLayout
public MigLayout()Constructor with no constraints. -
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as "".
-
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as "".colConstraints- The constraints for the columns in the grid.nullwill be treated as "".
-
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as "".colConstraints- The constraints for the columns in the grid.nullwill be treated as "".rowConstraints- The constraints for the rows in the grid.nullwill be treated as "".
-
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as an empty constraint.
-
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as an empty constraint.colConstraints- The constraints for the columns in the grid.nullwill be treated as an empty constraint.
-
MigLayout
Constructor.- Parameters:
layoutConstraints- The constraints that concern the whole layout.nullwill be treated as an empty constraint.colConstraints- The constraints for the columns in the grid.nullwill be treated as an empty constraint.rowConstraints- The constraints for the rows in the grid.nullwill be treated as an empty constraint.
-
-
Method Details
-
getLayoutConstraints
Returns layout constraints either as aStringorLCdepending what was sent in to the constructor or set withsetLayoutConstraints(Object).- Returns:
- The layout constraints either as a
StringorLCdepending what was sent in to the constructor or set withsetLayoutConstraints(Object). Nevernull.
-
setLayoutConstraints
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.nullis converted to""for storage.- Throws:
RuntimeException- if the constraint was not valid.
-
getColumnConstraints
Returns the column layout constraints either as aStringorAC.- Returns:
- The column constraints either as a
StringorLCdepending what was sent in to the constructor or set withsetLayoutConstraints(Object). Nevernull.
-
setColumnConstraints
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.nullis converted to""for storage.- Throws:
RuntimeException- if the constraint was not valid.
-
getRowConstraints
Returns the row layout constraints as a String representation. This string is the exact string as set withsetRowConstraints(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
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.nullis converted to""for storage.- Throws:
RuntimeException- if the constraint was not valid.
-
getConstraintMap
Returns a shallow copy of the constraints map.- Returns:
- A shallow copy of the constraints map. Never
null.
-
setConstraintMap
Sets the constraints map.- Parameters:
map- The map. Will be copied.
-
setComponentConstraintsImpl
private void setComponentConstraintsImpl(org.eclipse.swt.widgets.Control comp, Object constr, boolean noCheck) Sets the component constraint for the component that already must be handled by this layout manager.See the class JavaDocs for information on how this string is formatted.
- Parameters:
comp- The component to set the constraints for.constr- The component constraints as a String orCC.nullis ok.noCheck- Doesn't check if control already is managed.- Throws:
RuntimeException- if the constraint was not valid.IllegalArgumentException- If the component is not handling the component.
-
isManagingComponent
public boolean isManagingComponent(org.eclipse.swt.widgets.Control c) Returns if this layout manager is currently managing this component.- Parameters:
c- The component to check. Ifnullthenfalsewill be returned.- Returns:
- If this layout manager is currently managing this component.
-
addLayoutCallback
Adds the callback function that will be called at different stages of the layout cycle.- Parameters:
callback- The callback. Notnull.
-
removeLayoutCallback
Removes the callback if it exists.- Parameters:
callback- The callback. May benull.
-
setDebug
Sets the debugging state for this layout manager instance. If debug is turned on a timer will repaint the last laid out parent with debug information on top.Red fill and dashed dark red outline is used to indicate occupied cells in the grid. Blue dashed outline indicate component bounds set.
Note that debug can also be set on the layout constraints. There it will be persisted. The value set here will not. See the class JavaDocs for information.
- Parameters:
parentW- The parent. Nevernull.b-truemeans debug is turned on.
-
getDebug
private boolean getDebug()Returns the current debugging state.- Returns:
- The current debugging state.
-
getDebugMillis
private int getDebugMillis()Returns the debug millis. Combines the value fromLC.getDebugMillis()andLayoutUtil.getGlobalDebugMillis()- Returns:
- The combined value.
-
checkCache
private void checkCache(org.eclipse.swt.widgets.Composite parent) Check if something has changed and if so recreate it to the cached objects.- Parameters:
parent- The parent that is the target for this layout manager.
-
checkConstrMap
private void checkConstrMap(org.eclipse.swt.widgets.Composite parent) Checks so all components in ccMap actually exist in the parent's collection. Removes any references that don't.- Parameters:
parent- The parent to compare ccMap against. Never null.
-
checkParent
-
getLayoutAlignmentX
public float getLayoutAlignmentX(org.eclipse.swt.widgets.Composite parent) -
getLayoutAlignmentY
public float getLayoutAlignmentY(org.eclipse.swt.widgets.Composite parent) -
computeSize
protected org.eclipse.swt.graphics.Point computeSize(org.eclipse.swt.widgets.Composite parent, int wHint, int hHint, boolean flushCache) - Specified by:
computeSizein classorg.eclipse.swt.widgets.Layout
-
layout
protected void layout(org.eclipse.swt.widgets.Composite parent, boolean flushCache) - Specified by:
layoutin classorg.eclipse.swt.widgets.Layout
-
flushCache
protected boolean flushCache(org.eclipse.swt.widgets.Control control) - Overrides:
flushCachein classorg.eclipse.swt.widgets.Layout
-
readResolve
- Throws:
ObjectStreamException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-