home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / MEDIT.LZH / BMPBTN.CPP < prev    next >
C/C++ Source or Header  |  1996-05-23  |  4KB  |  183 lines

  1. /*  Project medit
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    medit.apx Application
  6.     ファイル:        bmpbtn.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TBMPButton (TButton) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <owl\button.h>
  19. #include "anim.h"
  20. #include "winframe.h"
  21. #include "bmpbtn.h"
  22.  
  23. #define TIMELAG 200
  24.  
  25. //
  26. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  27. // 応答テーブルを作成する
  28. //
  29. DEFINE_RESPONSE_TABLE1(TBMPButton, TButton)
  30. //{{TBMPButtonRSP_TBL_BEGIN}}
  31.     EV_WM_PAINT,
  32.     EV_WM_TIMER,
  33.     EV_WM_LBUTTONDOWN,
  34.     EV_WM_LBUTTONUP,
  35. //{{TBMPButtonRSP_TBL_END}}
  36. END_RESPONSE_TABLE;
  37.  
  38.  
  39. //{{TBMPButton Implementation}}
  40.  
  41.  
  42. TBMPButton::TBMPButton (TWindow* parent, AnimationData *a, int id, int X, int Y, int W, int H, BOOL isDefault, TModule* module):
  43.     TButton(parent, id, NULL, X, Y, W, H, isDefault, module)
  44. {
  45.     // INSERT>> コンストラクタ用のコードはここに
  46.  
  47.     anim = a;
  48.     wid = id;
  49.     Attr.Style |= BS_OWNERDRAW;
  50.     dib = new TDib(*GetModule(), id);
  51.     intimer = FALSE;
  52.     push = FALSE;
  53. }
  54.  
  55.  
  56. TBMPButton::~TBMPButton ()
  57. {
  58.     Destroy();
  59.  
  60.     // INSERT>> デストラクタ用のコードはここに
  61.     delete dib;
  62. }
  63.  
  64. void TBMPButton::EvPaint ()
  65. {
  66.     TButton::EvPaint();
  67.  
  68.     // INSERT>> 追加コードはここに
  69.  
  70.     TClientDC dc(*this);
  71.     TSize s = dib->Size();
  72.     TRect imageRect(0,0, s.cx, s.cy);
  73.     dc.SetDIBitsToDevice(imageRect, TPoint(0,0), *dib);
  74.  
  75. }
  76.  
  77.  
  78.  
  79. void TBMPButton::ODASelect (DRAWITEMSTRUCT far& drawInfo)
  80. {
  81.     TButton::ODASelect(drawInfo);
  82.  
  83.     // INSERT>> 追加のコードはここに
  84.  
  85. #if 0
  86.     KillTimer(0);
  87.     TClientDC dc(*this);
  88.     if (wid == BITMAP_BUTTON_FRAMEFORWARD || wid == BITMAP_BUTTON_FRAMEBACKWARD) {
  89.         if (drawInfo.itemState & ODS_SELECTED) {
  90.             if (wid == BITMAP_BUTTON_FRAMEFORWARD) {
  91.                 anim->Frame->EvButtonForward();
  92.             } else {
  93.                 anim->Frame->EvButtonBackward();
  94.             }
  95.             if (!push) {
  96.                 SetTimer(0,TIMELAG);
  97. dc.TextOut(0,0,"p");
  98.                 push = TRUE;
  99.             }
  100.         } else {
  101. dc.TextOut(0,0,"n");
  102.             push = FALSE;
  103.         }
  104.     }
  105. #endif
  106. #if 0
  107.         if (drawInfo.itemAction & ODA_SELECT
  108.          && drawInfo.itemState & ODS_SELECTED) {
  109.             if (wid == BITMAP_BUTTON_FRAMEFORWARD) {
  110.                 anim->Frame->EvButtonForward();
  111.             } else {
  112.                 anim->Frame->EvButtonBackward();
  113.             }
  114.             SetTimer(0,TIMELAG);
  115.         }
  116. #endif
  117. #if 0
  118.         if (drawInfo.itemState & ODS_SELECTED) {
  119.             if (wid == BITMAP_BUTTON_FRAMEFORWARD) {
  120.                 anim->Frame->EvButtonForward();
  121.             } else {
  122.                 anim->Frame->EvButtonBackward();
  123.             }
  124.             SetTimer(0,TIMELAG);
  125.         } else {
  126.             KillTimer(0);
  127.         }
  128. #endif
  129.  
  130. }
  131.  
  132.  
  133. void TBMPButton::EvTimer (UINT timerId)
  134. {
  135.     TButton::EvTimer(timerId);
  136.  
  137.     // INSERT>> 追加コードはここに
  138.  
  139.     if (intimer || !push) {
  140.         return;
  141.     }
  142.     intimer = TRUE;
  143.     KillTimer(0);
  144.     if (wid == BITMAP_BUTTON_FRAMEFORWARD) {
  145.         anim->Frame->EvButtonForward();
  146.     } else if (wid == BITMAP_BUTTON_FRAMEBACKWARD) {
  147.         anim->Frame->EvButtonBackward();
  148.     }
  149.     if (push) {
  150.         SetTimer(0,33);
  151.     }
  152.     intimer = FALSE;
  153. }
  154.  
  155.  
  156. void TBMPButton::EvLButtonDown (UINT modKeys, TPoint& point)
  157. {
  158.     TButton::EvLButtonDown(modKeys, point);
  159.  
  160.     // INSERT>> 追加コードはここに
  161.     push = TRUE;
  162.     if (wid == BITMAP_BUTTON_FRAMEFORWARD || wid == BITMAP_BUTTON_FRAMEBACKWARD) {
  163.         if (wid == BITMAP_BUTTON_FRAMEFORWARD) {
  164.             anim->Frame->EvButtonForward();
  165.         } else {
  166.             anim->Frame->EvButtonBackward();
  167.         }
  168.         SetTimer(0,TIMELAG);
  169.     }
  170. }
  171.  
  172.  
  173. void TBMPButton::EvLButtonUp (UINT modKeys, TPoint& point)
  174. {
  175.     TButton::EvLButtonUp(modKeys, point);
  176.  
  177.     // INSERT>> 追加コードはここに
  178.  
  179.     push = FALSE;
  180.        KillTimer(0);
  181. }
  182.  
  183.