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

  1. /*  Project wireview
  2.     DoGA
  3.     Copyright (c) 1995. Project Team DoGA. All Rights Reserved.
  4.  
  5.     サブシステム:    wireview.apx Application
  6.     ファイル:        bmpbtn.cpp
  7.     作成者:          Masamichi Takatsu
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TBmpButton (TButton) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include "bmpbtn.h"
  19.  
  20. #include "log.h"
  21.  
  22. //
  23. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  24. // 応答テーブルを作成する
  25. //
  26. DEFINE_RESPONSE_TABLE1(TBmpButton, TButton)
  27. //{{TBmpButtonRSP_TBL_BEGIN}}
  28.     EV_WM_DRAWITEM,
  29. //{{TBmpButtonRSP_TBL_END}}
  30. END_RESPONSE_TABLE;
  31.  
  32.  
  33. //{{TBmpButton Implementation}}
  34.  
  35.  
  36. TBmpButton::TBmpButton (TWindow* parent, int cid, int bid, int X, int Y, int W, int H, BOOL isDefault, TModule* module):
  37.     TButton(parent, cid, NULL, X, Y, W, H, isDefault, module)
  38. {
  39.     // INSERT>> コンストラクタ用のコードはここに
  40.  
  41.     ctrlid = cid;
  42.     bmpid = bid;
  43.     Attr.Style |= BS_OWNERDRAW;
  44.     dib = new TDib(*GetModule(), bmpid);
  45.  
  46.  
  47. }
  48.  
  49.  
  50. TBmpButton::~TBmpButton ()
  51. {
  52.     Destroy();
  53.     delete dib;
  54.  
  55.     // INSERT>> デストラクタ用のコードはここに
  56.  
  57. }
  58.  
  59.  
  60. void TBmpButton::EvDrawItem (UINT ctrlId, DRAWITEMSTRUCT far& draw)
  61. {
  62.     TButton::EvDrawItem(ctrlId, draw);
  63.        TDC dc(draw.hDC);
  64.     TRect rect = dc.GetClipBox();
  65.     TSize size = dib->Size();
  66.     if (draw.itemAction == ODA_DRAWENTIRE) {
  67.         TRect dst(0, 0, size.cx, size.cy);
  68.         dc.SetDIBitsToDevice(dst,TPoint(0,0), *dib);
  69.     }
  70.     if (draw.itemAction == ODA_DRAWENTIRE
  71.      || draw.itemAction == ODA_SELECT) {
  72.         if (draw.itemState & ODS_SELECTED) {
  73.             dc.SelectObject(TPen(TColor::Black, 3));
  74.             dc.MoveTo(0,       size.cy);
  75.             dc.LineTo(0,       0);
  76.             dc.LineTo(size.cx, 0);
  77.             dc.SelectObject(TPen(TColor::White, 3));
  78.             dc.LineTo(size.cx, size.cy);
  79.             dc.LineTo(0,       size.cy);
  80.         } else {
  81.             dc.SelectObject(TPen(TColor::White, 3));
  82.             dc.MoveTo(0,       size.cy);
  83.             dc.LineTo(0,       0);
  84.             dc.LineTo(size.cx, 0);
  85.             dc.SelectObject(TPen(TColor::Black, 3));
  86.             dc.LineTo(size.cx, size.cy);
  87.             dc.LineTo(0,       size.cy);
  88.         }
  89.     }
  90. #if 0
  91.     if (draw.itemAction == ODA_DRAWENTIRE) {
  92.         TSize size = dib->Size();
  93.         if (size.cx < rect.right - rect.left - 4
  94.          || size.cy < rect.bottom - rect.top - 4) {
  95.             TRect dst(rect.left  + ((rect.right-rect.left) - size.cx)/2,
  96.                       rect.top   + ((rect.bottom-rect.top) - size.cy)/2,
  97.                       rect.right - ((rect.right-rect.left) - size.cx)/2,
  98.                       rect.left  - ((rect.bottom-rect.top) - size.cy)/2);
  99.             dc.SelectObject(TBrush(TColor::LtGray));
  100.             dc.Rectangle(rect);
  101.             dc.SetDIBitsToDevice(dst,TPoint(0,0), *dib);
  102.         } else {
  103.             int w = rect.right - rect.left - 4;
  104.             int h = rect.bottom - rect.top - 4;
  105.             dc.SetDIBitsToDevice(rect,TPoint((size.cx-w)/2-2, (size.cy-w)/2-2), *dib);
  106.         }
  107.     }
  108.     if (draw.itemAction == ODA_DRAWENTIRE
  109.      || draw.itemAction == ODA_SELECT) {
  110.         if (draw.itemState & ODS_SELECTED) {
  111.             dc.SelectObject(TPen(TColor::Black, 3));
  112.             dc.MoveTo(rect.left,  rect.bottom);
  113.             dc.LineTo(rect.left,  rect.top);
  114.             dc.LineTo(rect.right, rect.top);
  115.             dc.SelectObject(TPen(TColor::White, 3));
  116.             dc.LineTo(rect.right, rect.bottom);
  117.             dc.LineTo(rect.left,  rect.bottom);
  118.         } else {
  119.             dc.SelectObject(TPen(TColor::White, 3));
  120.             dc.MoveTo(rect.left,  rect.bottom);
  121.             dc.LineTo(rect.left,  rect.top);
  122.             dc.LineTo(rect.right, rect.top);
  123.             dc.SelectObject(TPen(TColor::Black, 3));
  124.             dc.LineTo(rect.right, rect.bottom);
  125.             dc.LineTo(rect.left,  rect.bottom);
  126.         }
  127.     }
  128. #endif
  129.  
  130. }
  131.  
  132.