[GME-commit] GMESRC/GME/Gme PannButton.cpp,NONE,1.1
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Thu Mar 25 14:06:38 CST 2004
- Previous message: [GME-commit] GMESRC/GME/Gme GMEView.cpp,1.136,1.137
- Next message: [GME-commit]
GMESRC/GME/Gme PannWinDlg.h,NONE,1.1 PannWinDlg.cpp,NONE,1.1
PanningWindow.h,NONE,1.1 PanningWindow.cpp,NONE,1.1
PannButton.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/gme/GMESRC/GME/Gme
In directory braindrain:/tmp/cvs-serv11228
Added Files:
PannButton.cpp
Log Message:
Panning Window embedded
CVS User: bogyom
--- NEW FILE: PannButton.cpp ---
// PannButton.cpp : implementation file
//
#include "stdafx.h"
#include "gme.h"
#include "PannButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPannButton
CPannButton::CPannButton()
{
m_viewRect = CRect(0,0,0,0);
m_bitmapDC = NULL;
m_bitmapS = CRect(0,0,0,0);
m_bitmapO = CRect(0,0,0,0);
}
CPannButton::~CPannButton()
{
if (m_bitmapDC)
delete m_bitmapDC;
}
BEGIN_MESSAGE_MAP(CPannButton, CButton)
//{{AFX_MSG_MAP(CPannButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPannButton message handlers
void CPannButton::SetBitmapDC(CDC *bdc, CRect &orisize, CRect &actsize) // may be empty
{
if (m_bitmapDC)
delete m_bitmapDC;
m_bitmapDC = bdc;
m_bitmapO = orisize;
m_bitmapS = actsize;
Invalidate();
UpdateWindow();
}
void CPannButton::SetViewRect(CRect &vrect)
{
// vrect is on the logical coordinate system
double rx = (double)(m_bitmapS.Width())/ m_bitmapO.Width();
double ry = (double)(m_bitmapS.Height())/ m_bitmapO.Height();
m_viewRect.left = (int)(vrect.left * rx);
m_viewRect.right = (int)(vrect.right * rx);
m_viewRect.top = (int)(vrect.top * ry);
m_viewRect.bottom = (int)(vrect.bottom * ry);
Invalidate();
UpdateWindow();
}
void CPannButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (!m_bitmapDC)
{
return;
}
if (lpDrawItemStruct->itemAction == ODA_DRAWENTIRE)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC); // device context for painting
CRect vrect;
GetParent()->GetClientRect(&vrect);
m_bitmapDC->SetMapMode(MM_TEXT);
dc.SetMapMode(MM_TEXT);
double dx = (double)(vrect.Width())/m_bitmapS.Width();
double dy = (double)(vrect.Height())/m_bitmapS.Height();
double dd = (dx <= dy)? dx: dy;
dd = (dd < 1)? dd: 1;
vrect.right = min(vrect.right, dd * m_bitmapS.Width());
vrect.bottom = min(vrect.bottom, dd * m_bitmapS.Height());
BOOL ret = dc.StretchBlt(0, 0, vrect.Width(), vrect.Height(), m_bitmapDC,
0, 0, m_bitmapS.Width(), m_bitmapS.Height(), SRCCOPY);
if (!m_viewRect.IsRectEmpty())
{
double rx = (double)(vrect.Width())/ m_bitmapS.Width();
double ry = (double)(vrect.Height())/ m_bitmapS.Height();
CRect vRect(0,0,0,0);
vRect.left = m_viewRect.left * rx;
vRect.right = m_viewRect.right * rx;
vRect.top = m_viewRect.top * ry;
vRect.bottom = m_viewRect.bottom * ry;
vRect.right = min(vRect.right, vrect.right);
vRect.bottom = min(vRect.bottom, vrect.bottom);
CBrush brush;
DWORD dw = GetSysColor(COLOR_WINDOWTEXT);
BYTE r = GetRValue(dw);
BYTE g = GetGValue(dw);
BYTE b = GetBValue(dw);
brush.CreateSolidBrush(RGB(r,g,b));
dc.FrameRect(&vRect, &brush);
}
dc.Detach();
}
}
- Previous message: [GME-commit] GMESRC/GME/Gme GMEView.cpp,1.136,1.137
- Next message: [GME-commit]
GMESRC/GME/Gme PannWinDlg.h,NONE,1.1 PannWinDlg.cpp,NONE,1.1
PanningWindow.h,NONE,1.1 PanningWindow.cpp,NONE,1.1
PannButton.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list