home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / BMPBTN.CPP < prev    next >
C/C++ Source or Header  |  1995-09-19  |  3KB  |  145 lines

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        bmpbtn.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TBitmapButton (TButton) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include "bmpbtn.h"
  19. #include "design.h"
  20. #include "parts.h"
  21. #include "winframe.h"
  22. #include "seltype.h"
  23. #include "log.h"
  24.  
  25. const int buttonsize = 16;
  26.  
  27. //
  28. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  29. // 応答テーブルを作成する
  30. //
  31. DEFINE_RESPONSE_TABLE1(TBitmapButton, TButton)
  32. //{{TBitmapButtonRSP_TBL_BEGIN}}
  33.     EV_WM_PAINT,
  34.     EV_WM_TIMER,
  35. //{{TBitmapButtonRSP_TBL_END}}
  36. END_RESPONSE_TABLE;
  37.  
  38.  
  39. //{{TBitmapButton Implementation}}
  40.  
  41.  
  42. TBitmapButton::TBitmapButton (TWindow* parent, DesignData *dd, int id, int X, int Y, int W, int H, BOOL isDefault, TModule* module):
  43.     TButton(parent, id, "", X, Y, W, H, isDefault, module)
  44. {
  45.     // TButton 用の,デフォルトのウィンドウスタイルをオーバーライドする
  46.     Attr.Style |= WS_CHILD | WS_VISIBLE;
  47.     Attr.Style &= ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
  48.  
  49.     // INSERT>> コンストラクタ用のコードはここに
  50.  
  51.     Attr.Style |= BS_OWNERDRAW;
  52.     dib = new TDib(*GetModule(), id);
  53.  
  54.     designdata = dd;
  55. }
  56.  
  57.  
  58. TBitmapButton::~TBitmapButton ()
  59. {
  60.     Destroy();
  61.  
  62.     // INSERT>> デストラクタ用のコードはここに
  63.     delete dib;
  64. }
  65.  
  66.  
  67. void TBitmapButton::EvPaint ()
  68. {
  69.     TButton::EvPaint();
  70.  
  71.     // INSERT>> 追加コードはここに
  72.     TClientDC dc(*this);
  73.     TSize s = dib->Size();
  74.     TRect imageRect(0,0, s.cx, s.cy);
  75.     if (Attr.W == s.cx && Attr.H == s.cy) {
  76.         dc.SetDIBitsToDevice(imageRect, TPoint(0,0), *dib);
  77.     } else {
  78.         TRect clientRect(0,0, Attr.W, Attr.H);
  79.         dc.StretchDIBits(clientRect, imageRect, *dib);
  80.     }
  81. }
  82.  
  83.  
  84. void TBitmapButton::SetupWindow ()
  85. {
  86.     TButton::SetupWindow();
  87.  
  88.     // INSERT>> 追加のコードはここに
  89. }
  90.  
  91.  
  92.  
  93.  
  94. void TBitmapButton::ODADrawEntire (DRAWITEMSTRUCT far& drawInfo)
  95. {
  96.     TButton::ODADrawEntire(drawInfo);
  97.  
  98.     // INSERT>> 追加のコードはここに
  99.  
  100. }
  101.  
  102.  
  103. void TBitmapButton::ODAFocus (DRAWITEMSTRUCT far& drawInfo)
  104. {
  105.     TButton::ODAFocus(drawInfo);
  106.  
  107.     // INSERT>> 追加のコードはここに
  108.  
  109. }
  110.  
  111.  
  112. void TBitmapButton::ODASelect (DRAWITEMSTRUCT far& drawInfo)
  113. {
  114.     TButton::ODASelect(drawInfo);
  115.  
  116.     // INSERT>> 追加のコードはここに
  117.  
  118.     if (drawInfo.itemState & ODS_SELECTED) {
  119.         if (designdata->select == designdata->camera) {
  120.             designdata->Frame->EvButton(Attr.Id, SelPers | SelStat);
  121.         } else {
  122.             designdata->Frame->EvButton(Attr.Id, SelPers);
  123.         }
  124.         SetTimer(0,100);
  125.     } else {
  126.         KillTimer(0);
  127.         designdata->Redraw(SelXYZ);
  128.     }
  129. }
  130.  
  131.  
  132. void TBitmapButton::EvTimer (UINT timerId)
  133. {
  134.     TButton::EvTimer(timerId);
  135.  
  136.     // INSERT>> 追加コードはここに
  137.  
  138.     if (designdata->select == designdata->camera) {
  139.         designdata->Frame->EvButton(Attr.Id, SelPers | SelStat);
  140.     } else {
  141.         designdata->Frame->EvButton(Attr.Id, SelPers);
  142.     }
  143. }
  144.  
  145.