void
JXFSBindingTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JPoint editCell;
	if (GetEditedCell(&editCell) && cell == editCell)
		{
		return;
		}

	HilightIfSelected(p, cell, rect);

	const JFSBinding* b = itsBindingList->GetBinding(cell.y);
	JFSBinding::CommandType type;
	JBoolean singleFile;
	const JString& cmd = b->GetCommand(&type, &singleFile);

	if (cell.x == kPatternColumn)
		{
		p.SetFont(GetFontManager()->GetDefaultMonospaceFont());

		JRect r = rect;
		r.left += kHMarginWidth;
		p.String(r, b->GetPattern(), JPainter::kHAlignLeft, JPainter::kVAlignCenter);

		p.SetFont(GetFontManager()->GetDefaultFont());
		}
	else if (cell.x == kCommandColumn)
		{
		p.SetFont(GetFontManager()->GetDefaultMonospaceFont());

		JRect r = rect;
		r.left += kHMarginWidth;
		p.String(r, cmd, JPainter::kHAlignLeft, JPainter::kVAlignCenter);

		p.SetFont(GetFontManager()->GetDefaultFont());
		}
	else if (cell.x == kTypeColumn)
		{
		const JString& str = itsTypeMenu->GetItemText(kCmdTypeToMenuIndex[type]);
		p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
		}
	else if (cell.x == kSingleFileColumn && singleFile)
		{
		JRect r;
		r.top    = rect.ycenter();
		r.left   = rect.xcenter();
		r.bottom = r.top+1;
		r.right  = r.left+1;
		r.Expand(3, 3);

		p.SetFilling(kJTrue);
		p.Ellipse(r);
		p.SetFilling(kJFalse);
		}
}
JBoolean
CBSymbolTable::CalcColWidths
	(
	const JString& symbolName,
	const JString* signature
	)
{
	JSize w = (GetFontManager())->GetStringWidth(
		JGetDefaultFontName(), kJDefaultFontSize, JFontStyle(), symbolName);

	if (signature != NULL)
		{
		w += (GetFontManager())->GetStringWidth(
			JGetDefaultFontName(), kJDefaultFontSize, JFontStyle(), *signature);
		}

	if (w > itsMaxStringWidth)
		{
		itsMaxStringWidth = w;
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
JXPathInput::JXPathInput
	(
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXInputField(enclosure, hSizing, vSizing, x,y, w,h),
	itsCompleter(NULL),
	itsCompletionMenu(NULL)
{
	itsAllowInvalidPathFlag = kJFalse;
	itsRequireWriteFlag     = kJFalse;
	itsExpectURLDropFlag    = kJFalse;
	SetIsRequired();
	SetCharacterInWordFunction(IsCharacterInWord);
	SetDefaultFont(GetFontManager()->GetDefaultMonospaceFont());
	ShouldBroadcastCaretLocationChanged(kJTrue);
	SetHint(JGetString(kHintID));
	ListenTo(this);
}
THXVarTable::THXVarTable
	(
	THXVarList*			varList,
	JXTextMenu*			fontMenu,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h)
{
	const JSize rowHeight = 2*kVMarginWidth +
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle());
	SetDefaultRowHeight(rowHeight);

	itsVarList   = varList;
	itsTextInput = NULL;
	itsFontMenu  = fontMenu;

	AppendCols(2);	// name, function

	const JSize count = itsVarList->GetElementCount() - THXVarList::kUserFnOffset;
	AppendRows(count);

	FitToEnclosure();	// make sure SetColWidth() won't fail
	ListenTo(this);		// adjust fn col width

	SetColWidth(kNameColumn, GetApertureWidth()/3);
	// kFnColumn width set automatically
}
void
GLFitDescriptionList::SyncWithManager()
{
	RemoveAllRows();
	
	const JSize count = GetFitManager()->GetFitCount();
	AppendRows(count);

	itsNameList->DeleteAll();
	
	for (JIndex i=1; i<=count; i++)
		{
		const GLFitDescription& fd	= GetFitManager()->GetFitDescription(i);
		JString* str	= jnew JString(fd.GetFnName());
		assert(str != NULL);
		itsNameList->Append(str);

		const JCoordinate width = 2*kHMarginWidth + kIconWidth + 
			GetFontManager()->GetDefaultFont().GetStringWidth(*str);
		if (width > itsMinColWidth)
			{
			itsMinColWidth = width;
			}
		}

	AdjustColWidth();
}
void
FitParmsTable::Append
	(
	const JCharacter* col1, 
	const JCharacter* col2
	)
{
	
	const JFontManager* fm = GetFontManager();
	JSize lineHeight = fm->GetDefaultFont().GetLineHeight();
	AppendRows(1, lineHeight + 2);
	JString* str = jnew JString(col1);
	itsCol1->Append(str);
	JSize col1Width = GetColWidth(1);
	JSize strWidth = fm->GetDefaultFont().GetStringWidth(*str);
	if (strWidth + 10 > col1Width)
		{
		SetColWidth(1, strWidth + 10);
		}
	str = jnew JString(col2);
	itsCol2->Append(str);
	JSize col2Width = GetColWidth(2);
	strWidth = fm->GetDefaultFont().GetStringWidth(*str);
	if (strWidth + 10 > col2Width)
		{
		SetColWidth(2, strWidth + 10);
		}
	TableRefresh();
}
void
JXTabGroup::PlaceCardFile()
{
	const JSize h = kSelMargin + kBorderWidth + 2*kTextMargin +
					(GetFontManager())->GetLineHeight(itsFontName, itsFontSize, itsFontStyle);

	JRect r = GetAperture();
	if (itsEdge == kTop)
		{
		r.top += h;
		}
	else if (itsEdge == kLeft)
		{
		r.left += h;
		}
	else if (itsEdge == kBottom)
		{
		r.bottom -= h;
		}
	else if (itsEdge == kRight)
		{
		r.right -= h;
		}
	else
		{
		assert( 0 );
		}

	r.Shrink(kBorderWidth, kBorderWidth);
	itsCardFile->Place(r.left, r.top);
	itsCardFile->SetSize(r.width(), r.height());
}
CBShellEditor::CBShellEditor
	(
	CBTextDocument*		document,
	const JCharacter*	fileName,
	JXMenuBar*			menuBar,
	CBTELineIndexInput*	lineInput,
	CBTEColIndexInput*	colInput,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	CBTextEditor(document, fileName, menuBar, lineInput, colInput,
				 scrollbarSet, enclosure, hSizing, vSizing, x,y, w,h)
{
	itsShellDoc    = (CBShellDocument*) document;
	itsInsertIndex = 1;

	SetDefaultFontStyle(JFontStyle(kJTrue, kJFalse, 0, kJFalse));

	itsInsertFont            = GetDefaultFont();
	itsInsertFont.style.bold = kJFalse;
	itsInsertFont.id         = (GetFontManager())->UpdateFontID(itsInsertFont.id, itsInsertFont.size, itsInsertFont.style);
}
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);
}
void
JXTabGroup::ScrollUpToTab
	(
	const JIndex index
	)
{
	assert( itsTitles->IndexValid(index) );
	assert( index > itsFirstDrawIndex );

	const JFontManager* fontMgr = GetFontManager();
	const JFontID fontID        = fontMgr->GetFontID(itsFontName, itsFontSize, itsFontStyle);

	const JCoordinate scrollArrowWidth = 2*(kArrowWidth + kBorderWidth);

	const JRect ap        = GetAperture();
	const JCoordinate min = (itsEdge == kTop || itsEdge == kBottom ? ap.left : ap.top);
	const JCoordinate max = (itsEdge == kTop || itsEdge == kBottom ? ap.right : ap.bottom);
	JCoordinate left      = min + kSelMargin;
	JCoordinate right     = left;
	JArray<JCoordinate> widthList;

	const JSize count  = itsTitles->GetElementCount();
	JBoolean offScreen = kJFalse;
	for (JIndex i=itsFirstDrawIndex; i<=index; i++)
		{
		const TabInfo info = itsTabInfoList->GetElement(index);

		right += 2*kBorderWidth + info.preMargin + info.postMargin +
				 fontMgr->GetStringWidth(fontID, itsFontSize, itsFontStyle,
										 *(itsTitles->NthElement(i)));
		if (info.closable)
			{
			right += kCloseMarginWidth + itsCloseImage->GetWidth();
			}
		widthList.AppendElement(right - left);

		if (!offScreen &&
			right >= max - scrollArrowWidth &&
			!(itsFirstDrawIndex == 1 && i == count && right <= max))
			{
			offScreen = kJTrue;
			}

		left = right;
		}

	if (offScreen)
		{
		JIndex i = 1;
		while (right > max - scrollArrowWidth && itsFirstDrawIndex < index)
			{
			right -= widthList.GetElement(i);
			itsFirstDrawIndex++;
			i++;
			}
		}
}
JX2DCurveNameList::JX2DCurveNameList
	(
	const JArray<J2DCurveInfo>&	curveInfo,
	const JIndex				startIndex,
	JXScrollbarSet*				scrollbarSet,
	JXContainer*				enclosure,
	const HSizingOption			hSizing,
	const VSizingOption			vSizing,
	const JCoordinate			x,
	const JCoordinate			y,
	const JCoordinate			w,
	const JCoordinate			h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth +
		fontMgr->GetDefaultFont().GetLineHeight();
	SetDefaultRowHeight(rowHeight);

	const JSize count = curveInfo.GetElementCount();

	itsNameList = jnew JPtrArray<JString>(JPtrArrayT::kForgetAll, count);
	assert(itsNameList != NULL);

	AppendRows(count);
	for (JIndex i=1; i<=count; i++)
		{
		const J2DCurveInfo info = curveInfo.GetElement(i);
		itsNameList->Append(info.name);

		const JCoordinate width = 2*kHMarginWidth +
			fontMgr->GetDefaultFont().GetStringWidth(*(info.name));
		if (width > itsMinColWidth)
			{
			itsMinColWidth = width;
			}
		}

	AppendCols(1);
	AdjustColWidth();

	JXColormap* colormap = GetColormap();
	SetRowBorderInfo(0, colormap->GetBlackColor());
	SetColBorderInfo(0, colormap->GetBlackColor());

	BeginEditing(JPoint(1, startIndex));
}
void
CBSymbolTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	HilightIfSelected(p, cell, rect);

	const JIndex symbolIndex = CellToSymbolIndex(cell);

	CBLanguage lang;
	CBSymbolList::Type type;
	const JString& symbolName =
		itsSymbolList->GetSymbol(symbolIndex, &lang, &type);

	const JString* signature;
	itsSymbolList->GetSignature(symbolIndex, &signature);

	if (CalcColWidths(symbolName, signature))
		{
		AdjustColWidths();
		}

	const JXImage* icon     = NULL;
	const JFontStyle& style = (CBGetSymbolTypeList())->GetStyle(type, &icon);

	// draw icon

	if (icon != NULL)
		{
		JRect r = rect;
		r.right = r.left + kIconWidth;
		p.Image(*icon, icon->GetBounds(), r);
		}

	// draw name

	p.SetFontStyle(style);

	JRect r = rect;
	r.left += kIconWidth + kHMarginWidth;
	p.String(r, symbolName, JPainter::kHAlignLeft, JPainter::kVAlignCenter);

	if (signature != NULL)
		{
		r.left += (GetFontManager())->GetStringWidth(
			JGetDefaultFontName(), kJDefaultFontSize, JFontStyle(), symbolName);
		p.String(r, *signature, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
		}
}
GMAccountList::GMAccountList
	(
	GMAccountDialog*		dialog,
	JPtrArray<GMAccount>*	accounts,
	JXScrollbarSet*			scrollbarSet,
	JXContainer*			enclosure,
	const HSizingOption		hSizing,
	const VSizingOption		vSizing,
	const JCoordinate		x,
	const JCoordinate		y,
	const JCoordinate		w,
	const JCoordinate		h
	)
	:
   JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
   itsInput(NULL),
   itsDialog(dialog),
   itsAccountInfo(accounts)
{
	itsMinColWidth = 1;

	JXColormap* colormap         = GetColormap();
	const JColorIndex blackColor = colormap->GetBlackColor();
	SetRowBorderInfo(0, blackColor);
	SetColBorderInfo(0, blackColor);

	const JSize fontHeight =
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(),
		kJDefaultFontSize, JFontStyle());
	const JCoordinate rowHeight = fontHeight + 2*kVMarginWidth;
	SetDefaultRowHeight(rowHeight);
	SetAllRowHeights(rowHeight);

	itsLineHeight =
		GetFontManager()->GetLineHeight(JGetDefaultFontName(),
		kJDefaultFontSize, JFontStyle()) + 2 * kVMarginWidth;

	ListenTo(itsAccountInfo);
}
GLFitDescriptionList::GLFitDescriptionList
	(
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth + fontMgr->GetDefaultFont().GetLineHeight();
	SetDefaultRowHeight(rowHeight);

	const JSize count = GetFitManager()->GetFitCount();

	itsNameList = jnew JPtrArray<JString>(JPtrArrayT::kDeleteAll);
	assert(itsNameList != NULL);

	AppendCols(1);
	SyncWithManager();

	JXColormap* colormap = GetColormap();
	SetRowBorderInfo(0, colormap->GetBlackColor());
	SetColBorderInfo(0, colormap->GetBlackColor());

	itsBuiltInIcon	= jnew JXImage(GetDisplay(), JXPM(glBuiltInFit));
	assert(itsBuiltInIcon != NULL);
	itsBuiltInIcon->ConvertToRemoteStorage();

	itsNonLinearIcon	= jnew JXImage(GetDisplay(), JXPM(glNonLinearFit));
	assert(itsNonLinearIcon != NULL);
	itsNonLinearIcon->ConvertToRemoteStorage();

	itsPolyIcon	= jnew JXImage(GetDisplay(), JXPM(glPolyFit));
	assert(itsPolyIcon != NULL);
	itsPolyIcon->ConvertToRemoteStorage();

	itsExecutableIcon = jnew JXImage(GetDisplay(), JXPM(jx_executable_small));
	assert( itsExecutableIcon != NULL );
	itsExecutableIcon->ConvertToRemoteStorage();

	ListenTo(GetFitManager());
}
JXStyleTable::JXStyleTable
	(
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,kDefColWidth, scrollbarSet, enclosure,
				hSizing,vSizing, x,y, w,h)
{
	itsStyleData = new JStyleTableData(this, GetFontManager(), GetColormap());
	assert( itsStyleData != NULL );
}
GLFitParameterTable::GLFitParameterTable
	(
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL),
	itsHasStartValues(kJTrue),
	itsColHeaderWidget(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth +
		fontMgr->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle());
	SetDefaultRowHeight(rowHeight);

	itsNameList = new JPtrArray<JString>(JPtrArrayT::kDeleteAll);
	assert(itsNameList != NULL);

	itsStartValues	= new JArray<JFloat>;
	assert(itsStartValues != NULL);

	itsFitValues	= new JArray<JFloat>;
	assert(itsFitValues != NULL);

	itsErrorValues	= new JArray<JFloat>;
	assert(itsErrorValues != NULL);

	AppendCols(4, kDefColWidth);
	AdjustColWidth();

	JXColormap* colormap = GetColormap();
//	SetRowBorderInfo(0, colormap->GetBlackColor());
//	SetColBorderInfo(0, colormap->GetBlackColor());

}
Esempio n. 17
0
void
JXFontCharSetMenu::BuildMenu
	(
	const JCharacter*	fontName,
	const JSize			fontSize
	)
{
	RemoveAllItems();

	JPtrArray<JString> charSetList(JPtrArrayT::kDeleteAll);
	if (!(GetFontManager())->GetFontCharSets(fontName, fontSize, &charSetList))
		{
		itsCurrIndex = 0;
		itsCharSet.Clear();
		StopListening(this);
		return;
		}

	const JSize count = charSetList.GetElementCount();
	JString id;
	for (JIndex i=1; i<=count; i++)
		{
		const JString* charSet = charSetList.NthElement(i);
		id                     = *charSet + "::JX";
		AppendItem(*charSet, kJTrue, kJTrue, NULL, NULL, id);
		}

	SetUpdateAction(kDisableNone);

	itsCurrIndex = 1;
	itsCharSet   = *(charSetList.FirstElement());

	StopListening(this);
	JString name, charSet;
	if (JFontManager::ExtractCharacterSet(fontName, &name, &charSet))
		{
		SetCharSet(charSet);
		}
	else
		{
		SelectDefaultCharSet();
		}
	ListenTo(this);
}
JCoordinate
JXStyleTable::GetMin1DVisibleWidth
	(
	const JPoint& cell
	)
	const
{
	if (IsEditing())
		{
		return JXEditTable::GetMin1DVisibleWidth(cell);
		}
	else
		{
		JSize size;
		const JString& name = GetFont(&size);
		return kMin1DVisCharCount *
			(GetFontManager())->GetCharWidth(name, size, JFontStyle(), 'W');
		}
}
CBSymbolTable::CBSymbolTable
	(
	CBSymbolDirector*	symbolDirector,
	CBSymbolList*		symbolList,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXTable(10, 10, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h)
{
	itsSymbolDirector = symbolDirector;
	itsSymbolList     = symbolList;
	itsMaxStringWidth = 0;

	itsVisibleList = new JArray<JIndex>(CBSymbolList::kBlockSize);
	assert( itsVisibleList != NULL );

	itsVisibleListLockedFlag = kJFalse;
	itsNameFilter            = NULL;
	itsNameLiteral           = NULL;

	const JIndex blackColor = (GetColormap())->GetBlackColor();
	SetRowBorderInfo(0, blackColor);
	SetColBorderInfo(0, blackColor);

	AppendCols(1);
	SetDefaultRowHeight((GetFontManager())->
							GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) +
						2*kVMarginWidth);

	SetSelectionBehavior(kJTrue, kJTrue);

	ListenTo(itsSymbolList);
	ListenTo(CBGetSymbolTypeList());
}
JXFLInputBase::JXFLInputBase
	(
	JXFileListSet*			flSet,
	JXStringHistoryMenu*	historyMenu,
	JXContainer*			enclosure,
	const HSizingOption		hSizing,
	const VSizingOption		vSizing,
	const JCoordinate		x,
	const JCoordinate		y,
	const JCoordinate		w,
	const JCoordinate		h
	)
	:
	JXInputField(enclosure, hSizing, vSizing, x,y, w,h),
	itsFLSet(flSet),
	itsHistoryMenu(historyMenu)
{
	const JFont& font = GetFontManager()->GetDefaultMonospaceFont();
	SetFont(font);
	itsHistoryMenu->SetDefaultFont(font, kJTrue);
	ListenTo(itsHistoryMenu);
}
void
JXChooseMonoFont::PrependOtherMonospaceFonts
	(
	JXXFontMenu* menu
	)
{
	JPtrArray<JString> fontNames(JPtrArrayT::kDeleteAll);
	GetFontManager()->GetMonospaceFontNames(&fontNames);

	const JSize count = fontNames.GetElementCount();
	if (count > 0)
		{
		for (JIndex i=count; i>=1; i--)
			{
			const JString* fontName = fontNames.NthElement(i);
			menu->PrependItem(*fontName, JXMenu::kRadioType);
			menu->SetItemFontName(1, *fontName);
			}

		menu->ShowSeparatorAfter(count);
		}
}
void
CMLineIndexTable::AdjustToText()
{
	const JFontManager* fontMgr = GetFontManager();

	JFont font = itsText->GetCurrentFont();

	const JSize lineCount       = itsText->IsEmpty() ? 0 : itsText->GetLineCount();
	const JString lineCountStr  = GetLongestLineText(lineCount);
	const JSize lineHeight      = font.GetLineHeight();
	const JSize lineNumberWidth = font.GetStringWidth(lineCountStr);

	SetColWidth(kBreakpointColumn, lineHeight);
	SetColWidth(kExecPointColumn,  lineHeight);
	SetColWidth(kLineNumberColumn, lineNumberWidth + 2*kMarginWidth);

	SetAllRowHeights(lineHeight);
	const JSize origRowCount = GetRowCount();
	if (origRowCount < lineCount)
		{
		AppendRows(lineCount - origRowCount, lineHeight);
		}
	else if (origRowCount > lineCount)
		{
		RemovePrevRows(origRowCount, origRowCount - lineCount);
		}

	const JCoordinate tableWidth = GetBoundsWidth();
	const JCoordinate apWidth    = GetApertureWidth();
	if (tableWidth != apWidth)
		{
		AdjustSize(tableWidth-apWidth, 0);
		itsText->Place(GetFrameWidth(), 0);
		itsText->AdjustSize(apWidth-tableWidth, 0);
		}

	ScrollTo(0, itsVScrollbar->GetValue());
	UpdateBreakpoints();
}
void
GMFilterNameTable::GMFilterNameTableX()
{
	AppendCols(1, kDefColWidth);
	AdjustColWidths();

	const JFontManager* fm	= GetFontManager();
	itsRowHeight	=
		fm->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize,
						JFontStyle()) + kRowHeightAdjust;

	const JSize count = itsFilters->GetElementCount();
	AppendRows(count, itsRowHeight);

	AdjustButtons();
	WantInput(kJFalse);

	ListenTo(itsNewButton);
	ListenTo(itsRemoveButton);

	const Atom dndName	= GetDNDManager()->GetDNDSelectionName();
	GetDisplay()->RegisterXAtom(kDragFilterXAtomName);
}
JXInputField*
JXFSBindingTable::CreateXInputField
	(
	const JPoint&		cell,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
{
	assert( itsTextInput == NULL );

	JTableSelection& s = GetTableSelection();
	s.ClearSelection();
	s.SelectCell(cell);

	itsTextInput = jnew JXInputField(this, kFixedLeft, kFixedTop, x,y, w,h);
	assert( itsTextInput != NULL );

	const JFSBinding* b = itsBindingList->GetBinding(cell.y);
	if (cell.x == kPatternColumn)
		{
		itsTextInput->SetText(b->GetPattern());
		}
	else if (cell.x == kCommandColumn)
		{
		JFSBinding::CommandType type;
		JBoolean singleFile;
		const JString& cmd = b->GetCommand(&type, &singleFile);
		itsTextInput->SetText(cmd);
		}

	itsTextInput->SetFont(GetFontManager()->GetDefaultMonospaceFont());
	itsTextInput->SetIsRequired();
	ListenTo(itsTextInput);
	return itsTextInput;
}
void
FitParmsTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JString* str;
	p.SetFont(GetFontManager()->GetDefaultFont());
	JRect r = rect;
	if (cell.x == 1)
		{
		r.right -= kHMarginWidth;
		str = itsCol1->NthElement(cell.y);
		p.String(r, *str, JPainter::kHAlignRight, JPainter::kVAlignCenter);
		}
	else
		{
		r.left += kHMarginWidth;
		str = itsCol2->NthElement(cell.y);
		p.String(r, *str, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
		}
}
CBCommandTable::CBCommandTable
	(
	const CBCommandManager::CmdList& cmdList,

	JXTextButton*		addCmdButton,
	JXTextButton*		removeCmdButton,
	JXTextButton*		duplicateCmdButton,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h)
{
	itsTextInput   = NULL;
	itsDNDRowIndex = 0;

	itsCommandXAtom =
		(GetDisplay())->RegisterXAtom(CBCommandSelection::GetCommandXAtomName());

	// font

	(CBGetPrefsManager())->GetDefaultFont(&itsFontName, &itsFontSize);

	const JSize rowHeight = 2*kVMarginWidth + JMax(
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()),
		(GetFontManager())->GetLineHeight(itsFontName, itsFontSize, JFontStyle()));
	SetDefaultRowHeight(rowHeight);

	// buttons

	itsAddCmdButton       = addCmdButton;
	itsRemoveCmdButton    = removeCmdButton;
	itsDuplicateCmdButton = duplicateCmdButton;

	ListenTo(itsAddCmdButton);
	ListenTo(itsRemoveCmdButton);
	ListenTo(itsDuplicateCmdButton);

	// type menu

	itsOptionsMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10);
	assert( itsOptionsMenu != NULL );
	itsOptionsMenu->SetToHiddenPopupMenu();
	itsOptionsMenu->SetMenuItems(kOptionsMenuStr);
	itsOptionsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsOptionsMenu);

	// base path

	CBProjectDocument* doc = NULL;
	if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc))
		{
		itsBasePath = doc->GetFilePath();
		}

	// data

	itsCmdList = new CBCommandManager::CmdList(cmdList);
	assert( itsCmdList != NULL );
	FinishCmdListCopy(itsCmdList);

	for (JIndex i=1; i<=kColCount; i++)
		{
		AppendCols(1, kInitColWidth[i-1]);
		}

	AppendRows(itsCmdList->GetElementCount());

	UpdateButtons();
	ListenTo(&(GetTableSelection()));
}
JXFSBindingTable::JXFSBindingTable
	(
	JFSBindingList*		list,
	JXTextButton*		addButton,
	JXTextButton*		removeButton,
	JXTextButton*		duplicateButton,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption hSizing,
	const VSizingOption vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,1, scrollbarSet, enclosure, hSizing, vSizing, x, y, w, h),
	itsBindingList(list),
	itsAddButton(addButton),
	itsRemoveButton(removeButton),
	itsDuplicateButton(duplicateButton),
	itsTextInput(NULL)
{
	// row height

	const JSize rowHeight = 2*kVMarginWidth + JMax(
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()),
		(GetFontManager())->GetLineHeight(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle()));
	SetDefaultRowHeight(rowHeight);

	// buttons

	ListenTo(itsAddButton);
	ListenTo(itsRemoveButton);
	ListenTo(itsDuplicateButton);

	// type menu

	itsTypeMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10);
	assert( itsTypeMenu != NULL );
	itsTypeMenu->Hide();
	itsTypeMenu->SetToHiddenPopupMenu(kJTrue);
	itsTypeMenu->SetMenuItems(kTypeMenuStr);
	itsTypeMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsTypeMenu);

	// regex for testing

	itsTestRegex = new JRegex;
	assert( itsTestRegex != NULL );

	// data

	for (JIndex i=1; i<=kColCount; i++)
		{
		AppendCols(1, kInitColWidth[i-1]);
		}
	UpdateColWidths();

	const JSize rowCount = itsBindingList->GetElementCount();
	AppendRows(rowCount);

	UpdateButtons();
	ListenTo(&(GetTableSelection()));
}
Esempio n. 28
0
void
TestWidget::DrawStuff
	(
	JPainter& p
	)
{
JIndex i;

	JXColormap* colormap = GetColormap();

	p.SetPenColor(colormap->GetGreenColor());
	JRect ellipseRect(100,50,150,300);
	p.Ellipse(ellipseRect);

	p.SetPenColor(colormap->GetBlackColor());

	if (itsFillFlag)
		{
		p.SetFilling(kJTrue);
		}

	JRect ap = GetAperture();
	p.Line(ap.topLeft(), ap.bottomRight());
	p.Line(ap.topRight(), ap.bottomLeft());

	p.SetLineWidth(2);
	p.SetFontName("Times");
	p.SetFontSize(18);

	p.Image(*itsHomeImage, itsHomeImage->GetBounds(), itsHomeRect);

	its2Rect = JRect(150, 5, 200, 30);
	p.SetPenColor(colormap->GetRedColor());
	p.Rect(its2Rect);
	p.SetFontStyle(colormap->GetRedColor());
	p.String(its2Rect.topLeft(), "2",
			 its2Rect.width(),  JPainter::kHAlignCenter,
			 its2Rect.height(), JPainter::kVAlignCenter);

	its3Rect = JRect(10, 150, 40, 200);
	p.SetPenColor(colormap->GetBlueColor());
	p.Rect(its3Rect);
	p.SetFontStyle(colormap->GetBlueColor());
	p.String(its3Rect.topLeft(), "3",
			 its3Rect.width(),  JPainter::kHAlignCenter,
			 its3Rect.height(), JPainter::kVAlignCenter);

	p.SetLineWidth(1);
	p.SetFont(GetFontManager()->GetDefaultFont());

	p.ShiftOrigin(10,10);

	p.Point(0,0);
	for (i=1; i<=itsRandPointCount; i++)
		{
		p.Point(itsRNG.UniformLong(0,200), itsRNG.UniformLong(0,200));
		}

	p.SetPenColor(colormap->GetRedColor());
	p.Line(10,0, 0,10);
	p.SetPenColor(colormap->GetGreenColor());
	p.LineTo(10,20);
	p.SetPenColor(colormap->GetBlueColor());
	p.LineTo(0,30);

	p.ShiftOrigin(2,0);

	JPoint textPt(40,30);
	p.String(  0.0, textPt, "Hello");
	p.String( 90.0, textPt, "Hello");
	p.String(180.0, textPt, "Hello");
	p.String(270.0, textPt, "Hello");

	p.ShiftOrigin(-2, 0);

	p.SetPenColor(colormap->GetBlueColor());
	JRect r(70, 290, 150, 390);
	p.Rect(r);
/*
	for (JCoordinate y=70; y<150; y++)
		{
		p.SetPenColor(colormap->GetGrayColor(y-50));
		p.Line(290,y, 390,y);
		}

	for (JCoordinate x=290; x<390; x++)
		{
		p.SetPenColor(colormap->GetGrayColor(x-290));
		p.Line(x,70, x,150);
		}

	p.SetLineWidth(2);
	for (JCoordinate y=70; y<150; y+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60));
		p.Line(290,y, 390,y);
		}
	p.SetLineWidth(1);

	p.SetLineWidth(2);
	for (JCoordinate x=290; x<390; x+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60));
		p.Line(x,70, x,150);
		}
	p.SetLineWidth(1);
*/
	p.String(  0.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String( 90.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String(180.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String(270.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);

	p.String(  0.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String( 90.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String(180.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String(270.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);

	p.SetPenColor(colormap->GetBlueColor());
	p.Rect(200, 10, 100, 50);
	p.String(200, 10, "Hello", 100, JPainter::kHAlignLeft);
	p.String(200, 10+p.GetLineHeight(), "Hello", 100, JPainter::kHAlignCenter);
	p.String(200, 10+2*p.GetLineHeight(), "Hello", 100, JPainter::kHAlignRight);

	p.SetPenColor(colormap->GetDarkGreenColor());
	p.SetFilling(kJTrue);
	p.Rect(290, 160, 100, 80);
	p.SetFilling(kJFalse);
/*
	for (JCoordinate y=160; y<240; y++)
		{
		p.SetPenColor(colormap->GetGrayColor(y-140));
		p.Line(290,y, 390,y);
		}

	for (JCoordinate x=290; x<390; x++)
		{
		p.SetPenColor(colormap->GetGrayColor(x-290));
		p.Line(x,160, x,240);
		}

	p.SetLineWidth(2);
	for (JCoordinate y=160; y<240; y+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60));
		p.Line(290,y, 390,y);
		}
	p.SetLineWidth(1);

	p.SetLineWidth(2);
	for (JCoordinate x=290; x<390; x+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60));
		p.Line(x,160, x,240);
		}
	p.SetLineWidth(1);
*/
	textPt.Set(340, 200);
	p.SetFontName("Times");
	p.SetFontStyle(colormap->GetBlueColor());
	p.String(  0.0, textPt, "Hello");
	p.String( 90.0, textPt, "Hello");
	p.SetFontStyle(colormap->GetYellowColor());
	p.String(180.0, textPt, "Hello");
	p.String(270.0, textPt, "Hello");

	p.SetPenColor(colormap->GetYellowColor());
	r.Set(0,11,80,91);
	p.Rect(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetBlueColor());
	p.Ellipse(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetRedColor());
	p.Arc(r, 270.0-45.0, -270.0);

	JPolygon poly;
	poly.AppendElement(JPoint(0,85));
	poly.AppendElement(JPoint(10,85));
	poly.AppendElement(JPoint(5,95));
	p.Polygon(poly);

	p.Line(0,100, 2,98);
	p.LineTo(4,100);
	p.LineTo(2,102);
	p.LineTo(0,100);

	poly.SetElement(1, JPoint(0,5));
	poly.SetElement(2, JPoint(2,0));
	poly.SetElement(3, JPoint(4,5));
	p.Polygon(2,105, poly);

	// test filling rule

	p.SetPenColor(colormap->GetRedColor());
	p.SetFilling(kJTrue);

	JPolygon fillRulePoly;
	fillRulePoly.AppendElement(JPoint(175,45));
	fillRulePoly.AppendElement(JPoint(165,65));
	fillRulePoly.AppendElement(JPoint(190,50));
	fillRulePoly.AppendElement(JPoint(160,50));
	fillRulePoly.AppendElement(JPoint(185,65));
	p.Polygon(fillRulePoly);

	p.SetFilling(kJFalse);

	// dashed lines

	p.DrawDashedLines(kJTrue);

	p.SetPenColor(colormap->GetBlackColor());

	JArray<JSize> dashList;			// pixel rulers
	dashList.AppendElement(1);
	dashList.AppendElement(1);
	p.SetDashList(dashList);
	p.Line(100,110, 200,110);
	p.Line(100,114, 200,114);
	p.Line(100,118, 200,118);

	dashList.SetElement(1, 2);		// simple pattern
	dashList.SetElement(2, 3);
	p.SetDashList(dashList);
	p.Line(100,112, 200,112);

	p.SetFontStyle(JFontStyle(kJFalse, kJFalse, 1, kJFalse));
	p.String(130,155, "underline without dashes");

	p.SetDashList(dashList, 3);		// test offset
	p.Line(100,116, 200,116);

	dashList.SetElement(1, 1);		// example with odd # of values from X manuals
	dashList.SetElement(2, 2);
	dashList.AppendElement(3);
	p.SetDashList(dashList);
	p.Line(100,120, 200,120);

	dashList.SetElement(1, 5);		// dash-dot pattern
	dashList.SetElement(2, 2);
	dashList.SetElement(3, 1);
	dashList.AppendElement(2);
	p.SetDashList(dashList);
	p.Line(100,122, 200,122);

	p.Ellipse(210,110, 20,20);
	p.DrawDashedLines(kJFalse);
	p.Ellipse(213,113, 14,14);
	p.Rect(207,107, 26,26);
	p.SetPenColor(colormap->GetYellowColor());
	p.DrawDashedLines(kJTrue);
	p.Ellipse(213,113, 14,14);

	// icons

	p.Image(*itsXPMImage, itsXPMImage->GetBounds(), 33,110);
	p.Image(*itsPartialXPMImage, itsXPMImage->GetBounds(), 50,121);
}