-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveTextureWnd.cpp
131 lines (107 loc) · 3.3 KB
/
ActiveTextureWnd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
// ActiveTextureWnd.cpp : implementation file
//
#include "StdH.h"
#include "ActiveTextureWnd.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CActiveTextureWnd
CActiveTextureWnd::CActiveTextureWnd()
{
m_pDrawPort = NULL;
m_pViewPort = NULL;
}
CActiveTextureWnd::~CActiveTextureWnd()
{
}
BEGIN_MESSAGE_MAP(CActiveTextureWnd, CWnd)
//{{AFX_MSG_MAP(CActiveTextureWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CActiveTextureWnd message handlers
void CActiveTextureWnd::OnPaint()
{
{
CPaintDC dc(this);
}
if( (m_pViewPort == NULL) && (m_pDrawPort == NULL) )
{
// initialize canvas for active texture button
_pGfx->CreateWindowCanvas( m_hWnd, &m_pViewPort, &m_pDrawPort);
}
// if there is a valid drawport, and the drawport can be locked
if( (m_pDrawPort != NULL) && (m_pDrawPort->Lock()) )
{
PIXaabbox2D rectPict;
rectPict = PIXaabbox2D( PIX2D(0, 0),
PIX2D(m_pDrawPort->GetWidth(), m_pDrawPort->GetHeight()));
// clear texture area to black
m_pDrawPort->Fill( C_BLACK | CT_OPAQUE);
// erase z-buffer
m_pDrawPort->FillZBuffer(ZBUF_BACK);
// if there is valid active texture
if( theApp.m_ptdActiveTexture != NULL)
{
CTextureObject toActiveTexture;
toActiveTexture.SetData( theApp.m_ptdActiveTexture);
m_pDrawPort->PutTexture( &toActiveTexture, rectPict);
}
else
{
// type text saying none selected
m_pDrawPort->SetFont( theApp.m_pfntSystem);
m_pDrawPort->SetTextAspect( 1.0f);
m_pDrawPort->PutText( "None", 25, 20);
m_pDrawPort->PutText( "selected", 8, 50);
}
// unlock the drawport
m_pDrawPort->Unlock();
if (m_pViewPort!=NULL)
{
m_pViewPort->SwapBuffers();
}
}
}
void CActiveTextureWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
if( theApp.m_ptdActiveTexture == NULL) return;
HGLOBAL hglobal = CreateHDrop( theApp.m_ptdActiveTexture->GetName());
m_DataSource.CacheGlobalData( CF_HDROP, hglobal);
m_DataSource.DoDragDrop( DROPEFFECT_COPY);
CWnd::OnLButtonDown(nFlags, point);
}
void CActiveTextureWnd::OnRButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnRButtonDown(nFlags, point);
}
void CActiveTextureWnd::OnDestroy()
{
CWnd::OnDestroy();
if( m_pViewPort != NULL)
{
_pGfx->DestroyWindowCanvas( m_pViewPort);
m_pViewPort = NULL;
}
m_pViewPort = NULL;
m_pDrawPort = NULL;
}