예제 #1
0
void CDocSelector::OnTimer(UINT nIDEvent) 
{
	for ( int i = 0; i < m_Buttons.GetSize(); i++ )
	{
		CSwitcherButton* wndButton = 
			(CSwitcherButton *) m_Buttons.GetAt( i );

		// May be the user has destroyed the view...
		if ( wndButton->m_AttachedView )
		{
			if ( GetFocus() == wndButton->m_AttachedView )
			{
				if ( wndButton->m_nState != SWITCHBUTTON_SELECTED )
				{
					wndButton->Select();

					m_iSelectedButton = i;
				}
			}
			else
			{
				if ( wndButton->m_nState == SWITCHBUTTON_SELECTED )
					wndButton->Unselect();
			}
		}
		// Yes, he has, critical condition..., break...
		else
			break;
	}

	CControlBar::OnTimer(nIDEvent);
}
예제 #2
0
void CDocSelector::OnDocmenuMoveright()
{

	if((m_iRID >= 0) && (m_iRID < m_Buttons.GetSize()) && (m_Buttons.GetSize() > 1))
	{

		int iNew = m_iRID+1 < m_Buttons.GetSize() ? m_iRID+1 : 0;
		CSwitcherButton* tmp  = (CSwitcherButton*)m_Buttons.GetAt(m_iRID);
		CSwitcherButton* tmp2  = (CSwitcherButton*)m_Buttons.GetAt(iNew);
		
		CWnd*			AttachedView = tmp2->m_AttachedView;
		CFrameWnd*		FrameWnd	 = tmp2->m_FrameWnd;
		HICON			iIcon		 = tmp2->m_iIcon;
		HBITMAP			hBmp		 = tmp2->m_hBmp;
		CString strText1 = ((CView*)tmp->m_AttachedView)->GetDocument()->GetTitle();
		CString strText2 = ((CView*)tmp2->m_AttachedView)->GetDocument()->GetTitle();

		tmp2->m_AttachedView = tmp->m_AttachedView;
		tmp2->m_FrameWnd     = tmp->m_FrameWnd;
		tmp2->m_iIcon		 = tmp->m_iIcon;
		tmp2->m_hBmp		 = tmp->m_hBmp;
		tmp->m_AttachedView = AttachedView;
		tmp->m_FrameWnd     = FrameWnd;
		tmp->m_iIcon = iIcon;
		tmp->m_hBmp  = hBmp;
		tmp->SetText(strText2);
		tmp2->SetText(strText1);
	}
}
예제 #3
0
void CDocSelector::OnTimer(UINT nIDEvent) 
{
	for ( int i = 0; i < m_Buttons.GetSize(); i++ )
	{
		CSwitcherButton* wndButton = 
			(CSwitcherButton *) m_Buttons.GetAt( i );

		// May be the user has destroyed the view...
		if ( wndButton->m_AttachedView )
		{

			// Modified by Bender to fix akward problem with CFormView and GetFocus()
			// MFC works in misterious ways ;)
			if(GetApp()->GetMainFrame()->MDIGetActive() == wndButton->m_AttachedView->GetParentFrame())
			//if ( GetFocus() == wndButton->m_AttachedView)
			{
				if ( wndButton->m_nState != SWITCHBUTTON_SELECTED )
				{
					wndButton->Select();

					m_iSelectedButton = i;
				}
			}
			else
			{
				if ( wndButton->m_nState == SWITCHBUTTON_SELECTED )
					wndButton->Unselect();
			}
		}
		// Yes, he has, critical condition..., break...
		else
			break;
	}

	CControlBar::OnTimer(nIDEvent);
}
예제 #4
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
}
예제 #5
0
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon ,HICON hIcon )
{
	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 ( hIcon)
	{
		newbutton->m_iIcon=hIcon;
		newbutton->m_iIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	}
	
	else

	if ( wIcon != -1 )
		newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), 
			MAKEINTRESOURCE( wIcon ) );
	// 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;
}