public void onEndBuild( SwingMetawidget metawidget ) { // Buttons Facet buttonsFacet = metawidget.getFacet( "buttons" ); if ( buttonsFacet != null ) { State state = getState( metawidget ); if ( state.currentColumn > 0 ) { state.currentColumn = 0; state.currentRow++; } metawidget.add( buttonsFacet, new CC().cell( 0, state.currentRow ).spanX().growX() ); } }
/** Corresponds exactly to the "gap left right top bottom" keyword. * @param args Same as for the "gap" keyword. Length 1-4, never null buf elements can be null. * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>. * @since 3.7.2 */ public final CC gap(String ... args) { switch (args.length) { default: throw new IllegalArgumentException("Illegal argument count: " + args.length); case 4: gapBottom(args[3]); case 3: gapTop(args[2]); case 2: gapRight(args[1]); case 1: gapLeft(args[0]); } return this; }
/** Same functionality as {@link #growX()} and {@link #growY()}. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. * @see #growX() * @see #growY() */ public final CC grow() { growX(); growY(); return this; }
if (cc.isNewline()) { sb.append(asAPI ? ".newline(" : ",newline"); BoundSize newlineGapSize = cc.getNewlineGapSize(); if (newlineGapSize != null) sb.append(asAPI ? "" : " ").append(getBS(newlineGapSize, asAPI)); if (cc.isExternal()) sb.append(asAPI ? ".external()" : ",external"); Boolean flowX = cc.getFlowX(); if (flowX != null) { if (asAPI) { UnitValue[] pad = cc.getPadding(); if (pad != null) { sb.append(asAPI ? ".pad(\"" : ",pad "); UnitValue[] pos = cc.getPos(); if (pos != null) { if (cc.isBoundsInGrid()) { for (int i = 0; i < 4; i++) { if (pos[i] != null) { String id = cc.getId(); if (id != null) { if (asAPI) { String tag = cc.getTag();
CC cc = new CC(); cc.setDockSide(0); continue; cc.setNewline(true); continue; cc.setNewlineGapSize(parseBoundSize(gapSz, true, true)); continue; cc.setFlowX(part.charAt(4) == 'x' ? Boolean.TRUE : Boolean.FALSE); continue; if (ix > -1) { String num = part.substring(ix).trim(); cc.setSkip(num.length() != 0 ? Integer.parseInt(num) : 1); continue; if (ix > -1) { String split = part.substring(ix).trim(); cc.setSplit(split.length() > 0 ? Integer.parseInt(split) : LayoutUtil.INF); continue; cc.setDockSide(2); continue; cc.setSpanY(parseSpan(part.substring(ix).trim())); continue;
CC componentConstraints = new CC(); componentConstraints.cell( ( state.currentColumn * 2 ) + 1, state.currentRow ); } else { componentConstraints.cell( state.currentColumn * 2, state.currentRow ); componentConstraints.spanX( 2 ); componentConstraints.pushX( 1f ).growX(); componentConstraints.spanX(); state.currentColumn = mNumberOfColumns; componentConstraints.alignY( "top" ); componentConstraints.pushY( 1f ).growY();
contentPane.add(hyperlink, new CC().dockNorth().gapLeft("10px").gapBottom("10px").gapTop("10px")); contentPane.add(southPanel, new CC().dockSouth().pad(10, 10, 10, 10).alignX("center")); contentPane.add(c, new CC().growX().gap("10px", "10px", "10px", "10px")); dialog.setSize(800, 400); dialog.setVisible(true);
protected String layoutBeforeChild( Control control, String labelText, String elementName, Map<String, String> attributes, Control container, SwtMetawidget metawidget ) { State state = getState( (Composite) container ); // Add label if ( SimpleLayoutUtils.needsLabel( labelText, elementName ) ) { Label label = new Label( (Composite) container, SWT.None ); // Required if ( attributes != null && TRUE.equals( attributes.get( REQUIRED ) ) && !WidgetBuilderUtils.isReadOnly( attributes ) && !metawidget.isReadOnly() ) { label.setText( labelText + "*" + StringUtils.SEPARATOR_COLON ); } else { label.setText( labelText + StringUtils.SEPARATOR_COLON ); } CC labelConstraints = new CC(); labelConstraints.cell( state.currentColumn * 2, state.currentRow ); labelConstraints.growX(); // Top align all labels, not just those belonging to 'tall' controls, // so that tall controls, regular controls and nested Metawidget // controls all line up labelConstraints.alignY( "top" ); // Apply some vertical padding so the label lines up with the control nicely labelConstraints.pad( state.defaultLabelVerticalPadding, 0, state.defaultLabelVerticalPadding, 0 ); // Add it label.setLayoutData( labelConstraints ); label.moveAbove( control ); } return labelText; }
colorsPanel.add(listOfColorsInSchme, new CC().alignY("top")); colorsPanel.add(colorChooser, new CC().alignY("top")); colorsPanel.add(logDetailsTextPane, new CC().spanX().growX()); updateLogDetails(); panel.add(colorsPanel, new CC().spanX().wrap()); addLabel("Default colors", new JXHyperlink(new AbstractAction("Reset to defaults") { @Override
private void initComponents() { setLayout(new MigLayout( "wrap 1, insets 5 15", // Layout Constraints "[grow]", // Column constraints with default align "[min!][grow]" // Row constraints with default align )); setBackground(Color.white); // TODO add padding to asbodypanel // TODO change look&feel of tabs (overview/visual) bodyPanel.setBackground(Color.white); header = new AgroSenseHeader(); super.add(header); super.add(bodyPanel, "grow"); super.add(footer, new CC().dockSouth().width("707px").height("140px")); }
/** Same functionality as {@link #setSpanX(int)} which means this cell will span the rest of the row. * This method returns <code>this</code> for chaining multiple calls. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>. * @see #setSpanX(int) * @see #spanX() */ public final CC spanX() { return spanX(LayoutUtil.INF); }
int hideMode = comp.isVisible() ? -1 : rootCc.getHideMode() != -1 ? rootCc.getHideMode() : lc.getHideMode(); setLinkedBounds(comp, rootCc, comp.getX(), comp.getY(), comp.getWidth(), comp.getHeight(), rootCc.isExternal()); i++; continue; // The "external" component should not be handled further. if (rootCc.getHorizontal().getSizeGroup() != null) sizeGroupsX++; if (rootCc.getVertical().getSizeGroup() != null) sizeGroupsY++; if (getPos(comp, rootCc) != null || rootCc.isExternal()) { if (!rootCc.isBoundsInGrid() || rootCc.isExternal()) { setLinkedBounds(comp, rootCc, comp.getX(), comp.getY(), comp.getWidth(), comp.getHeight(), rootCc.isExternal()); i++; continue; if (rootCc.getDockSide() != -1) { if (dockInsets == null) dockInsets = new int[] {-MAX_DOCK_GRID, -MAX_DOCK_GRID, MAX_DOCK_GRID, MAX_DOCK_GRID}; addDockingCell(dockInsets, rootCc.getDockSide(), new CompWrap(comp, rootCc, hideMode, useVisualPadding)); i++; continue; Boolean cellFlowX = rootCc.getFlowX(); Cell cell = null;
CC controlConstraints = new CC(); controlConstraints.setHideMode( 3 ); control.setLayoutData( controlConstraints ); control.setVisible( false ); CC controlConstraints = new CC(); controlConstraints.cell( ( state.currentColumn * 2 ) + 1, state.currentRow ); } else { controlConstraints.cell( state.currentColumn * 2, state.currentRow ); controlConstraints.spanX( 2 ); controlConstraints.pushX( 1f ).growX(); controlConstraints.spanX(); state.currentColumn = mNumberOfColumns; controlConstraints.alignY( "top" ); controlConstraints.pushY( 1f ).growY();
/** grow weight for the component horizontally and optionally vertically. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @param widthHeight The new shrink weight and height. 1-2 arguments, never null. * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. * @since 3.7.2 */ public final CC grow(float ... widthHeight) { switch (widthHeight.length) { default: throw new IllegalArgumentException("Illegal argument count: " + widthHeight.length); case 2: growY(widthHeight[1]); case 1: growX(widthHeight[0]); } return this; }
public void onEndBuild( SwtMetawidget metawidget ) { // Buttons Facet buttonsFacet = metawidget.getFacet( "buttons" ); if ( buttonsFacet != null ) { State state = getState( metawidget ); if ( state.currentColumn > 0 ) { state.currentColumn = 0; state.currentRow++; } buttonsFacet.setLayoutData( new CC().cell( 0, state.currentRow ).spanX().growX() ); buttonsFacet.moveBelow( null ); } }