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

  1. extends PlainChar;
  2.  
  3. constructor PanelChar (x,y,w,h) {
  4.    super(x,y);
  5.    //print ("panelchar : w "+w+" h "+h);
  6.    width=0;
  7.    height=0;
  8.    if (w+0>0 && h+0>0) resize(w,h); 
  9.    else if (!designMode()) resize(100,50); 
  10.    angle=0;
  11.    alpha=255;
  12.    scaleX=1;
  13.    col=$clWhite;
  14.    font="élér éoû╛Æ⌐";
  15. }
  16.  
  17. /*function useScreenXY(s) {
  18.    _useScr=s;
  19. }*/
  20.  
  21. function drawFrame() {
  22.   //print ("panelchard : w "+width+" h "+height);
  23.   panel.fillRect(0,0,width,height,panel.getTransParentColor());
  24.   panel.drawLine(1      ,1       ,width-2,       1,$clWhite);
  25.   panel.drawLine(width-2,1       ,width-2,height-2,$clWhite);
  26.   panel.drawLine(width-2,height-2,      1,height-2,$clWhite);
  27.   panel.drawLine(1      ,height-2,      1,       1,$clWhite);
  28. }
  29. function onGenerate() {
  30.    if (width+0>0 && height+0>0) resize(width,height);
  31.    else resize(99,98);
  32.    if (text) setText();
  33.    else if (designMode()) drawFrame();
  34. }
  35. function getWidth() {
  36.   return width*scaleX;
  37. }
  38. function getHeight() {
  39.   if (!scaleY) return height*scaleX;
  40.   return height*scaleY;
  41. }
  42.  
  43. function onChangeAttr (an,v,reason) {
  44.   //print ("changed "+an+"="+v+"//"+reason);
  45.   if (designMode()) {
  46.     if (text) setText();
  47.     if (reason && (an=="width" || an=="height")) {
  48.        resize(width,height);
  49.        drawFrame();
  50.     }
  51.   }
  52. }
  53.  
  54. function setFont(f,b,i,u){
  55.    if (f) font=f;
  56.    bold=b;
  57.    italic=i;
  58.    underLine=u;
  59.    super.setFont(f,b,i,u);
  60. }
  61.  
  62. function setText(t,c,sz) {
  63.    if (t) text=t;
  64.    if (c) col=c;
  65.    if (sz) size=sz;
  66.    setFont(font,bold,italic,underLine);
  67.    resize( textWidth(text,size),textHeight(text,size) ) ;
  68.    panel.clear();
  69.    panel.drawText(0,0,text,col,size);
  70. }
  71.  
  72. function setDefaultProperties(xx,yy) {
  73.    super.setDefaultProperties(xx,yy);
  74.    changeAttr("width","50");
  75.    changeAttr("height","50");
  76.    width=50;height=50;
  77.    resize(width,height);
  78.    if (designMode()) drawFrame();
  79.    changeAttr("angle","0");
  80.    changeAttr("alpha","255");
  81.    changeAttr("col","$clWhite");
  82.    changeAttr("size","12");
  83. }
  84.  
  85.  
  86. function resize(w,h) {
  87.    width=w;
  88.    height=h;   
  89. //   if (!panel || w > panel.width || h > panel.height) {
  90.    if (panel is Panel) panel.resize(w,h);
  91.    else panel=new Panel(w,h);
  92. //   }
  93. }
  94. function load(fn) {
  95.   panel.load(fn);
  96.   width=panel.width;
  97.   height=panel.height;
  98. }
  99. function save(fn,sx,sy,dx,dy) {
  100.   panel.save(fn,sx,sy,dx,dy);
  101. }
  102.  
  103. function drawFocus() {
  104.       var w,h,xx,yy;
  105.       xx=x;yy=y;
  106.       w=getWidth()/2;h=getHeight()/2;
  107.       drawSprite(xx-w,yy-h,0);
  108.       drawSprite(xx+w,yy-h,0);
  109.       drawSprite(xx+w,yy+h,0);
  110.       drawSprite(xx-w,yy+h,0);
  111. }
  112.  
  113. function draw() {
  114.   var sx,sy;
  115.   super.draw();
  116.   panel.angle=trunc(angle);  
  117.   panel.alpha=alpha;  
  118.   panel.zOrder=zOrder;
  119.   panel.target=this;
  120.   if (!scaleY) panel.stretchDraw(x,y,width*scaleX,height*scaleX);
  121.   else panel.stretchDraw(x,y,width*scaleX,height*scaleY);
  122. }
  123.