// ---------------------------------------------------------------------------- // Name : NearPosition() // Desc : 현재 포인터와 가장 가까운 아이템 슬롯의 포인터를 리턴한다. // ---------------------------------------------------------------------------- int CUICompound::NearPosition ( int nX, int nY ) { ConvertToWindow( nX, nY ); int nNearPoint = 0xffff; int nItemSlotX, nItemSlotY; int nDest; int nIndex = 0; for ( int i = 0; i < COMPOUND_ITEM_SLOT_COUNT; i++ ) { nItemSlotX = m_rcItemSlot[i].Left + m_rcItemSlot[i].GetWidth() / 2; nItemSlotY = m_rcItemSlot[i].Top + m_rcItemSlot[i].GetHeight() / 2; nDest = abs ( nX - nItemSlotX ) + abs ( nY - nItemSlotY ); if ( nNearPoint > nDest ) { nIndex = i; nNearPoint = nDest; } } return nIndex; }
void View::Sync( int left, int top, int right, int bottom ) { if ( GetWindow() == NULL ) return; Rect box; if ( (left == 0) && (top == 0) && (right == -1) && (bottom == -1) ) { box = ConvertToWindow( Bounds() ); } else { box = ConvertToWindow( Rect( left, top, right, bottom ) ); } if ( box.IsValid() == false ) return; GetWindow()->Sync( box.left, box.top, box.right, box.bottom ); }
uint32 View::GetPixel( int x, int y ) { if ( GetWindow() == NULL ) return 0; if ( (y < 0) || (y > Bounds().bottom) ) return 0; if ( (x < 0) || (x > Bounds().right) ) return 0; Point a(x,y); a = ConvertToWindow( a ); return GetWindow()->GetPixel( a.x, a.y ); }
void View::PutPixel( int x, int y, uint32 col ) { if ( GetWindow() == NULL ) return; if ( (y < 0) || (y > Bounds().bottom) ) return; if ( (x < 0) || (x > Bounds().right) ) return; Point a(x,y); a = ConvertToWindow( a ); GetWindow()->PutPixel( a.x, a.y, col ); }
// ---------------------------------------------------------------------------- // Name : InsideNumXY() // Desc : // ---------------------------------------------------------------------------- void CUISelectList::InsideNumY(UIRect rc,int btnSize,int btnGap, int* n_x ,int* n_y ) { int tv_i,tv_divY,tv_sum; if( IsInsideRect(*n_x,*n_y,rc) ){ ConvertToWindow(*n_x,*n_y); tv_divY=rc.GetHeight()/btnSize; for(tv_i=1; tv_i <= tv_divY ;tv_i++){ tv_sum=btnSize*tv_i+rc.Top+btnGap*(tv_i-1); if( tv_sum > *n_y) { *n_y=tv_i-1; break; } } } }