Exemple #1
0
// Show      - Show the titletip if needed.
// rectTitle - The rectangle within which the original title
//             is constrained - in client coordinates.
// cpcTitleText - The text to be displayed.
// nOffsetX  - Number of pixels that the text is offset from
//             the left border of the cell.
void
ZListTip::Show( CRect rectTitle, zCPCHAR cpcTitleText,
                int nOffsetX /* = 0 */,
                LPRECT pHoverRect /* = 0 */,
                const LOGFONT *pLogFont /* = 0 */,
                COLORREF clrText /* = CLR_DEFAULT */,
                COLORREF clrBack /* = CLR_DEFAULT */ )
{
#ifdef DEBUG_ALL
   TraceLine( "ZListTip::Show %s   Delay: %d", cpcTitleText, m_lHoverDelay );
#endif

   m_csTitle = cpcTitleText;

   // If window is not valid, display rect is empty, text is empty,
   // title tip is already displayed, or app does not have focus ...
   // don't do anything.
   if ( mIs_hWnd( m_hWnd ) == 0 || rectTitle.IsRectEmpty( ) ||
        cpcTitleText == 0 || *cpcTitleText == 0 ||
        mIs_hWndVisible( m_hWnd ) || GetFocus( ) == 0 )
   {
      return;
   }

   // Define the rectangle outside which the titletip will be hidden.
   // We add a buffer of one pixel around the rectangle.
   m_rectTitle.top = -1;
   m_rectTitle.left = -1;
   m_rectTitle.right = rectTitle.Width( );
   m_rectTitle.bottom = rectTitle.Height( ) + 1;

   // Determine the width of the text.
   m_pParentWnd->ClientToScreen( rectTitle );

   CClientDC dc( this );
   CFont *pFontDC;
// if ( pLogFont )
// {
//    CFont font;
//    font.CreateFontIndirect( pLogFont );
//    pFontDC = dc.SelectObject( &font );
// }
// else
   {
      // Use same font as ctrl.
      pFontDC = dc.SelectObject( m_pParentWnd->GetFont( ) );
   }

   m_nOffsetX = nOffsetX - 1;
   CRect rectDisplay = rectTitle;
   CSize size = dc.GetTextExtent( m_csTitle );
   rectDisplay.top--;
   rectDisplay.left--;
   rectDisplay.right = rectDisplay.left + size.cx + 2 * m_nOffsetX;
   dc.SelectObject( pFontDC );

   if ( rectDisplay.right > rectTitle.right + 1 )
   {
      UINT uFlags = SWP_NOACTIVATE;
      if ( m_lHoverDelay == 0 )
      {
         uFlags |= SWP_SHOWWINDOW;
      }
      else
      if ( m_lHoverDelay > 0 )
      {
         if ( m_uToolTipTimerId )
            KillTimer( m_uToolTipTimerId );

         m_uToolTipTimerId = SetTimer( g_nIdShowToolTipEvt, m_lHoverDelay, 0 );
      // TraceLine( "ZListTip::Show Timer Id: %d", m_uToolTipTimerId );
      }

      SetWindowPos( &wndTop, rectDisplay.left, rectDisplay.top,
                    rectDisplay.Width( ), rectDisplay.Height( ), uFlags );
      DrawTipText( );
      SetCapture( );
   }
}
Exemple #2
0
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon, LPCTSTR lpszImage )
{
	CRect rect;
	GetClientRect(&rect);

	// Yogesh Jagota
	CDocument* pDoc = ((CView *) wnd)->GetDocument();

	CString sPath = pDoc->GetPathName();
	CString sFileName;
	
	if ( sPath.IsEmpty() )
		sPath = pDoc->GetTitle();

	// Can be only the filename, like Noname01
	if ( sPath.Find( _T('\\') ) != -1 )
		sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 );
	else
		sFileName = sPath;

	// If there is no space left to display extra buttons...
	int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH ) 
		/ ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN;

	bool bShowButton = true;
	if ( nNewSize <= MINWIDTH )
	{
		// Check if the menu button is displayed, if not, display it...
		m_btnMenuButton.ShowWindow( SW_SHOW );

		// Don't show the button...
		bShowButton = false;
	}
	else
		m_nDisplayedButtons++;

	// End Yogesh Jagota

	CSwitcherButton* newbutton = new CSwitcherButton();

	 // Yogesh Jagota
	newbutton->m_AttachedView = wnd;

	// I am saving the frame to make life easier in case
	// of activation in selection process...
	CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
	CWnd * pWnd = pFrame->GetWindow( GW_CHILD );
	ASSERT (pWnd);
	pWnd = pWnd->GetWindow( GW_CHILD );
	while (pWnd)
	{
		if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd )
			newbutton->m_FrameWnd = (CFrameWnd *)pWnd;

		pWnd = pWnd->GetWindow( GW_HWNDNEXT );
	}

	// Load the icon....
	if ( wIcon != 0 ){

		newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), 
			MAKEINTRESOURCE( wIcon ) );
	}
	
	else if(lpszImage  != 0){

		HBITMAP hTmp = (HBITMAP)::LoadImage(NULL, lpszImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_DEFAULTCOLOR);
		if(hTmp){

			newbutton->m_hBmp = CEmoticonManager::ReplaceColor(hTmp, RGB(255, 0, 255), ::GetSysColor(COLOR_3DFACE), 0);
			DeleteObject(hTmp);
		}
		else{

			newbutton->m_hBmp = NULL;
		}
	}
	// End Yogesh Jagota

	newbutton->m_iID = m_Buttons.GetSize();
	if (!newbutton->DoCreate(this, m_iNextButtonStart, 
		rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2, 
		sFileName, sPath )) // Yogesh Jagota
	{
		return FALSE;
	}

	if ( !bShowButton )
		newbutton->ShowWindow( SW_HIDE );

	m_Buttons.Add((void*)newbutton);
	m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;

	if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width())
	{
		// this loop makes a neat little animation
		int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) 
			/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;

//		Yogesh Jagota. Removed animation because did'nt liked it.
//		Remove if you want animated addition or removal of buttons.
//
		register int y;
		for (y = m_iButtonWidth; y >= newsize; y-=3)
		{
			ResizeButtons(y);
			Sleep(15);
		}

		if (y != newsize)
//			/* ResizeButtons(newsize); */ <- this is the next line...
//		End Yogesh Jagota

		ResizeButtons(newsize);

		if (m_iButtonWidth < MINWIDTH)
		{
			// the smallest allowable button size has been reached...
			// in this version, we can't handle this
			ASSERT(0);
			return FALSE;
		}
	}
	else
		m_btnMenuButton.ShowWindow( SW_HIDE );

	// Yogesh Jagota
	if ( m_iSelectedButton != -1 )
		((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Unselect();

	m_iSelectedButton = newbutton->m_iID;
	((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Select();
	// End Yogesh Jagota

	return TRUE;
}
Exemple #3
0
BOOL CDocSelector::RemoveButton(CWnd* wnd)
{
	// Yogesh Jagota
	int index = -1;

	for ( int i = 0; i < m_Buttons.GetSize(); i++ )
	{
		if ( GetButtonFromID( i )->m_AttachedView == wnd )
		{
			index = i;
			break;
		}
	}

	if ( index == -1 )
		return FALSE;
	// End Yogesh Jagota

	if (index >= m_Buttons.GetSize() || index < 0)
	{
		ASSERT(0); // out of range
		return FALSE;
	}

	if (m_iSelectedButton == index)
		m_iSelectedButton = -1;
	if (m_iSelectedButton > index)
		m_iSelectedButton -= 1;

	delete GetButtonFromID(index);
	m_Buttons.RemoveAt(index);

	for (register int x = index; x < m_Buttons.GetSize(); x++)
		GetButtonFromID(x)->m_iID -= 1;

	m_iNextButtonStart -= m_iButtonWidth + 1;

	if (m_iButtonWidth != DS_WIDTH)
	{
		// do that funky animation thing
		CRect rect;
		GetClientRect(&rect);
		int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) 
			/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;

		if (newsize > DS_WIDTH) newsize = DS_WIDTH;


//		Yogesh Jagota. Removed animation because did'nt liked it.
//		Remove if you want animated addition or removal of buttons.
//
//		this loop is shortened to make the following loop....
		if (newsize > m_iButtonWidth)
		{
			register int y;
			for (y = m_iButtonWidth; y <= newsize; y+=3)
			{
				ResizeButtons(y);
				Sleep(15);
			}
			if (y != newsize)
				ResizeButtons(newsize);
		}
//		End Yogesh Jagota

		if (newsize > m_iButtonWidth)
			ResizeButtons(newsize);
	}

	ResizeButtons(m_iButtonWidth);

	return TRUE;
}
Exemple #4
0
bool CreateTagControls(
		CDialog* dlgParent, UINT dlgID,
		CComboBoxEx*& editParentCtrl, CComboBoxEx*& editTagCtrl, CListCtrl*& listCtrl,
		TagArray* tagArray )
{
	s_ftID = dlgID;

	s_TagTitleWnd.HookWindow(dlgParent);

	// Make the list control.
	s_ftListCtrl = WNEW CFindTagListCtrl;
	s_ftListCtrl->SubclassDlgItem( IDC_FT_TAGS, dlgParent );
	s_ftListCtrl->m_tagArray = tagArray;

	DWORD dwStyle = s_ftListCtrl->SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE, 0 ,0);
	dwStyle |= LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES ;
	s_ftListCtrl->SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0,dwStyle );

	CRect rect;
	s_ftListCtrl->GetClientRect(&rect);
	int listWidth = rect.Width() - GetSystemMetrics(SM_CXVSCROLL);

	// Get any saved column widths.
	CString windowProfile = "WindowPositions\\" + MakeWindowID(s_ftID);
	s_sub1Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub1", TYPE_WIDTH);
	s_sub1_5Width	= AfxGetApp()->GetProfileInt(windowProfile, "Sub1_5", (int)((listWidth - s_sub1Width) * 0.25));
	s_sub2Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub2", (int)((listWidth - s_sub1Width) * 0.25));
	s_sub3Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub3", (int)((listWidth - s_sub1Width) * 0.50));
	s_sub4Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub4", 100);
	s_sub5Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub5", 400);
//	s_sub6Width		= AfxGetApp()->GetProfileInt(windowProfile, "Sub6", 400);
	if (s_sub1Width <= 0)
		s_sub1Width = TYPE_WIDTH;
	if (s_sub1_5Width <= 0)
		s_sub1_5Width = (int)((listWidth - s_sub1Width) * 0.25);
	if (s_sub2Width <= 0)
		s_sub2Width = (int)((listWidth - s_sub1Width) * 0.25);
	if (s_sub3Width <= 0)
		s_sub3Width = (int)((listWidth - s_sub1Width) * 0.50);
	if (s_sub4Width <= 0)
		s_sub4Width = 100;
	if (s_sub5Width <= 0)
		s_sub5Width = 400;
//	if (s_sub6Width <= 0)
//		s_sub6Width = 400;

	// Set the column names of the list control.
	s_ftListCtrl->InsertColumn(0, "Type",		LVCFMT_LEFT, s_sub1Width);
	s_ftListCtrl->InsertColumn(1, "Namespace",	LVCFMT_LEFT, s_sub1_5Width);
	s_ftListCtrl->InsertColumn(2, "Parent",		LVCFMT_LEFT, s_sub2Width);
	s_ftListCtrl->InsertColumn(3, "Tag",		LVCFMT_LEFT, s_sub3Width);
	s_ftListCtrl->InsertColumn(4, "Filename",	LVCFMT_LEFT, s_sub4Width);
//	s_ftListCtrl->InsertColumn(5, "Path",		LVCFMT_LEFT, s_sub5Width);
	s_ftListCtrl->InsertColumn(5, "Line",		LVCFMT_LEFT, s_sub5Width);

	// Make the parent edit field.
	s_ftEditParentCtrl = WNEW CFindTagEdit;
	s_ftEditParentCtrl->SubclassDlgItem( IDC_FT_PARENT, dlgParent );
	s_ftEditParentCtrl->m_buddyList = s_ftListCtrl;

	int i;
	for (i = 0; i < m_tagParentEditStringArray.GetSize(); ++i)
		s_ftEditParentCtrl->CComboBox::AddString(m_tagParentEditStringArray[i]);

	// Make the tag edit field.
	s_ftEditTagCtrl = WNEW CFindTagEdit;
	s_ftEditTagCtrl->SubclassDlgItem( IDC_FT_NAME, dlgParent );
	s_ftEditTagCtrl->m_buddyList = s_ftListCtrl;

	for (i = 0; i < m_tagEditStringArray.GetSize(); ++i)
		s_ftEditTagCtrl->CComboBox::AddString(m_tagEditStringArray[i]);

	listCtrl = s_ftListCtrl;
	editParentCtrl = s_ftEditParentCtrl;
	editTagCtrl = s_ftEditTagCtrl;

	if (HasExpired())
		return true;

	return true;
}
void EPropWnd::SetScrollPage()
{
	CSize PageSize = GetScrollPageSize();

	if( PageSize.cx==0 && PageSize.cy==0 )
	{
		SetScrollPos ( SB_HORZ , 0     );
		SetScrollPos ( SB_VERT , 0     );
		ShowScrollBar( SB_BOTH , FALSE );
	}
	else
	{
		CRect wr;
		GetWindowRect(&wr);
		CSize ClientSize = wr.Size();

		bool bEnableH = false;
		bool bEnableV = false;

		if( PageSize.cx > ClientSize.cx )
		{
			ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
			bEnableH = true;
		}

		if( PageSize.cy > ClientSize.cy )
		{
			ClientSize.cx -= GetSystemMetrics(SM_CXVSCROLL);
			bEnableV = true;

			if( bEnableH == false )
			{
				if( PageSize.cx > ClientSize.cx )
				{
					ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
					bEnableH = true;
				}
			}
		}

		SCROLLINFO si;
		si.cbSize = sizeof(si);
		si.fMask  = SIF_PAGE | SIF_POS | SIF_RANGE;

		if( bEnableH )
		{
			si.nPage  = ClientSize.cx;			//size of scrolltab
			si.nMin   = 0;
			si.nMax   = PageSize.cx-1;
			si.nPos   = GetScrollPos(SB_HORZ);
			ShowScrollBar( SB_HORZ , TRUE );
			SetScrollInfo( SB_HORZ , &si );
		}
		else
		{
			ShowScrollBar( SB_HORZ , FALSE );
			SetScrollPos( SB_HORZ , 0 );
		}

		if( bEnableV )
		{
			si.nPage  = ClientSize.cy;			//size of scrolltab
			si.nMin   = 0;
			si.nMax   = PageSize.cy-1;
			si.nPos   = GetScrollPos(SB_VERT);
			ShowScrollBar( SB_VERT , TRUE );
			SetScrollInfo( SB_VERT , &si );
		}
		else
		{
			ShowScrollBar( SB_VERT , FALSE );
			SetScrollPos( SB_VERT , 0 );
		}

	}
}
//*****************************************************************************
void CBCGPCaptionBar::RecalcLayout ()
{
	CClientDC dc (NULL);

	CFont* pOldFont = dc.SelectObject (
		m_hFont == NULL ? &globalData.fontRegular : CFont::FromHandle (m_hFont));
	ASSERT (pOldFont != NULL);

	TEXTMETRIC tm;
	dc.GetTextMetrics (&tm);

	int nTextHeight = tm.tmHeight + 2;
	CSize sizeImage = GetImageSize ();

	const int nButtonVertMargin = CBCGPVisualManager::GetInstance()->GetMessageBarMargin();
	const int nBorderSize = m_bIsMessageBarMode ? 0 : m_nBorderSize;

	//-------------------------------------------------------------------
	// the height is set to the default (provided by the user in Create)
	// or calculated if it is -1
	//-------------------------------------------------------------------
	if (m_nDefaultHeight != -1)
	{
		m_nCurrentHeight = m_nDefaultHeight;
	}
	else
	{
		if (!m_strBtnText.IsEmpty () && m_bIsMessageBarMode)
		{
			nTextHeight += 2 * nButtonVertMargin;
		}

		m_nCurrentHeight = max (nTextHeight, sizeImage.cy) + 
			m_nMargin * 2 + nBorderSize;
	}

	if (m_bIsMessageBarMode)
	{
		m_nCurrentHeight += CBCGPVisualManager::GetInstance()->GetMessageBarMargin() * 2;
	}

	// for left and center alignment: icon, button, text
	// for right alignment: text, button, icon

	CRect rectClient;
	GetClientRect (rectClient);

	if (rectClient.IsRectEmpty ())
	{
		dc.SelectObject (pOldFont);
		return;
	}

	if (m_bIsMessageBarMode)
	{
		CSize sizeImage = CBCGPMenuImages::Size ();
		const int nCloseButtonMargin = 4;

		sizeImage.cx += 2 * nCloseButtonMargin;
		sizeImage.cy += 2 * nCloseButtonMargin;

		m_rectClose = CRect (
			CPoint (rectClient.right - sizeImage.cx, rectClient.top + nCloseButtonMargin),
			sizeImage);

		m_rectClose.right--;

		rectClient.DeflateRect (nCloseButtonMargin, nCloseButtonMargin);
		rectClient.right -= m_rectClose.Width ();
	}
	else
	{
		m_rectClose.SetRectEmpty();
	}

	BOOL bButtonLeftOfIcon = FALSE;
	BOOL bTextLeftOfButton = FALSE;
	BOOL bTextLeftOfIcon = FALSE;

	BOOL bIconCenter = FALSE;
	BOOL bButtonCenter = FALSE;
	BOOL bButtonAfterText = FALSE;
	BOOL bTextCenter = FALSE;

	// differs from the current height, because the border size is non-client area
	int nBaseLine = rectClient.CenterPoint ().y;
	int nCenterOffset = rectClient.CenterPoint ().x;

	int nNextXOffsetLeft  = rectClient.left + m_nMargin;
	int nNextXOffsetRight = rectClient.right - m_nMargin;
	int nNextXOffsetCenter = nCenterOffset;

	if (IsImageSet ())
	{
		if (sizeImage.cy < rectClient.Height () || m_bIsMessageBarMode)
		{
			// center the icon if its height lesser than client area height
			m_rectImage.top = nBaseLine - sizeImage.cy / 2;
		}
		else
		{
			// otherwise, clip it from the buttom
			m_rectImage.top = rectClient.top + m_nMargin;
		}

		if (!m_bStretchImage)
		{
			m_rectImage.bottom = m_rectImage.top + sizeImage.cy;
		}
		else
		{
			m_rectImage.bottom = rectClient.bottom - m_nMargin;
		}

		switch (m_iconAlignment)
		{
		case ALIGN_LEFT:
			m_rectImage.left = nNextXOffsetLeft;
			m_rectImage.right = m_rectImage.left + sizeImage.cx;
			nNextXOffsetLeft = m_rectImage.right + m_nHorzElementOffset;
			break;

		case ALIGN_RIGHT:
			m_rectImage.left = nNextXOffsetRight - sizeImage.cx;
			m_rectImage.right = m_rectImage.left + sizeImage.cx;
			nNextXOffsetRight = m_rectImage.left - m_nHorzElementOffset;
			// only in this case button and text is at the left side of the icon
			bButtonLeftOfIcon = TRUE; 
			bTextLeftOfIcon = TRUE;
			break;

		case ALIGN_CENTER:
			bIconCenter = TRUE;
			nNextXOffsetCenter -= sizeImage.cx / 2;

			if (m_btnAlignnment == ALIGN_LEFT)
			{
				bButtonLeftOfIcon = TRUE;
			}

			if (m_textAlignment == ALIGN_LEFT)
			{
				bTextLeftOfIcon = TRUE;
			}
			break;

		default:
			ASSERT (FALSE);
		}
	}
	else
	{
		m_rectImage.SetRectEmpty();
	}

	int nButtonWidth = 0;

	if (!m_strBtnText.IsEmpty ())
	{
		nButtonWidth = dc.GetTextExtent (m_strBtnText).cx + 2 * m_nHorzElementOffset;

		if (m_bIsMessageBarMode)
		{
			nButtonWidth += 2 * nButtonHorzMargin;
		}

		if (m_uiBtnID != 0 && m_bBtnEnabled && m_bBtnHasDropDownArrow)
		{
			nButtonWidth += nMenuArrowWidth;
		}

		// the button always has a height equivalent to the bar's height
		m_rectButton.top = rectClient.top;
		m_rectButton.bottom = rectClient.bottom;

		if (m_bIsMessageBarMode)
		{
			m_rectButton.DeflateRect (0, nButtonVertMargin);
		}

		switch (m_btnAlignnment)
		{
		case ALIGN_LEFT:
			if (!m_bIsMessageBarMode || m_textAlignment != ALIGN_LEFT)
			{
				m_rectButton.left = nNextXOffsetLeft;

				if (nNextXOffsetLeft == rectClient.left + m_nMargin)
				{
					m_rectButton.left = rectClient.left + m_nMargin;
				}

				m_rectButton.right = m_rectButton.left + nButtonWidth;
				nNextXOffsetLeft = m_rectButton.right + m_nHorzElementOffset;
			}
			else
			{
				bButtonAfterText = TRUE;
			}
			break;

		case ALIGN_RIGHT:
			m_rectButton.left = nNextXOffsetRight - nButtonWidth;

			if (nNextXOffsetRight == rectClient.right - m_nMargin)
			{
				m_rectButton.left = rectClient.right - nButtonWidth - m_nMargin;
			}

			m_rectButton.right = m_rectButton.left + nButtonWidth;
			nNextXOffsetRight = m_rectButton.left - m_nHorzElementOffset;
			// only in this case text at the left side of the button
			bTextLeftOfButton = TRUE;
			break;

		case ALIGN_CENTER:
			bButtonCenter = TRUE;
			nNextXOffsetCenter -= nButtonWidth / 2;

			if (m_textAlignment == ALIGN_LEFT)
			{
				bTextLeftOfButton = TRUE;
			}
			break;

		default:
			ASSERT (FALSE);
			return;
		}
	}
	else
	{
		m_rectButton.SetRectEmpty();
	}

	CSize sizeText (0, 0);

	if (!m_strText.IsEmpty ())
	{
		sizeText = GetTextSize (&dc, m_strText);

		m_rectText.top = nBaseLine - sizeText.cy / 2;
		m_rectText.bottom = m_rectText.top + sizeText.cy;

		switch (m_textAlignment)
		{
		case ALIGN_LEFT:
			m_rectText.left = nNextXOffsetLeft;
			nNextXOffsetLeft += sizeText.cx + 2 * m_nMargin;
			break;

		case ALIGN_RIGHT:
			m_rectText.left = nNextXOffsetRight - sizeText.cx;
			break;

		case ALIGN_CENTER:
			bTextCenter = TRUE;
			nNextXOffsetCenter -= sizeText.cx / 2;
			break;

		default:
			ASSERT (FALSE);
			return;
		}

		m_rectText.right = m_rectText.left + sizeText.cx;
		AdjustRectToMargin (m_rectText, rectClient, m_nMargin);
		m_rectDrawText = m_rectText;
	}

	if (bIconCenter)
	{
		m_rectImage.left = nNextXOffsetCenter;
		m_rectImage.right = m_rectImage.left + sizeImage.cx;
		nNextXOffsetCenter = m_rectImage.right + m_nHorzElementOffset;
	}

	if (bButtonAfterText)
	{
		m_rectButton.left = nNextXOffsetLeft;
		m_rectButton.right = m_rectButton.left + nButtonWidth;

		if (m_rectButton.right + m_nMargin > rectClient.right)
		{
			m_rectButton.right = rectClient.right - m_nMargin;
			m_rectButton.left = m_rectButton.right - nButtonWidth;
		}
	}
	else if (bButtonCenter)
	{
		m_rectButton.left = nNextXOffsetCenter;
		m_rectButton.right = m_rectButton.left + nButtonWidth;
		nNextXOffsetCenter = m_rectButton.right + m_nHorzElementOffset;
	}

	if (bTextCenter)
	{
		m_rectText.left = nNextXOffsetCenter;
		m_rectText.right = m_rectText.left + sizeText.cx; 
		AdjustRectToMargin (m_rectText, rectClient, m_nMargin);
		m_rectDrawText = m_rectText;
	}

	if (IsImageSet ())
	{
		// do not retain image size if it should be stretched
		AdjustRectToMargin (m_rectImage, rectClient, m_nMargin, !m_bStretchImage);

		if (m_rectImage.left < rectClient.left || 
			m_rectImage.right > rectClient.right)
		{
			m_rectImage.SetRectEmpty ();
		}
	}

	CRect rectButtonTemp = m_rectButton;
	if (!m_strBtnText.IsEmpty () && IsImageSet ())
	{
		CheckRectangle (rectButtonTemp, m_rectImage, bButtonLeftOfIcon);
	}

	if (!m_strBtnText.IsEmpty ())
	{
		AdjustRectToMargin (rectButtonTemp, rectClient, m_nMargin);

		if (m_rectButton.Width () + m_rectImage.Width () + 2 * m_nMargin > rectClient.Width ())
		{
			m_rectButton.SetRectEmpty ();
		}
	}

	if (!m_strText.IsEmpty ())
	{
		CheckRectangle (m_rectDrawText, m_rectImage, bTextLeftOfIcon); 
		CheckRectangle (m_rectDrawText, rectButtonTemp, bTextLeftOfButton || bButtonAfterText);
	}

	dc.SelectObject (pOldFont);

	m_bTextIsTruncated = m_rectDrawText.Width () < sizeText.cx;

	UpdateTooltips ();
}
Exemple #7
0
void CResizableLayout::CalcNewChildPosition(const CResizableLayout::LayoutInfo& layout,
                                const CRect &rectParent, CRect &rectChild, UINT& uFlags)
{
    CWnd* pParent = GetResizableWnd();

    ::GetWindowRect(layout.hWnd, &rectChild);
    ::MapWindowPoints(NULL, pParent->m_hWnd, (LPPOINT)&rectChild, 2);

    CRect rectNew;

    // calculate new top-left corner
    rectNew.left = layout.sizeMarginTL.cx + rectParent.Width() * layout.sizeTypeTL.cx / 100;
    rectNew.top = layout.sizeMarginTL.cy + rectParent.Height() * layout.sizeTypeTL.cy / 100;

    // calculate new bottom-right corner
    rectNew.right = layout.sizeMarginBR.cx + rectParent.Width() * layout.sizeTypeBR.cx / 100;
    rectNew.bottom = layout.sizeMarginBR.cy + rectParent.Height() * layout.sizeTypeBR.cy / 100;

    // adjust position, if client area has been scrolled
    rectNew.OffsetRect(rectParent.TopLeft());

    // get the refresh property
    BOOL bRefresh = layout.properties.bAskRefresh ?
        NeedsRefresh(layout, rectChild, rectNew) : layout.properties.bCachedNeedsRefresh;

    // set flags
    uFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION;
    if (bRefresh)
        uFlags |= SWP_NOCOPYBITS;
    if (rectNew.TopLeft() == rectChild.TopLeft())
        uFlags |= SWP_NOMOVE;
    if (rectNew.Size() == rectChild.Size())
        uFlags |= SWP_NOSIZE;

    // update rect
    rectChild = rectNew;
}
BOOL CSkillReportDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  여기에 추가 초기화 작업을 추가합니다.

	// 리스트 컨트롤 초기화
	{
		const TCHAR* separator = _T( "................................................" );

		{
			const DWORD addStyle = LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT;
			CRect rect;

			{
				mReportListCtrl.GetWindowRect( rect );

				mReportListCtrl.InsertColumn( 0, _T( "" ),	LVCFMT_LEFT, int( rect.Width() * 0.4f ) );
				mReportListCtrl.InsertColumn( 1, _T( "" ),	LVCFMT_LEFT, int( rect.Width() * 0.13f ) );
				mReportListCtrl.InsertColumn( 2, _T( "" ),	LVCFMT_LEFT, int( rect.Width() * 0.17f ) );
				mReportListCtrl.InsertColumn( 3, _T( "" ),	LVCFMT_LEFT, int( rect.Width() * 0.3f ) );
				mReportListCtrl.SetExtendedStyle( mReportListCtrl.GetExtendedStyle() | addStyle );

				// 헤더
				{
					const DWORD row = mReportListCtrl.GetItemCount();

					CString textName;
					textName.LoadString( IDS_STRING20 );
					mReportListCtrl.InsertItem( row, textName, 0 );

					CString textLevel;
					textLevel.LoadString( IDS_STRING5 );
					mReportListCtrl.SetItemText( row, 1, textLevel );

					CString textSkillPoint;
					textSkillPoint.LoadString( IDS_STRING96 );
					mReportListCtrl.SetItemText( row, 2, textSkillPoint );

					CString textMoney;
					textMoney.LoadString( IDS_STRING199 );
					mReportListCtrl.SetItemText( row, 3, textMoney );
				}
				
				// 구분선
				{
					const DWORD row = mReportListCtrl.GetItemCount();

					mReportListCtrl.InsertItem( row, separator, 0 );
					mReportListCtrl.SetItemText( row, 1, separator );
					mReportListCtrl.SetItemText( row, 2, separator );
					mReportListCtrl.SetItemText( row, 3, separator );
				}
			}
		}

		const CSkillDialog* dialog = mApplication.GetSkillDialog();
		ASSERT( dialog );

		const CSkillDialog::SkillMap& skillMap = dialog->mSkillMap;

		
		DWORD usedMoney = 0;
		DWORD usedPoint = 0;

		for(
			CSkillDialog::SkillMap::const_iterator it = skillMap.begin();
			skillMap.end() != it;
			++it )
		{
			const SKILL_BASE& skill = it->second;

			for( int level = 1; level <= skill.Level; ++level )
			{
				const ActiveSkillScript* script = mApplication.GetActiveSkillScript( skill.wSkillIdx / 100 * 100 + level );

				if( ! script )
				{
					continue;
				}

				{
					const DWORD row = mReportListCtrl.GetItemCount();

					mReportListCtrl.InsertItem( row, script->mName, 0 );

					CString text;
					text.Format( _T( "%d" ), level );
					mReportListCtrl.SetItemText( row, 1, text );

					text.Format( _T( "%d" ), script->mPoint );
					mReportListCtrl.SetItemText( row, 2, text );

					text.Format( _T( "%d" ), script->mMoney );
					mReportListCtrl.SetItemText( row, 3, text );
				}

				{
					usedMoney += script->mMoney;
					usedPoint += script->mPoint;
				}
			}
		}

		if( skillMap.empty() )
		{
			const DWORD row = mReportListCtrl.GetItemCount();

			CString textEmpty;
			textEmpty.LoadString( IDS_STRING203 );

			mReportListCtrl.InsertItem( row, textEmpty, 0 );
		}

		// 구분선
		{
			const DWORD row = mReportListCtrl.GetItemCount();

			mReportListCtrl.InsertItem( row, separator, 0 );
			mReportListCtrl.SetItemText( row, 1, separator );
			mReportListCtrl.SetItemText( row, 2, separator );
			mReportListCtrl.SetItemText( row, 3, separator );
		}

		// 결과
		{
			const DWORD row = mReportListCtrl.GetItemCount();

			CString textSum;
			textSum.LoadString( IDS_STRING204 );

			mReportListCtrl.InsertItem( row, textSum, 0 );

			CString text;
			text.Format( _T( "%d" ), usedPoint );
			mReportListCtrl.SetItemText( row, 2, text );

			text.Format( _T( "%d" ), usedMoney );
			mReportListCtrl.SetItemText( row, 3, text );
		}
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
Exemple #9
0
//---------------------------------------------------------------------------
// Function name        : RecalLayout
// Description    : 
//---------------------------------------------------------------------------
void CRollupCtrl::RecalLayout()
{
        //Check StartPosY
        CRect r; GetClientRect(&r);
        int BottomPagePos = m_StartYPos+m_PageHeight;

        int nWidth      = r.Width();
        int nHeight = r.Height();
        if (BottomPagePos<nHeight)              m_StartYPos = nHeight-m_PageHeight;
        if (m_StartYPos>0)                                              m_StartYPos = 0;

        ////////////////////////////////////////////
        //Calc new pages's positions 
        // used column sub-divisions if necessary
        int nPageWidth = nWidth-RC_SCROLLBARWIDTH;

        if (m_bEnabledAutoColumns)
        {
                nPageWidth=m_nColumnWidth;
                if (nPageWidth>nWidth-RC_SCROLLBARWIDTH)
                        nPageWidth=nWidth-RC_SCROLLBARWIDTH;
        }

        int posx=0;
        int posy=0;
        int nMaxHeight=-1;

        CArray<CPoint, CPoint&> carrayPos;

        for (int i=0; i<m_PageList.GetSize(); i++)
        {
                RC_PAGEINFO* pi = m_PageList[i];

                //Page Height
                int nCurPageHeight=RC_PGBUTTONHEIGHT+(RC_GRPBOXINDENT/2);
                if (pi->bExpanded && pi->bEnable)
                {
                        CRect tr; pi->pwndTemplate->GetWindowRect(&tr);
                        nCurPageHeight+=tr.Height();
                }

                //Split to a new column ?
                if (m_bEnabledAutoColumns && ((nWidth-posx-m_nColumnWidth-RC_SCROLLBARWIDTH )>m_nColumnWidth) && i!=0 && (posy+(nCurPageHeight/2))>nHeight)
                {
                        posx+=m_nColumnWidth;   //New column
                        posy=0;
                }

                CPoint cpos(posx, posy);
                carrayPos.Add(cpos);
                
                posy+=nCurPageHeight;
                if (posy>nMaxHeight)    nMaxHeight=posy;
        }

        if (nMaxHeight!=-1)
        {
                m_PageHeight=nMaxHeight;

                BottomPagePos = m_StartYPos+m_PageHeight;
                if (BottomPagePos<nHeight)              m_StartYPos = nHeight-m_PageHeight;
                if (m_StartYPos>0)                                              m_StartYPos = 0;
        }

        ////////////////////////////////////////////
        //Update children windows position
        HDWP hdwp = BeginDeferWindowPos((int)m_PageList.GetSize()*3);   //*3 for pwndButton+pwndTemplate+pwndGroupBox
        if (hdwp)
        {

                int posx=0;
                int posy=m_StartYPos;

                for (int i=0; i<m_PageList.GetSize(); i++)
                {
                        RC_PAGEINFO* pi = m_PageList[i];

                        posx=carrayPos[i].x;
                        posy=carrayPos[i].y+m_StartYPos;

                        //Enable-Disable Button
                        pi->pwndButton->SetCheck(pi->bEnable&pi->bExpanded);
                        pi->pwndButton->EnableWindow(pi->bEnable);

                        //Update Button's position and size

                        //Expanded
                        if (pi->bExpanded && pi->bEnable)       
                        {
                                CRect tr; pi->pwndTemplate->GetWindowRect(&tr);

                                //Update GroupBox position and size
                                DeferWindowPos(hdwp, pi->pwndGroupBox->m_hWnd, 0, posx+2, posy, nPageWidth-3, tr.Height()+RC_PGBUTTONHEIGHT+RC_GRPBOXINDENT-4, SWP_NOZORDER|SWP_SHOWWINDOW);

                                //Update Template position and size
                                DeferWindowPos(hdwp, pi->pwndTemplate->m_hWnd, 0, posx+RC_GRPBOXINDENT, posy+RC_PGBUTTONHEIGHT, nPageWidth-(RC_GRPBOXINDENT*2), tr.Height(), SWP_NOZORDER);

                                //Update Button's position and size
                                DeferWindowPos(hdwp, pi->pwndButton->m_hWnd, 0, posx+RC_GRPBOXINDENT, posy, nPageWidth-(RC_GRPBOXINDENT*2), RC_PGBUTTONHEIGHT, SWP_NOZORDER|SWP_SHOWWINDOW);

                        //Collapsed
                        } else {        

                                //Update GroupBox position and size
                                DeferWindowPos(hdwp, pi->pwndGroupBox->m_hWnd, 0, posx+2, posy, nPageWidth-3, 16, SWP_NOZORDER|SWP_SHOWWINDOW);

                                //Update Template position and size
                                DeferWindowPos(hdwp, pi->pwndTemplate->m_hWnd, 0, posx+RC_GRPBOXINDENT, 0, 0, 0,SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);

                                //Update Button's position and size
                                DeferWindowPos(hdwp, pi->pwndButton->m_hWnd, 0, posx+RC_GRPBOXINDENT, posy, nPageWidth-(RC_GRPBOXINDENT*2), RC_PGBUTTONHEIGHT, SWP_NOZORDER|SWP_SHOWWINDOW);

                        }

                }
                EndDeferWindowPos(hdwp);
        }

        ////////////////////////////////////////////
        //Update children windows visibility
        hdwp = BeginDeferWindowPos((int)m_PageList.GetSize());
        if (hdwp)
        {

                for (int i=0; i<m_PageList.GetSize(); i++){
                        RC_PAGEINFO* pi = m_PageList[i];

                        //Expanded
                        if (pi->bExpanded && pi->bEnable) {
                                DeferWindowPos(hdwp, pi->pwndTemplate->m_hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
                        //Collapsed
                        } else {
                                DeferWindowPos(hdwp, pi->pwndTemplate->m_hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
                        }

                }
                EndDeferWindowPos(hdwp);
        }


        //////////////////////////////////////////
        //Update Scroll Bar
        CRect br = CRect(r.right-RC_SCROLLBARWIDTH,r.top, r.right, r.bottom);
        InvalidateRect(&br, FALSE);
        UpdateWindow();

}
Exemple #10
0
void CViewSockTrackerImage::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// 這邊畫 圖片
	/////////////////////////////////////////////////////////////////////
	CRect RectImage;
	GetClientRect( &RectImage );
	if(m_pBitmap != NULL && csInfomation == "" )  
	{  
		CBitmap   bmp;  
		if(bmp.Attach(m_pBitmap))  
		{  
			CString csW = _T("");
			
			BITMAP   bmpInfo;  
			bmp.GetBitmap(&bmpInfo);  
			
			CDC   dcMemory;  
			dcMemory.CreateCompatibleDC(pDC);  
			dcMemory.SelectObject(&bmp);  
			pDC->SetStretchBltMode(HALFTONE);  
			pDC->StretchBlt(RectImage.left,RectImage.top,RectImage.Width(),RectImage.Height(),&dcMemory,0,0,
				bmpInfo.bmWidth,bmpInfo.bmHeight,SRCCOPY);  
			bmp.Detach();

			//
			m_w = bmpInfo.bmWidth;
			m_h = bmpInfo.bmHeight;
		}  
	}  
	//

	// 這邊畫 Pattern ROI 
	/////////////////////////////////////////////////////////////////////
	if(m_pBitmap != NULL && csInfomation == "" )  
	{
		CRect rect;	
		COLORREF color = RGB(255, 255, 0);
		m_AlignRectTracker.SetRectColor( color );
		m_AlignRectTracker.GetTrueRect(&rect); 
		if( m_bLoadRect )
		{
			m_bLoadRect = false;
			m_AlignRectTracker.m_rect = m_LoadRect;
			m_AlignRectTracker.Draw( pDC, m_LoadRect );
		}
		else
			m_AlignRectTracker.Draw( pDC );
	}
	/////////////////////////////////////////////////////////////////////

	if( csInfomation != "" )
	{
		CRect RectText;
		GetClientRect( &RectText );
		int x = 0;
		int y = 0;		

		x = 20;
		y = RectText.Height() / 2;

		pDC->TextOut( x, y, csInfomation );
		pDC->TextOut( x, y + 15 , "Image is lost" );
		csInfomation = "";
	}

	// 
	m_pBitmap = NULL;
}
void CSAPrefsStatic::MakeCaptionBitmap()
{
	if (m_bm.m_hObject)
		return;								   // already have bitmap; return

   CRect cr;
   GetClientRect(cr);
   int w = cr.Width();
   int h = cr.Height();

	// Create bitmap same size as caption area and select into memory DC
	//
	CWindowDC dcWin(this);
	CDC dc;
	dc.CreateCompatibleDC(&dcWin);
	m_bm.DeleteObject();
	m_bm.CreateCompatibleBitmap(&dcWin, w, h);
	CBitmap* pOldBitmap = dc.SelectObject(&m_bm);

   COLORREF clrBG = ::GetSysColor(COLOR_ACTIVECAPTION); // background color
	int r = GetRValue(clrBG);				// red..
	int g = GetGValue(clrBG);				// ..green
	int b = GetBValue(clrBG);				// ..blue color vals
	int x = 8*cr.right/8;					// start 5/6 of the way right
	int w1 = x - cr.left;					// width of area to shade

   int NCOLORSHADES = 1;		// this many shades in gradient

	int xDelta= max( w / NCOLORSHADES , 1);	// width of one shade band

	PaintRect(dc, x, 0, cr.right-x, h, clrBG);

	while (x > xDelta) 
   {												// paint bands right to left
		x -= xDelta;							// next band
		int wmx2 = (w1-x)*(w1-x);			// w minus x squared
		int w2  = w1*w1;						// w squared
		PaintRect(dc, x, 0, xDelta, h,	
			RGB(r-(r*wmx2)/w2, g-(g*wmx2)/w2, b-(b*wmx2)/w2));
	}

	PaintRect(dc,0,0,x,h,RGB(GetRValue(clrBG),GetGValue(clrBG),GetBValue(clrBG)));  // whatever's left ==> black

	// draw the 'constant' text

	// create a font, if we need to
	if (m_nameFont.GetSafeHandle()==NULL)
	{
		m_nameFont.CreateFont( 18, 0, 0, 0, FW_BOLD,
											0, 0, 0, ANSI_CHARSET,
											OUT_DEFAULT_PRECIS,
											CLIP_DEFAULT_PRECIS,
											DEFAULT_QUALITY,
											FF_MODERN,
											m_csFontName);	
	}

	CFont * OldFont = dc.SelectObject(&m_nameFont);

	// restore old font
	dc.SelectObject(OldFont);

	// Restore DC
	dc.SelectObject(pOldBitmap);
}
void CSkinListBox::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	//没有节点就不用继续执行了
	if( GetCount()==0 ) return;

	//变量定义
	CRect rcItem=lpDrawItemStruct->rcItem;
	CDC * pDCControl=CDC::FromHandle(lpDrawItemStruct->hDC);

 	//创建缓冲
 	CDC BufferDC;
 	CBitmap ImageBuffer;
 	BufferDC.CreateCompatibleDC(pDCControl);
 	ImageBuffer.CreateCompatibleBitmap(pDCControl,rcItem.Width(),rcItem.Height());
 
 	//设置环境
 	BufferDC.SelectObject(&ImageBuffer);
	BufferDC.SelectObject(GetCtrlFont());

	//获取字符
	CString strString;
	GetText(lpDrawItemStruct->itemID,strString);

	//计算位置
	CRect rcString;
	rcString.SetRect(4,0,rcItem.Width()-8,rcItem.Height());

	//颜色定义
	COLORREF crTextColor=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0)?m_colSelectText:m_colNormalText;

	//绘画背景
	BufferDC.FillSolidRect(0,0,rcItem.Width(),rcItem.Height(),m_colBack);

	//节点选中
	if ( (lpDrawItemStruct->itemState&ODS_SELECTED) != 0 )
	{
		if ( m_pSelectImg!= NULL && !m_pSelectImg->IsNull() )
		{
			m_pSelectImg->Draw(&BufferDC,CRect(0,0,rcItem.Width(),rcItem.Height()));
		}
	}

	//节点高亮
	else if ( m_nHovenItem == lpDrawItemStruct->itemID )
	{
		if ( m_pBackImgH!= NULL && !m_pBackImgH->IsNull() )
		{
			m_pBackImgH->Draw(&BufferDC,CRect(0,0,rcItem.Width(),rcItem.Height()));
		}
	}

	//绘画字符
	BufferDC.SetBkMode(TRANSPARENT);
	BufferDC.SetTextColor(crTextColor);
	BufferDC.DrawText(strString,&rcString,DT_VCENTER|DT_SINGLELINE);

	//绘画界面
	pDCControl->BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),&BufferDC,0,0,SRCCOPY);

 	//清理资源
 	BufferDC.DeleteDC();
 	ImageBuffer.DeleteObject();
}
Exemple #13
0
// Show      - Show the titletip if needed.
// rectTitle - The rectangle within which the original title
//             is constrained - in client coordinates.
// cpcTitleText - The text to be displayed.
// nOffsetX  - Number of pixels that the text is offset from
//             the left border of the cell.
void
ZTitleTip::Show( CRect rectTitle, zCPCHAR cpcTitleText,
                 int nOffsetX /* = 0 */,
                 LPRECT pHoverRect /* = 0 */,
                 const LOGFONT *pLogFont /* = 0 */,
                 COLORREF clrText /* = CLR_DEFAULT */,
                 COLORREF clrBack /* = CLR_DEFAULT */ )
{
#ifdef DEBUG_ALL
   TraceLine( "ZTitleTip::Show %s   Delay: %d", cpcTitleText, m_lHoverDelay );
#endif

   CString csTitle = _T( " " );
   csTitle += cpcTitleText;
   csTitle += _T( " " );
   if ( rectTitle == m_rectTitle && m_csTitle == csTitle )
      return;

// TraceLine( "ZTitleTip::Show csTitle: %s   m_csTitle: %s", csTitle, m_csTitle );
// TraceRect( "ZTitleTip::Show rectTitle: ", rectTitle );
// TraceRect( "ZTitleTip::Show m_rectTitle: ", m_rectTitle );

   m_csTitle = csTitle;

   if ( mIs_hWnd( m_hWnd ) == 0 )
      Create( m_pParentWnd );

   ASSERT( ::IsWindow( GetSafeHwnd( ) ) );
   if ( mIs_hWnd( m_hWnd ) == 0 )
      return;

   m_rectHover = pHoverRect ? pHoverRect : rectTitle;
   m_rectHover.right++;
   m_rectHover.bottom++;

// TraceRect( "ZTitleTip::Show Hover1", m_rectHover );
   m_pParentWnd->ClientToScreen( m_rectHover );
// TraceRect( "ZTitleTip::Show Hover2", m_rectHover );

   m_nOffsetX = nOffsetX;
   m_clrText = clrText;
   m_clrBack = clrBack;
#if 0
   // Define the rectangle outside which the titletip will be hidden.
   // We add a buffer of one pixel around the rectangle.
   m_rectTitle.top    = -1;
   m_rectTitle.left   = -m_nOffsetX - 1;
   m_rectTitle.right  = rectTitle.Width( ) - m_nOffsetX;
   m_rectTitle.bottom = rectTitle.Height( ) + 1;
#else
   m_rectTitle = rectTitle;
#endif
// TraceRect( "ZTitleTip::Show rectTitle: ", m_rectTitle );

   // If window is not valid, display rect is empty, text is empty,
   // title tip is already displayed, or app does not have focus ...
   // don't do anything.
   if ( mIs_hWnd( m_hWnd ) == 0 || rectTitle.IsRectEmpty( ) ||
        cpcTitleText == 0 || *cpcTitleText == 0 ||
        mIs_hWndVisible( m_hWnd ) || GetFocus( ) == 0 )
   {
      return;
   }

   if ( m_lHoverDelay > 0 )
   {
      if ( m_uToolTipTimerId )
         KillTimer( m_uToolTipTimerId );

      m_uToolTipTimerId = SetTimer( g_nIdShowTitleTipEvt, m_lHoverDelay, 0 );
   }
   else
   {
      DrawTipText( 1 );
   }

   SetCapture( );
}
Exemple #14
0
void
ZTitleTip::DrawTipText( int nId )
{
// TraceLineI( "ZTitleTip::DrawTipText Id: ", nId );
   CClientDC dc( this );
   CFont     *pFontDC;
   int       nOldMode = dc.SetBkMode( TRANSPARENT );

// if ( pLogFont )
// {
//    CFont font;
//    font.CreateFontIndirect( pLogFont );
//    pFontDC = dc.SelectObject( &font );
// }
// else
   {
      // Use same font as ctrl.
      pFontDC = dc.SelectObject( m_pParentWnd->GetFont( ) );
   }

   CSize size = dc.GetTextExtent( m_csTitle );

   TEXTMETRIC tm;
   dc.GetTextMetrics( &tm );
   size.cx += tm.tmOverhang;

   // Determine the width of the text.
   CRect rectTitle = m_rectTitle;
   m_pParentWnd->ClientToScreen( rectTitle );

   CRect rectDisplay = rectTitle;
   rectDisplay.left += m_nOffsetX;
   rectDisplay.right = rectDisplay.left + size.cx + m_nOffsetX;

   CRect rectExtent = rectTitle;
   int nTextHeight = dc.DrawText( m_csTitle, rectExtent, DT_CALCRECT | DT_TOP );

   // Do not display if the text fits within available space.
   if ( nTextHeight > size.cy ||
        rectDisplay.right > rectTitle.right - m_nOffsetX )
   {
      // Show the titletip.
      if ( nTextHeight > size.cy )
         SetWindowPos( &wndTop, rectDisplay.left, rectDisplay.top,
                       rectExtent.Width( ) + 4, nTextHeight + 2,
                       SWP_SHOWWINDOW | SWP_NOACTIVATE );
      else
         SetWindowPos( &wndTop, rectDisplay.left, rectDisplay.top,
                       rectDisplay.Width( ), rectDisplay.Height( ),
                       SWP_SHOWWINDOW | SWP_NOACTIVATE );

      // FNA - handle colors correctly.
      if ( m_clrBack != CLR_DEFAULT )
      {
         CBrush brushBk( m_clrBack );
         CBrush *pOldBrush = dc.SelectObject( &brushBk );
         CRect rect;
         dc.GetClipBox( &rect );     // Erase the area needed

         dc.PatBlt( rect.left, rect.top, rect.Width( ),
                    rect.Height( ), PATCOPY );
         dc.SelectObject( pOldBrush );
      }

      // Set color.
      if ( m_clrText != CLR_DEFAULT )  // FNA
         dc.SetTextColor( m_clrText ); // FA

   // dc.SetBkMode( TRANSPARENT );
      if ( nTextHeight > size.cy )
      {
         rectDisplay.top = 0;
         rectDisplay.right -= rectDisplay.left;
         rectDisplay.left = 0;
         rectDisplay.bottom = rectDisplay.top + nTextHeight + 2;
         dc.DrawText( m_csTitle, rectDisplay, DT_TOP );
      }
      else
      {
         dc.TextOut( 0, 0, m_csTitle );
      }
   }
   else
   {
      Hide( );
   }

   dc.SetBkMode( nOldMode );
   dc.SelectObject( pFontDC );
}
Exemple #15
0
LRESULT CView::OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(uMsg);
	UNREFERENCED_PARAMETER(wParam);
	UNREFERENCED_PARAMETER(lParam);

	if (m_pPicture)
	{
		CRect rcImage = GetImageRect();
		DWORD dwStyle = (DWORD)GetWindowLongPtr(GWL_STYLE);
		DWORD dwExStyle = (DWORD)GetWindowLongPtr(GWL_EXSTYLE);
		AdjustWindowRectEx(&rcImage, dwStyle, FALSE, dwExStyle);

		CRect rcView = GetClientRect();
		AdjustWindowRectEx(&rcView, dwStyle, FALSE, dwExStyle);

		SCROLLINFO si;
		ZeroMemory(&si, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
		si.nMin   = 0;

		if (rcView.Width()  >= rcImage.Width())
		{
			m_xCurrentScroll = 0;
			ShowScrollBar(SB_HORZ, FALSE);
		}
		else
		{
			si.nMax   = rcImage.Width();
			si.nPage  = rcView.Width();
			si.nPos   = m_xCurrentScroll;
			SetScrollInfo(SB_HORZ, si, TRUE);
			ShowScrollBar(SB_HORZ, TRUE);
		}

		if (rcView.Height() >= rcImage.Height())
		{
			m_yCurrentScroll = 0;
			ShowScrollBar(SB_VERT, FALSE);
		}
		else
		{
			si.nMax   = rcImage.Height();
			si.nPage  = rcView.Height();
			si.nPos   = m_yCurrentScroll;
			SetScrollInfo(SB_VERT, si, TRUE);
			ShowScrollBar(SB_VERT, TRUE);
		}

		int xNewPos = MIN(m_xCurrentScroll, rcImage.Width() - rcView.Width());
		m_xCurrentScroll = MAX(xNewPos, 0);
		int yNewPos = MIN(m_yCurrentScroll, rcImage.Height() - rcView.Height());
		m_yCurrentScroll = MAX(yNewPos, 0);

		// Paint the window directly to eliminate flicker
		CClientDC dcView(*this);
		Paint(dcView);
	}

	return 0L;
}
// Show 		 - Show the titletip if needed
// rectTitle	 - The rectangle within which the original 
//				    title is constrained - in client coordinates
// lpszTitleText - The text to be displayed
// xoffset		 - Number of pixel that the text is offset from
//				   left border of the cell
void Printing::CPntTitleTip::Show(CRect rectTitle, LPCTSTR lpszTitleText, int xoffset /*=0*/,
                     LPRECT lpHoverRect /*=NULL*/,
                     const LOGFONT* lpLogFont /*=NULL*/,
                     COLORREF crTextClr /* CLR_DEFAULT */,
                     COLORREF crBackClr /* CLR_DEFAULT */)
{
    if (!IsWindow(m_hWnd))
        Create(m_pParentWnd);

	ASSERT( ::IsWindow( GetSafeHwnd() ) );

    if (rectTitle.IsRectEmpty())
        return;

	// If titletip is already displayed, don't do anything.
	if( IsWindowVisible() ) 
		return;

    m_rectHover = (lpHoverRect != NULL)? lpHoverRect : rectTitle;
    m_rectHover.right++; m_rectHover.bottom++;

	m_pParentWnd->ClientToScreen( m_rectHover );
    ScreenToClient( m_rectHover );

	// Do not display the titletip is app does not have focus
	if( GetFocus() == NULL )
		return;

	// Define the rectangle outside which the titletip will be hidden.
	// We add a buffer of one pixel around the rectangle
	m_rectTitle.top    = -1;
	m_rectTitle.left   = -xoffset-1;
	m_rectTitle.right  = rectTitle.Width()-xoffset;
	m_rectTitle.bottom = rectTitle.Height()+1;

	// Determine the width of the text
	m_pParentWnd->ClientToScreen( rectTitle );

	CClientDC dc(this);
	CString strTitle = _T("");
    strTitle += _T(" ");
    strTitle += lpszTitleText; 
    strTitle += _T(" ");

	CFont font, *pOldFont = NULL;
    if (lpLogFont)
    {
        font.CreateFontIndirect(lpLogFont);
	    pOldFont = dc.SelectObject( &font );
    }
    else
    {
        // use same font as ctrl
	    pOldFont = dc.SelectObject( m_pParentWnd->GetFont() );
    }

	CSize size = dc.GetTextExtent( strTitle );

    TEXTMETRIC tm;
    dc.GetTextMetrics(&tm);
    size.cx += tm.tmOverhang;

	CRect rectDisplay = rectTitle;
	rectDisplay.left += xoffset;
	rectDisplay.right = rectDisplay.left + size.cx + xoffset;
    
    // Do not display if the text fits within available space
    if ( rectDisplay.right > rectTitle.right-xoffset )
    {
		// Show the titletip
        SetWindowPos( &wndTop, rectDisplay.left, rectDisplay.top, 
            rectDisplay.Width(), rectDisplay.Height(), 
            SWP_SHOWWINDOW|SWP_NOACTIVATE );
        
        // FNA - handle colors correctly
        if (crBackClr != CLR_DEFAULT)
        {
		    CBrush backBrush(crBackClr);
		    CBrush* pOldBrush = dc.SelectObject(&backBrush);
		    CRect rect;
		    dc.GetClipBox(&rect);     // Erase the area needed 

		    dc.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),  PATCOPY);
		    dc.SelectObject(pOldBrush);
	    }
        // Set color
        if (crTextClr != CLR_DEFAULT)//FNA
            dc.SetTextColor(crTextClr);//FA

        dc.SetBkMode( TRANSPARENT );
        dc.TextOut( 0, 0, strTitle );
        SetCapture();
    }
    
    dc.SelectObject( pOldFont );
}
//*****************************************************************************
void CBCGPCaptionBar::OnDrawButton (CDC* pDC, CRect rect, 
								   const CString& strButton, BOOL bEnabled)
{
	ASSERT_VALID (pDC);

	COLORREF clrText = CBCGPVisualManager::GetInstance ()->OnFillCaptionBarButton (pDC, this,
		rect, m_bIsBtnPressed || m_bIsBtnForcePressed, m_bIsBtnHighlighted, !m_bBtnEnabled,
		m_bBtnHasDropDownArrow, FALSE);

	CRect rectText = rect;
	rectText.DeflateRect (m_nHorzElementOffset, 0);

	if (m_bIsMessageBarMode)
	{
		rectText.DeflateRect (nButtonHorzMargin, 0);
	}

	if (m_uiBtnID != 0 && bEnabled && m_bBtnHasDropDownArrow)
	{
		rectText.right -= nMenuArrowWidth;
	}

	COLORREF clrTextOld = (COLORREF)-1;
	if (clrText != (COLORREF)-1)
	{
		clrTextOld = pDC->SetTextColor (clrText);
	}

	pDC->DrawText (strButton, rectText,
					DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER);

	if (clrTextOld != (COLORREF)-1)
	{
		pDC->SetTextColor (clrTextOld);
	}

	if (m_uiBtnID != 0 && bEnabled)
	{
		if (m_uiBtnID != 0 && m_bBtnHasDropDownArrow)
		{
			// Draw menu triangle:
			CRect rectArrow = rect;
			rectArrow.top = rectArrow.CenterPoint().y - nMenuArrowWidth / 2;
			rectArrow.bottom = rectArrow.top + nMenuArrowWidth;
			rectArrow.left = rectText.right;

			int iXMiddle = rectArrow.left + rectArrow.Width () / 2;

			rectArrow.DeflateRect (0, rectArrow.Height () / 3);
			rectArrow.DeflateRect (rectArrow.Height () / 3, rectArrow.Height () / 3);
			rectArrow.left = iXMiddle - rectArrow.Height () - 1;
			rectArrow.right = iXMiddle + rectArrow.Height () + 1;

			int iHalfWidth =	(rectArrow.Width () % 2 != 0) ?
								(rectArrow.Width () - 1) / 2 :
								rectArrow.Width () / 2;

			CPoint pts [3];
			pts[0].x = rectArrow.left;
			pts[0].y = rectArrow.top;
			pts[1].x = rectArrow.right;
			pts[1].y = rectArrow.top;
			pts[2].x = rectArrow.left + iHalfWidth;
			pts[2].y = rectArrow.bottom + 1;

			CBrush brArrow (globalData.IsHighContastMode() ? globalData.clrWindowText : pDC->GetTextColor ());

			CPen* pOldPen = (CPen*) pDC->SelectStockObject (NULL_PEN);
			CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brArrow);

			pDC->SetPolyFillMode (WINDING);
			pDC->Polygon (pts, 3);

			pDC->SelectObject (pOldBrush);
			pDC->SelectObject (pOldPen);
		}

		CBCGPVisualManager::GetInstance ()->OnDrawCaptionBarButtonBorder (pDC, this,
			rect, m_bIsBtnPressed || m_bIsBtnForcePressed, m_bIsBtnHighlighted, !m_bBtnEnabled,
			m_bBtnHasDropDownArrow, FALSE);
	}
}	
Exemple #18
0
void CImageDisp::DisplayWithoutZoom(CDC *pDC)
{
    CRect client; GetClientRect(&client);

    m_ZoomX = m_ZoomY = 1.;
    m_Disp.SetRect(0, 0, min(m_pDib->Width(), client.Width()), min(m_pDib->Height(), client.Height()));

    if ((m_pDib->Width()>client.Width()) || (m_pDib->Height()>client.Height())) {
      CRect target;
      target.SetRect(0, 0, min(m_pDib->Width(), client.Width()), min(m_pDib->Height(), client.Height()));
      if (m_bCentering) {
        CPoint Scroll(0,0);
        if (client.Width()>m_pDib->Width()) Scroll.x = (client.Width()-m_pDib->Width())/2;
        if (client.Height()>m_pDib->Height()) Scroll.y = (client.Height()-m_pDib->Height())/2;
        target += Scroll;
      }
      m_Disp = target;

      CRect source;
      if (m_pDib->Height()>client.Height()) source.SetRect(0, m_pDib->Height()-client.Height(), min(m_pDib->Width(), client.Width()), m_pDib->Height());
      else source = target;
      m_pDib->LoadPaletteImage(pDC, &target, &source);
    }
    else {
      if (m_bCentering) {
        CPoint Scroll(0,0);
        Scroll.x = (client.Width()-m_pDib->Width())/2;
        Scroll.y = (client.Height()-m_pDib->Height())/2;
        m_Disp += Scroll;
        m_pDib->LoadPaletteImage(pDC, &m_Disp);
      }
      else m_pDib->LoadPaletteImage(pDC);
    }
}
Exemple #19
0
BOOL CResizableLayout::NeedsRefresh(const CResizableLayout::LayoutInfo& layout,
                                    const CRect& rectOld, const CRect& rectNew)
{
    if (layout.bMsgSupport)
    {
        REFRESHPROPERTY refresh;
        refresh.rcOld = rectOld;
        refresh.rcNew = rectNew;
        if (Send_NeedsRefresh(layout.hWnd, &refresh))
            return refresh.bNeedsRefresh;
    }

    int nDiffWidth = (rectNew.Width() - rectOld.Width());
    int nDiffHeight = (rectNew.Height() - rectOld.Height());

    // is the same size?
    if (nDiffWidth == 0 && nDiffHeight == 0)
        return FALSE;

    // optimistic, no need to refresh
    BOOL bRefresh = FALSE;

    // window classes that need refresh when resized
    if (layout.sWndClass == WC_STATIC)
    {
//mpc-hc custom code start
        LONG_PTR style = ::GetWindowLongPtr(layout.hWnd, GWL_STYLE);
//mpc-hc custom code end

        switch (style & SS_TYPEMASK)
        {
        case SS_LEFT:
        case SS_CENTER:
        case SS_RIGHT:
            // word-wrapped text
            bRefresh = bRefresh || (nDiffWidth != 0);
            // vertically centered text
            if (style & SS_CENTERIMAGE)
                bRefresh = bRefresh || (nDiffHeight != 0);
            break;

        case SS_LEFTNOWORDWRAP:
            // text with ellipsis
            if (style & SS_ELLIPSISMASK)
                bRefresh = bRefresh || (nDiffWidth != 0);
            // vertically centered text
            if (style & SS_CENTERIMAGE)
                bRefresh = bRefresh || (nDiffHeight != 0);
            break;

        case SS_ENHMETAFILE:
        case SS_BITMAP:
        case SS_ICON:
            // images
        case SS_BLACKFRAME:
        case SS_GRAYFRAME:
        case SS_WHITEFRAME:
        case SS_ETCHEDFRAME:
            // and frames
            bRefresh = TRUE;
            break;
        }
    }

    // window classes that don't redraw client area correctly
    // when the hor scroll pos changes due to a resizing
    BOOL bHScroll = FALSE;
    if (layout.sWndClass == WC_LISTBOX)
        bHScroll = TRUE;

    // fix for horizontally scrollable windows
    if (bHScroll && (nDiffWidth > 0))
    {
        // get max scroll position
        SCROLLINFO info;
        info.cbSize = sizeof(SCROLLINFO);
        info.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
        if (::GetScrollInfo(layout.hWnd, SB_HORZ, &info))
        {
            // subtract the page size
            info.nMax -= __max(info.nPage-1,0);
        }

        // resizing will cause the text to scroll on the right
        // because the scrollbar is going beyond the right limit
        if ((info.nMax > 0) && (info.nPos + nDiffWidth > info.nMax))
        {
            // needs repainting, due to horiz scrolling
            bRefresh = TRUE;
        }
    }

    return bRefresh;
}
Exemple #20
0
void CImageDisp::DisplayShrinkOnly(CDC *pDC)
{
    CRect client; GetClientRect(&client);

    if ((client.Width()<m_pDib->Width()) || (client.Height()<m_pDib->Height())) {
      double xz = (double) client.Width() / (double) m_pDib->Width();
      double yz = (double) client.Height() / (double) m_pDib->Height();
      xz = min(xz, yz);
      yz = xz;
      m_ZoomX = xz;
      m_ZoomY = yz;
      int width = (int) (((double) m_pDib->Width()) * xz);
      int height = (int) (((double) m_pDib->Height()) * yz);
      CRect disp;
      if (m_bCentering) {
        disp.left = (client.Width() - width)/2;
        disp.top = (client.Height() - height)/2;
        disp.right = disp.left + width;
        disp.bottom = disp.top + height;
      }
      else {
        disp.left = 0; 
        disp.top = 0; 
        disp.right = width; 
        disp.bottom = height; 
      }
      m_Disp = disp;

      pDC->SetStretchBltMode(COLORONCOLOR);
      m_pDib->LoadPaletteImage(pDC, &disp);	
    }
    else DisplayWithoutZoom(pDC);


	// --------------------------------------------------------
	// ------------------------twkim---------------------------
	// --------------------------------------------------------
	// Clip 영역 실시간으로 그리기
	//CVisionTab *pVTDlg = (CVisionTab*)::AfxGetMainWnd();
	CVisionTab *pVTDlg = (CVisionTab*)GetParent();
	if(!pVTDlg->clip) {
		CClientDC dc(this);
		dc.SetROP2(R2_BLACK);
		dc.MoveTo(m_clipStart); dc.LineTo(m_clipStart.x, m_clipEnd.y);
		dc.MoveTo(m_clipStart); dc.LineTo(m_clipEnd.x, m_clipStart.y);
		dc.MoveTo(m_clipStart.x, m_clipEnd.y); dc.LineTo(m_clipEnd);
		dc.MoveTo(m_clipEnd.x, m_clipStart.y); dc.LineTo(m_clipEnd);
	}

	// 해당 영역의 Depth value 실시간 출력
	if(m_PointDepth.x >= 0 && m_PointDepth.y >= 0) {
		// drawing cross at the position
		DrawCross(m_PointDepth);

		// Control창에 해당 좌표의 depth 값 출력
		// 실제 이미지 크기에 맞게 좌표 조정
		CPoint rpt;
		rpt.x = (int)m_PointDepth.x/m_ZoomX;
		rpt.y = (int)m_PointDepth.y/m_ZoomY;
		
		CString str;
		str.Format("X: %d, Y: %d, Dist: %d ", rpt.x, rpt.y, pVTDlg->kinect.getDepthValue(rpt.x, rpt.y));
		pVTDlg->SetDlgItemTextA(IDC_DISPDEPTHVAL, str);
	}

}
Exemple #21
0
void CUIDesignerView::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CClientDC dc(this);
	OnPrepareDC(&dc);//Device coordinates to Logical coordinates
	dc.SetWindowOrg(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates

	CPoint ptLogical=point-m_ptDPtoLP;//Device coordinates to Logical coordinates
	ptLogical.Offset(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates

	CControlUI* pControl=m_LayoutManager.FindControl(ptLogical);
	CTrackerElement* pTracker=NULL;
	if(pControl==NULL)
		pControl=m_LayoutManager.GetForm();

	int nHit=m_MultiTracker.HitTest(ptLogical);
	int nType=GetControlType(pControl);
	if((nFlags&MK_CONTROL)==0&&nHit==hitNothing)
		m_MultiTracker.RemoveAll();
	if(nHit==hitNothing)
		m_MultiTracker.Add(CreateTracker(pControl));
	else
		m_MultiTracker.SetFocus(ptLogical);

	if(nHit>=0||nType==typeControl)
	{
		m_MultiTracker.Track(this, ptLogical, FALSE,&dc);
	}
	else
	{
		CUITracker tracker;
		int nClass=g_pToolBoxWnd->GetCurSel()->GetClass();
		CRect rect;
		if (tracker.TrackRubberBand(this, point, TRUE))
		{
			rect=tracker.GetRect();
			rect.NormalizeRect();
			rect.OffsetRect(-FORM_OFFSET_X,-FORM_OFFSET_Y);
			if(rect.Width()<10&&rect.Height()<10)
				rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT);
		}
		else
		{
			rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT);
		}

		if(nClass>classPointer)
		{
			CControlUI* pNewControl=m_LayoutManager.NewUI(nClass, rect, pControl, &m_LayoutManager);
			CArray<CControlUI*,CControlUI*> arrSelected;
			arrSelected.Add(pNewControl);
			m_UICommandHistory.Begin(arrSelected, actionAdd);
			m_UICommandHistory.End();
			g_pClassView->InsertUITreeItem(pNewControl);
			g_pToolBoxWnd->SetCurSel(classPointer);

			m_MultiTracker.RemoveAll();
			m_MultiTracker.Add(CreateTracker(pNewControl));
			this->GetDocument()->SetModifiedFlag();
		}
	}

	g_pClassView->SelectUITreeItem(m_MultiTracker.GetFocused());
	if(m_MultiTracker.GetSize()==1)
		g_pPropertiesWnd->ShowProperty(m_MultiTracker.GetFocused());
	else
		g_pPropertiesWnd->ShowProperty(NULL);
	
	this->Invalidate(FALSE);

// 	__super::OnLButtonDown(nFlags, point);
}
Exemple #22
0
void CImageDisp::DisplayFitToWindow(CDC *pDC)
{
    CRect client; GetClientRect(&client);

    double xz = (double) client.Width() / (double) m_pDib->Width();
    double yz = (double) client.Height() / (double) m_pDib->Height();
	// TODO
    xz = min(xz, yz);
    yz = xz;
    m_ZoomX = xz;
    m_ZoomY = yz;
    int width = (int) (((double) m_pDib->Width()) * xz);
    int height = (int) (((double) m_pDib->Height()) * yz);
    CRect disp;
    if (m_bCentering) {
      disp.left = (client.Width() - width)/2;
      disp.top = (client.Height() - height)/2;
      disp.right = disp.left + width;
      disp.bottom = disp.top + height;
    }
    else {
      disp.left = 0; 
      disp.top = 0; 
      disp.right = width; 
      disp.bottom = height; 
    }
    m_Disp = disp;


    pDC->SetStretchBltMode(COLORONCOLOR);
    m_pDib->LoadPaletteImage(pDC, &disp);

	
	// --------------------------------------------------------
	// ------------------------twkim---------------------------
	// --------------------------------------------------------
	// Clip 영역 실시간으로 그리기
	//CVisionTab *pVTDlg = (CVisionTab*)::AfxGetMainWnd();
	CVisionTab *pVTDlg = (CVisionTab*)GetParent();
	// clip했을 때 사각형 지우려면 주석 반대로...
	if(true/*!pRTV4Dlg->clip*/) {
		CClientDC dc(this);
		dc.SetROP2(R2_BLACK);
		dc.MoveTo(m_clipStart); dc.LineTo(m_clipStart.x, m_clipEnd.y);
		dc.MoveTo(m_clipStart); dc.LineTo(m_clipEnd.x, m_clipStart.y);
		dc.MoveTo(m_clipStart.x, m_clipEnd.y); dc.LineTo(m_clipEnd);
		dc.MoveTo(m_clipEnd.x, m_clipStart.y); dc.LineTo(m_clipEnd);
	}

	// 해당 영역의 Depth value 실시간 출력
	if(m_PointDepth.x >= 0 && m_PointDepth.y >= 0) {
		
		DrawCross(m_PointDepth);

		// Control창에 해당 좌표의 depth 값 출력
		// 실제 이미지 크기에 맞게 좌표 조정
		// Image를 clip했을 때 적절한 좌표 변환 처리가 필요함...
		CPoint rpt = GetGlobalCoordinate(m_PointDepth);

		CString str;
		str.Format("X: %d, Y: %d, Dist: %d ", rpt.x, rpt.y, pVTDlg->kinect.getDepthValue(rpt.x, rpt.y));
		pVTDlg->SetDlgItemTextA(IDC_DISPDEPTHVAL, str);
	}
	
	// Calib points 그리기
	if(pVTDlg->m_calibPoint.GetNum()) {
		int num = pVTDlg->m_calibPoint.GetNum();
		CPoint pt;
		for(int j=0; j<num; j++) {
			pt.x = pVTDlg->m_calibPoint.GetVal(j,0);
			pt.y = pVTDlg->m_calibPoint.GetVal(j,1);
			DrawCross(pt);
		}
	}
		
}
void CSkinVerticleScrollbar::Draw()
{

	CClientDC dc(this);
	CRect clientRect;
	GetClientRect(&clientRect);
	CMyMemDC memDC(&dc, &clientRect);
	memDC.FillSolidRect(&clientRect,  RGB(74,82,107));
	CDC bitmapDC;
	bitmapDC.CreateCompatibleDC(&dc);

	CBitmap bitmap;
	bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_TOP);
	CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);
	memDC.BitBlt(clientRect.left,clientRect.top,20,17,&bitmapDC,0,0,SRCCOPY);
	bitmapDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
	pOldBitmap = NULL;

	bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_UPARROW);
	pOldBitmap = bitmapDC.SelectObject(&bitmap);
	memDC.BitBlt(clientRect.left,clientRect.top+17,20,19,&bitmapDC,0,0,SRCCOPY);
	bitmapDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
	pOldBitmap = NULL;
	
	//draw the background (span)
	bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_SPAN);
	pOldBitmap = bitmapDC.SelectObject(&bitmap);
	int nHeight = clientRect.Height() - 37;

	memDC.StretchBlt(clientRect.left, clientRect.top+37, 20,nHeight,&bitmapDC, 0,0, 20, 1, SRCCOPY);

	bitmapDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
	pOldBitmap = NULL;
	
	//draw the down arrow of the scrollbar
	bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_DOWNARROW);
	pOldBitmap = bitmapDC.SelectObject(&bitmap);
	memDC.BitBlt(clientRect.left,nHeight,20,16,&bitmapDC,0,0,SRCCOPY);
	bitmapDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
	pOldBitmap = NULL;

		//draw the down arrow of the scrollbar
	bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_BOTTOM);
	pOldBitmap = bitmapDC.SelectObject(&bitmap);
	memDC.BitBlt(clientRect.left+1,nHeight+26,20,22,&bitmapDC,0,0,SRCCOPY);
	bitmapDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
	pOldBitmap = NULL;

	//If there is nothing to scroll then don't
	//show the thumb control otherwise show it
	if(pList->GetScrollLimit(SB_VERT) != 0)
	{
		//draw the thumb control
		bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_THUMB);
		pOldBitmap = bitmapDC.SelectObject(&bitmap);
		memDC.BitBlt(clientRect.left,clientRect.top+nThumbTop,20,26,&bitmapDC,0,0,SRCCOPY);
		bitmapDC.SelectObject(pOldBitmap);
		bitmap.DeleteObject();
		pOldBitmap = NULL;
	}
}
Exemple #24
0
void CForceSyncDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	if (!m_InitDialogDone)
		return;

	// Compute the change in width (dx)
	CRect rect;
	GetWindowRect(&rect);
	int dx = rect.Width() - m_LastRect.Width();
	int dy = rect.Height() - m_LastRect.Height();
	// Save the new size
	m_LastRect = rect;

	// Widen the list box by the change in width (dx) and
	// heighten the list box by the change in height (dy)
	m_List.GetWindowRect(&rect);
	m_List.SetWindowPos(NULL, 0, 0, rect.right - rect.left + dx, 
								    rect.bottom - rect.top + dy, SWP_NOMOVE | SWP_NOZORDER);

	// Widen the group and combo boxes by the change in width
	// Slide them down by the change in height
	CWnd *pWnd = GetDlgItem(IDC_STATIC1);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left, rect.top + dy, rect.right - rect.left + dx, 
								   rect.bottom - rect.top, SWP_NOZORDER);
	pWnd = GetDlgItem(IDC_EDITCHANGNUM);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left, rect.top + dy, rect.right - rect.left + dx, 
								   rect.bottom - rect.top, SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	// Slide radio buttons and the static text at the bottom
	// down by the change in height
	pWnd = GetDlgItem(IDC_OPEN);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	pWnd = GetDlgItem(IDC_FORCERESYNC);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	pWnd = GetDlgItem(IDC_STATIC2);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	// Slide the buttons to the right by the change in width
	// and down by the change in height
	pWnd = GetDlgItem(IDOK);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	pWnd = GetDlgItem(IDC_DELETESELECTED);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	pWnd = GetDlgItem(IDCANCEL);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);

	pWnd = GetDlgItem(IDHELP);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(rect);
	pWnd->SetWindowPos(NULL, rect.left + dx, rect.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
	pWnd->InvalidateRect(NULL, TRUE);
}
Exemple #25
0
void DynamicShow(CDialog *dlg,int flag)
{
	if(!g_bShowDynamic)
		return;
	CRect rc;
	dlg->GetWindowRect(&rc);
	time_t t2;
	t2=time(NULL);
	srand((unsigned int)t2);
	int swidth,sheight;
	int wwidth,wheight;
	swidth=::GetSystemMetrics(SM_CXSCREEN);
	sheight=::GetSystemMetrics(SM_CYSCREEN);
	wwidth=rc.Width();
	wheight=rc.Height();
	int stepw=1,steph=1;
	if(wwidth<wheight)
	{
		steph=wheight/wwidth+1;
	}
	else if(wwidth>wheight)
	{
		stepw=wwidth/wheight+1;
	}

	int dir=rand()%4;
	const int disstep=4;
	int i,j;

	if(flag)
	{
		switch(dir)
		{
		case 0:
			{
				rc.DeflateRect (0,0,wwidth,wheight);
				dlg->MoveWindow(&rc);
				while((rc.Width () <wwidth) || (rc.Height () <wheight) )
				{
					if(rc.Width()<wwidth)
						i=stepw;
					else
						i=0;
					if(rc.Height ()<wheight )
						j=steph;
					else
						j=0;
					rc.InflateRect (0,0,i,j);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 1:
			{
				rc.DeflateRect (wwidth,0,0,wheight);
				dlg->MoveWindow(&rc);
				while((rc.Width () <wwidth) || (rc.Height () <wheight) )
				{
					if(rc.Width()<wwidth)
						i=stepw;
					else
						i=0;
					if(rc.Height ()<wheight )
						j=steph;
					else
						j=0;
					rc.InflateRect (i,0,0,j);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 2:
			{
				rc.DeflateRect (0,wheight,wwidth,0);
				dlg->MoveWindow(&rc);
				while((rc.Width () <wwidth) || (rc.Height () <wheight) )
				{
					if(rc.Width()<wwidth)
						i=stepw;
					else
						i=0;
					if(rc.Height ()<wheight )
						j=steph;
					else
						j=0;
					rc.InflateRect (0,j,i,0);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 3:
			{
				rc.DeflateRect (wwidth,wheight,0,0);
				dlg->MoveWindow(&rc);
				while((rc.Width () <wwidth) || (rc.Height () <wheight) )
				{
					if(rc.Width()<wwidth)
						i=stepw;
					else
						i=0;

					if(rc.Height ()<wheight )
						j=steph;
					else
						j=0;
					rc.InflateRect (i,j,0,0);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		}
	}
	else
	{
		switch(dir)
		{
		case 0:
			{
				while((rc.Width () >disstep) || (rc.Height () >disstep ))
				{
					if(rc.Width()>disstep)
						i=stepw;
					else
						i=0;
					if(rc.Height ()>disstep)
						j=steph;
					else
						j=0;
					rc.DeflateRect (0,0,i,j);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 1:
			{
				while((rc.Width () >disstep) || (rc.Height () >disstep) )
				{
					if(rc.Width()>disstep)
						i=stepw;
					else
						i=0;
					if(rc.Height ()>disstep )
						j=steph;
					else
						j=0;
					rc.DeflateRect (i,0,0,j);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 2:
			{
				while((rc.Width () >disstep) || (rc.Height () >disstep) )
				{
					if(rc.Width()>disstep)
						i=stepw;
					else
						i=0;
					if(rc.Height ()>disstep )
						j=steph;
					else
						j=0;
					rc.DeflateRect (0,j,i,0);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		case 3:
			{
				while((rc.Width () >disstep) || (rc.Height () >disstep) )
				{
					if(rc.Width()>disstep)
						i=stepw;
					else
						i=0;

					if(rc.Height ()>disstep )
						j=steph;
					else
						j=0;
					rc.DeflateRect (i,j,0,0);
					dlg->MoveWindow(&rc);
				}
			}
			break;
		}
	}
}
Exemple #26
0
void CIconStatic::SetIcon(LPCTSTR pszIconID)
{
	m_strIconID = pszIconID;

	// If this function is called for the first time and we did not yet call 'SetWindowText', we take
	// the window label which is already specified for the window (the label which comes from the resource)
	CString strText;
	CStatic::GetWindowText(strText);
	CStatic::SetWindowText(_T(""));
	if (!strText.IsEmpty() && m_strText.IsEmpty())
		m_strText = strText;

	CRect rRect;
	GetClientRect(rRect);

	CDC *pDC = GetDC();
	CDC MemDC;
	CBitmap *pOldBMP;
	
	VERIFY( MemDC.CreateCompatibleDC(pDC) );

	CFont *pOldFont = MemDC.SelectObject(GetFont());

	CRect rCaption(0,0,0,0);
	MemDC.DrawText(m_strText, rCaption, DT_CALCRECT);
	ASSERT( rCaption.Width() >= 0 );
	ASSERT( rCaption.Height() >= 0 );
	if (rCaption.Height() < 16)
		rCaption.bottom = rCaption.top + 16;
	rCaption.right += 25;
	if (rRect.Width() >= 16 && rCaption.Width() > rRect.Width() - 16)
		rCaption.right = rCaption.left + rRect.Width() - 16;

	if (m_MemBMP.m_hObject)
		VERIFY( m_MemBMP.DeleteObject() );
	VERIFY( m_MemBMP.CreateCompatibleBitmap(pDC, rCaption.Width(), rCaption.Height()) );
	pOldBMP = MemDC.SelectObject(&m_MemBMP);

	// Get the background color from the parent window. This way the controls which are
	// embedded in a dialog window can get painted with the same background color as
	// the dialog window.
	HBRUSH hbr = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORSTATIC, (WPARAM)MemDC.m_hDC, (LPARAM)m_hWnd);
	FillRect(MemDC, &rCaption, hbr);

	if (!m_strIconID.IsEmpty())
		VERIFY( DrawState( MemDC.m_hDC, NULL, NULL, (LPARAM)(HICON)CTempIconLoader(m_strIconID, 16, 16), NULL, 3, 0, 16, 16, DST_ICON | DSS_NORMAL) );

	// clear all alpha channel data
	BITMAP bmMem;
	if (m_MemBMP.GetObject(sizeof bmMem, &bmMem) >= sizeof bmMem && bmMem.bmBitsPixel == 32)
	{
		DWORD dwSize = m_MemBMP.GetBitmapBits(0, NULL);
		if (dwSize)
		{
			LPBYTE pPixels = (LPBYTE)malloc(dwSize);
			if (pPixels)
			{
				if (m_MemBMP.GetBitmapBits(dwSize, pPixels) == dwSize)
				{
					LPBYTE pLine = pPixels;
					int iLines = bmMem.bmHeight;
					while (iLines-- > 0)
					{
						LPDWORD pdwPixel = (LPDWORD)pLine;
						for (int x = 0; x < bmMem.bmWidth; x++)
							*pdwPixel++ &= 0x00FFFFFF;
						pLine += bmMem.bmWidthBytes;
					}
					m_MemBMP.SetBitmapBits(dwSize, pPixels);
				}
				free(pPixels);
			}
		}
	}

	rCaption.left += 22;
	
	if(IsThemeActive() && IsAppThemed())
    {
		HTHEME hTheme = OpenThemeData(NULL, L"BUTTON"); 
		DrawThemeText(hTheme, MemDC.m_hDC, BP_GROUPBOX, GBS_NORMAL, m_strText, m_strText.GetLength(), 
			DT_WORDBREAK | DT_CENTER | DT_WORD_ELLIPSIS, NULL, &rCaption); 
		CloseThemeData(hTheme);
	}
	else
	{
		MemDC.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
		MemDC.DrawText(m_strText, rCaption, DT_SINGLELINE | DT_LEFT | DT_END_ELLIPSIS);
	}

	ReleaseDC(pDC);

	MemDC.SelectObject(pOldBMP);
	MemDC.SelectObject(pOldFont);
	
	if (m_wndPicture.m_hWnd == NULL)
		m_wndPicture.Create(NULL, WS_CHILD | WS_VISIBLE | SS_BITMAP, CRect(0,0,0,0), this);
	m_wndPicture.SetWindowPos(NULL, rRect.left+8, rRect.top, rCaption.Width()+22, rCaption.Height(), SWP_SHOWWINDOW);
	m_wndPicture.SetBitmap(m_MemBMP);

	CRect r;
	GetWindowRect(r);
	r.bottom = r.top + 20;
	GetParent()->ScreenToClient(&r);
	GetParent()->RedrawWindow(r);
}
Exemple #27
0
void CDocSelector::ResizeButtons(int NewSize)
{
//	Yogesh Jagota
//	if (NewSize < MINWIDTH || NewSize > DS_WIDTH)
//		return;
//	End Yogesh Jagota

	// Yogesh Jagota
	// We are having good space to draw the buttons...
	if ( NewSize > DS_WIDTH )
	{
		m_btnMenuButton.ShowWindow( SW_HIDE );
		return;
	}

	// Oh no! we are not...
	if ( NewSize < MINWIDTH )
	{
		m_btnMenuButton.ShowWindow( SW_SHOW );
		return;
	}

	CRect rRect;
	GetClientRect( &rRect );

	int nShow = SW_HIDE;
	// End Yogesh Jagota

	m_iButtonWidth = NewSize;
	m_iNextButtonStart = DS_LEFT_MARGIN;

	m_nDisplayedButtons = 0; // Yogesh Jagota
	for (register int x = 0; x < m_Buttons.GetSize(); x++)
	{
		CSwitcherButton* btn = (CSwitcherButton*)m_Buttons.GetAt(x);
		btn->SetWindowPos(NULL, m_iNextButtonStart, 3, 
			m_iButtonWidth, DS_HEIGHT - 2, SWP_NOZORDER|SWP_NOCOPYBITS);

		m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;

		// Yogesh Jagota
		btn->ShowWindow( SW_SHOW );

		if ( m_iNextButtonStart > ( rRect.Width() - DS_MENU_BUTTON_WIDTH ) )
		{
			for ( int i = x; i < m_Buttons.GetSize(); i++)
			{
				CSwitcherButton* btn = ( CSwitcherButton *) m_Buttons.GetAt( i );

				btn->ShowWindow( SW_HIDE );
			}

			nShow = SW_SHOW;
			break;
		}

		m_nDisplayedButtons++;
		// End Yogesh Jagota
	}

	RedrawWindow();

	m_btnMenuButton.ShowWindow( nShow ); // Yogesh Jagota
}
Exemple #28
0
void CFastSplitter::MovePanes()
{
	if (m_hWnd == 0)
		return;
	ASSERT(m_mode < MOD_Last);

	CRect rect;
	GetClientRect(&rect);//GetRelativeRect());
	m_RealSplitterPos = m_SplitterPos;
	ApplyConstraints(m_RealSplitterPos, rect.Width(), rect.Height());
	CRect firstRc(rect);
	CRect secondRc(rect);
	m_SplitterRect.SetRect(0,0,0,0);
	if (!m_bVertSplitter)
	{
		switch (m_mode)
		{
		case MOD_Normal:
			firstRc.bottom = firstRc.top + m_RealSplitterPos;
			secondRc.top = firstRc.bottom + m_nSplitterWidth;
			m_SplitterRect.SetRect(rect.left, firstRc.bottom, rect.right, secondRc.top - 1);
			break;
		case MOD_FirstMaximized:
			firstRc = rect;
			secondRc.top = secondRc.bottom;
			break;
		case MOD_SecondMaximized:
			firstRc.bottom = firstRc.top;
			secondRc = rect;
			break;
		}
	}
	else
	{
		switch (m_mode)
		{
		case MOD_Normal:
			firstRc.right = firstRc.left + m_RealSplitterPos;
			secondRc.left = firstRc.right + m_nSplitterWidth;
			m_SplitterRect.SetRect(firstRc.right, rect.top, secondRc.left - 1, rect.bottom);
			break;
		case MOD_FirstMaximized:
			firstRc = rect;
			secondRc.left = secondRc.right;
			break;
		case MOD_SecondMaximized:
			firstRc.right = firstRc.left;
			secondRc = rect;
			break;
		}
	}
	if (m_pFPane != NULL)
	{
		m_pFPane->SetParent(this);
		if (firstRc.Width() > 0 && firstRc.Height() > 0)
		{
			CRect rc;
			m_pFPane->GetWindowRect(&rc);
			ScreenToClient(&rc);
			if (rc != firstRc || !m_pFPane->IsWindowVisible())
				m_pFPane->SetWindowPos(0, firstRc.left, firstRc.top, firstRc.Width(), firstRc.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW);
		}
		else
			m_pFPane->ShowWindow(SW_HIDE);
	}
	if (m_pFPane != NULL)
	{
		m_pSPane->SetParent(this);
		if (secondRc.Width() > 0 && secondRc.Height() > 0)
		{
			CRect rc;
			m_pSPane->GetWindowRect(&rc);
			ScreenToClient(&rc);
			if (rc != secondRc || !m_pSPane->IsWindowVisible())
				m_pSPane->SetWindowPos(0, secondRc.left, secondRc.top, secondRc.Width(), secondRc.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW);
		}
		else
			m_pSPane->ShowWindow(SW_HIDE);
	}
}
void CLogiSimView::OnDraw(CDC* pDC)
{
	CLogiSimDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	//´õºí ¹öÆÛ¸µ
	CDC mDC;
	CBitmap m_Bitmap;
	CRect rect;
	GetClientRect(&rect);
	mDC.CreateCompatibleDC(pDC);
	m_Bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
	mDC.SelectObject(&m_Bitmap);
	mDC.PatBlt(0, 0, rect.Width(), rect.Height(), WHITENESS);
	// TODO: ¿©±â¿¡ ¿ø½Ã µ¥ÀÌÅÍ¿¡ ´ëÇÑ ±×¸®±â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
	//º¸µå¸¦ ±×¸³´Ï´Ù.
	pDoc->logisim->PrintBoard(&mDC);
	//°¢ °ÔÀÌÆ®¸¦ ±×¸³´Ï´Ù.
	/*
	for (int i = 0; i < pDoc->logisim->circuits.size(); i++){
	drawCircuit(&mDC, pDoc->logisim->circuits[i]);
	}
	*/
	for (int i = 0; i < pDoc->andArr.size(); i++){
		LogiSimAndGate* temp = pDoc->andArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->orArr.size(); i++){
		LogiSimOrGate* temp = pDoc->orArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->notArr.size(); i++){
		LogiSimNotGate* temp = pDoc->notArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->nandArr.size(); i++){
		LogiSimNandGate* temp = pDoc->nandArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->norArr.size(); i++){
		LogiSimNorGate* temp = pDoc->norArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->xorArr.size(); i++){
		LogiSimXorGate* temp = pDoc->xorArr[i];
		temp->Draw(&mDC);
	}
	for (int i = 0; i < pDoc->wPinArr.size(); i++){
		LogiSimWestPin* temp = pDoc->wPinArr[i];
		temp->Draw(&mDC);
	}
	if (pDoc->logisim->isDrawLine == true && this->isMouseClicked == true){
		pDoc->logisim->DrawPreLine(&mDC, this->sPoint, this->ePoint);
	}
	pDoc->logisim->DrawLine(&mDC);


	//´õºí ¹öÆÛ¸µ 

	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &mDC, 0, 0, SRCCOPY);
}
//调整控件
void CGameClientView::RectifyGameView(int nWidth, int nHeight)
{

	int nVDPosY = 0;

#ifdef VIDEO_GAME
	nVDPosY = 50;
#endif

	//设置坐标
	m_ptFace[0].x=nWidth/2-m_nXFace/2;
	m_ptFace[0].y=m_nYBorder+5;
	m_ptName[0].x=nWidth/2+5+m_nXFace/2;
	m_ptName[0].y=m_nYBorder+2;
	m_ptTimer[0].x=nWidth/2;//nWidth/2-m_nXFace/2-m_nXTimer/2-5;
	m_ptTimer[0].y=nHeight/2;//m_nYBorder+m_nYTimer/2+2;

	m_ptReady[0].x=nWidth/2+5+m_nXFace/2+120;
	m_ptReady[0].y=m_nYBorder+25;
	m_ptScore[0].x=nWidth/2-21;
	m_ptScore[0].y=m_nYBorder+m_nYFace+130;
	m_ptLand[0].x=nWidth/2-m_nXFace/2-m_LandSize.cx-m_nXTimer*2;
	m_ptLand[0].y=m_nXBorder+5;

	//设置坐标
	m_ptFace[1].x=m_nXBorder+5;
	m_ptFace[1].y=nHeight/2-m_nYFace-nVDPosY;
	m_ptName[1].x=m_nXBorder+5;
	m_ptName[1].y=nHeight/2+5-nVDPosY;
	m_ptTimer[1].x=nWidth/2;//m_nXBorder+2+m_nXTimer/2;
	m_ptTimer[1].y=nHeight/2;//nHeight/2-m_nYFace-5-m_nYTimer/2-nVDPosY;
	m_ptReady[1].x=m_nXBorder+5+m_nXTimer;
	m_ptReady[1].y=nHeight/2-m_nYFace-m_nYTimer/2-5-nVDPosY;
	m_ptScore[1].x=m_nXBorder+m_nXFace+147-10;
	m_ptScore[1].y=nHeight/2-m_nYFace-30-nVDPosY;
	m_ptLand[1].x=m_nXBorder+5;
	m_ptLand[1].y=nHeight/2+40-nVDPosY;

	//设置坐标
	m_ptFace[3].x=nWidth-m_nXBorder-m_nXFace-5;
	m_ptFace[3].y=nHeight/2-m_nYFace-nVDPosY;
	m_ptName[3].x=nWidth-m_nXBorder-5;
	m_ptName[3].y=nHeight/2+5-nVDPosY;
	m_ptTimer[3].x=nWidth/2;//nWidth-m_nXBorder-m_nXTimer/2-2;
	m_ptTimer[3].y=nHeight/2;//nHeight/2-m_nYFace-m_nYTimer/2-5-nVDPosY;
	m_ptReady[3].x=nWidth-m_nXBorder-m_nXTimer-5;
	m_ptReady[3].y=nHeight/2-m_nYFace-m_nYTimer/2-5-nVDPosY;
	m_ptScore[3].x=nWidth-m_nXBorder-m_nXFace-190-7;
	m_ptScore[3].y=nHeight/2-m_nYFace-30-nVDPosY;
	m_ptLand[3].x=nWidth-m_nXBorder-m_LandSize.cx-5;
	m_ptLand[3].y=nHeight/2+40-nVDPosY;

	//用户扑克
	m_UserCardControl[3].SetBenchmarkPos(nWidth-m_nXFace-m_nXBorder-147,nHeight/2-40,enXRight,enYCenter);
	m_UserCardControl[1].SetBenchmarkPos(m_nXBorder+m_nXFace+147,nHeight/2-40,enXLeft,enYCenter);
	m_UserCardControl[0].SetBenchmarkPos(nWidth/2,160,enXCenter,enYTop);
	m_HandCardControl[3].SetBenchmarkPos(nWidth-m_nXBorder-m_nXFace-50,nHeight/2,enXRight,enYCenter);
	m_HandCardControl[1].SetBenchmarkPos(m_nXBorder+m_nXFace+50,nHeight/2,enXLeft,enYCenter);
	m_HandCardControl[0].SetBenchmarkPos(nWidth/2+40,100,enXCenter,enYCenter);	

	////////////////////////////////////////////////////////////////////////////
//	BYTE cbCardData[ ] = { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 };
//	m_BackCardControl.SetCardData( cbCardData, 8 );
//	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID ) {
//	//	if ( wChairID == ME_VIEW_CHAIR )
//		m_HandCardControl[ wChairID ].SetCardData( cbCardData, 25 );
//		m_HandCardControl[ wChairID ].SetDisplayFlag( true );
//		m_UserCardControl[ wChairID ].SetCardData( cbCardData, 10 ); 
//		m_bPass[ wChairID ] = true; 
//	}
//	
//	m_BackCardControl.SetDisplayFlag( true );
//	m_HandCardControl[ ME_VIEW_CHAIR ].SetDisplayFlag( true );
//	if ( m_ScoreView.m_hWnd == NULL ) m_ScoreView.Create(IDD_GAME_SCORE,this);
////	m_ScoreView.ShowWindow( SW_SHOW );
//	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID ) {
//		m_ScoreView.SetGameScore( wChairID, "dkfjdkfjdf", 00 );
//	}
	//////////////////////////////////////////////////////////////////////////////

#ifdef VIDEO_GAME

	//视频组件
	CRect VDRect;
	m_DlgVedioService[ 0 ].GetWindowRect( &VDRect );

	m_DlgVedioService[ 0 ].MoveWindow( nWidth - m_nXBorder - 5 - VDRect.Width(),m_nYBorder + 5 , VDRect.Width(), VDRect.Height() );
	m_DlgVedioService[ 1 ].MoveWindow( m_nXBorder + 5, nHeight / 2 - 10, VDRect.Width(), VDRect.Height() );
	m_DlgVedioService[ 3 ].MoveWindow( nWidth - VDRect.Width() - m_nXBorder - 5, nHeight / 2 - 10, VDRect.Width(), VDRect.Height() );

	m_DlgVedioService[ ME_VIEW_CHAIR ].GetWindowRect( &VDRect );
	m_DlgVedioService[ ME_VIEW_CHAIR ].MoveWindow( m_nXBorder + 5, nHeight - VDRect.Height() - m_nYBorder - 5, VDRect.Width(), VDRect.Height() );

#endif

	//设置坐标
	m_ptFace[ME_VIEW_CHAIR].x=nWidth/2-m_nXFace/2;
	m_ptFace[ME_VIEW_CHAIR].y=nHeight-m_nYBorder-m_nYFace-5;
	m_ptName[ME_VIEW_CHAIR].x=nWidth/2+5+m_nXFace/2;
	m_ptName[ME_VIEW_CHAIR].y=nHeight-m_nYBorder-m_nYFace-2;
	m_ptTimer[ME_VIEW_CHAIR].x=nWidth/2;//nWidth/2-m_nXFace/2-m_nXTimer/2-5;
	m_ptTimer[ME_VIEW_CHAIR].y=nHeight/2;//nHeight-m_nYBorder-m_nYTimer/2-2;
	m_ptReady[ME_VIEW_CHAIR].x=nWidth/2 + 10;
	m_ptReady[ME_VIEW_CHAIR].y=nHeight-217-m_nYBorder;
	m_ptScore[ME_VIEW_CHAIR].x=nWidth/2-21;
	m_ptScore[ME_VIEW_CHAIR].y=nHeight-m_nYBorder-m_nYFace-210;
	m_ptLand[ME_VIEW_CHAIR].x=nWidth/2-m_nXFace/2-m_LandSize.cx-m_nXTimer*2;
	m_ptLand[ME_VIEW_CHAIR].y=nHeight-m_nXBorder-m_LandSize.cy-5;

	//移动按钮
	CRect rcButton;
	HDWP hDwp=BeginDeferWindowPos(32);
	m_btStart.GetWindowRect(&rcButton);
	const UINT uFlags=SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCOPYBITS|SWP_NOSIZE;
	DeferWindowPos(hDwp,m_btStart,NULL,(nWidth-rcButton.Width())/2,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btOutCard,NULL,nWidth/2-rcButton.Width()*3/2-10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btAutoOutCard,NULL,nWidth/2-rcButton.Width()/2,nHeight-217-m_nYBorder+99999,0,0,uFlags);//提示
	DeferWindowPos(hDwp,m_btPassCard,NULL,nWidth/2+rcButton.Width()/2+10,nHeight-217-m_nYBorder,0,0,uFlags);

	DeferWindowPos(hDwp,m_btOneScore,	NULL,nWidth/2-rcButton.Width()*2-12+30,						nHeight-217-m_nYBorder,0,0,uFlags);//1分+9999
	DeferWindowPos(hDwp,m_btTwoScore,	NULL,nWidth/2+10+30,nHeight-217-m_nYBorder,					0,0,uFlags);//2分
	DeferWindowPos(hDwp,m_btThreeScore,	NULL,nWidth/2-rcButton.Width()*2-12+30,nHeight-217-m_nYBorder,	0,0,uFlags);//3分
	DeferWindowPos(hDwp,m_btGiveUpScore,NULL,nWidth/2+10+30,nHeight-217-m_nYBorder,					0,0,uFlags);//不叫

	DeferWindowPos(hDwp,m_btSortCard,NULL,nWidth-m_nXBorder-rcButton.Width()-15,nHeight-rcButton.Height()*2-m_nYBorder-40,0,0,uFlags);
	///////////////////////////////////////////////////添加按钮的位置///////////////////////////////////////////
	DeferWindowPos(hDwp,m_btLiGun,NULL,nWidth/2-rcButton.Width()*3/2-10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btNotLiGun,NULL,nWidth/2+rcButton.Width()/2+10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btJueGun,NULL,nWidth/2-rcButton.Width()*3/2-10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btNotJueGun,NULL,nWidth/2+rcButton.Width()/2+10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btAgree,NULL,nWidth/2-rcButton.Width()*3/2-10,nHeight-217-m_nYBorder,0,0,uFlags);
	DeferWindowPos(hDwp,m_btDisagree,NULL,nWidth/2+rcButton.Width()/2+10,nHeight-217-m_nYBorder,0,0,uFlags);
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	EndDeferWindowPos(hDwp);

	CRect rcBtAutoPlay;
	m_btAutoPlayOn.GetWindowRect( rcBtAutoPlay );
	m_btAutoPlayOn .MoveWindow( nWidth - m_nXBorder - 5 - rcBtAutoPlay.Width() , nHeight-5-rcBtAutoPlay.Height(), rcBtAutoPlay.Width(), rcBtAutoPlay.Height(), FALSE);
    m_btAutoPlayOff.MoveWindow( nWidth - m_nXBorder - 5 - rcBtAutoPlay.Width(), nHeight-5-rcBtAutoPlay.Height(), rcBtAutoPlay.Width(), rcBtAutoPlay.Height(), FALSE);
	m_btSortCard.MoveWindow( nWidth - m_nXBorder - 5 - rcBtAutoPlay.Width(), nHeight-10-2*rcBtAutoPlay.Height(), rcBtAutoPlay.Width(), rcBtAutoPlay.Height(), FALSE);

	//移动扑克
	//m_BackCardControl.SetBenchmarkPos(m_nXBorder+5,m_nYBorder+5,enXLeft,enYTop);
	m_HandCardControl[ME_VIEW_CHAIR].SetBenchmarkPos(nWidth/2+15,nHeight-m_nYFace-m_nYBorder-25,enXCenter,enYBottom);
	m_UserCardControl[ME_VIEW_CHAIR].SetBenchmarkPos(nWidth/2,nHeight-223-m_nYBorder,enXCenter,enYBottom);

	return;
}