Esempio n. 1
0
void CXTPSkinObjectTab::FillClient(CDC* pDC, CRect rc)
{
	FillBackground(pDC, rc);

	if (GetStyle() & TCS_BUTTONS)
		return;

	CXTPSkinManagerClass* pClass = GetSkinClass();

	CRect rcClient(rc);
	CRect rcHeader = GetHeaderRect();

	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rcClient.right = rcHeader.left;
	}
	else if (IsLeft(dwStyle))
	{
		rcClient.left = rcHeader.right;
	}
	else if (IsBottom(dwStyle))
	{
		rcClient.bottom = rcHeader.top;
	}
	else
	{
		rcClient.top = rcHeader.bottom;
	}

	pClass->DrawThemeBackground(pDC, TABP_PANE, 0, &rcClient);
}
Esempio n. 2
0
CRect CXTPSkinObjectTab::GetHeaderRect()
{
	CRect rcHeader;
	GetClientRect(&rcHeader);

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	// get the selected tab item rect.
	CRect rcItem;
	pTabCtrl->GetItemRect(pTabCtrl->GetCurSel(), &rcItem);

	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rcHeader.left = rcItem.left;
	}
	else if (IsLeft(dwStyle))
	{
		rcHeader.right = rcItem.right;
	}
	else if (IsBottom(dwStyle))
	{
		rcHeader.top = rcItem.top;
	}
	else
	{
		rcHeader.bottom = (rcHeader.top + rcItem.Height()) * pTabCtrl->GetRowCount() + GetMetrics()->m_cyEdge;
	}
	return rcHeader;
}
Esempio n. 3
0
BOOL CGuiControlBar::IsLegal(UINT uAlin)
{
	m_First=GetFirstPos();
//	if (IsFloating()) return FALSE;
	switch(uAlin)
	{
		case HTLEFT:
			if (IsHorz() && m_pos >0 && (m_pos != m_Last && m_pos != m_First)) return TRUE;
			if (IsVert() && m_pos <= m_Last && IsRight() ) return TRUE;
			return FALSE;
			break;
		case HTTOP:
			if (m_pos != m_First && IsVert()) return TRUE;
			if (IsHorz() && m_pos <= m_Last && IsBottom() ) return TRUE;
			return FALSE;
			break;
		case HTRIGHT:
			if (m_pos <= m_Last && IsVert() && IsLeft() ) return TRUE;
			if (IsHorz() && m_pos >0 &&  m_pos != m_Last) return TRUE;
			return FALSE;
		case HTBOTTOM:
			if ((m_pos != m_Last && m_pos != m_First) && IsHorz() && IsBottom()) return TRUE;
			if (m_pos <= m_Last && IsHorz() && IsTop()) return TRUE;
			//if (IsVert() && m_pos >0 ) return TRUE;
			return FALSE;
			break;
	}
	return FALSE;
}
Esempio n. 4
0
 void add(const byte* data, word32 len)
 {
     if (IsLeft(len)) {
         memcpy(buffer_.get_buffer() + current_, data, len);
         current_ += len;
     }
 }
Esempio n. 5
0
void CControlResizer::HideControls(int id, bool bHide, bool bLeft, bool bHorizontally)
{
	const ResizeProp *rszBaseControl(GetControl(id));
	if (rszBaseControl == NULL)
		return;
	if (bHide) {
		if (m_iHiddenLen) { // already hidden
			if (m_iHiddenLen < 0 && bLeft) // already hidden in left/top
				return;
			// First show - then hide
			HideControls(id, !bHide, bLeft, bHorizontally);
		}
	}
	if (bHide) {
		m_iHiddenLen = 0;
		// first hide all controls left
		m_ControlsHidden.RemoveAll();
		INT_PTR arrayCount  = m_ResizePropArray.GetCount();
		for (INT_PTR i = 0; i < arrayCount; i++) {
			const ResizeProp &rszProp(m_ResizePropArray.GetAt(i));
			int leftLen = IsLeft(rszBaseControl->controlID, rszProp.controlID, bLeft, bHorizontally);
			if (leftLen) {
				m_pDialog->GetDlgItem(rszProp.controlID)->ShowWindow(SW_HIDE);
				m_ControlsHidden.Add(rszProp.controlID);
				if (leftLen < 0) {
					if (leftLen < m_iHiddenLen)
						m_iHiddenLen = leftLen;
				}
				else {
					if (leftLen > m_iHiddenLen)
						m_iHiddenLen = leftLen;
				}
			}
		}
		int cx(0), cy(0);
		if (bHorizontally)
			cy = m_iHiddenLen;
		else
			cx = m_iHiddenLen;
		DoReSize(cx, cy);
	}
	else { // show the control
		// first resize
		int cx(0), cy(0);
		m_iHiddenLen = -m_iHiddenLen;
		if (bHorizontally)
			cy = m_iHiddenLen;
		else
			cx = m_iHiddenLen;
		m_iHiddenLen = 0;
		DoReSize(cx, cy);
		// then show all hidden control
		INT_PTR arrayCount  = m_ControlsHidden.GetCount();
		for (INT_PTR i = 0; i < arrayCount; i++) {
			m_pDialog->GetDlgItem(m_ControlsHidden[i])->ShowWindow(SW_SHOW);
		}
		m_ControlsHidden.RemoveAll();
	}
}
Esempio n. 6
0
void CXTPSkinObjectTab::DrawTabIcon(CDC* pDC, CRect& rcItem, int iItem)
{
	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	TC_ITEM tci;
	tci.mask = TCIF_IMAGE;

	BOOL bResult = pTabCtrl->GetItem(iItem, &tci);

#ifdef _UNICODE
	if (!bResult)
	{
		TC_ITEMA tcia;
		::ZeroMemory(&tcia, sizeof(TC_ITEMA));

		tcia.mask = TCIF_IMAGE;

		bResult = (BOOL)::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia);
		tci.iImage = tcia.iImage;
	}
#endif
	if (!bResult)
		return;

	CImageList* pImageList = pTabCtrl->GetImageList();
	if (!pImageList || tci.iImage < 0)
		return;

	CPoint point = rcItem.TopLeft();

	DWORD dwStyle = GetStyle();

	if (IsHorz(dwStyle))
	{
		point.Offset(GetMetrics()->m_cxEdge * 2, IsTop(dwStyle) ? GetMetrics()->m_cyEdge : 1);
	}
	else
	{
		point.Offset(IsLeft(dwStyle) ? GetMetrics()->m_cxEdge : 1, GetMetrics()->m_cyEdge * 2);
	}

	// Draw any associated icons.
	pImageList->Draw(pDC, tci.iImage, point, ILD_TRANSPARENT);

	IMAGEINFO info;
	::ZeroMemory(&info, sizeof(info));

	pImageList->GetImageInfo(tci.iImage, &info);
	CRect rcImage(info.rcImage);

	if (IsHorz(dwStyle))
	{
		rcItem.left += rcImage.Width() + GetMetrics()->m_cxEdge;
	}
	else
	{
		rcItem.top += rcImage.Height() + GetMetrics()->m_cyEdge;
	}
}
Esempio n. 7
0
static void search_ball(Info * info) {
        //info->destP.x = gety(info);
        //info->destP.y = getx(info)+50;
        //do_forward(info,DEFAULT_A);
       /*if (is_start == 0 && POSITI !=0) {
            run_rota(45,POSITI);
            run_forward(50,200);
            //run_rotaR(25);
            //run_forward(40,200);
            is_start = 1;        
        }*/                              //--- by hanlei
        if (IsBallCatch(info)) {
            info->state = BALL_CATCHED;
            info->sched_var.waitlost = 3;
            info->sched_var.doorseen = 0;            
            mylogfd(SCHFD, "[sche]State changing:SEARCH_BALL->ball_catched\n");
            if (!IsDoorSeen(info)) do_rota_with_ball(info, POSITI*360, 1);
            return;
        }  
        if (IsMiddle(info)) {            
            if (info->sched_var.waitforward -- == 0) {
                    info->sched_var.waitforward = SCHED_waitforward_TIME;
                    info->last_cmd = CMD_FORWARD;
                    info->state = FORWARDING_BALL;
                       
                    info->destP.x = gety(info);                
                    info->destP.y = - getx(info);
                    mylogfd(SCHFD, "[sche]SEARCH_BALL->forwarding_ball\n");
                    do_forward(info, DEFAULT_A);
                    return;
            }
        } else  {
			info->sched_var.count = 0;
			info->sched_var.door_count = 0;
			info->sched_var.door_dis = 10000;
			info->sched_var.max_green_sum = 0;
			info->sched_var.max_green_count = 0;
            if (IsBallAllSeen(info)) info->sched_var.wait = 0;
            else if (IsBallSeen(info)) info->sched_var.wait = 1;
            else info->sched_var.wait = 3;
            int dir ;
            if (START_FLAG == 0){
                START_FLAG = 1;
                dir = POSITI;
            }           
            dir = info->sched_var.search_dir;               //  search_ball -- redwalker
            if (IsBallSeen(info) && IsRight(info)) dir = -1; 
            if (IsBallSeen(info) && IsLeft(info)) dir = 1;
            info->state = SEARCHING_BALL;
            mylogfd(SCHFD, "[sche]SEARCH_BALL->search_ball\n");
            info->last_cmd = CMD_SEARCH_BALL;
            info->sched_var.search_dir = dir;
            do_search_ball(info, dir);
        }
}
Esempio n. 8
0
static void forwarding_ball(Info * info) {
        if (IsRight(info)) info->sched_var.search_dir = -2;
        if (IsLeft(info)) info->sched_var.search_dir = 2;
        if (IsBallCatch(info))   {
            mylogfd(SCHFD, "[sche]forwarding_ball->ball_catched\n");
            info->last_cmd = CMD_STOP; 
            info->state = BALL_CATCHED;
            info->sched_var.doorseen = 0;        
            do_stop(info);            //  delet // -- redwalker
            if (!IsDoorSeen(info)) do_rota_with_ball(info, POSITI*360, 1);
           return;
        }
        if (!IsBallSeen(info)) {  
            mylogfd(SCHFD, "[sche]forwarding_ball->stop when lose ball\n");
            info->state = SEARCH_BALL;
            do_stop(info);
            return;
        }
       /* else if (IsBallVeryNear(info))
        {
            mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n");
            info->state = CATCHING_BALL;
            info->destP.x = gety(info);
            iinfo->destP.y = -getx(info);
            do_catch_ball(info);
        }*/
        if (IsMiddle(info)) {
            do_adjust(-1);
        }
        if (IsLeft(info)) {
            do_adjust(1);
        }
        if (IsRight(info)) {
            do_adjust(0);
        }
        if (checkDone ()) {
            mylogfd(SCHFD, "[sche]checkDone forwarding_ball\n");
            info->state = SEARCH_BALL;
            mylogfd(SCHFD, "[sche]forwarding_ball->SEARCH_BALL\n");
            return;
        }         
}
Esempio n. 9
0
CRect CGuiControlBar::GetDockRect()
{
	CRect rcWin;
	if (IsVert())
		if (IsLeft())
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rcWin);
		else
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_RIGHT)->GetWindowRect(rcWin);
	else
		if(IsBottom())
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_BOTTOM)->GetWindowRect(rcWin);
		else
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rcWin);
	return rcWin;
}
Esempio n. 10
0
inline bool PolygonIntersection::IsPointInPolygon(const Point3D& pt, const Polygon3D& poly, const Vector3D& n)
{
	if (poly.points.size() < 3)
		return false;

	const Vector3D up = Point3D(poly.points[1]) - Point3D(poly.points[0]);

	int wn = 0;    // the  winding number counter
	// loop through all edges of the polygon
	for (auto i = poly.points.begin(); i != poly.points.end(); ++i)
	{
		const Point3D p0(*i);
		const Point3D p1((i + 1) != poly.points.end() ? *(i + 1) : poly.points.front());
		const Vector3D ev = p1 - p0;

		if (abs(ev.Normalized() * (pt - p0).Normalized()) >= 1 - GEOMETRIC_COMPUTATION_EPSILON)
		{
			// on one of the edges
			return true;
		}

		if ((pt - p0) * up >= 0)
		{          // start y <= P.y
			if ((pt - p1) * up < 0)      // an upward crossing
				if (IsLeft(pt, p0, ev, n))  // P left of  edge
					++wn;            // have  a valid up intersect
		}
		else
		{                        // start y > P.y (no test needed)
			if ((pt - p1) * up >= 0)     // a downward crossing
				if (!IsLeft(pt, p0, ev, n))  // P right of  edge
					--wn;            // have  a valid down intersect
		}
	}
	return wn != 0;
}
Esempio n. 11
0
void CXTPSkinObjectTab::OnDraw(CDC* pDC)
{
	CRect rc = GetHeaderRect();
	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rc.left -= 2;
	}
	else if (IsLeft(dwStyle))
	{
		rc.right += 2;
	}
	else if (IsBottom(dwStyle))
	{
		rc.top -= 2;
	}
	else
	{
		rc.bottom += 2;
	}

	CXTPBufferDC dcMem(*pDC, rc);
	FillClient(&dcMem, CXTPClientRect(this));

	if (m_bActiveX)
	{
		m_bPaint = TRUE;
		CXTPBufferDC dcMem2(*pDC, rc);
		DefWindowProc(WM_PAINT, (WPARAM)dcMem2.GetSafeHdc(), 0);
		dcMem2.Discard();
		m_bPaint = FALSE;
	}

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	CXTPFontDC font(&dcMem, GetFont());
	dcMem.SetBkMode(TRANSPARENT);

	for (int iItem = 0; iItem < pTabCtrl->GetItemCount(); ++iItem)
	{
		DrawTab(&dcMem, iItem);
	}

	DrawTab(&dcMem, pTabCtrl->GetCurSel());
}
Esempio n. 12
0
int MapOrientation(double cosThis, double cosNext, double cutOff){
    if(IsLeft(cosThis, cutOff) && IsLeft(cosNext, cutOff)){ return 0; }
    if(IsLeft(cosThis, cutOff) && IsRight(cosNext, cutOff)){ return 1; }
    if(IsLeft(cosThis, cutOff) && IsUndefined(cosNext, cutOff)){ return 2; }

    if(IsRight(cosThis, cutOff) && IsLeft(cosNext, cutOff)){ return 3; }
    if(IsRight(cosThis, cutOff) && IsRight(cosNext, cutOff)){ return 4; }
    if(IsRight(cosThis, cutOff) && IsUndefined(cosNext, cutOff)){ return 5; }

    if(IsUndefined(cosThis, cutOff) && IsLeft(cosNext, cutOff)){ return 6; }
    if(IsUndefined(cosThis, cutOff) && IsRight(cosNext, cutOff)){ return 7; }
    if(IsUndefined(cosThis, cutOff) && IsUndefined(cosNext, cutOff)){ return 8; }

    return 999;
}
Esempio n. 13
0
static void catching_ball(Info* info) {
        if (IsBallCatch(info)) {
            mylogfd(SCHFD, "[sche]State changing:catching_ball->ball_catched\n"); 
            info->state = BALL_CATCHED;
            info->sched_var.doorseen = 0;
            info->sched_var.waitlost = 3;       
            do_stop(info);
            if (!IsDoorSeen(info)) do_rota_with_ball(info, -POSITI*360, 1);    // get in a paramiter -- redwalker

        }
        else if (!IsBallAllSeen(info)) {
             mylogfd(SCHFD, "[sche]catching_ball->SEARCH_BALL\n");
             info->state = SEARCH_BALL;
             do_stop(info);
        }
        else if (!IsBallVeryNear(info))
        {
            mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n");
            info->state = FORWARDING_BALL;
            info->destP.x = gety(info);
            info->destP.y = - getx(info);
            do_forward(info, DEFAULT_A);
        }
        else if (checkDone()) {
            mylogfd(SCHFD,"[sche]checkDone catching_ball \n");
            info->last_cmd = CMD_CATCH_BALL;
            info->destP.x = gety(info);
            info->destP.y = - getx(info); 
            do_catch_ball(info);
        }
        if (IsMiddle(info)) {
            do_adjust(-1);
        }
        if (IsLeft(info)) {
            do_adjust(1);
        }
        if (IsRight(info)) {
            do_adjust(0);
        }
}
Esempio n. 14
0
static void ball_catched(Info* info) {
        if (IsRight(info)) info->sched_var.search_dir = -1;
        if (IsLeft(info)) info->sched_var.search_dir = 1;
        if (IsDoorSeen(info)) {
            info->sched_var.doorseen = 1;
        }

     /*   if (info->sched_var.doorseen && !IsDoorSeen(info)) {
            info->sched_var.doorseen = 0;
            info->state = MOVING;
            do_rota_with_ball(info, 90, 1);
            return;
        }*/
     //   mylogfd(SCHFD, "%d %d %d\n", info->sched_var.is_door_seen, info->video_info->door_pos.x, info->video_info2->door_pos.x);

        if (IsDoorSeen(info)) {
			if (getDoorMidy(info) > 250) {
				info->destP.x = 50;
				info->destP.y = 0;
				info->state = MOVING;
				do_catch_ball(info);
			}
            mylogfd(SCHFD, "[sche]see door to face door\n");
			if (IsDoorLeft(info)) info->sched_var.search_door_dir = 1;
			else info->sched_var.search_door_dir = -1;
		//	do_stop(info);
			do_rota_with_ball(info, info->sched_var.search_door_dir * 90, 1);
            info->state = FACE_DOOR;
            return;
        }
        if (!IsBallCatch(info)) {
            mylogfd(SCHFD, "[sche]lose balll\n");
            info->last_cmd = CMD_STOP;
            do_stop(info);
            info->state = SEARCH_BALL;
            return;
        }
}
Esempio n. 15
0
AFX_INLINE BOOL IsVert(DWORD dwStyle)
{
	return (IsRight(dwStyle) || IsLeft(dwStyle));
}
Esempio n. 16
0
BOOL CGuiToolBarWnd::IsVert()
{
	if (IsLeft() || IsRight())	return TRUE;
	return FALSE;
}
Esempio n. 17
0
void CGuiControlBar::OnInvertTracker(const CRect& rect)
{
	ASSERT_VALID(this);
	ASSERT(!rect.IsRectEmpty());
		
	CRect rcWin=GetDockRect();
	
	CDC *pDC = m_pDockSite->GetDCEx(NULL,
        DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE);
	CRect rcBar;
	GetWindowRect(rcBar);
	if (IsVert())  //el sentido de las barras es vertical
	{

		
		
		if (m_SideMove==HTLEFT || m_SideMove==HTRIGHT) //el mouse esta en el borde izquierdo o derecho
		{
			rcWin.OffsetRect(-rect.left,-rect.top);
			rcWin.top+=10;
			rcWin.left=rect.left+2;
			rcWin.right=rect.right+2;
		}
		else  //el mouse esta el borde de arriba pero de una barra vertical
		{
			rcBar.OffsetRect(-rect.TopLeft());
			rcWin=rcBar;
			if (IsLeft() || IsRight())   //a la izquierda
			{
				
				rcWin.top=rect.top-2;
				rcWin.bottom=rect.bottom-2;
			}
			//
			
		}
	}
	else  //el sentido de las barras es horizontal
	{
		
		if (m_SideMove==HTTOP || m_SideMove==HTBOTTOM) //el mouse esta en el borde de arriba o abajo
		{
			rcWin.OffsetRect(-rect.left,-rect.top);
			rcWin.top=rect.top-2;
			rcWin.bottom=rect.bottom-2;
		}
		else		//el mouse esta en el borde derecho
		{
			rcBar.OffsetRect(-rect.TopLeft());
			rcWin=rcBar;
			if (IsBottom() || IsTop())	//abajo
			{		
				rcWin.left=rect.left+2;
				rcWin.right=rect.right+2;
			}
		}
	}
	ClientToScreen(&rcWin);
	GetParentFrame()->ScreenToClient(&rcWin);
	// invert the brush pattern (looks just like frame window sizing)
	CBrush* pBrush = CDC::GetHalftoneBrush();
	HBRUSH hOldBrush = NULL;
	if (pBrush != NULL)
		hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, pBrush->m_hObject);
	pDC->PatBlt(rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), PATINVERT);
	if (hOldBrush != NULL)
		SelectObject(pDC->m_hDC, hOldBrush);
	m_pDockSite->ReleaseDC(pDC);
}
bool Preprocessor::ConvertExpression( LexemList& expression, LexemList& output )
{
    if( expression.empty() )
    {
        PrintMessage( "Empty expression." );
        return true;
    }

    // Convert to RPN
    std::vector<Lexem> stack;
    for( LLITR it = expression.begin(); it != expression.end(); ++it )
    {
        PreprocessLexem( it, expression );
        Lexem& lexem = *it;
        if( IsIdentifier( lexem ) )
        {
            output.push_back( lexem );
        }
        else if( IsOperator( lexem ) )
        {
            while( stack.size() )
            {
                Lexem& lex = stack.back();
                if( IsOperator( lex ) &&
                    ( (OperLeftAssoc( lexem ) && ( OperPrecedence( lexem ) <= OperPrecedence( lex ))) ||
                      (OperPrecedence( lexem ) < OperPrecedence( lex )) ) )
                {
                    output.push_back( lex );
                    stack.pop_back();
                }
                else
                    break;
            }
            stack.push_back( lexem );
        }
        else if( IsLeft( lexem ) )
        {
            stack.push_back( lexem );
        }
        else if( IsRight( lexem ) )
        {
            bool foundLeft = false;
            while( stack.size() )
            {
                Lexem& lex = stack.back();
                if( IsLeft( lex ) )
                {
                    foundLeft = true;
                    break;
                }
                else
                {
                    output.push_back( lex );
                    stack.pop_back();
                }
            }

            if( !foundLeft )
            {
                PrintErrorMessage( "Mismatched parentheses." );
                return false;
            }

            stack.pop_back();
        }
        else
        {
            PrintErrorMessage( "Unknown token: " + lexem.Value );
            return false;
        }
    }

    // input end, flush the stack
    while( stack.size() )
    {
        Lexem& lex = stack.back();
        if( IsLeft( lex ) || IsRight( lex ) )
        {
            PrintErrorMessage( "Mismatched parentheses." );
            return false;
        }
        output.push_back( lex );
        stack.pop_back();
    }
    return true;
}
Esempio n. 19
0
BOOL CGuiControlBar::IsVert()
{
	if (IsLeft() || IsRight())	return TRUE;
	return FALSE;
}
Esempio n. 20
0
 void advance(word32 i) {
     if (IsLeft(i)) current_ += i;
 }
Esempio n. 21
0
 byte next() {
     if (IsLeft(1)) return buffer_[current_++];
     else return 0;
 }