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 >
Wrap
C/C++ Source or Header
|
1995-12-15
|
4KB
|
132 lines
/* Project wireview
DoGA
Copyright (c) 1995. Project Team DoGA. All Rights Reserved.
サブシステム: wireview.apx Application
ファイル: bmpbtn.cpp
作成者: Masamichi Takatsu
概要
====
TBmpButton (TButton) のインプリメンテーション用のソースファイル
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include "bmpbtn.h"
#include "log.h"
//
// このアプリケーションで処理するすべてのメッセージ/コマンドの
// 応答テーブルを作成する
//
DEFINE_RESPONSE_TABLE1(TBmpButton, TButton)
//{{TBmpButtonRSP_TBL_BEGIN}}
EV_WM_DRAWITEM,
//{{TBmpButtonRSP_TBL_END}}
END_RESPONSE_TABLE;
//{{TBmpButton Implementation}}
TBmpButton::TBmpButton (TWindow* parent, int cid, int bid, int X, int Y, int W, int H, BOOL isDefault, TModule* module):
TButton(parent, cid, NULL, X, Y, W, H, isDefault, module)
{
// INSERT>> コンストラクタ用のコードはここに
ctrlid = cid;
bmpid = bid;
Attr.Style |= BS_OWNERDRAW;
dib = new TDib(*GetModule(), bmpid);
}
TBmpButton::~TBmpButton ()
{
Destroy();
delete dib;
// INSERT>> デストラクタ用のコードはここに
}
void TBmpButton::EvDrawItem (UINT ctrlId, DRAWITEMSTRUCT far& draw)
{
TButton::EvDrawItem(ctrlId, draw);
TDC dc(draw.hDC);
TRect rect = dc.GetClipBox();
TSize size = dib->Size();
if (draw.itemAction == ODA_DRAWENTIRE) {
TRect dst(0, 0, size.cx, size.cy);
dc.SetDIBitsToDevice(dst,TPoint(0,0), *dib);
}
if (draw.itemAction == ODA_DRAWENTIRE
|| draw.itemAction == ODA_SELECT) {
if (draw.itemState & ODS_SELECTED) {
dc.SelectObject(TPen(TColor::Black, 3));
dc.MoveTo(0, size.cy);
dc.LineTo(0, 0);
dc.LineTo(size.cx, 0);
dc.SelectObject(TPen(TColor::White, 3));
dc.LineTo(size.cx, size.cy);
dc.LineTo(0, size.cy);
} else {
dc.SelectObject(TPen(TColor::White, 3));
dc.MoveTo(0, size.cy);
dc.LineTo(0, 0);
dc.LineTo(size.cx, 0);
dc.SelectObject(TPen(TColor::Black, 3));
dc.LineTo(size.cx, size.cy);
dc.LineTo(0, size.cy);
}
}
#if 0
if (draw.itemAction == ODA_DRAWENTIRE) {
TSize size = dib->Size();
if (size.cx < rect.right - rect.left - 4
|| size.cy < rect.bottom - rect.top - 4) {
TRect dst(rect.left + ((rect.right-rect.left) - size.cx)/2,
rect.top + ((rect.bottom-rect.top) - size.cy)/2,
rect.right - ((rect.right-rect.left) - size.cx)/2,
rect.left - ((rect.bottom-rect.top) - size.cy)/2);
dc.SelectObject(TBrush(TColor::LtGray));
dc.Rectangle(rect);
dc.SetDIBitsToDevice(dst,TPoint(0,0), *dib);
} else {
int w = rect.right - rect.left - 4;
int h = rect.bottom - rect.top - 4;
dc.SetDIBitsToDevice(rect,TPoint((size.cx-w)/2-2, (size.cy-w)/2-2), *dib);
}
}
if (draw.itemAction == ODA_DRAWENTIRE
|| draw.itemAction == ODA_SELECT) {
if (draw.itemState & ODS_SELECTED) {
dc.SelectObject(TPen(TColor::Black, 3));
dc.MoveTo(rect.left, rect.bottom);
dc.LineTo(rect.left, rect.top);
dc.LineTo(rect.right, rect.top);
dc.SelectObject(TPen(TColor::White, 3));
dc.LineTo(rect.right, rect.bottom);
dc.LineTo(rect.left, rect.bottom);
} else {
dc.SelectObject(TPen(TColor::White, 3));
dc.MoveTo(rect.left, rect.bottom);
dc.LineTo(rect.left, rect.top);
dc.LineTo(rect.right, rect.top);
dc.SelectObject(TPen(TColor::Black, 3));
dc.LineTo(rect.right, rect.bottom);
dc.LineTo(rect.left, rect.bottom);
}
}
#endif
}