    001package org.vishia.gral.awt;
    002
    003import java.awt.Container;
    004import java.awt.Label;
    005import java.awt.TextArea;
    006import java.io.IOException;
    007
    008import org.vishia.gral.base.GralGraphicTimeOrder;
    009import org.vishia.gral.base.GralTextBox;
    010import org.vishia.gral.ifc.GralColor;
    011import org.vishia.gral.ifc.GralFont;
    012import org.vishia.gral.ifc.GralRectangle;
    013import org.vishia.gral.ifc.GralUserAction;
    014
    015/**
    016 *
    017 */
    018public class AwtTextBox extends GralTextBox.GraphicImplAccess
    019{
    020  protected AwtTextAreaImpl textFieldSwt;
    021
    022  /**A possible prompt for the text field or null. */
    023  /*packagePrivate*/ Label promptSwt;
    024
    025  StringBuffer newText = new StringBuffer();
    026
    027
    028  public AwtTextBox(GralTextBox widgg, Container parent, int style, AwtWidgetMng mng)
    029  { widgg.super(widgg);
    030    textFieldSwt = new AwtTextAreaImpl();
    031    parent.add(textFieldSwt);
    032  }
    033
    034  //@Override public Widget getWidgetImplementation(){ return textFieldSwt; }
    035  //@Override public boolean setFocus(){ return textFieldSwt.setFocus(); }
    036
    037
    038
    039  /*
    040
    041  @Override public void setTextInGThread(CharSequence text){
    042    textFieldSwt.setText(text.toString());
    043  }
    044
    045
    046
    047  @Override public void appendTextInGThread(CharSequence text){
    048    textFieldSwt.append(text.toString());
    049  }
    050
    051
    052*/
    053
    054
    055
    056  @Override public Object getWidgetImplementation()
    057  { return textFieldSwt;
    058  }
    059
    060
    061
    062
    063
    064
    065
    066  protected GralGraphicTimeOrder changeTextBoxTrail = new GralGraphicTimeOrder("AwtTextBox.changeTextBoxTrail")
    067  { @Override public void executeOrder()
    068    { if(newText.length() >0){
    069        textFieldSwt.append(newText.toString());
    070        newText.setLength(0);
    071      }
    072    }
    073  };
    074
    075
    076  protected GralGraphicTimeOrder changeText = new GralGraphicTimeOrder("AwtTextBox.changeTextB")
    077  { @Override public void executeOrder()
    078    { if(newText.length() >0){
    079        textFieldSwt.setText(newText.toString());
    080        newText.setLength(0);
    081      }
    082      //countExecution();
    083      //windowMng.removeDispatchListener(this);
    084    }
    085  };
    086
    087
    088  @Override public void setBoundsPixel(int x, int y, int dx, int dy)
    089  { textFieldSwt.setBounds(x,y,dx,dy);
    090  }
    091
    092
    093
    094
    095  @Override public void repaintGthread(){  textFieldSwt.repaint();  }
    096
    097
    098
    099
    100  @Override public boolean setFocusGThread()
    101  { return AwtWidgetHelper.setFocusOfTabSwt(textFieldSwt);
    102  }
    103
    104
    105
    106
    107  @Override public void removeWidgetImplementation()
    108  {
    109    Container parent = textFieldSwt.getParent();
    110    parent.remove(textFieldSwt);
    111    textFieldSwt = null;
    112  }
    113
    114
    115
    116
    117
    118public static class AwtTextAreaImpl extends TextArea implements AwtWidget
    119  {
    120    Object data;
    121
    122    AwtTextAreaImpl()
    123    { super("test");
    124
    125    }
    126
    127    @Override public Object getData(){ return data; }
    128
    129    @Override public void setData(Object dataP){ this.data = dataP; }
    130
    131  }
    132
    133
    134
    135
    136
    137@Override
    138public void setVisibleGThread(boolean bVisible)
    139{
    140  // TODO Auto-generated method stub
    141
    142}
    143
    144@Override
    145public GralRectangle getPixelPositionSize()
    146{
    147  // TODO Auto-generated method stub
    148  return null;
    149}
    150
    151
    152
    153
    154
    155
    156}