home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / WIREVIEW.LZH / WINFRAME.CPP < prev    next >
C/C++ Source or Header  |  1995-12-20  |  7KB  |  253 lines

  1. /*  Project wireview
  2.     DoGA
  3.     Copyright (c) 1995. Project Team DoGA. All Rights Reserved.
  4.  
  5.     サブシステム:    wireview.apx Application
  6.     ファイル:        winframe.cpp
  7.     作成者:          Masamichi Takatsu
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TWinFrame (TWindow) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17. #include <owl\slider.h>
  18.  
  19. #include "files.h"
  20. #include "matrix.h"
  21. #include "anim.h"
  22. #include "motion.h"
  23. #include "winframe.h"
  24. #include "view.h"
  25. #include "log.h"
  26. #include "bmpbtn.h"
  27.  
  28. #define ID_TIME 410
  29.  
  30. //
  31. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  32. // 応答テーブルを作成する
  33. //
  34. DEFINE_RESPONSE_TABLE1(TWinFrame, TWindow)
  35. //{{TWinFrameRSP_TBL_BEGIN}}
  36.     EV_CHILD_NOTIFY_ALL_CODES(ID_TIME, EvSlider),
  37.     EV_BN_CLICKED(BITMAP_BUTTON_PLAY, EvButtonPlay),
  38.     EV_BN_CLICKED(BITMAP_BUTTON_STOP, EvButtonStop),
  39.     EV_BN_CLICKED(BITMAP_BUTTON_FRAMEFORWARD, EvButtonForward),
  40.     EV_BN_CLICKED(BITMAP_BUTTON_FRAMEBACKWARD, EvButtonBackward),
  41.     EV_WM_TIMER,
  42.     EV_WM_SIZE,
  43.     EV_WM_ACTIVATE,
  44. //{{TWinFrameRSP_TBL_END}}
  45. END_RESPONSE_TABLE;
  46.  
  47.  
  48. //{{TWinFrame Implementation}}
  49.  
  50.  
  51. TWinFrame::TWinFrame (TWindow* parent, const char far* title, TModule* module):
  52.     TWindow(parent, title, module)
  53. {
  54.     // INSERT>> コンストラクタ用のコードはここに
  55.     int screenX = GetSystemMetrics(SM_CXSCREEN);
  56.     int screenY = GetSystemMetrics(SM_CYSCREEN);
  57.  
  58.     int wx, wy;
  59.  
  60.     if (screenX <= 800) {
  61.         wx = screenX-80;
  62.         wy = screenX * 3 / 4;
  63.     } else {
  64.         wx = 800;
  65.         wy = 600;
  66.     }
  67.     Attr.W = wx;
  68. #define BUTTONSIZE 24
  69.     Attr.H = wy + BUTTONSIZE;
  70.     anim = new AnimationData();
  71.     anim->Frame = this;
  72.     anim->PersView  = new TWinView(this, anim, 0, 0,  wx, wy);
  73.  
  74.     anim->frameCounter = new THSlider(this, ID_TIME, 0, wy, wx-BUTTONSIZE*4, BUTTONSIZE);
  75.     int x = wx-BUTTONSIZE*4, y = wy;
  76.  
  77.     anim->button[0] = new TBmpButton(this, BITMAP_BUTTON_FRAMEBACKWARD, BITMAP_BUTTON_FRAMEBACKWARD, x, y, 24, 24); x += 24;
  78.     anim->button[1] = new TBmpButton(this, BITMAP_BUTTON_STOP,          BITMAP_BUTTON_STOP,          x, y, 24, 24); x += 24;
  79.     anim->button[2] = new TBmpButton(this, BITMAP_BUTTON_PLAY,          BITMAP_BUTTON_PLAY,          x, y, 24, 24); x += 24;
  80.     anim->button[3] = new TBmpButton(this, BITMAP_BUTTON_FRAMEFORWARD,  BITMAP_BUTTON_FRAMEFORWARD,  x, y, 24, 24); x += 24;
  81.  
  82. #if 0
  83.     if (_argc > 1) {
  84.         anim->ReadFile(_argv[1]);
  85.     }
  86. #endif
  87. }
  88.  
  89.  
  90. TWinFrame::~TWinFrame ()
  91. {
  92.     Destroy();
  93.  
  94.     // INSERT>> デストラクタ用のコードはここに
  95.  
  96. }
  97.  
  98.  
  99. void TWinFrame::SetupWindow ()
  100. {
  101.     TWindow::SetupWindow();
  102.  
  103.     // INSERT>> 追加のコードはここに
  104.  
  105. //    SetTimer(OpPlay, 66);
  106. //    SetTimer(OpPause, 1000);
  107.     anim->frameCounter->SetRange(BEGIN,anim->maxframe);
  108.     anim->frameCounter->SetPosition(anim->selectframe);
  109.     anim->frameCounter->SetRuler(10);
  110.  
  111. }
  112.  
  113.  
  114. void TWinFrame::EvTimer (UINT timerId)
  115. {
  116.     TWindow::EvTimer(timerId);
  117.  
  118.     // INSERT>> 追加コードはここに
  119.     if (timerId == OpPlay) {
  120.         anim->playmode = PmTimer;
  121.         anim->PersView->Redraw();
  122.         if (anim->selectframe >= anim->maxframe) {
  123.             if (anim->playmode == PmTimer) {
  124.                 SetTimer(OpPause, 30);
  125.                 KillTimer(OpPlay);
  126.             }
  127.             anim->SelectFrame(BEGIN);
  128.         } else {
  129.             anim->SelectFrame(anim->selectframe+1);
  130.         }
  131.     } else if (timerId == OpPause) {
  132.         anim->playmode = PmLoop;
  133.         KillTimer(timerId);
  134.         anim->PersView->Animation();
  135.     }
  136. }
  137.  
  138. void TWinFrame::EvButtonPlay (void)
  139. {
  140.     anim->opstat = OpPlay;
  141.     SetTimer(OpPause, 100);
  142. }
  143.  
  144. void TWinFrame::EvButtonStop (void)
  145. {
  146.     KillTimer(OpPause);
  147.     anim->opstat = OpPause;
  148. }
  149.  
  150. void TWinFrame::EvButtonForward (void)
  151. {
  152.     KillTimer(OpPause);
  153.     anim->opstat = OpPause;
  154.     if (anim->selectframe < anim->maxframe) {
  155.         anim->SelectFrame(anim->selectframe+1);
  156.         anim->PersView->Redraw();
  157.     }
  158. }
  159.  
  160. void TWinFrame::EvButtonBackward (void)
  161. {
  162.     KillTimer(OpPause);
  163.     anim->opstat = OpPause;
  164.     if (anim->selectframe > BEGIN) {
  165.         anim->SelectFrame(anim->selectframe-1);
  166.         anim->PersView->Redraw();
  167.     }
  168. }
  169.  
  170. void TWinFrame::EvSlider(UINT code)
  171. {
  172.     KillTimer(OpPause);
  173.     anim->opstat = OpPause;
  174.     int frame = anim->frameCounter->GetPosition();
  175.     if (code != SB_ENDSCROLL
  176.      && anim->selectframe != frame
  177.      && anim->wireframe != NULL
  178.       && BEGIN <= frame
  179.      && frame <= anim->maxframe
  180.      && anim->wireframe[frame-BEGIN].line != NULL) {
  181.            anim->selectframe = frame;
  182.         anim->PersView->Redraw();
  183.     } else if (code == SB_ENDSCROLL
  184.      && anim->selectframe != frame
  185.      && anim->wireframe != NULL
  186.      && BEGIN <= frame && frame <= anim->maxframe) {
  187.          anim->selectframe = frame;
  188.         anim->PersView->Redraw();
  189.     }
  190. //    ::SetFocus(anim->Status->HWindow);
  191. }
  192.  
  193.  
  194. void TWinFrame::CloseWindow (int retVal)
  195. {
  196.     TWindow::CloseWindow(retVal);
  197.  
  198.     // INSERT>> 追加のコードはここに
  199.     anim->opstat = OpPause;
  200. }
  201.  
  202.  
  203. void TWinFrame::EvSize (UINT sizeType, TSize& size)
  204. {
  205.     TWindow::EvSize(sizeType, size);
  206.  
  207.     // INSERT>> 追加コードはここに
  208. #if 0
  209.     int screenX = GetSystemMetrics(SM_CXSCREEN);
  210.     int screenY = GetSystemMetrics(SM_CYSCREEN);
  211.  
  212.     int wx, wy;
  213.     if (size.cy > size.cx * 3 / 4) {
  214.         wx = size.cy * 4 / 3;
  215.         wy = size.cy;
  216.     } else {
  217.         wx = size.cx;
  218.         wy = size.cx * 3 / 4;
  219.     }
  220.     wireview_w = wx;
  221.     wireview_h = wy + BUTTONSIZE;
  222. //    anim->Frame->MoveWindow(0, 0, wx, wy+BUTTONSIZE);
  223.     anim->PersView->MoveWindow(0,0,wx,wy);
  224.     anim->frameCounter->MoveWindow(0, wy, wx-BUTTONSIZE*4, BUTTONSIZE);
  225.     int x = wx-BUTTONSIZE*4, y = wy;
  226.  
  227.     anim->button[0]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  228.     anim->button[1]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  229.     anim->button[2]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  230.     anim->button[3]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  231.     Invalidate();
  232. #endif
  233.     anim->PersView->MoveWindow(0,0,size.cx,size.cy-BUTTONSIZE);
  234.     anim->frameCounter->MoveWindow(0, size.cy-BUTTONSIZE, size.cx-BUTTONSIZE*4, BUTTONSIZE);
  235.     int x = size.cx-BUTTONSIZE*4, y = size.cy-BUTTONSIZE;
  236.  
  237.     anim->button[0]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  238.     anim->button[1]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  239.     anim->button[2]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  240.     anim->button[3]->MoveWindow(x, y, BUTTONSIZE, BUTTONSIZE); x += BUTTONSIZE;
  241.     Invalidate();
  242. }
  243.  
  244.  
  245. void TWinFrame::EvActivate (UINT active, BOOL minimized, HWND hWndOther )
  246. {
  247.     TWindow::EvActivate(active, minimized, hWndOther );
  248.  
  249.     // INSERT>> 追加コードはここに
  250.  
  251. }
  252.  
  253.