int firstLineContentWidth = firstLineWidth - noneContentWidth; int availableContentWidth = lineWidth - noneContentWidth;
int firstLineAdjustedWidth = firstLineWidth; int lineAdjustedWidth = lineWidth; if (this.maximumWidth != 0 ) { if (firstLineAdjustedWidth > this.maximumWidth ) { firstLineAdjustedWidth = this.maximumWidth; } if (lineAdjustedWidth > this.maximumWidth ) { lineAdjustedWidth = this.maximumWidth; } } int firstLineContentWidth = firstLineAdjustedWidth - noneContentWidth; int availableContentWidth = lineAdjustedWidth - noneContentWidth;
	protected final void init( int firstLineWidth, int lineWidth ) {		//#debug		Debug.debug("intialising item " + this.getClass().getName() );		if (this.style != null && !this.isStyleInitialised) {			setStyle( this.style );		}		//#ifdef polish.useDynamicStyles			else if (this.style == null) {				initStyle();			}		//#endif		int labelWidth = 0;		int labelHeight = 0;		if (this.label != null) {			if (!this.label.isInitialised) {				this.label.init( firstLineWidth, lineWidth );			}			labelWidth = this.label.itemWidth;			labelHeight = this.label.itemHeight;		}		// calculate content width and content height:		int noneContentWidth =  			 	this.marginLeft + this.borderWidth + this.paddingLeft 				+ this.paddingRight + this.borderWidth + this.marginRight;		//#ifdef polish.useBeforeStyle			noneContentWidth += this.beforeWidth;		//#endif		//#ifdef polish.useAfterStyle			noneContentWidth += this.afterWidth;		//#endif		/*		if (noneContentWidth >= firstLineWidth) {			System.out.println("INVALID NONE CONTENT WIDTH=" + noneContentWidth);		}		*/		int firstLineContentWidth = firstLineWidth - noneContentWidth;		int availableContentWidth = lineWidth - noneContentWidth;		// initialise content by subclass:		initContent( firstLineContentWidth, availableContentWidth );		this.itemWidth = noneContentWidth + this.contentWidth;		int cHeight = this.contentHeight;		//#ifdef polish.useBeforeStyle			if (this.contentHeight < this.beforeHeight) {				cHeight = this.beforeHeight;			}		//#endif		//#ifdef polish.useAfterStyle			if (this.contentHeight < this.afterHeight) {				cHeight = this.afterHeight;			}		//#endif		int noneContentHeight = this.marginTop + this.borderWidth + this.paddingTop 			  + this.paddingBottom + this.borderWidth + this.marginBottom;		if (this.itemWidth + labelWidth <= lineWidth) {			// label and content fit on one row:			this.itemWidth += labelWidth;			this.useSingleRow = true;			if (this.label != null) {				if ( (this.label.layout & LAYOUT_NEWLINE_AFTER) != 0 ) {					this.useSingleRow = false;					cHeight += labelHeight;				}			}			if ( cHeight + noneContentHeight < labelHeight ) {				cHeight = labelHeight - noneContentHeight;			}		} else {			this.useSingleRow = false;			cHeight += labelHeight;		}		if ( this.isLayoutExpand ) {			this.itemWidth = lineWidth;		} else if (this.itemWidth > lineWidth) {			this.itemWidth = lineWidth;		}		this.itemHeight = cHeight + noneContentHeight;		if (this.useSingleRow) {			this.backgroundWidth = this.itemWidth - this.marginLeft - this.marginRight - labelWidth;			this.backgroundHeight = cHeight							  + noneContentHeight							  - this.marginTop							  - this.marginBottom;		} else {			this.backgroundWidth = this.itemWidth - this.marginLeft - this.marginRight;			this.backgroundHeight = cHeight							  + noneContentHeight							  - this.marginTop							  - this.marginBottom							  - labelHeight;		}		this.isInitialised = true;	}