home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / baku100.zip / baku100 / Kernel / TextChar.tonyu < prev    next >
Text File  |  2005-09-09  |  2KB  |  70 lines

  1. extends PlainChar;
  2.  
  3. constructor TextChar(xx,yy,t,c,s){
  4.  super(xx,yy);
  5.  text=null;
  6.  col=$clWhite;
  7.  size=20;
  8.  if (t) text=t;
  9.  if (c) col=c;
  10.  if (s) size=s;
  11. }
  12.  
  13. function setDefaultProperties(xx,yy) {
  14.    super.setDefaultProperties(xx,yy);
  15.    text="âeâLâXâg";
  16.    col=$clWhite;
  17.    font="élér âSâVâbâN";
  18.    changeAttr("font","\""+font+"\"");
  19.    changeAttr("text","\"âeâLâXâg\"");
  20.    changeAttr("col","$clWhite");
  21.    size=20;
  22.    changeAttr("size",size);
  23.    maxTextWidth=0;
  24. }
  25.  
  26. function maxTextLength(s,w,sz) {
  27.    var t;
  28.    t=s.length();
  29.    while (textWidth(s.subString(0,t),sz)>w && t>0) t-=1;
  30.    return t;
  31. }
  32.  
  33. function draw() {
  34.    var w,t,yy,ds;
  35.    
  36.    if (!text && designMode()) text="(no caption)";
  37.    setFont(font,bold,italic,underLine);
  38.    if (!maxTextWidth) {
  39.        drawText(x,y,text,col,size,zOrder);
  40.    } else {
  41.       ds=text;
  42.       yy=y;
  43.       while (ds.length()>0) {
  44.          t=maxTextLength(ds,maxTextWidth,size);
  45.          if (t<=0) t=1;
  46.          drawText(x,yy, ds.subString(0,t),col,size,zOrder);
  47.          ds=ds.subString(t);
  48.          yy+=textHeight(ds,size);
  49.       }  
  50.       if(designMode()) drawLine(x+maxTextWidth,y,x+maxTextWidth,yy+4,$clAqua);
  51.    }             
  52.    super.draw();
  53. }
  54.  
  55. function edit(width) {
  56.   $TextEditor.setTextListener(this);
  57.   $TextEditor.setText(text);
  58.   if (width) {
  59.     $TextEditor.setPosition(x,y,width,0);
  60.   } else {
  61.     $TextEditor.setPosition(x,y,textWidth(text,size),0);
  62.   }
  63.   $TextEditor.setFont(size,font);
  64.   $TextEditor.edit();
  65. }
  66.  
  67. function onTextEditComplete(t) {
  68.   text=t;
  69. }
  70.