📄 window.cpp
字号:
}
else
{
m_dwAttrib &= ~GUI_ACTIVE;
}
}
CWindow* CWindow::GetParent()
{
return m_pParent;
}
void CWindow::SetParent(CWindow* pParent)
{
m_pParent = pParent;
if(pParent)
{
pParent->AddWindow(this);
}
}
void CWindow::AddWindow(CWindow* pWnd)
{
m_SubWindows.push_back(pWnd);
}
void CWindow::RemoveWindow(CWindow* pWnd, bool bDel)
{
WndItor itor = m_SubWindows.begin();
while(itor != m_SubWindows.end())
{
if((*itor) == pWnd)
{
m_SubWindows.erase(itor);
if(bDel)
{
S_DELETE(pWnd);
}
return;
}
itor++;
}
}
void CWindow::RemoveWindow(DWORD WndID, bool bDel)
{
WndItor itor = m_SubWindows.begin();
while(itor != m_SubWindows.end())
{
if((*itor)->GetID() == m_dwID)
{
m_SubWindows.erase(itor);
if(bDel)
{
S_DELETE((*itor));
}
return;
}
itor++;
}
}
int CWindow::GetSubWindowsCount()
{
return m_SubWindows.size();
}
CWindow* CWindow::GetSubWindow(DWORD WndID)
{
WndItor itor = m_SubWindows.begin();
while(itor != m_SubWindows.end())
{
if((*itor)->GetID() == WndID)
{
return (*itor);
}
itor++;
}
return NULL;
}
//--------------------------------------------------
// 新的渲染方式(九格宫窗口)
//--------------------------------------------------
void CWindow::RenderNewStyle(unsigned long hTex, const RECT &rc, DWORD color, int border)
{
GRect src;
GRect dst;
int width = rc.right-rc.left;
int height = rc.bottom - rc.top;
if(color>>24==0) return;
src.SetRectWH(0, 0, border, border);
g_pGraphics->RenderSprite(hTex, rc.left, rc.top, &src, 0xffffffff);
src.SetRectWH(border*2, 0, border, border);
g_pGraphics->RenderSprite(hTex, rc.left+width-border, rc.top, &src, 0xffffffff);
src.SetRectWH(border*3, 0, border, border);
g_pGraphics->RenderSprite(hTex, rc.left, rc.top+height-border, &src, 0xffffffff);
src.SetRectWH(border*5, 0, border, border);
g_pGraphics->RenderSprite(hTex, rc.left+width-border, rc.top+height-border, &src, 0xffffffff);
src.SetRectWH(border, 0, border, border);
dst.SetRectWH(rc.left+border, rc.top, width-border*2, border);
g_pGraphics->RenderSprite(hTex, &dst, &src, 0xffffffff);
src.SetRectWH(border*4, 0, border, border);
dst.SetRectWH(rc.left+border, rc.top+height-border, width-border*2, border);
g_pGraphics->RenderSprite(hTex, &dst, &src, 0xffffffff);
src.SetRectWH(border*6, 0, border, border);
dst.SetRectWH(rc.left, rc.top+border, border, height-border*2);
g_pGraphics->RenderSprite(hTex, &dst, &src, 0xffffffff);
src.SetRectWH(border*7, 0, border, border);
dst.SetRectWH(rc.left+width-border, rc.top+border, border, height-border*2);
g_pGraphics->RenderSprite(hTex, &dst, &src, 0xffffffff);
}
void CWindow::RenderExpand()
{
int Width = m_Width/32;
int Height = m_Height/32;
int LastWidth = m_Width%32;
int LastHeight = m_Height%32;
GRect src;
for(int i=0; i<=Height; i++)
{
for(int j=0; j<=Width;j++)
{
if(i == 0)
{
if(j == 0)
{
src.SetRectWH(0, 0, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width)
{
src.SetRectWH(64, 0, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32-32+LastWidth, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width-1)
{
src.SetRectWH(32, 0, LastWidth, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else
{
src.SetRectWH(32, 0, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
}
else if(i == Height)
{
if(j == 0)
{
src.SetRectWH(0, 64, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32-32+LastHeight, &src, 0xffffffff);
continue;
}
else if(j == Width)
{
src.SetRectWH(64, 64, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32-32+LastWidth, m_ptPos.y+i*32-32+LastHeight, &src, 0xffffffff);
continue;
}
else if(j == Width-1)
{
src.SetRectWH(32, 64, LastWidth, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32-32+LastHeight, &src, 0xffffffff);
continue;
}
else
{
src.SetRectWH(32, 64, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32-32+LastHeight, &src, 0xffffffff);
continue;
}
}
else if(i == Height-1)
{
if(j == 0)
{
src.SetRectWH(0, 32, 32, LastHeight);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width)
{
src.SetRectWH(64, 32, 32, LastHeight);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32-32+LastWidth, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width-1)
{
src.SetRectWH(32, 32, LastWidth, LastHeight);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, m_dwColor);
continue;
}
else
{
src.SetRectWH(32, 32, 32, LastHeight);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, m_dwColor);
continue;
}
}
else
{
if(j == 0)
{
src.SetRectWH(0, 32, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width)
{
src.SetRectWH(64, 32, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32-32+LastWidth, m_ptPos.y+i*32, &src, 0xffffffff);
continue;
}
else if(j == Width-1)
{
src.SetRectWH(32, 32, LastWidth, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, m_dwColor);
continue;
}
else
{
src.SetRectWH(32, 32, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+j*32, m_ptPos.y+i*32, &src, m_dwColor);
continue;
}
}
}
}
}
void CWindow::RenderExpandEx()
{
GRect src;
GRect dst;
src.SetRectWH(0, 0, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x, m_ptPos.y, &src, 0xffffffff);
src.SetRectWH(64, 0, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+m_Width-32, m_ptPos.y, &src, 0xffffffff);
src.SetRectWH(0, 64, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x, m_ptPos.y+m_Height-32, &src, 0xffffffff);
src.SetRectWH(64, 64, 32, 32);
g_pGraphics->RenderSprite(m_hTexture, m_ptPos.x+m_Width-32, m_ptPos.y+m_Height-32, &src, 0xffffffff);
src.SetRectWH(32, 0, 32, 32);
dst.SetRectWH(m_ptPos.x+32, m_ptPos.y, m_Width-32*2, 32);
g_pGraphics->RenderSprite(m_hTexture, &dst, &src, 0xffffffff);
src.SetRectWH(32, 64, 32, 32);
dst.SetRectWH(m_ptPos.x+32, m_ptPos.y+m_Height-32, m_Width-32*2, 32);
g_pGraphics->RenderSprite(m_hTexture, &dst, &src, 0xffffffff);
src.SetRectWH(0, 32, 32, 32);
dst.SetRectWH(m_ptPos.x, m_ptPos.y+32, 32, m_Height-32*2);
g_pGraphics->RenderSprite(m_hTexture, &dst, &src, 0xffffffff);
src.SetRectWH(64, 32, 32, 32);
dst.SetRectWH(m_ptPos.x+m_Width-32, m_ptPos.y+32, 32, m_Height-32*2);
g_pGraphics->RenderSprite(m_hTexture, &dst, &src, 0xffffffff);
src.SetRectWH(32, 32, 32, 32);
dst.SetRectWH(m_ptPos.x+32, m_ptPos.y+32, m_Width-32*2, m_Height-32*2);
g_pGraphics->RenderSprite(m_hTexture, &dst, &src, m_dwColor);
}
void CWindow::CreateRGN(GRect *rc)
{
int LineWidth = g_pTextureManager->GetTexture(m_hTexture)->GetWidth();
int width = rc->Width();
int height = rc->Height();
bool *pTemp = new bool[width*height];
memset(pTemp, 0, width*height);
D3DLOCKED_RECT d3dlr;
if(g_pTextureManager->LockTexture(m_hTexture, &d3dlr, rc))
{
DWORD *p = (DWORD*)d3dlr.pBits;
/*
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
{
if((*(p+i*LineWidth+j))>>24)
{
pTemp[i*width+j] = true;
}
}
}
*/
//-----------------------------------
// 注意: ASM算法假定LineWidth==width
//-----------------------------------
int count = height*width;
__asm
{
push esi
push edi
mov esi, p
mov edi, pTemp
mov ecx, count
CONTINUE:
lodsd
shr eax, 24
stosb
loop CONTINUE
pop edi
pop esi
};
g_pTextureManager->UnLockTexture(m_hTexture);
}
S_DELETE_ARRAY(m_pRgnInfo);
if(!m_ComplexDraw)
{
m_pRgnInfo = new bool[width*height];
memcpy(m_pRgnInfo, pTemp, width*height);
}
else
{
m_pRgnInfo = new bool[m_Width*m_Height];
for(int i=0; i<m_Height; i++)
{
for(int j=0; j<m_Width; j++)
{
if(i<32)
{
if(j<32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[i*LineWidth+j];
}
else if(j<m_Width-32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[i*LineWidth+32];
}
else
{
m_pRgnInfo[i*m_Width+j] = pTemp[i*LineWidth+j-(m_Width-width)];
}
}
else if(i<m_Height-32)
{
if(j<32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[32*LineWidth+j];
}
else if(j<m_Width-32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[32*LineWidth+32];
}
else
{
m_pRgnInfo[i*m_Width+j] = pTemp[32*LineWidth+j-(m_Width-width)];
}
}
else
{
if(j<32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[(i-(m_Height-height))*LineWidth+j];
}
else if(j<m_Width-32)
{
m_pRgnInfo[i*m_Width+j] = pTemp[(i-(m_Height-height))*LineWidth+32];
}
else
{
m_pRgnInfo[i*m_Width+j] = pTemp[(i-(m_Height-height))*LineWidth+j-(m_Width-width)];
}
}
}
}
}
S_DELETE_ARRAY(pTemp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -