newntui/discovermdi/src/dockablebrowser.cpp
//----------------------------------------------------------------------------
// Pop-up menu will appear on right mouse button click
//----------------------------------------------------------------------------
Pop-up menu will appear on right mouse button click
Pop - up menu will appear on right mouse button click
void CDockableBrowser::OnRButtonEvent(short x,short y) {
CPoint point(x,y);
CMenu popup;
CMenu query;
CMenu uses;
CMenu where;
CMenu show;
CMenu defines;
int   usesCount=0;
int   whereCount=0;
int   showCount=0;
int   definesCount=0;
CMainFrame* mainFrm=(CMainFrame*) AfxGetMainWnd();
    MakeMenuMap();
	popup.CreatePopupMenu();
    CCMIntegrator* pIntegrator=(CCMIntegrator*) GetDlgItem(IDC_CMINTEGRATORCTRL);
	if(pIntegrator->IsConnected()) {
		CreateCMMenu(&m_pCMMenu);
		if(m_pCMMenu!=NULL) {
			popup.AppendMenu(MF_POPUP,(unsigned int)m_pCMMenu->m_hMenu,"Source Control");
			popup.AppendMenu(MF_SEPARATOR);
		}
	}
	query.CreatePopupMenu();
	popup.AppendMenu(MF_POPUP,(unsigned int)query.m_hMenu,"Query");
	uses.CreatePopupMenu();
	where.CreatePopupMenu();
	show.CreatePopupMenu();
	defines.CreatePopupMenu();
	POSITION pos;
	pos=m_MenuMap.GetHeadPosition();
	while(pos) {
		CString name;
		int id;
		name = m_MenuMap.GetAt(pos).m_Query;
		id   = m_MenuMap.GetAt(pos).m_ID;
		if(name.Find("Uses")==0) {
	        uses.AppendMenu(MF_STRING,id,name);
			usesCount++;
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Where")==0) {
	        where.AppendMenu(MF_STRING,id,name);
			whereCount++;
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Defines")==0) {
	        defines.AppendMenu(MF_STRING,id,name);
			definesCount++;
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Show")==0) {
	        show.AppendMenu(MF_STRING,id,name);
			showCount++;
		    m_MenuMap.GetNext(pos);
			continue;
		}
		m_MenuMap.GetNext(pos);
    }
	if(usesCount>0)    query.AppendMenu(MF_POPUP,(unsigned int)uses.m_hMenu,"Uses");
	if(whereCount>0)   query.AppendMenu(MF_POPUP,(unsigned int)where.m_hMenu,"Where");
	if(definesCount>0) query.AppendMenu(MF_POPUP,(unsigned int)defines.m_hMenu,"Defines");
	if(showCount>0)    query.AppendMenu(MF_POPUP,(unsigned int)show.m_hMenu,"Show");
	pos=m_MenuMap.GetHeadPosition();
	while(pos) {
		CString name;
		int id;
		name = m_MenuMap.GetAt(pos).m_Query;
		id   = m_MenuMap.GetAt(pos).m_ID;
		if(name.Find("Uses")==0) {
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Where")==0) {
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Defines")==0) {
		    m_MenuMap.GetNext(pos);
			continue;
		}
		if(name.Find("Show")==0) {
		    m_MenuMap.GetNext(pos);
			continue;
		}
	    query.AppendMenu(MF_STRING,id,name);
		m_MenuMap.GetNext(pos);
    }
	popup.AppendMenu(MF_STRING,IDC_CLOSURE,"Closure");
	if(m_Closure==TRUE)
	    popup.CheckMenuItem(IDC_CLOSURE,MF_BYCOMMAND|MF_CHECKED);
    else
	    popup.CheckMenuItem(IDC_CLOSURE,MF_BYCOMMAND|MF_UNCHECKED);
	popup.AppendMenu(MF_STRING,IDC_SHORTNAMES,"Short names");
	CQueryResults* list  = (CQueryResults *) GetDlgItem(IDC_RESULTS);
	if(list->GetShortNames()==TRUE)
	    popup.CheckMenuItem(IDC_SHORTNAMES,MF_BYCOMMAND|MF_CHECKED);
    else
	    popup.CheckMenuItem(IDC_SHORTNAMES,MF_BYCOMMAND|MF_UNCHECKED);
	popup.AppendMenu(MF_SEPARATOR);
	popup.AppendMenu(MF_STRING,IDC_SELECTFILTER,"Select Filter ...");
    CString sizeStr = ExecuteCommand(CString("size $DiscoverSelection"));
    mainFrm->m_SelectionSize=atoi(sizeStr);
	popup.AppendMenu(MF_STRING,IDC_RESETFILTER, "Clear Filter");
	popup.AppendMenu(MF_SEPARATOR);
	popup.AppendMenu(MF_STRING,IDC_SELATTRIBUTES,"Select Attributes ...");
	popup.AppendMenu(MF_STRING,IDC_SELECTSORT, "Select sorting ...");
	popup.AppendMenu(MF_SEPARATOR);
	CMenu exportPopup;
	exportPopup.CreatePopupMenu();
	popup.AppendMenu(MF_POPUP,(unsigned int)exportPopup.m_hMenu,"Export to ...");
	exportPopup.AppendMenu(MF_STRING,IDC_ADDELEMENTS, "Group...");
	exportPopup.AppendMenu(MF_STRING,IDC_SAVEELEMENTS, "Text file...");
	CRect main;
	CRect child;
	GetWindowRect(main);
	CQueryResults* Results  = (CQueryResults *) GetDlgItem(IDC_RESULTS);
	Results->GetWindowRect(child);
	point.y+=child.top-main.top;
	point.x+=child.left-main.left;
	ClientToScreen(&point);
    popup.TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
	popup.DestroyMenu();
	query.DestroyMenu();
	where.DestroyMenu();
	uses.DestroyMenu();
	defines.DestroyMenu();
	show.DestroyMenu();
}
void CDockableBrowser :: OnRButtonEvent ( short x , short y ) { CPoint point ( x , y ) ; CMenu popup ; CMenu query ; CMenu uses ; CMenu where ; CMenu show ; CMenu defines ; int usesCount = 0 ; int whereCount = 0 ; int showCount = 0 ; int definesCount = 0 ; CMainFrame * mainFrm = ( CMainFrame * ) AfxGetMainWnd ( ) ; MakeMenuMap ( ) ; popup . CreatePopupMenu ( ) ; CCMIntegrator * pIntegrator = ( CCMIntegrator * ) GetDlgItem ( IDC_CMINTEGRATORCTRL ) ; if ( pIntegrator -> IsConnected ( ) ) { CreateCMMenu ( & m_pCMMenu ) ; if ( m_pCMMenu != NULL ) { popup . AppendMenu ( MF_POPUP , ( unsigned int ) m_pCMMenu -> m_hMenu , " " ) ; popup . AppendMenu ( MF_SEPARATOR ) ; } } query . CreatePopupMenu ( ) ; popup . AppendMenu ( MF_POPUP , ( unsigned int ) query . m_hMenu , " " ) ; uses . CreatePopupMenu ( ) ; where . CreatePopupMenu ( ) ; show . CreatePopupMenu ( ) ; defines . CreatePopupMenu ( ) ; POSITION pos ; pos = m_MenuMap . GetHeadPosition ( ) ; while ( pos ) { CString name ; int id ; name = m_MenuMap . GetAt ( pos ) . m_Query ; id = m_MenuMap . GetAt ( pos ) . m_ID ; if ( name . Find ( " " ) == 0 ) { uses . AppendMenu ( MF_STRING , id , name ) ; usesCount ++ ; m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { where . AppendMenu ( MF_STRING , id , name ) ; whereCount ++ ; m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { defines . AppendMenu ( MF_STRING , id , name ) ; definesCount ++ ; m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { show . AppendMenu ( MF_STRING , id , name ) ; showCount ++ ; m_MenuMap . GetNext ( pos ) ; continue ; } m_MenuMap . GetNext ( pos ) ; } if ( usesCount > 0 ) query . AppendMenu ( MF_POPUP , ( unsigned int ) uses . m_hMenu , " " ) ; if ( whereCount > 0 ) query . AppendMenu ( MF_POPUP , ( unsigned int ) where . m_hMenu , " " ) ; if ( definesCount > 0 ) query . AppendMenu ( MF_POPUP , ( unsigned int ) defines . m_hMenu , " " ) ; if ( showCount > 0 ) query . AppendMenu ( MF_POPUP , ( unsigned int ) show . m_hMenu , " " ) ; pos = m_MenuMap . GetHeadPosition ( ) ; while ( pos ) { CString name ; int id ; name = m_MenuMap . GetAt ( pos ) . m_Query ; id = m_MenuMap . GetAt ( pos ) . m_ID ; if ( name . Find ( " " ) == 0 ) { m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { m_MenuMap . GetNext ( pos ) ; continue ; } if ( name . Find ( " " ) == 0 ) { m_MenuMap . GetNext ( pos ) ; continue ; } query . AppendMenu ( MF_STRING , id , name ) ; m_MenuMap . GetNext ( pos ) ; } popup . AppendMenu ( MF_STRING , IDC_CLOSURE , " " ) ; if ( m_Closure == TRUE ) popup . CheckMenuItem ( IDC_CLOSURE , MF_BYCOMMAND | MF_CHECKED ) ; else popup . CheckMenuItem ( IDC_CLOSURE , MF_BYCOMMAND | MF_UNCHECKED ) ; popup . AppendMenu ( MF_STRING , IDC_SHORTNAMES , " " ) ; CQueryResults * list = ( CQueryResults * ) GetDlgItem ( IDC_RESULTS ) ; if ( list -> GetShortNames ( ) == TRUE ) popup . CheckMenuItem ( IDC_SHORTNAMES , MF_BYCOMMAND | MF_CHECKED ) ; else popup . CheckMenuItem ( IDC_SHORTNAMES , MF_BYCOMMAND | MF_UNCHECKED ) ; popup . AppendMenu ( MF_SEPARATOR ) ; popup . AppendMenu ( MF_STRING , IDC_SELECTFILTER , " " ) ; CString sizeStr = ExecuteCommand ( CString ( " " ) ) ; mainFrm -> m_SelectionSize = atoi ( sizeStr ) ; popup . AppendMenu ( MF_STRING , IDC_RESETFILTER , " " ) ; popup . AppendMenu ( MF_SEPARATOR ) ; popup . AppendMenu ( MF_STRING , IDC_SELATTRIBUTES , " " ) ; popup . AppendMenu ( MF_STRING , IDC_SELECTSORT , " " ) ; popup . AppendMenu ( MF_SEPARATOR ) ; CMenu exportPopup ; exportPopup . CreatePopupMenu ( ) ; popup . AppendMenu ( MF_POPUP , ( unsigned int ) exportPopup . m_hMenu , " " ) ; exportPopup . AppendMenu ( MF_STRING , IDC_ADDELEMENTS , " " ) ; exportPopup . AppendMenu ( MF_STRING , IDC_SAVEELEMENTS , " " ) ; CRect main ; CRect child ; GetWindowRect ( main ) ; CQueryResults * Results = ( CQueryResults * ) GetDlgItem ( IDC_RESULTS ) ; Results -> GetWindowRect ( child ) ; point . y += child . top - main . top ; point . x += child . left - main . left ; ClientToScreen ( & point ) ; popup . TrackPopupMenu ( TPM_LEFTALIGN , point . x , point . y , this ) ; popup . DestroyMenu ( ) ; query . DestroyMenu ( ) ; where . DestroyMenu ( ) ; uses . DestroyMenu ( ) ; defines . DestroyMenu ( ) ; show . DestroyMenu ( ) ; }
Pop-up menu will appear on right mouse button click
Pop - up menu will appear on right mouse button click
// This function will make menu map - assosiations between command IDs and // queries names. // Base menu // Query pop-up menu // Query sub-menus // Filling query sub-menus // Attaching query sub-menus if not empty // Adding all queries not in the submenus // Filter items // Attribute and sorting items // Export item // Export pop-up menu // coordinates calculation to position menu window properly // selection loop // destroy all menus and free handles