mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 18:30:27 +01:00
90 lines
1.9 KiB
C++
90 lines
1.9 KiB
C++
|
/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */
|
||
|
|
||
|
// TexView.cpp : implementation file
|
||
|
//
|
||
|
|
||
|
#include "stdafx.h"
|
||
|
#include "seriousskastudio.h"
|
||
|
#include "TexView.h"
|
||
|
|
||
|
#ifdef _DEBUG
|
||
|
#undef new
|
||
|
#define new DEBUG_NEW
|
||
|
#undef THIS_FILE
|
||
|
static char THIS_FILE[] = __FILE__;
|
||
|
#endif
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////////
|
||
|
// CTexView
|
||
|
|
||
|
CTexView::CTexView()
|
||
|
{
|
||
|
m_pDrawPort=NULL;
|
||
|
m_pViewPort=NULL;
|
||
|
}
|
||
|
|
||
|
CTexView::~CTexView()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
BEGIN_MESSAGE_MAP(CTexView, CWnd)
|
||
|
//{{AFX_MSG_MAP(CTexView)
|
||
|
ON_WM_PAINT()
|
||
|
ON_WM_SIZE()
|
||
|
//}}AFX_MSG_MAP
|
||
|
END_MESSAGE_MAP()
|
||
|
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////////
|
||
|
// CTexView message handlers
|
||
|
|
||
|
void CTexView::OnPaint()
|
||
|
{
|
||
|
{CPaintDC dc(this);}
|
||
|
|
||
|
if (m_pDrawPort==NULL || !m_pDrawPort->Lock()) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// clear browsing window
|
||
|
m_pDrawPort->FillZBuffer( ZBUF_BACK);
|
||
|
m_pDrawPort->Fill( C_BLACK | CT_OPAQUE);
|
||
|
if(m_ptoPreview.GetData()!=NULL) {
|
||
|
PIXaabbox2D rectPict;
|
||
|
rectPict = PIXaabbox2D( PIX2D(0, 0), PIX2D(m_pDrawPort->GetWidth(), m_pDrawPort->GetHeight()));
|
||
|
m_pDrawPort->PutTexture(&m_ptoPreview,rectPict);
|
||
|
}
|
||
|
m_pDrawPort->Unlock();
|
||
|
if (m_pViewPort!=NULL) {
|
||
|
// swap it
|
||
|
m_pViewPort->SwapBuffers();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BOOL CTexView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
|
||
|
{
|
||
|
_pGfx->CreateWindowCanvas( pParentWnd->m_hWnd, &m_pViewPort, &m_pDrawPort);
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
void CTexView::ChangeTexture(CTString strNewTexObject)
|
||
|
{
|
||
|
m_ptoPreview.SetData_t(strNewTexObject);
|
||
|
Invalidate(TRUE);
|
||
|
}
|
||
|
|
||
|
void CTexView::OnSize(UINT nType, int cx, int cy)
|
||
|
{
|
||
|
CRect rc;
|
||
|
GetParent()->GetClientRect(&rc);
|
||
|
INDEX iWidth = cx;
|
||
|
if(cy<cx) iWidth=cy;
|
||
|
INDEX iX = rc.right/2-cx/2;
|
||
|
if(iX!=0 && iWidth>0)
|
||
|
{
|
||
|
::SetWindowPos(m_pViewPort->vp_hWndParent,wndTop,iX,55,iWidth,cy,SWP_NOZORDER);
|
||
|
m_pViewPort->Resize();
|
||
|
}
|
||
|
}
|