reman3/Rayman_X/cpa/tempgrp/ITF/frmgest.cpp

869 lines
24 KiB
C++

#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/FRMGest.hpp"
#include "itf/CPAProj.hpp"
#include "acp_driver.h"
// Global
FRMGest g_oFrameGest;
CList<CWnd *, CWnd *> g_oHideList;
//------------------------------------------------------------------------
BEGIN_MESSAGE_MAP(BaseFrame, CFrameWnd)
ON_WM_ACTIVATE()
ON_WM_SYSCOMMAND()
//CPA2 Gabi Dumitrascu 98/07/13
ON_WM_NCMOUSEMOVE()
ON_WM_NCHITTEST()
//End CPA2 Gabi Dumitrascu 98/07/13
END_MESSAGE_MAP()
//------------------------------------------------------------------------
BOOL bWasZoomed = FALSE;
void BaseFrame::mfnv_UpdateTitle(char *msg)
{
CString act, nouv = msg;
char actc[255], *p;
g_oBaseFrame.GetWindowText(act);
strcpy(actc, (char *) (LPCSTR) act);
p = strchr(actc, ']') + 1;
*p = '\0';
act = actc;
act += " " + nouv;
g_oBaseFrame.SetWindowText(act);
}
BOOL BaseFrame::PreTranslateMessage( MSG* pMsg )
{
BOOL bRes;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_KEYUP))
{
if(pMsg->message == WM_KEYDOWN)
bRes = M_GetMainApp()->fn_bTreatAppKeyboard((UINT) pMsg->wParam | 0x40000000);
else
bRes = M_GetMainApp()->fn_bTreatAppKeyboard((UINT) pMsg->wParam | 0xC0000000);
return bRes;
}
else
return M_GetMainWnd()->PreTranslateMessage(pMsg);
}
void BaseFrame::OnActivate(UINT State, CWnd *pwnd, BOOL bMini)
{
BOOL bActive;
static BOOL prevent = FALSE;
if(prevent)
return;
prevent = TRUE;
bActive = State != WA_INACTIVE;
if(IsIconic()&&bActive)
{
if(bWasZoomed)
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
else
SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
if(M_GetMainWnd())
M_GetMainWnd()->OnActivateApp(bActive, NULL);
if(bActive == FALSE)
{
if((pwnd==NULL)||(pwnd==M_GetMainWnd()))
GetDesktopWindow()->SetFocus();
else
pwnd->SetFocus();
}
// CFrameWnd::OnActivate(State, pwnd, bMini);
// if(bActive)
// SetFocus();
prevent = FALSE;
}
void BaseFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
static BOOL prevent = FALSE;
if(prevent)
return;
prevent = TRUE;
UINT uiTrueNID = nID & 0xFFFFFFF0;
if(uiTrueNID == SC_CLOSE)
TerminateProcess(GetCurrentProcess(),0);
if(uiTrueNID == SC_MINIMIZE)
{
bWasZoomed = IsZoomed();
OnActivate(WA_INACTIVE, NULL, FALSE);
}
/* if(!M_bEditorsActive())
{
UINT uiTrueNID = nID & 0xFFFFFFF0;
if((uiTrueNID == SC_MAXIMIZE) || (uiTrueNID == SC_RESTORE))
{
M_GetMainWnd()->OnActivateApp(TRUE, NULL);
// OnActivate(TRUE, NULL);
}
else if(uiTrueNID == SC_MINIMIZE)
{
M_GetMainWnd()->OnActivateApp(FALSE, NULL);
//OnActivate(FALSE, NULL);
}
}*/
CFrameWnd::OnSysCommand(nID, lParam);
if(!IsWindowVisible())
ShowWindow(TRUE);
prevent = FALSE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : OnNcMouseMove
// Date : 98/07/13
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description :
// Author : Gabi Dumitrascu - CPA
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void BaseFrame::OnNcMouseMove (UINT nHitTest, CPoint point)
{
DEV_ViewPort *pViewPort = M_GetMainDevice2 ()->GetDevice (0)->GetViewPort ();
if (pViewPort)
{
POINTS pts;
pts.x = (short)point.x;
pts.y = (short)point.y;
pViewPort->SendMessage (WM_NCMOUSEMOVE, nHitTest, (LPARAM)&pts);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : OnNcHitTest
// Date : 98/07/13
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description :
// Author : Gabi Dumitrascu - CPA
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
UINT BaseFrame::OnNcHitTest (CPoint point)
{
DEV_ViewPort *pViewPort = M_GetMainDevice2 ()->GetDevice (0)->GetViewPort ();
if (pViewPort)
{
POINTS pts;
pts.x = (short)point.x;
pts.y = (short)point.y;
pViewPort->SendMessage (WM_NCHITTEST, (LPARAM)&pts);
}
return CFrameWnd::OnNcHitTest (point);
}
//------------------------------------------------------------------------
BaseFrame g_oBaseFrame;
// Constructor / Destructor
//------------------------------------------------------------------------
FRMGest::FRMGest(void)
{
int x, y, iAct = 1;
memset(ma_p_oWinArray, 0, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
memset(ma_p_oOccupyArray, 0, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
mp_oFirstWindow = NULL;
m_iCanRefresh = 0;
m_iBeginSize = 0;
// Default order to treat windows
for(x = 1; x <= FRM_C_MaxCol; x++)
for(y = 1; y <= FRM_C_MaxRow; y++)
ma_iOrder[x][y] = iAct++;
}
FRMGest::~FRMGest(void)
{
m_lstFrames.RemoveAll();
}
// Add one frame
//------------------------------------------------------------------------
void FRMGest::mfn_vAddOneFrame(FRMBase *_p_oFrm)
{
m_lstFrames.AddTail(_p_oFrm);
}
// Compute position of window when activated
// _p_oFrm : Frame that appears
// _p_oLast : Last frame at the same position
//------------------------------------------------------------------------
void FRMGest::mfn_vComputeActivatePos(FRMBase *_p_oFrm)
{
FRMBase *p_stOther;
if(_p_oFrm == NULL)
return;
if(_p_oFrm->m_iInitWidth)
_p_oFrm->mfn_vComputeWidthWindow(_p_oFrm->m_iInitWidth);
//
// We compute width depending of other windows
//
else
{
p_stOther = fn_vSearchHorizWindow(_p_oFrm, -1);
if(p_stOther)
_p_oFrm->m_oCurPos.left = p_stOther->m_oCurPos.right;
p_stOther = fn_vSearchHorizWindow(_p_oFrm, 1);
if(p_stOther)
_p_oFrm->m_oCurPos.right = p_stOther->m_oCurPos.left;
}
if(_p_oFrm->m_iInitHeight)
_p_oFrm->mfn_vComputeHeightWindow(_p_oFrm->m_iInitHeight);
//
// We compute height depending of other windows
//
else
{
p_stOther = fn_vSearchVertWindow(_p_oFrm, -1);
if(p_stOther)
_p_oFrm->m_oCurPos.top = p_stOther->m_oCurPos.bottom;
p_stOther = fn_vSearchVertWindow(_p_oFrm, 1);
if(p_stOther)
_p_oFrm->m_oCurPos.bottom = p_stOther->m_oCurPos.top;
}
}
// Expand position of window
//------------------------------------------------------------------------
void FRMGest::mfn_vExpandFrame(int x, int y)
{
int xt, yt;
BOOL bRes;
FRMBase *p_oFrm = ma_p_oOccupyArray[x][y];
// To the left
if(x != 1)
{
yt = y;
bRes = TRUE;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x-1][yt++])
bRes = FALSE;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x-1][yt--])
bRes = FALSE;
if(bRes)
{
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x-1][yt++] = p_oFrm;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x-1][yt--] = p_oFrm;
mfn_vExpandFrame(x-1, y);
}
}
// To the right
if(x != FRM_C_MaxCol)
{
yt = y;
bRes = TRUE;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x+1][yt++])
bRes = FALSE;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x+1][yt--])
bRes = FALSE;
if(bRes)
{
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x+1][yt++] = p_oFrm;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x+1][yt--] = p_oFrm;
mfn_vExpandFrame(x+1, y);
}
}
// To the top
if(y != 1)
{
xt = x;
bRes = TRUE;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt++][y-1])
bRes = FALSE;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt--][y-1])
bRes = FALSE;
if(bRes)
{
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt++][y-1] = p_oFrm;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt--][y-1] = p_oFrm;
mfn_vExpandFrame(x, y-1);
}
}
// To the bottom
if(y != FRM_C_MaxRow)
{
xt = x;
bRes = TRUE;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt++][y+1])
bRes = FALSE;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt--][y+1])
bRes = FALSE;
if(bRes)
{
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt++][y+1] = p_oFrm;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt--][y+1] = p_oFrm;
mfn_vExpandFrame(x, y+1);
}
}
}
void FRMGest::mfn_vSearchNextOrder(int iAct, int *p_iX, int *p_iY)
{
int x, y;
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
if(ma_iOrder[x][y] == (iAct+1))
{
*p_iX = x;
*p_iY = y;
return;
}
}
}
}
FRMBase *FRMGest::fn_vSearchHorizWindow(FRMBase *_p_oFrm, int dx)
{
int x = _p_oFrm->m_iCol + dx;
while(ma_p_oOccupyArray[x][_p_oFrm->m_iRow] == _p_oFrm)
x += dx;
return ma_p_oOccupyArray[x][_p_oFrm->m_iRow];
}
FRMBase *FRMGest::fn_vSearchVertWindow(FRMBase *_p_oFrm, int dy)
{
int y = _p_oFrm->m_iRow + dy;
while(ma_p_oOccupyArray[_p_oFrm->m_iCol][y] == _p_oFrm)
y += dy;
return ma_p_oOccupyArray[_p_oFrm->m_iCol][y];
}
// Try to expand all windows in each directions
//---------------------------------------------
void FRMGest::mfn_vExpandAll(void)
{
int i, x, y, iOrder = 0;
FRMBase *p_oTest;
CSize sizeFrame(GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME));
CSize sizeScreen(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
CSize sizeDlgFrame(GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME));
sizeScreen.cx -= 2*sizeDlgFrame.cx;
sizeScreen.cy -= (sizeDlgFrame.cy+GetSystemMetrics(SM_CYCAPTION));
memcpy(ma_p_oOccupyArray, ma_p_oWinArray, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
for(i = 0; i <= FRM_C_MaxCol * FRM_C_MaxRow; i++)
{
mfn_vSearchNextOrder(iOrder, &x, &y);
if(ma_p_oWinArray[x][y])
mfn_vExpandFrame(x, y);
iOrder++;
}
// To update locking
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
p_oTest = ma_p_oWinArray[x][y];
if(p_oTest)
p_oTest->m_cLock = 0;
}
}
// Some well known positions
// Update locking too
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
p_oTest = ma_p_oOccupyArray[x][y];
ASSERT(p_oTest);
if(x == 1)
{
p_oTest->m_oCurPos.left = 0;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveLeft;
}
if(y == 1)
{
p_oTest->m_oCurPos.top = 0;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveTop;
}
if(x == FRM_C_MaxCol)
{
p_oTest->m_oCurPos.right = sizeScreen.cx - 2*sizeFrame.cx;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveRight;
}
if(y == FRM_C_MaxRow)
{
p_oTest->m_oCurPos.bottom = sizeScreen.cy - 2*sizeFrame.cy;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveBottom;
}
}
}
}
// Update intial with and height of window
//------------------------------------------------------------------------
void FRMGest::mfn_vUpdateWidthHeight(FRMBase *_p_oFrm)
{
if(_p_oFrm->m_bKeepPos)
{
if(_p_oFrm->m_iInitWidth)
_p_oFrm->m_iInitWidth = _p_oFrm->m_oCurPos.right - _p_oFrm->m_oCurPos.left;
if(_p_oFrm->m_iInitHeight)
_p_oFrm->m_iInitHeight = _p_oFrm->m_oCurPos.bottom - _p_oFrm->m_oCurPos.top;
}
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Activate window
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void FRMGest::mfn_vActivateWindow(FRMBase *_p_oFrm)
{
FRMBase *p_oLast = ma_p_oWinArray[_p_oFrm->m_iCol][_p_oFrm->m_iRow];
int x, y;
BOOL bFS1,bFS2;
DEV_MultiDevice *OldMulti=NULL, *NewMulti=NULL;
bFS1 = TRUE;
bFS2 = TRUE;
_p_oFrm->SetParent(&g_oBaseFrame);
if(_p_oFrm->IsIconic())
_p_oFrm->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
_p_oFrm->EnableWindow(TRUE);
mfn_vUpdateLastPos();
_p_oFrm->GetWindowRect(&_p_oFrm->m_oLastPos);
g_oBaseFrame.ScreenToClient(&_p_oFrm->m_oLastPos);
_p_oFrm->GetWindowRect(&_p_oFrm->m_oCurPos);
g_oBaseFrame.ScreenToClient(&_p_oFrm->m_oCurPos);
//
// Activate new window
//
//_p_oFrm->SetParent(&g_oBaseFrame);
x = _p_oFrm->m_iCol;
y = _p_oFrm->m_iRow;
if (x == 2 && y == 2 && p_oLast && _p_oFrm)
{
OldMulti = ((FRMBaseMenu*)p_oLast)->GetMultiDevice();
NewMulti = ((FRMBaseMenu*)_p_oFrm)->GetMultiDevice();
if (OldMulti && NewMulti)
{
// check fullscreen
bFS2 = NewMulti->GetDevice(0)->IsFullScreen();
bFS1 = OldMulti->GetDevice(0)->IsFullScreen();
}
}
ma_p_oWinArray[x][y] = _p_oFrm;
_p_oFrm->fn_vOnActivate();
if(!M_bEditorsActive())
return;
//
// Expand position of window depending of neighbours
// - ma_p_oOccupyArray is initialised
// - Frames are locked depending of their position
//
mfn_vExpandAll();
//
// Compute position of window
//
mfn_vComputeActivatePos(_p_oFrm);
//
// Show window if it's enabled
//
if(m_iCanRefresh >= 0)
{
_p_oFrm->m_bAlreadySize = TRUE;
_p_oFrm->ShowWindow(TRUE);
_p_oFrm->m_bAlreadySize = FALSE;
}
//
// Recompute size of other windows for each border
// (only if necessary)
//
if(_p_oFrm->m_iInitWidth)
{
if(fn_vSearchHorizWindow(_p_oFrm, -1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveLeft);
if(fn_vSearchHorizWindow(_p_oFrm, 1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveRight);
}
if(_p_oFrm->m_iInitHeight)
{
if(fn_vSearchVertWindow(_p_oFrm, -1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveTop);
if(fn_vSearchVertWindow(_p_oFrm, 1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveBottom);
}
// Window has been one time activated
if(m_iCanRefresh >= 0)
mfn_vRefreshWindows(FALSE);
//
// Hide the window the window at this place
//
#ifdef USE_DIRECTX
if(NewMulti) NewMulti->GetDevice(0)->SetMainWindowForRender();//chbani
#else
if (bFS1 != bFS2)
{
OldMulti->GetDevice(0)->SwapFullScreen();
NewMulti->GetDevice(0)->SwapFullScreen();
}
#endif
if(p_oLast)
{
mfn_vUpdateWidthHeight(p_oLast);
p_oLast->m_bAlreadySize = TRUE;
// if(p_oLast != M_GetMainWnd())
p_oLast->ShowWindow(FALSE);
// else
// p_oLast->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
p_oLast->m_bAlreadySize = FALSE;
}
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Disactivate window
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void FRMGest::mfn_vDisactivateWindow(FRMBase *_p_oFrm)
{
mfn_vUpdateWidthHeight(_p_oFrm);
_p_oFrm->m_bAlreadySize = TRUE;
if(_p_oFrm != M_GetMainWnd())
{
if((m_iCanRefresh >= 0) || (m_iCanRefresh <= -4500))
_p_oFrm->ShowWindow(FALSE);
else
g_oHideList.AddTail((CWnd *) _p_oFrm);
}
_p_oFrm->m_bAlreadySize = FALSE;
ma_p_oWinArray[_p_oFrm->m_iCol][_p_oFrm->m_iRow] = NULL;
mfn_vExpandAll();
if(m_iCanRefresh >= 0)
mfn_vRefreshWindows(FALSE);
}
//************************************************************************
//************************************************************************
// To recompute the size of a window.
//------------------------------------------------------------------------
void FRMGest::mfn_vRecomputeSizeOpposite(FRMBase *_p_oFrm, FRMBase *_p_oRef, char cMove)
{
if(_p_oFrm == NULL)
return;
if(_p_oFrm == _p_oRef)
return;
switch(cMove)
{
case FRM_C_MoveTop:
_p_oFrm->m_oCurPos.bottom = _p_oRef->m_oCurPos.top;
break;
case FRM_C_MoveBottom:
_p_oFrm->m_oCurPos.top = _p_oRef->m_oCurPos.bottom;
break;
case FRM_C_MoveLeft:
_p_oFrm->m_oCurPos.right = _p_oRef->m_oCurPos.left;
break;
case FRM_C_MoveRight:
_p_oFrm->m_oCurPos.left = _p_oRef->m_oCurPos.right;
break;
}
}
//------------------------------------------------------------------------
void FRMGest::mfn_vRecomputeSizeSame(FRMBase *_p_oFrm, FRMBase *_p_oRef, char cMove)
{
if(_p_oFrm == NULL)
return;
if(_p_oFrm == _p_oRef)
return;
switch(cMove)
{
case FRM_C_MoveTop:
_p_oFrm->m_oCurPos.top = _p_oRef->m_oCurPos.top;
break;
case FRM_C_MoveBottom:
_p_oFrm->m_oCurPos.bottom = _p_oRef->m_oCurPos.bottom;
break;
case FRM_C_MoveLeft:
_p_oFrm->m_oCurPos.left = _p_oRef->m_oCurPos.left;
break;
case FRM_C_MoveRight:
_p_oFrm->m_oCurPos.right = _p_oRef->m_oCurPos.right;
break;
}
}
// When a window has moved
//------------------------------------------------------------------------
#define M_vFRMTestSizeWin(x, y, name1, name2)\
if\
(\
(ma_p_oOccupyArray[x][y])\
&& (_p_oFrm->name1.cLinkSame & cMove)\
&& (!(ma_p_oOccupyArray[x][y]->m_cLock & cMove))\
&& (ma_p_oOccupyArray[x][y]->name2.cLinkSame & cMove)\
)\
{\
mfn_vRecomputeSizeSame(ma_p_oOccupyArray[x][y], _p_oFrm, cMove);\
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x][y], cMove);\
}
// When a window has been moved
//------------------------------------------------------------------------
void FRMGest::mfn_vAWindowHasMoved(FRMBase *_p_oFrm, char cMove)
{
int x, y, xt, yt;
if(_p_oFrm == NULL)
return;
if(_p_oFrm->m_bAlreadySize)
return;
_p_oFrm->m_bAlreadySize = TRUE;
//
// Normal resize due to position in array
//
x = _p_oFrm->m_iCol;
y = _p_oFrm->m_iRow;
switch(cMove)
{
case FRM_C_MoveTop:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[xt][y-1], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[xt][y-1], FRM_C_MoveBottom);
}
}
break;
case FRM_C_MoveBottom:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[xt][y+1], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[xt][y+1], FRM_C_MoveTop);
}
}
break;
case FRM_C_MoveLeft:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[x-1][yt], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x-1][yt], FRM_C_MoveRight);
}
}
break;
case FRM_C_MoveRight:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[x+1][yt], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x+1][yt], FRM_C_MoveLeft);
}
}
break;
}
//
// Size due to links
//
switch(cMove)
{
case FRM_C_MoveTop:
case FRM_C_MoveBottom:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
M_vFRMTestSizeWin(x-1, yt, m_stWinLeft, m_stWinRight);
M_vFRMTestSizeWin(x+1, yt, m_stWinRight, m_stWinLeft);
}
}
break;
case FRM_C_MoveLeft:
case FRM_C_MoveRight:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
M_vFRMTestSizeWin(xt, y-1, m_stWinTop, m_stWinBottom);
M_vFRMTestSizeWin(xt, y+1, m_stWinBottom, m_stWinTop);
}
}
break;
}
_p_oFrm->m_bAlreadySize = FALSE;
}
// Refresh all windows
//------------------------------------------------------------------------
void FRMGest::mfn_vRefreshWindows(BOOL _bForce)
{
int x, y;
if(m_iCanRefresh >= 0)
{
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
if(ma_p_oWinArray[x][y])
{
if
(
(!ma_p_oWinArray[x][y]->m_oCurPos.EqualRect(ma_p_oWinArray[x][y]->m_oLastPos))
|| (ma_p_oWinArray[x][y]->m_oLastPos.IsRectEmpty())
|| (_bForce)
)
{
ma_p_oWinArray[x][y]->MoveWindow(ma_p_oWinArray[x][y]->m_oCurPos);
if(!(ma_p_oWinArray[x][y]->GetStyle() & WS_VISIBLE))
{
ma_p_oWinArray[x][y]->m_bAlreadySize = TRUE;
ma_p_oWinArray[x][y]->ShowWindow(TRUE);
ma_p_oWinArray[x][y]->m_bAlreadySize = FALSE;
}
}
}
}
}
/*
* We hide all the eventual windows
*/
POSITION pos, lpos;
pos = g_oHideList.GetHeadPosition();
while(pos)
{
CWnd *pWnd = g_oHideList.GetAt(pos);
lpos = pos;
g_oHideList.GetNext(pos);
g_oHideList.RemoveAt(lpos);
pWnd->ShowWindow(SW_HIDE);
}
}
}
// Set/Reset refresh mode
//------------------------------------------------------------------------
void FRMGest::mfn_vSetRefresh(BOOL _bVal)
{
if(_bVal)
{
if(m_iCanRefresh < 0)
m_iCanRefresh++;
}
else
m_iCanRefresh--;
if(m_iCanRefresh == 0)
mfn_vRefreshWindows(TRUE);
}
// Update m_oLastPos of each windows
//------------------------------------------------------------------------
void FRMGest::mfn_vUpdateLastPos(void)
{
int x, y;
for(x = 1; x <= FRM_C_MaxCol; x++)
for(y = 1; y <= FRM_C_MaxRow; y++)
if(ma_p_oWinArray[x][y])
{
ma_p_oWinArray[x][y]->GetWindowRect(ma_p_oWinArray[x][y]->m_oLastPos);
g_oBaseFrame.ScreenToClient(&ma_p_oWinArray[x][y]->m_oLastPos);
}
}
#endif // ACTIVE_EDITOR