[ Nexacro.Component -  Object Position2 ]

 

 

 

// L = left, T =top, R = right, B = bottom, W = width, H = height

var _L = 0, _T = 1, _R = 2, _B = 3, _W = 4, _H = 5;

/*******************************************************************************
★ 설명
Modal Dialog실행 함수
★ parameter
NewChildFrame()과 동일
★ return
- 성공 = variant ( Dialog창에서 close()에 의해 Return된 값 )
- 실패 = null
******************************************************************************/

function Dialog(sID, sURL, sArg, nLeft, nTop, nWidth, nHeight, sStyle)

{

var rtn=null;

var newChild;

var MyFrame = this.getOwnerFrame();

 

newChild = _NewChildFrame(sID, sURL, sArg, nLeft, nTop, nWidth, nHeight, sStyle);

rtn = newChild.showModal(MyFrame, sArg);

this.removeChild(newChild.name);

newChild.destroy();

newChild = null;

return rtn;

}

 

/*******************************************************************************
★ 설명
Modaless Dialog실행 함수
★ parameter
NewChildFrame()과 동일
★ return
- 성공 = true ( 정상작동여부 )
- 실패 = false
******************************************************************************/

function Open(sID, sURL, sArg, nLeft, nTop, nWidth, nHeight, sStyle)

{

var rtn;

var newChild;

var MyFrame = this.getOwnerFrame();

 

newChild = _NewChildFrame(sID, sURL, sArg, nLeft, nTop, nWidth, nHeight, sStyle);

 

return newChild.showModeless(MyFrame, sArg);

}

 

/*******************************************************************************
★ 설명
Grid Header Click하면 Sorting하는 함수
★ parameter
1. obj:Grid : Grid Object ( 예 : Grid00 )
2. e:GridClickEventInfo : Click Event Object ( Grid Onclick Envent의 Argument e )
3. ASC_MARK : Ascending Mark (옵션 : Default = "▼")( 예 : "▼" )
4. DESC_MARK : Descending Mark (옵션 : Default = "▲")( 예 : "▲" )
★ return
- 성공 = true
- 실패 = false
******************************************************************************/

function GridSort(obj:Grid, e:GridClickEventInfo, ASC_MARK, DESC_MARK)

{

// 컬럼의 정렬방식을 'head'의 text에 "↑,↓"여부로 판단.

// 이미지로 대체 가능.

var bindDs = eval(obj.binddataset);

var i, cell_cnt;

 

if (bindDs.rowcount == 0) return false;

if( gf_isNull(ASC_MARK) ) ASC_MARK = "▼";

if( gf_isNull(DESC_MARK) ) DESC_MARK = "▲";

 

cell_cnt = obj.getCellCount("head");

var BodyColId = (obj.getCellProperty("body", e.col,"text")).toString().split(":"); // e.col : 바인드된 컬럼.

 

for( i = 0 ; i < cell_cnt ; i++ )

{

if(obj.getCellText(-1, i)=="undefined")

continue;

 

var strHeadText = obj.getCellText(-1, i);

 

if(i==e.cell)

{

if(strHeadText.substr(strHeadText.length-1) == ASC_MARK)

{

obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1)+DESC_MARK);

bindDs.keystring = "S:-"+BodyColId[1];

}

else if (strHeadText.substr(strHeadText.length-1) == DESC_MARK)

{

obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1)+ASC_MARK);

bindDs.keystring = "S:+"+BodyColId[1];

}

else

{

obj.setCellProperty( "head", i, "text", strHeadText+ASC_MARK);

bindDs.keystring = "S:+"+BodyColId[1];

}

}

else // 정렬표시 삭제

{

if (strHeadText.substr(strHeadText.length-1) == ASC_MARK || strHeadText.substr(strHeadText.length-1) == DESC_MARK)

{

obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1));

}

}

}

return true;

}

 

/*********************************************************************************************
** 나중에?????
** function name : gf_exportExcel()
** function description : Grid의 내용을 Excel로 Export 한다.
** argument : CUCO_ICPH 고객유입경로
** SHORTCUT 단축키
** CONTENTS 상담내용
** return Type : None
** return description :
*********************************************************************************************/

function GridExportExcel(objGrid, strTitle, strCondition, strSheetName)

{

/*

var objExport = new ExportHCardObject();

objExport.exporttype = ExportHCardTypes.EXCEL;

objExport.activepagename = strSheetName;

 

objExport.addExportItem(ExportHCardItemTypes.GRID, objGrid, "A5", "allband","allrecord","suppress","allstyle", "맑은 고딕,9", "맑은 고딕,11,bold",

strTitle, //title

strCondition, //condition

"A4", //conditionposition

true //removefirstcol

);

 

objExport.export();

objExport = null;

*/

}

 

/*******************************************************************************
★ 설명
Object의 type을 문자열로 얻어온다.
★ parameter
1. oObj : type을 얻어올 Object
(예 : mainframe, this.getOwnerFrame(), this, button,...)
★ return
- 성공 = Object의 type문자열(예 : "MainFrame", "ChildFrame", "Form", "Button",...)
- 실패 = null ( oObj가 null인 경우 )
******************************************************************************/

function GetObjType(oObj)

{

var sType;

 

if( gf_isNull(oObj) ) return null;

 

sType = oObj.toString().valueOf().substr(1,6);

if( sType.toLowerCase() == "object" )

return Mid(oObj.toString().valueOf(), " ", "]");

 

return null;

}

 

/*******************************************************************************
★ 설명
모든 Collection이 type을 이용하여 얻어오는 것이 없으므로 type을 이용하여
Collection을 얻어오는 함수임
단, type은 Object에 의해 나오는 Value값을 의미한다.
예를들어, gf_message(Button0)="[object Button]" 에서 "Button"을 Type이라 한다.
★ parameter
1. oCollection : Collection Object(예 : this.components, mainframe.all, ...)
2. sType : Type문자열 (예 : "ChildFrame", "Button")
★ return
- 성공 = Collection List중 sType에 적합한 Object만 Array로 Return한다.
- 실패 =
******************************************************************************/

function GetObjTypeCollection(oCollection, sType)

{

var sType, i, arr=new Array(), arr_no=0, sColType;

 

if( gf_isNull(oCollection) ) return arr;

if( gf_isNull(sType) )

{

arr = oCollection;

return arr;

}

for( i = 0 ; i < oCollection.length ; i++ )

{

sColType = GetObjType(oCollection[i]);

if( sColType == null ) continue;

if( sType.toLowerCase() == sColType.toLowerCase() )

{

arr[arr_no] = oCollection[i];

arr_no++;

}

}

 

return arr;

}

 

/*******************************************************************************
★ 설명
oObj가 Popup창(showModaless()에 의해 뜬창)인지 확인한다.
단, gf_showModal()에 의해 뜬 창은 해당되지 않는다.
★ parameter
1. oObj : Popup창 여부를 확인할 Object
★ return
- oObj가 Popup창인 경우 = true
- oObj가 Popup창이 아닌 경우 = false
★ 주의사항
단, gf_showModal()에 의해 뜬 창은 해당되지 않는다.
******************************************************************************/

function IsObjPopup(oObj)

{

if( gf_isNull(oObj) ) return false;

 

if( application.popupframes(oObj.name) == null )

return false;

else

return true;

}

 

/*******************************************************************************
★ 설명
oObj에 해당하는 좌표계가 Screen좌표계인지를 체크한다.
★ parameter
1. oObj : 체크할 Object(예 : mainframe, this.getOwnerFrame(), this, button,...)
★ return
- oObj가 Screenr기준 좌표계인 경우 = true
- oObj가 Screenr기준 좌표계가 아닌경우 = false
******************************************************************************/

function IsObjScreenPos(oObj)

{

var sType;

 

sType = GetObjType(oObj);

if( gf_isNull(sType) ) return false;

 

if( sType.toLowerCase() == "mainframe" )

return true;

if( sType.toLowerCase() == "childframe" )

{

if( IsObjPopup(oObj) == true )

return true;

}

 

return false;

}

 

/*******************************************************************************
★ 설명
oObj에 해당하는 Object가 Position을 갖지 않는 Object인지 판단한다.
★ parameter
1. oObj : 체크할 Object(예 : application, mainframe, this.getOwnerFrame(), this, button,...)
★ return
- oObj가 position property가 없는 경우 = true
- oObj가 position property가 있는 경우 = false
******************************************************************************/

function IsObjNoPos(oObj)

{

var sType;

 

sType = GetObjType(oObj);

if( gf_isNull(sType) ) return false;

 

if( sType.toLowerCase() == "application" )

return true;

 

return false;

}

 

/*******************************************************************************
★ 설명
system의 cursorx, cursory를 해당 Object의 영역좌표에 맞는 값으로 변경한다.
★ parameter
1. oObj : Object
(예 : mainframe, this.getOwnerFrame(), this, button,...)
★ return
- 성공 = oObj좌표계에 해당하는 Cursor position 문자열 ( 예 : "20 20" )
- 실패 = null
★ 주의사항
단, event에서 얻어지는 cursor좌표는 아니다.
******************************************************************************/

function GetObjCursorPos(oObj)

{

var sObjPos;

var cursorx, cursory;

var sCursorPos;

 

if( gf_isNull(oObj) ) return null;

if( IsObjNoPos(oObj) ) return null;

 

cursorx = system.cursorx;

cursory = system.cursory;

 

if( IsObjScreenPos(oObj) == true )

sCursorPos = cursorx + " " + cursory;

else

sCursorPos = (system.screenToClientX(oObj, cursorx)+oObj.position.left) + " " + (system.screenToClientY(oObj, cursory)+oObj.position.top);

 

return sCursorPos;

}

 

/*******************************************************************************
★ 설명
sAreaPos의 Center위치에 맞는 sObjPos의 position을 구한다.
★ parameter
1. sAreaPos : 영역에 해당하는 Position 문자열
(예 : "10 10 50 50", this.position,...)
2. sObjPos : Center에 위치할 대상 Object의 Position
(옵션 : Default="" ==> Object의 Width=0, Height=0인 경우에 해당함)
(예 : "", "10 10 30 30", this.position,...)
★ return
- 성공 = sAreaPos의 좌표계에 해당하는 Center position 문자열
( 예 : sObjPos=""인 경우 ==> "30 30",
sObjPos="10 10 20 20"인 경우 ==> "20 20 40 40" )
- 실패 = null
******************************************************************************/

function GetCenterPos(sAreaPos, sObjPos)

{

var vAreaPos = new Array();

var vObjPos = new Array();

var vCenterPos = new Array();

 

vAreaPos = _PosStr2Arr(sAreaPos);

if( vAreaPos == null ) return null;

vObjPos = _PosStr2Arr(sObjPos);

if( vObjPos == null )

{

vCenterPos[_L] = vAreaPos[_L] + Math.round(vAreaPos[_W]/2);

vCenterPos[_T] = vAreaPos[_T] + Math.round(vAreaPos[_H]/2);

}

else

{

vCenterPos[_L] = vAreaPos[_L] + Math.round(vAreaPos[_W]/2) - Math.round(vObjPos[_W]/2);

vCenterPos[_T] = vAreaPos[_T] + Math.round(vAreaPos[_H]/2) - Math.round(vObjPos[_H]/2);

if( vObjPos.length > 2 )

{

vCenterPos[_R] = vCenterPos[_L] + vObjPos[_W];

vCenterPos[_B] = vCenterPos[_T] + vObjPos[_H];

}

}

 

return _PosArr2Str(vCenterPos);

}

 

/*******************************************************************************
★ 설명
nLeft, nTop좌표로
sPosition의 Width에 대해 n Offset Width만큼,
sPosition의 Height에 대해 n Offset Height만큼
이동한 좌표 Position문자열을 획득한다.
★ parameter
1. sPosition : position 문자열 (예 : "absolute 10 10 20 20" = object.position )
   단, "absolute"는 생략 가능하다.
2. nLeft : 이동할 Left 값 ( 예 : 10 또는 -10 )
3. nOffsetTop : 이동할 Top 값 ( 예 : 10 또는 -10 )
4. nOffsetWidth : 이동할 Offset Width값 ( 예 : 10 또는 -10 )
   (옵션 : Default = 0, 즉 이동하지 않는다)
5. nOffsetHeight : 이동할 Offset Height값 ( 예 : 10 또는 -10 )
(옵션 : Default = 0, 즉 이동하지 않는다)

★ return
- 성공 = 이동될 Position문자열 ( 예 : "absolute 20 20 30 30" 또는 "absolute 0 0 10 10" )
단, sPosition이 2개만 지정된 경우 offsetWidth, nOffsetHeight에 어떤값을 지정하면
이 경우는 Widht=0, Height=0와 동일하므로 4개로 바꾸어 Return한다.
( 예 : GetMovePos("10 10", 20, 20) = "20 20 20 20" )
- 실패 = null ( sPosition이 적합한 값이 아닌 경우 )
★ 목적
XPlatform은 Width, Height가 아닌 Right, Bottom을 적용하기 때문에 헷갈리는 면이 있다.
또한, object를 이동시키는 함수는 있지만 이동될 좌표만 구하는 함수가 없기 때문에
이 함수를 만들었다.
******************************************************************************/

function GetMovePos(sPosition, nLeft, nTop, nOffsetWidth, nOffsetHeight)

{

var sType;

var aPosition = new Array();

var aRetPosition = new Array();

 

aPosition = _PosStr2Arr(sPosition);

if( aPosition == null ) return null;

if( gf_isNull(nLeft) ) return null;

if( gf_isNull(nTop) ) return null;

 

aRetPosition[_L] = nLeft;

aRetPosition[_T] = nTop;

 

if( aPosition.length <= 2 )

{

if( gf_isNull(nOffsetWidth) == true && gf_isNull(nOffsetHeight) == true )

return _PosArr2Str(aRetPosition);

else

{

aPosition[_W] = 0;

aPosition[_H] = 0;

}

}

if( gf_isNull(nOffsetWidth) )

nOffsetWidth = 0;

if( gf_isNull(nOffsetHeight) )

nOffsetHeight = 0;

 

aRetPosition[_R] = aRetPosition[_L] + (aPosition[_W] + nOffsetWidth);

aRetPosition[_B] = aRetPosition[_T] + (aPosition[_H] + nOffsetHeight);

return _PosArr2Str(aRetPosition);

}

 

/*******************************************************************************
★ 설명
sPosition대비
Left좌표에 대해 nOffsetLeft만큼, Top좌표에 대해 nOffsetTop만큼,
Width에 대해 n Offset Width만큼, Height에 대해 n Offset Height만큼
이동한 좌표 Position문자열을 획득한다.
★ parameter
1. sPosition : position 문자열 (예 : "absolute 10 10 20 20" = object.position )
단, "absolute"는 생략 가능하다.
2. nLeft : sPosition대비 이동할 Left Offset값 ( 예 : 10 또는 -10 )
3. nOffsetTop : sPosition대비 이동할 Left Offset값 ( 예 : 10 또는 -10 )
4. nOffsetWidth : sPosition대비 이동할 Width Offset 값 ( 예 : 10 또는 -10 )
(옵션 : Default = 0, 즉 이동하지 않는다)
5. nOffsetHeight : sPosition대비 이동할 Height Offset 값 ( 예 : 10 또는 -10 )
(옵션 : Default = 0, 즉 이동하지 않는다)
★ return
- 성공 = 이동될 Position문자열 ( 예 : "absolute 20 20 30 30" 또는 "absolute 0 0 10 10" )
단, sPosition이 2개만 지정된 경우 offsetWidth, nOffsetHeight에 어떤값을 지정하면
이 경우는 Widht=0, Height=0와 동일하므로 4개로 바꾸어 Return한다.
( 예 : GetMovePos("10 10", 20, 20) = "20 20 20 20" )
- 실패 = null ( sPosition이 적합한 값이 아닌 경우 )
******************************************************************************/

function GetMoveToPos(sPosition, nOffsetLeft, nOffsetTop, nOffsetWidth, nOffsetHeight)

{

var nLeft, nTop;

var aPosition = new Array();

 

aPosition = _PosStr2Arr(sPosition);

if( aPosition == null ) return null;

 

if( gf_isNull(nOffsetLeft) ) return null;

if( gf_isNull(nOffsetTop) ) return null;

 

nLeft = aPosition[_L] + nOffsetLeft;

nTop = aPosition[_T] + nOffsetTop;

 

return GetMovePos(sPosition, nLeft, nTop, nOffsetWidth, nOffsetHeight);

}

 

/*******************************************************************************
★ 설명
oObj에 해당하는 Object의 border width를 구하는 함수이다.
★ parameter
1. oObj : Object
(예 : mainframe, this.getOwnerFrame(), this, button,...)
★ return
- 성공 = oObj의 Border Width
- 실패 = -1
★ 목적
현재 XPlatform(2009.12.10.1)에서 border가 지정되지 않고 style로 적용되어 있으면
border를 구하지 못하므로 만들었다.
★ BUG
1. Component border가 지정되어 있지 않으면 값을 구할 수 없어 0으로 처리했음
2. ChildFrame의 border가 지정되어 있지 않으면 값을 구할 수 없어 0으로 처리됨
******************************************************************************/

function GetObjBorderWidth(oObj)

{

if( gf_isNull(oObj) ) return -1;

if( IsObjNoPos(oObj) ) return -1;

 

if( isNaN(oObj.style.border.width) || gf_isNull(oObj.style.border.width) )

{

var sType;

 

sType = GetObjType(oObj);

if( IsObjScreenPos(oObj) == true )

return 0-system.screenToClientX(oObj, oObj.position.left);

else

{

if( GetObjType(oObj.parent).toLowerCase() == "form" )

return 0;

else

return system.clientToScreenX(oObj, 0) - system.clientToScreenX(oObj, oObj.position.left);

}

}

else

return oObj.style.border.width;

}

 

/*******************************************************************************
★ 설명
oFromObj 좌표계의 sFromObjPos에 해당하는 Position을
oToObj 좌표계에 해당하는 Position으로 바꾼다.
★ parameter
1. sFromPos : 변경하고자 하는 oFromAreaObj좌표계 내에서의 Position
(예 : "10 10" 또는 "10 10 20 20", Button.position, ...)
2. oFromAreaObj : 변경할 좌표계 Object, 단, Screen의 경우는 "screen"을 넣으면 된다.
(예 : "screen", mainframe, this,...)
3. oToAreaObj : 변경할 좌표계 Object
단, Screen의 경우는 "screen"을 넣으면 된다.
(예 : "screen", mainframe, this,...)
★ return
- 성공 = oToObj 좌표계로 변경된 position 문자열
- 실패 = null
★ 목적
ScreenToClient, ClientToScreen 밖에 없고 A Object에서 B Object좌표계로
한번에 변경하는 함수가 없어서 만들었음
★ BUG
oFromAreaObj = form, oToAreaObj = "screen"인 경우 Xplatform Bug같다.
******************************************************************************/

function GetObjConvPos(sFromPos, oFromAreaObj, oToAreaObj)

{

var aFromPos = new Array();

var aRetPos = new Array();

 

if( gf_isNull(sFromPos) ) return null;

if( gf_isNull(oFromAreaObj) ) return null;

if( gf_isNull(oToAreaObj) ) return null;

if( IsObjNoPos(oFromAreaObj) ) return null;

if( IsObjNoPos(oToAreaObj) ) return null;

 

if( oFromAreaObj == oToAreaObj )

return sFromPos;

aFromPos = _PosStr2Arr(sFromPos);

 

if( oFromAreaObj.toString().toLowerCase() == "screen" )

{

aRetPos[_L] = system.screenToClientX( oToAreaObj, aFromPos[_L] );

aRetPos[_T] = system.screenToClientY( oToAreaObj, aFromPos[_T] );

}

else if( oToAreaObj.toString().toLowerCase() == "screen" )

{

aRetPos[_L] = system.clientToScreenX( oFromAreaObj, aFromPos[_L] );

aRetPos[_T] = system.clientToScreenY( oFromAreaObj, aFromPos[_T] );

}

else

{

aRetPos[_L] = system.clientToScreenX( oFromAreaObj, aFromPos[_L] );

aRetPos[_T] = system.clientToScreenY( oFromAreaObj, aFromPos[_T] );

aRetPos[_L] = system.screenToClientX( oToAreaObj, aRetPos[_L] );

aRetPos[_T] = system.screenToClientY( oToAreaObj, aRetPos[_T] );

}

if( aFromPos.length > 2 )

{

aRetPos[_R] = aRetPos[_L] + aFromPos[_W];

aRetPos[_B] = aRetPos[_T] + aFromPos[_H];

}

 

return _PosArr2Str(aRetPos);

}

 

/*******************************************************************************
★ 설명
sAreaPos좌표계 내에서 주어진 Align 조건에 따라
sObjPos의 좌표를 재 계산한다.
★ parameter
1. sAreaPos : Object가 움직일 좌표영역에 해당하는 Position 문자열 ( 예 : "10 10 100 100" )
2. sObjPos : Align될 Object의 현재 Position문자열 ( 예 : "50 50 60 60" )
3. sAxisPos : 기준이 되는 X,Y축 Position문자열
( 옵션 : Default=""==>sAreaPos의 center ) ( 예 : "60 60" )
4. sOffsetPos : sAxisPos로부터의 Offset Position문자열
( 옵션 : Default="0 0" ) ( 예 : "10 10" 또는 "-10 -10" )
5. nAlign : sAxisPos를 기준으로 한 정렬형태 ( 옵션 : Default=0 )
0 = 중앙정렬, 1 = 1사분면, 2 = 2사분면, 3 = 3사분면, 4 = 4사분면
6. bAuto : nAlign을 기준으로 sObjPos의 Width, Height가 들어갈 수 있는
사분면을 자동으로 찾아 정렬한다.( 옵션 : Default=false )
true = 자동정렬, false = 자동정렬 하지 않음
7. bBigResize : Object의 width, height가 해당 4분면의 영역보다 크면 4분면에 맞추어
Object의 width, height를 줄여서 조정한다.
즉, obj > Area이면 obj를 Area의 사분면에 맞춰 줄인다. ( 옵션 : Default = false )
true = Size 조정, false = Size 조정하지 않음
8. bSmallResize : Object의 width, height가 해당 4분면의 영역보다 작으면 4분면에 맞추어
Object의 width, height를 늘려서 조정한다.
즉, obj < Area이면 obj를 Area의 사분면에 맞춰 늘인다. ( 옵션 : Default = false )
true = Size 조정, false = Size 조정하지 않음
★ return
- 성공 = 주어진 조건에 맞는 정렬된 Object의 Position문자열
- 실패 = null
★ 주의사항
1. bAuto와 (bBigResize, bSmallResize)는 동시에 true일 수 없다.
bAuto가 true이면 bBigResize, bSmallResize는 false로 처리된다.
2. (sAxisPos+sOffsetPos)가 sAreaPos의 범위를 벗어나면 null이 return된다.
단, sObjPos의 최종 Align된 Position은 sAreaPos의 범위를 벗어날 수도 있다.
2. 모든 Position은 sAreaPos의 좌표계에 맞도록 전달되어야 한다.
따라서, 머리가 아프다면 모든 좌표를 screen좌표로 처리한다면
좀 더 쉬워지겠지...
******************************************************************************/

function GetAlignPos( sAreaPos, sObjPos, sAxisPos, sOffsetPos, nAlign, bAuto, bBigResize, bSmallResize )

{

var aAreaPos = new Array();

var aAxisPos = new Array();

var aObjPos = new Array();

var aOffsetPos = new Array();

var aAlignPos = new Array();

 

aAreaPos = _PosStr2Arr(sAreaPos);

if( aAreaPos == null ) return null;

aObjPos = _PosStr2Arr(sObjPos);

if( aObjPos == null ) return null;

if( gf_isNull(sAxisPos) != true )

{

aAxisPos = _PosStr2Arr(sAxisPos);

if( aAxisPos == null ) return null;

}

else

{

aAxisPos[_L] = aAreaPos[_L] + Math.round(aAreaPos[_W]/2);

aAxisPos[_T] = aAreaPos[_T] + Math.round(aAreaPos[_H]/2);

}

 

if( gf_isNull(sOffsetPos) != true )

{

aOffsetPos = _PosStr2Arr(sOffsetPos);

if( aOffsetPos == null ) return null;

}

else

{

aOffsetPos[_L] = 0;

aOffsetPos[_T] = 0;

}

if( gf_isNull(nAlign) ) nAlign = 0;

if( gf_isNull(bAuto) ) bAuto = true;

if( gf_isNull(bBigResize) ) bBigResize = false;

if( gf_isNull(bSmallResize) ) bSmallResize = false;

if( bAuto == true )

{

bBigResize = false;

bSmallResize = false;

}

 

// Axis를 Offset만큼 보정

aAxisPos[_L] += aOffsetPos[_L];

aAxisPos[_T] += aOffsetPos[_T];

 

// Axis가 Area의 범위를 벗어나면 return null

if( aAxisPos[_L] < aAreaPos[_L] )

return null;

if( aAxisPos[_L] > aAreaPos[_R] )

return null;

if( aAxisPos[_T] < aAreaPos[_T] )

return null;

if( aAxisPos[_T] > aAreaPos[_B] )

return null;

 

// Center에 위치

if( nAlign == 0 )

{

aAlignPos[_L] = aAxisPos[_L] - Math.round(aObjPos[_W]/2);

aAlignPos[_T] = aAxisPos[_T] - Math.round(aObjPos[_H]/2);

}

// 1사분면에 위치

else if( nAlign == 1 )

{

aAlignPos[_L] = aAxisPos[_L];

aAlignPos[_T] = aAxisPos[_T] - aObjPos[_H];

}

// 2사분면에 위치

else if( nAlign == 2 )

{

aAlignPos[_L] = aAxisPos[_L] - aObjPos[_W];

aAlignPos[_T] = aAxisPos[_T] - aObjPos[_H];

}

// 3사분면에 위치

else if( nAlign == 3 )

{

aAlignPos[_L] = aAxisPos[_L] - aObjPos[_W];

aAlignPos[_T] = aAxisPos[_T];

}

// 4사분면에 위치

else if( nAlign == 4 )

{

aAlignPos[_L] = aAxisPos[_L];

aAlignPos[_T] = aAxisPos[_T];

}

 

aAlignPos[_R] = aAlignPos[_L] + aObjPos[_W];

aAlignPos[_B] = aAlignPos[_T] + aObjPos[_H];

 

// Auto처리

if( bAuto == true )

{

var i;

var aAlignPosAuto, sAlignPosAuto, nCurAlign;

if( nAlign != 0 )

{

for( i = 0 ; i <= 4 ; i++ )

{

nCurAlign = (nAlign+i)%5;

if( nCurAlign == 0 )

continue;

sAlignPosAuto = GetAlignPos( sAreaPos, sObjPos, sAxisPos, sOffsetPos,

nCurAlign, false, false, false );

aAlignPosAuto = _PosStr2Arr(sAlignPosAuto);

if( (aAlignPosAuto[_L] >= aAreaPos[_L]) &&

(aAlignPosAuto[_R] <= aAreaPos[_R]) &&

(aAlignPosAuto[_T] >= aAreaPos[_T]) &&

(aAlignPosAuto[_B] <= aAreaPos[_B]) )

{

aAlignPos = aAlignPosAuto;

break;

}

}

}

}

 

// Resize처리

if( bBigResize == true || bSmallResize == true )

{

if( nAlign == 1 )

{

if( bBigResize == true )

{

if( aAlignPos[_R] > aAreaPos[_R] ) aAlignPos[_R] = aAreaPos[_R];

if( aAlignPos[_T] < aAreaPos[_T] ) aAlignPos[_T] = aAreaPos[_T];

}

if( bSmallResize == true )

{

if( aAlignPos[_R] < aAreaPos[_R] ) aAlignPos[_R] = aAreaPos[_R];

if( aAlignPos[_T] > aAreaPos[_T] ) aAlignPos[_T] = aAreaPos[_T];

}

}

if( nAlign == 2 )

{

if( bBigResize == true )

{

if( aAlignPos[_L] < aAreaPos[_L] ) aAlignPos[_L] = aAreaPos[_L];

if( aAlignPos[_T] < aAreaPos[_T] ) aAlignPos[_T] = aAreaPos[_T];

}

if( bSmallResize == true )

{

if( aAlignPos[_L] > aAreaPos[_L] ) aAlignPos[_L] = aAreaPos[_L];

if( aAlignPos[_T] > aAreaPos[_T] ) aAlignPos[_T] = aAreaPos[_T];

}

}

if( nAlign == 3 )

{

if( bBigResize == true )

{

if( aAlignPos[_L] < aAreaPos[_L] ) aAlignPos[_L] = aAreaPos[_L];

if( aAlignPos[_B] > aAreaPos[_B] ) aAlignPos[_B] = aAreaPos[_B];

}

if( bSmallResize == true )

{

if( aAlignPos[_L] > aAreaPos[_L] ) aAlignPos[_L] = aAreaPos[_L];

if( aAlignPos[_B] < aAreaPos[_B] ) aAlignPos[_B] = aAreaPos[_B];

}

}

if( nAlign == 4 )

{

if( bBigResize == true )

{

if( aAlignPos[_R] > aAreaPos[_R] ) aAlignPos[_R] = aAreaPos[_R];

if( aAlignPos[_B] > aAreaPos[_B] ) aAlignPos[_B] = aAreaPos[_B];

}

if( bSmallResize == true )

{

if( aAlignPos[_R] < aAreaPos[_R] ) aAlignPos[_R] = aAreaPos[_R];

if( aAlignPos[_B] < aAreaPos[_B] ) aAlignPos[_B] = aAreaPos[_B];

}

}

// Axis를 중심으로 작은 쪽에 맞추어 Resizing한다.

if( nAlign == 0 )

{

var nSmallWidth, nSmallHeight;

nSmallWidth = Math.min(aAxisPos[_L] - aAreaPos[_L], aAreaPos[_R] - aAxisPos[_L]);

nSmallHeight = Math.min(aAxisPos[_T] - aAreaPos[_T], aAreaPos[_B] - aAxisPos[_T]);

 

var bWFlag=false, bHFlag=false;

if( bSmallResize == true )

{

if( Math.round(aObjPos[_W]/2) < nSmallWidth )

bWFlag = true;

if( Math.round(aObjPos[_H]/2) < nSmallHeight )

bHFlag = true;

}

if( bBigResize == true )

{

if( Math.round(aObjPos[_W]/2) > nSmallWidth )

bWFlag = true;

if( Math.round(aObjPos[_H]/2) > nSmallHeight )

bHFlag = true;

}

if( bWFlag == true )

{

aAlignPos[_L] = aAxisPos[_L] - nSmallWidth;

aAlignPos[_R] = aAxisPos[_L] + nSmallWidth;

}

if( bHFlag == true )

{

aAlignPos[_T] = aAxisPos[_T] - nSmallHeight;

aAlignPos[_B] = aAxisPos[_T] + nSmallHeight;

}

}

}

 

aAlignPos[_W] = aAlignPos[_R] - aAlignPos[_L];

aAlignPos[_H] = aAlignPos[_B] - aAlignPos[_T];

 

return _PosArr2Str(aAlignPos);

}

 

/*******************************************************************************
★ 설명
Position문자열을 Rect Object로 바꾼다.
★ parameter
1. sPos : Position 문자열 (예 : "10 10 50 50" 또는 "10 10")
★ return
1. 성공 = Rect Object
(※ 단, sPos = "10 10" ==> 2개인 경우
Rect.right = Rect.left, Rect.bottom = Rect.top,
Rect.width = 0, Rect.height = 0)
2. 실패 = null
★ 주의사항
Rect Object는 좌표를 처리하는 XPlatform 내부 Object로서 메뉴얼에는 존재치 않는다.
Rect Object의 멤버는 left, top, right, bottom, width, height가 있다.
(예 : rect가 Rect Object라면 rect.left, rect.top으로 사용하면 된다.)
******************************************************************************/

function PosStr2Rect(sPos)

{

var oRect = new Rect();

 

aPos = _PosStr2Arr(sPos);

if( aPos == null )

return null;

 

oRect.left = aPos[_L];

oRect.top = aPos[_T];

if( aPos.length == 2 )

{

oRect.right = aPos[_L];

oRect.bottom = aPos[_T];

oRect.width = 0;

oRect.height = 0;

}

else

{

oRect.right = aPos[_R];

oRect.bottom = aPos[_B];

oRect.width = aPos[_W];

oRect.height = aPos[_H];

}

 

return oRect;

}

 

/*******************************************************************************
★ 설명
Rect Object를 Position문자열로 바꾼다.
★ parameter
1. oRect : Rect Object(예 : Rect.left = 10, ... )
★ return
1. 성공 = Position문자열 ( 예 : "10 20 30 40" )
(※ 단, Rect.right = Rect.left, Rect.right = Rect.left,
Rect.right = 0, Rect.bottom = 0,
Rect.width = 0, Rect.height = 0 인경우는
return = "10 10")
2. 실패 = null
★ 주의사항
Rect Object는 좌표를 처리하는 XPlatform 내부 Object로서 메뉴얼에는 존재치 않는다.
Rect Object의 멤버는 left, top, right, bottom, width, height가 있다.
(예 : rect가 Rect Object라면 rect.left, rect.top으로 사용하면 된다.)
******************************************************************************/

function PosRect2Str(oRect)

{

if( gf_isNull(oRect) ) return null;

 

// 2개인 경우 처리

if( ( ( oRect.left == oRect.right ) || oRect.right == 0 || oRect.width == 0 ) &&

( ( oRect.top == oRect.bottom ) || oRect.bottom == 0 || oRect.height == 0 ) )

return oRect.left + " " + oRect.top;

else

return oRect.left + " " + oRect.top + " " + oRect.right + " " + oRect.bottom;

}

 

 

☞  

 

☞  

 
 
 
 

  

 

Posted by 농부지기
,