void
GPMTreeHeaderWidget::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JXDrawUpFrame(p, rect, kJXDefaultBorderWidth);

	JString str;
	if (!GetColTitle(cell.x, &str))
		{
		str = JString(cell.x, JString::kBase10);
		}

	JSize underLines = 0;
	if (itsList->TreeColIsSelected(cell.x))
		{
		underLines = 1;
		}

	const JFont font = GetFontManager()->GetFont(
		JGetDefaultFontName(), JGetDefaultRowColHeaderFontSize(),
		JFontStyle(kJTrue, kJFalse, underLines, kJFalse, (p.GetColormap())->GetBlackColor()));
	p.SetFont(font);
	p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
Ejemplo n.º 2
0
void
JXColHeaderWidget::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JXDrawUpFrame(p, rect, kCellFrameWidth);

	JString str;
	JBoolean hasTitle = kJFalse;
	if (itsTitles != NULL)
		{
		const JString* title = itsTitles->NthElement(cell.x);
		if (title != NULL)
			{
			str      = *title;
			hasTitle = kJTrue;
			}
		}
	if (!hasTitle)
		{
		str = JString(cell.x, 0);
		}

	p.SetFont(JGetDefaultFontName(), kFontSize,
			  JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor()));
	p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
void
JXRowHeaderWidget::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JXDrawUpFrame(p, rect, kCellFrameWidth);

	JString str;
	JBoolean hasTitle = kJFalse;
	if (itsTitles != NULL)
		{
		const JString* title = itsTitles->NthElement(cell.y);
		if (title != NULL)
			{
			str      = *title;
			hasTitle = kJTrue;
			}
		}
	if (!hasTitle)
		{
		str = JString(cell.y, JString::kBase10);
		}

	p.SetFont(JGetDefaultFontName(), kJDefaultRowColHeaderFontSize,
			  JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor()));
	p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);

	const JCoordinate wmin = p.GetStringWidth(str) + 2*itsHMarginWidth;
	if (rect.width() < wmin && itsMaxBcastWidth < wmin)
		{
		Broadcast(NeedsToBeWidened(wmin - itsMaxBcastWidth));
		itsMaxBcastWidth = wmin;
		}
}
void
CBCommandTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JPoint editCell;
	if (GetEditedCell(&editCell) && cell == editCell)
		{
		return;
		}

	HilightIfSelected(p, cell, rect);

	const CBCommandManager::CmdInfo info = itsCmdList->GetElement(cell.y);
	if (info.separator)
		{
		JPoint pt1 = rect.bottomLeft(), pt2 = rect.bottomRight();
		pt1.y--;
		pt2.y--;
		p.Line(pt1, pt2);
		}

	if (cell.x == kOptionsColumn)
		{
		JString s;
		if (info.isMake)
			{
			s += ",M";
			}
		if (info.isVCS)
			{
			s += ",V";
			}
		if (info.saveAll)
			{
			s += ",S";
			}
		if (info.oneAtATime)
			{
			s += ",O";
			}
		if (info.useWindow)
			{
			s += ",W";
			}
		if (info.raiseWindowWhenStart)
			{
			s += ",R";
			}
		if (info.beepWhenFinished)
			{
			s += ",B";
			}

		if (!s.IsEmpty())
			{
			if (s.GetFirstCharacter() == ',')
				{
				s.RemoveSubstring(1,1);
				}
			p.String(rect, s, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
			}
		}
	else
		{
		const JString* s = NULL;
		JFontStyle style;
		if (cell.x == kMenuTextColumn)
			{
			s = info.menuText;
			}
		else if (cell.x == kMenuShortcutColumn)
			{
			s = info.menuShortcut;
			}
		else if (cell.x == kScriptNameColumn)
			{
			s = info.name;
			}
		else if (cell.x == kCommandColumn)
			{
			s = info.cmd;
			}
		else if (cell.x == kPathColumn)
			{
			s = info.path;
			style.color =
				CBCommandPathInput::GetTextColor(*s, itsBasePath, kJFalse, p.GetColormap());
			}
		assert( s != NULL );

		p.SetFont(itsFontName, itsFontSize, style);

		JRect r = rect;
		r.left += kHMarginWidth;
		p.String(r, *s, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
		}
}
void
JXTreeListWidget::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	if (JIndex(cell.x) == itsNodeColIndex && itsDrawSelectionFlag)
		{
		HilightIfSelected(p, cell, rect);
		}

	const JTreeNode* node = itsTreeList->GetNode(cell.y);
	if (JIndex(cell.x) == itsToggleOpenColIndex && node->IsOpenable())
		{
		p.ShiftOrigin(rect.topLeft());

		const JPolygon* triangle = (itsTreeList->IsOpen(cell.y) ?
									&kOpenTriangle : &kClosedTriangle);
		if (kOpenTriangle.IsEmpty())
			{
			kOpenTriangle.AppendElement(JPoint(5,  6));
			kOpenTriangle.AppendElement(JPoint(15, 6));
			kOpenTriangle.AppendElement(JPoint(10, 11));

			kClosedTriangle.AppendElement(JPoint(10, 3));
			kClosedTriangle.AppendElement(JPoint(15, 8));
			kClosedTriangle.AppendElement(JPoint(10, 13));
			}

		const JColormap* colormap = p.GetColormap();

		if ((itsToggleDragIndex == cell.y && itsMouseInToggleFlag) ||
			itsDNDTargetIndex == JIndex(cell.y))
			{
			p.SetFilling(kJTrue);
			p.SetPenColor(colormap->GetBlackColor());
			p.Polygon(*triangle);
			}
		else
			{
			p.SetFilling(kJTrue);
			p.SetPenColor(colormap->GetGrayColor(90));
			p.Polygon(*triangle);

			p.SetFilling(kJFalse);
			p.SetPenColor(colormap->GetBlackColor());
			p.Polygon(*triangle);
			}

		p.ShiftOrigin(-(rect.topLeft()));
		}

	else if (JIndex(cell.x) == itsNodeColIndex)
		{
		JRect r = rect;
		r.left += GetNodeIndent(cell.y);
		p.SetClipRect(r);
		TLWDrawNode(p, cell, r);
		// Table controls clip rect, so we don't have to reset it.
		}
}
void
GPMProcessTreeList::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	GPMProcessTable::DrawRowBackground(p, cell, rect, (p.GetColormap())->GetGrayColor(95));

	if (cell.x == GPMProcessList::kTreeOpenClose ||
		cell.x == GPMProcessList::kTreeCommand)
		{
		JXNamedTreeListWidget::TableDrawCell(p, cell, rect);
		return;
		}

	HilightIfSelected(p, cell, rect);

	const JTreeNode* node        = GetTreeList()->GetNode(cell.y);
	const GPMProcessEntry& entry = * dynamic_cast<const GPMProcessEntry*>(node);

	JString str;
	JPainter::HAlignment halign = JPainter::kHAlignRight;
	if (cell.x == GPMProcessList::kTreeState)
		{
		GPMProcessTable::DrawProcessState(entry, p, rect, *itsZombieImage);
		}
	else if (cell.x == GPMProcessList::kTreePID)
		{
		str	= JString(entry.GetPID(), JString::kBase10);
		}
	else if (cell.x == GPMProcessList::kTreeUser)
		{
		str    = entry.GetUser();
		halign = JPainter::kHAlignLeft;
		}
/*	else if (cell.x == GPMProcessList::kTreePPID)
		{
		str	= JString(entry.GetPPID(), JString::kBase10);
		}
	else if (cell.x == GPMProcessList::kTreePriority)
		{
		str	= JString(entry.GetPriority(), JString::kBase10);
		}
*/	else if (cell.x == GPMProcessList::kTreeNice)
		{
		str	= JString(entry.GetNice(), JString::kBase10);
		}
	else if (cell.x == GPMProcessList::kTreeSize)
		{
		str	= JString(entry.GetSize(), JString::kBase10);
		}
/*	else if (cell.x == GPMProcessList::kTreeResident)
		{
		str	= JString(entry.GetResident(), JString::kBase10);
		}
	else if (cell.x == GPMProcessList::kTreeShare)
		{
		str	= JString(entry.GetShare(), JString::kBase10);
		}
*/	else if (cell.x == GPMProcessList::kTreeCPU)
		{
		str	= JString(entry.GetPercentCPU(), 1);
		}
	else if (cell.x == GPMProcessList::kTreeMemory)
		{
		str	= JString(entry.GetPercentMemory(), 1);
		}
	else if (cell.x == GPMProcessList::kTreeTime)
		{
		str	= JString(entry.GetTime(), JString::kBase10);
		}

	JRect r  = rect;
	r.left  += kHMarginWidth;
	r.right -= kHMarginWidth;
	p.JPainter::String(r, str, halign, JPainter::kVAlignCenter);
}