package cnp.ew.kdemo;

import java.awt.*;
import cnp.ew.spin.*;
import cnp.ew.misc.*;
import cnp.ew.layout.*;
import cnp.ew.lightweight.*;
import cnp.ew.text.*;
import cnp.ew.util.*;

public class CpPictureFieldPanel extends CpPanelLc
{
    CpFormattedStringSpinEditorLc pictureEditor;
    CpReadOnlyTextAreaLc statusLabel1, statusLabel2;

    public CpPictureFieldPanel(String labelString, String pictureString, String initialValue)
    {
        super(CpPanelLc.BORDER_LABELED_RAISED);
        setBorderMargin(10);

        CpAttachments attachments;

        setText(labelString);
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        setLayout(layout);

	    pictureEditor = new CpFormattedStringSpinEditorLc(pictureString);
	    pictureEditor.setString(initialValue);
	    add(pictureEditor);
	    pictureEditor.addObserver(this);
	    pictureEditor.setIsTabStop(true);
	    attachments = new CpAttachments();
        layout.setAttachments(pictureEditor, attachments);
        attachments.setHorizontalCentering();
        attachments.setTopAttachment(0);

        statusLabel1 = new CpReadOnlyTextAreaLc();
        statusLabel1.setFont(new Font("Dialog", Font.PLAIN, 12));
        add(statusLabel1);
        statusLabel1.setHorizontalAlignment(CpReadOnlyTextAreaLc.ALIGN_CENTER);
	    attachments = new CpAttachments();
        layout.setAttachments(statusLabel1, attachments);
        attachments.setLeftAttachment(0);
        attachments.setRightAttachment(0);
        attachments.setTopAttachment(5, pictureEditor);

	    statusLabel1.setText(pictureEditor.getFormattedString());


    }
    public void update(CpObservable o, int facet, Object arg)
    {

	    if (o == pictureEditor && facet == OBJECT_CHANGED) {
	        statusLabel1.setText(pictureEditor.getFormattedString());
	    }
	}

}

