1: /* $Id: 1048576.html,v 1.1.1.1 2000/08/28 11:39:25 hidetosi Exp $ */
   2: #include <btron/btron.h>
   3: #include <btron/hmi.h>
   4: #include <btron/vobj.h>
   5: #include <typedef.h>
   6: #include <bstdlib.h>
   7: #include <tstring.h>
   8: #include <errcode.h>
   9: #include "paperbox.h"
  10: #include "view.h"
  11: #include "doc.h"
  12: #include "databox.h"
  13: 
  14: void ErrEnd(TC* aErrMsg)
  15: {
  16:         pdsp_msg(aErrMsg);
  17:         ext_prc(0);
  18: }
  19: 
  20: W OpenWindow(M_EXECREQ* apMsg,W* apwUniqueData,BOOL aisDisp)
  21: /* apwUniqueData; 固有データ */
  22: /* aisDisp; 開いた仮身かどうか */
  23: {
  24:         W idWnd; /* ウィンドウID */
  25:         RECT rctWnd,rctWork; /*ウィンドウの表示位置*/
  26:         TC tFilename[APPNAMESIZE+1+21]; /* 実身名 */
  27:         TC* pFilename;
  28:         PAT ptnBack; /* 背景パターン */
  29: 
  30:         ptnBack.spat.kind=0;
  31:         ptnBack.spat.hsize=8;
  32:         ptnBack.spat.vsize=1;
  33:         ptnBack.spat.bgcol=-1;
  34:         ptnBack.spat.mask=FILL100;
  35: 
  36:         /* 固有データの読み込み */
  37:         if(!ReadUniqueData(apwUniqueData,&rctWnd,&rctWork))
  38:         {
  39:                rctWnd.c.left=100;
  40:                rctWnd.c.top=100;
  41:                rctWnd.c.right=300;
  42:                rctWnd.c.bottom=300;
  43:                rctWork.c.left=0;
  44:                rctWork.c.top=0;
  45:                rctWork.c.right=0;
  46:                rctWork.c.bottom=0;
  47:         }
  48: 
  49:         if(aisDisp) /* 開いた仮身なら */
  50:         {
  51:                M_DISPREQ* pDispReq;
  52:                W idDrawEnv;
  53: 
  54:                pDispReq=(M_DISPREQ*)apMsg;
  55:                ptnBack.spat.fgcol=pDispReq->bgcol;
  56: 
  57:                idWnd=wopn_iwd(pDispReq->gid);
  58:                idDrawEnv=wget_gid(idWnd);
  59:                gmov_cor(idDrawEnv,rctWork.c.left,rctWork.c.top);
  60:                gget_fra(idDrawEnv,&rctWnd);
  61:                gset_vis(idDrawEnv,rctWnd);
  62:                gfil_rec(idDrawEnv,rctWnd,&ptnBack,0,G_STORE);
  63:                return -idWnd;
  64:         }else{ /* 仮身のオープンなら */
  65:                /* W wAppNameKey; */
  66:                F_STATE fsState;
  67: 
  68:                ptnBack.spat.fgcol=apMsg->bgcol;
  69: 
  70:                /* wAppNameKey=dget_dat(TEXT_DATA,ID_ST_APLNAME,0); */
  71:                dget_dtp(TEXT_DATA,ID_ST_APLNAME,(void**)&pFilename);
  72:                tc_strncpy(tFilename,pFilename,APPNAMESIZE);
  73:                /* drel_dat(wAppNameKey); */
  74:                tFilename[APPNAMESIZE]=0x2127;
  75:                fil_sts(&(apMsg->lnk),tFilename+APPNAMESIZE+1,&fsState,NULL);
  76:                                                                      /* 実身名の獲得 */
  77:                /*ウィンドウをオープン*/
  78:                idWnd = wopn_wnd(WA_SIZE|WA_HHDL|WA_VHDL|WA_RBAR|WA_BBAR,
  79:                               apMsg->pwid,&rctWnd,NULL,fsState.f_atype&0x00ff,
  80:                               tFilename,&ptnBack,NULL);
  81:                if (idWnd < 0)
  82:                {
  83:                      TC tErrMsg[] = {0x2526, 0x2524, 0x2573, 0x2549, 0x2526, 0x242c, 0x332b, 0x2431, 0x245e, 0x243b, 0x2473, 0x2447, 0x2437, 0x243f, 0x0000};
  84:                      ErrEnd(tErrMsg);
  85:                }
  86:                wset_wrk(idWnd,&rctWork); /* データ内の表示する位置を設定 */
  87:                return idWnd;
  88:         }
  89: 
  90: }
  91: 
  92: void MAIN(M_EXECREQ* apMsg)
  93: {
  94:         W idWnd=0; /* ウィンドウID */
  95:         W idDatabox; /* データボックスのファイルID */
  96:         W* pwUniqueData; /* 固有データ */
  97:         WDSTAT wdsWindowState; /* ウインドウの状態 */
  98: 
  99:         gset_ptr(PS_BUSY,NULL,-1,-1); /* ポインタをゆのみにする */
 100: 
 101:         chg_wrk(NULL);
 102: 
 103:         idDatabox=dopn_dat(&(apMsg->self)); /* データボックスのオープン */
 104:         if( idDatabox < 0)
 105:         {
 106:                TC tErrMsg[] = {0x2547, 0x213c, 0x253f, 0x255c, 0x2543, 0x252f, 0x2539, 0x242c, 0x332b, 0x2431, 0x245e, 0x243b, 0x2473, 0x2447, 0x2437, 0x243f, 0x0000};
 107:                ErrEnd(tErrMsg);
 108:         }
 109:         /* 起動の仕方による動作の違い */
 110:         switch(apMsg->type)
 111:         {
 112:         case EXECREQ:
 113:                if(!(apMsg->mode & 2)) /* 仮身起動の時 */
 114:                {
 115:                      if(apMsg->mode & 1) /* デフォルト起動でない時 */
 116:                           pwUniqueData=NULL;
 117:                      else /* デフォルト起動の時 */
 118:                           pwUniqueData=(W*)apMsg->info;
 119: 
 120:                      if(!FileOpen(apMsg->vid,apMsg->lnk))
 121:                      {
 122:                           TC tErrMsg[] = {0x2555, 0x2521, 0x2524, 0x256b, 0x242c, 0x332b, 0x2431, 0x245e, 0x243b, 0x2473, 0x2447, 0x2437, 0x243f, 0x0000};
 123:                           ErrEnd(tErrMsg); /* ファイルが開けなかった */
 124:                      }
 125:                      idWnd=OpenWindow(apMsg,pwUniqueData,(BOOL)FALSE);
 126:                      osta_prc(apMsg->vid,idWnd); /* 実身処理の開始 */
 127:                      ReadFile(idWnd); /* 実身の読み込み */
 128:                      CloseFile();
 129:                      wreq_dsp(idWnd);
 130: 
 131:                      break; /* 次に進む */
 132:                }
 133:         case DISPREQ:
 134:                pwUniqueData=(W*)apMsg->info;
 135: 
 136:                if(!FileOpen(apMsg->vid,apMsg->lnk))
 137:                      ErrEnd((TC*)"\0"); /* ファイルが開けなかった */
 138:                idWnd=OpenWindow(apMsg,pwUniqueData,(BOOL)TRUE);
 139: 
 140:                ReadFile(idWnd); /* 実身の読み込み */
 141:                CloseFile();
 142: 
 143:                {
 144:                      RECT rctWnd;
 145: 
 146:                      gget_fra(wget_gid(-idWnd),&rctWnd);
 147:                      DrawOneRect(idWnd,rctWnd);
 148:                }
 149:                oend_req(apMsg->vid,0);
 150:                ext_prc(0); /* 終了 */
 151: 
 152:         case PASTEREQ:
 153:                oend_req(apMsg->vid,1);
 154:         default:
 155:                {
 156:                      TC tErrMsg[] = {0x3c42, 0x3954, 0x244e, 0x3b45, 0x4a7d, 0x242c, 0x4954, 0x4035, 0x2447, 0x2439, 0x0000};
 157:                      ErrEnd(tErrMsg);
 158:                }
 159:         }
 160: 
 161:         MenuInit(idWnd); /* メニューの初期化 */
 162: 
 163:         InitScrollBar(idWnd); /* スクロールバーの初期化 */
 164: 
 165:         gset_ptr(PS_SELECT,NULL,-1,-1); /* ポインタを元に戻す */
 166: 
 167:         for (;;)  /*イベントループ*/
 168:         {
 169:                WEVENT evWnd; /* イベント */
 170: 
 171:                wget_evt(&evWnd, WAIT);        /*イベントを取得*/
 172:                if(!EventExec(evWnd,idWnd))
 173:                {
 174:                      break; /* 終了 */
 175:                }
 176:         }
 177:         dcls_dat(idDatabox); /* データボックスのクローズ */
 178: 
 179:         /* プログラムの終了処理 */
 180:         gset_ptr(PS_BUSY,NULL,-1,-1); /* ポインタを変更 */
 181:         wget_sts(idWnd,&wdsWindowState,NULL); /* ウインドウの状態の取得 */
 182:         WriteUniqueData(wdsWindowState.r,wdsWindowState.wr);
 183:         FreeDocument(); /* メモリの解放 */
 184:         wcls_wnd(idWnd, CLR); /* ウインドウのクローズ */
 185:         gset_ptr(PS_SELECT,NULL,-1L,-1L); /* ポインタを元に戻す */
 186:         ext_prc(0);
 187: }
 188: