Exemplo n.º 1
0
bool View::
Display( FILE *file )
{
	ViewMembers::iterator	vmi;
	ClassAdUnParser			unparser;
	Value					val;
	ClassAd					*viewInfo;
	string					buf;

		// display view info
	if( !( viewInfo = GetViewInfo( ) ) ) return( false );
	unparser.Unparse( buf, viewInfo );
	fprintf( file, "%s\n", buf.c_str( ) );
	delete viewInfo;

	for( vmi = viewMembers.begin( ); vmi != viewMembers.end( ); vmi++ ) {
		vmi->GetKey( buf );
		vmi->GetRankValue( val );
		buf += ": ";
		unparser.Unparse( buf, val );
		fprintf( file, "%s\n", buf.c_str() );
	}

	return( true );
}
Exemplo n.º 2
0
// Get the name for the specified tab, made up of its view names (eg "Text, Contents")
//, could also store custom name for tab
BOOL BDataViews::GetTabName(int nTab, CString& strName, BDoc* pDoc)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDoc);

	// Walk through views to build up name for tab

	// Clear string first
	strName.Empty();

	// first we need to walk through the array till we get to the specified tab
	// then continue walking through array till we reach the end or hit a 0 0
	int nStart = GetTabIndex(nTab);
	int nIndex = nStart;
	int nItems = m_avi.GetSize();
	int nViews = 0;
	while (TRUE)
	{
		ViewInfo& rvi = GetViewInfo(nIndex);
		ULONG lngViewID = rvi.m_lngViewID;

		// Exit if we've reached the end of the views for this tab
		if (lngViewID == 0)
			break;

		ASSERT(lngViewID);

		BObject* pobjView = pDoc->GetObject(lngViewID);

		// Get view caption
		CString strView = pobjView->GetPropertyString(propCaption);
		if (strView.IsEmpty()) // if caption property is empty, just use the name
			strView = pobjView->GetPropertyString(propName);

		if (nViews > 0)
		{
			// Remove any ampersand so only first view name will get underline character.
			// (otherwise Windows will just underline the last &'d character in the string).
			strView.Remove(_T('&'));
			strName += ", "; 
			strName += strView;
		}
		else
		{			
			strName += strView;
		}

		nIndex++;
		nViews++;

		// Exit if we're past the end of the array
		if (nIndex >= nItems)
			break;
	}

	return TRUE;
}
Exemplo n.º 3
0
// Find which tab the specified view is on, if any.
// Returns 0 based tab index, or -1 if view not available.
int BDataViews::GetViewTab(ULONG lngViewID)
{
	ASSERT_VALID(this);

	int nTab = -1; // default

	// Walk through array to find specified view, keeping track of tab count
	int nTabs = 0;
	int nItems = m_avi.GetSize();
	for (int i = 0; i < nItems; i++)
	{
		ViewInfo& rvi = GetViewInfo(i);
		// Exit loop if we found the view
		if (rvi.m_lngViewID == lngViewID)
		{
			nTab = nTabs;
			break;
		}
		if (rvi.m_lngViewID == 0)
			nTabs++;
	}

/*
	// Walk through tab data to find specified view
	int iTabs = GetTabCount();
	for (int iTab = 0; iTab < iTabs; iTab++)
	{
		// Each tab stores an additional array of BDataView objects
//		BDataArray* pdatViews = (BDataArray*) m_pdatTabs->m_apdat[iTab];
//		int nViews = pdatViews->m_apdat.GetSize();

		// Walk through view objects, looking for specified view
		for (int iView = 0; iView < nViews; iView++)
		{
			BDataView* pdatView = (BDataView*) pdatViews->m_apdat[iView];
			ASSERT_VALID(pdatView);
//			ASSERT_VALID(pdatView->m_pobjView);
			if (pdatView->m_lngViewID == lngViewID)
//			if (pdatView->m_pobjView->GetObjectID() == lngViewID)
			{
				// Found view
				// Note: Easier to return here than try to break out of all the loops
				return iTab;
			}
		}
	}
	// Return -1 if view not found
	return -1;
*/

	return nTab;
}
Exemplo n.º 4
0
// Get the number of tabs represented in the array
int BDataViews::GetTabCount()
{
	ASSERT_VALID(this);
	ASSERT_VALID(&m_avi);

	// walk through array, checking for 0's indicating end of tab
	int nTabs = 0;
	int nItems = m_avi.GetSize();
	for (int i = 0; i < nItems; i++)
	{
		ViewInfo& rvi = GetViewInfo(i);
		if (rvi.m_lngViewID == 0)
			nTabs++;
	}
	return nTabs;
}
Exemplo n.º 5
0
// Get the index for the first view in the specified tab.
// Returns -1 if tab not found.
int BDataViews::GetTabIndex(int nTab)
{
	ASSERT_VALID(this);
	ASSERT_VALID(&m_avi);

	// Walk through array, checking for 0's that indicate the end of a tab.
	int nTabs = 0;
	int nItems = m_avi.GetSize();
	for (int i = 0; i < nItems; i++)
	{
		if (nTabs == nTab)
			return i;
		ViewInfo& rvi = GetViewInfo(i);
		if (rvi.m_lngViewID == 0)
			nTabs++;
	}
	return -1;
}