void
JMemoryManager::ReadValue
	(
	JBoolean*         hasValue,
	unsigned char*    value,
	const JCharacter* string
	)
{
	*hasValue = JConvertToBoolean(string != NULL);

	if (*hasValue && JStringCompare(string, "no", kJFalse) != 0)
		{
		const JCharacter* start = string;
		while ( isspace(*start) )
			{
			++start;
			}
		if (*start != '\0') // The string has a non-space value, so try to read as a number
			{
			JCharacter* end;
			unsigned char theValue = (unsigned char) strtol(start, &end, 0);
			if (*end == '\0') // We read the entire string, so the value must be good
				{
				*value = theValue;
				}
			}
		}
}
Esempio n. 2
0
void
JXMenuData::InsertItem
	(
	const JIndex		index,
	const JBoolean		isCheckbox,
	const JBoolean		isRadio,
	const JCharacter*	shortcuts,
	const JCharacter*	id
	)
{
	BaseItemData itemData;
	itemData.isCheckbox = JConvertToBoolean(isCheckbox || isRadio);
	itemData.isRadio    = isRadio;

	if (!JStringEmpty(shortcuts))
		{
		itemData.shortcuts = new JString(shortcuts);
		assert( itemData.shortcuts != NULL );
		}

	if (!JStringEmpty(id))
		{
		itemData.id = new JString(id);
		assert( itemData.id != NULL );
		}

	itsBaseItemData->InsertElementAtIndex(index, itemData);
}
JBoolean
JXDocumentManager::SearchFileMap
	(
	const JCharacter*	fileName,
	JString*			newFileName
	)
	const
{
	const JSize mapCount = itsFileMap->GetElementCount();
	for (JIndex i=mapCount; i>=1; i--)
		{
		FileMap map          = itsFileMap->GetElement(i);
		const JBoolean match = JConvertToBoolean( *(map.oldName) == fileName );
		if (match && JFileExists(*(map.newName)))
			{
			*newFileName = *(map.newName);
			return kJTrue;
			}
		else if (match)		// newName no longer exists (lazy checking)
			{
			delete map.oldName;
			delete map.newName;
			itsFileMap->RemoveElement(i);
			}
		}

	return kJFalse;
}
JBoolean
JParenthesesBalanced
	(
	const JCharacter*	expr,
	const JSize			length
	)
{
	long parenCount = 0;
	for (JSize i=0; i<length; i++)
		{
		if (*(expr + i) == '(')
			{
			parenCount++;
			}
		else if (*(expr + i) == ')')
			{
			parenCount--;
			}

		// if the count goes negative, it's an instant error

		if (parenCount < 0)
			{
			return kJFalse;
			}
		}

	// if the count is nonzero, a parentheses was not closed

	return JConvertToBoolean(parenCount == 0);
}
void
JXSearchTextDialog::UpdateDisplay()
{
	const JBoolean hasSearchText = HasSearchText();
	const JBoolean teWritable =
		JConvertToBoolean( itsTE != NULL && itsTE->GetType() == JTextEditor::kFullEditor );

	const JBoolean canSearch = JI2B(itsTE != NULL && !itsTE->IsEmpty() && hasSearchText);
	itsFindFwdButton->SetActive(canSearch);
	itsFindBackButton->SetActive(canSearch);

	const JBoolean canReplace = JI2B(canSearch && teWritable && itsTE->HasSelection());
	itsReplaceButton->SetActive(canReplace);
	itsReplaceFindFwdButton->SetActive(canReplace);
	itsReplaceFindBackButton->SetActive(canReplace);

	const JBoolean canReplaceAll = JI2B(canSearch && teWritable);
	itsReplaceAllFwdButton->SetActive(canReplaceAll);
	itsReplaceAllBackButton->SetActive(canReplaceAll);

	itsReplaceAllInSelButton->SetActive(canReplace);

	itsSingleLineCB->SetActive(itsSearchIsRegexCB->IsChecked());

	itsRetainFocusCB->SetActive(itsStayOpenCB->IsChecked());
}
JBoolean
JXGC::GetClipping
	(
	JPoint*			offset,
	Region*			region,
	JXImageMask**	pixmap
	)
{
	*offset = itsClipOffset;

	if (itsClipRegion != NULL)
		{
		*region = JXCopyRegion(itsClipRegion);
		}
	else
		{
		*region = NULL;
		}

	if (itsClipPixmap != None)
		{
		*pixmap = new JXImageMask(itsDisplay, itsClipPixmap);
		assert( *pixmap != NULL );
		}
	else
		{
		*pixmap = NULL;
		}

	return JConvertToBoolean( itsClipRegion != NULL || itsClipPixmap != None );
}
JBoolean
JFunctionWithVar::SameAs
	(
	const JFunction& theFunction
	)
	const
{
	if (!JFunction::SameAs(theFunction))
		{
		return kJFalse;
		}

	const JFunctionWithVar& theFunctionWithVar = (const JFunctionWithVar&) theFunction;

	if (itsVariableIndex != theFunctionWithVar.itsVariableIndex)
		{
		return kJFalse;
		}

	if (itsArrayIndex == NULL && theFunctionWithVar.itsArrayIndex == NULL)
		{
		return kJTrue;
		}
	else if (itsArrayIndex == NULL || theFunctionWithVar.itsArrayIndex == NULL)
		{
		return kJFalse;
		}
	else
		{
		return JConvertToBoolean( itsArrayIndex->SameAs(*(theFunctionWithVar.itsArrayIndex)) );
		}
}
JBoolean
SCPassiveLinearFilter
	(
	const SCComponent& comp
	)
{
	return JConvertToBoolean( comp.CastToSCPassiveLinearComp() != NULL );
}
JBoolean
JXIsPrint
	(
	const int keysym
	)
{
	return JConvertToBoolean( 0 < keysym && keysym <= 255 && JIsPrint(keysym) );
}
JBoolean
SCDepSourceFilter
	(
	const SCComponent& comp
	)
{
	return JConvertToBoolean( comp.CastToSCDepSource() != NULL );
}
JBoolean
JFunction::SameAs
	(
	const JFunction& theFunction
	)
	const
{
	return JConvertToBoolean( itsType == theFunction.itsType );
}
JBoolean
CBFnListDirector::IsShowingClass
	(
	const CBClass* theClass
	)
	const
{
	return JConvertToBoolean( itsFnListWidget->GetClass() == theClass );
}
JBoolean
JDecision::SameAs
	(
	const JDecision& theDecision
	)
	const
{
	return JConvertToBoolean( itsType == theDecision.itsType );
}
Esempio n. 14
0
JBoolean
JXWidget::HasFocus()
	const
{
	JXWidget* focusWidget;
	return JConvertToBoolean(
			(GetWindow())->GetFocusWidget(&focusWidget) &&
			focusWidget == this);
}
JBoolean
JBooleanXOR::Evaluate()
	const
{
	const JBoolean arg1 = (GetArg1())->Evaluate();
	const JBoolean arg2 = (GetArg2())->Evaluate();

	return JConvertToBoolean((arg1 && !arg2) || (!arg1 && arg2));
}
Esempio n. 16
0
JBoolean
JGetAssertHandler
	(
	JAssertBase** ah
	)
{
	*ah = theAssertHandler;
	return JConvertToBoolean( *ah != NULL );
}
JBoolean
SCCircuitVarList::ArrayIndexValid
	(
	const JIndex variableIndex,
	const JIndex elementIndex
	)
	const
{
	return JConvertToBoolean( elementIndex == 1 );
}
JBoolean
JXButtonStates::GetState
	(
	const unsigned int	state,
	const JIndex		i
	)
{
	assert( 0 < i && i <= kXButtonCount );
	return JConvertToBoolean( (state & (1L << (i+7))) != 0 );
}
JBoolean
SCVdepSource::RequiresNode
	(
	const JIndex index
	)
	const
{
	return JConvertToBoolean(index == itsPosDepNode || index == itsNegDepNode ||
							 SCDepSource::RequiresNode(index));
}
Esempio n. 20
0
JBoolean
JStringsEqual
	(
	const JCharacter*	s1,
	const JSize			s1Length,
	const JCharacter*	s2
	)
{
	return JConvertToBoolean( s1Length == strlen(s2) && memcmp(s2, s1, s1Length) == 0 );
}
JBoolean
SCLinearComp::RequiresNode
	(
	const JIndex index
	)
	const
{
	return JConvertToBoolean(index == itsPosNode || index == itsNegNode ||
							 SCComponent::RequiresNode(index));
}
Esempio n. 22
0
JBoolean
JXImage::GetMask		// virtual
	(
	JImageMask** mask
	)
	const
{
	*mask = itsMask;
	return JConvertToBoolean( itsMask != NULL );
}
JBoolean
JDiscreteEquality::ValueValid
	(
	const JIndex value
	)
	const
{
	return JConvertToBoolean( 1 <= value &&
				value <= (GetVariableList())->GetDiscreteValueCount(GetVariableIndex()) );
}
JBoolean
JDirInfo::OKToCreate
	(
	const JCharacter* dirName
	)
{
	return JConvertToBoolean( JDirectoryExists(dirName) &&
							  JDirectoryReadable(dirName) &&
							  JCanEnterDirectory(dirName) );
}
void
JXButtonStates::SetState
	(
	const unsigned int state
	)
{
	for (JIndex i=0; i<kXButtonCount; i++)
		{
		itsState[i] = JConvertToBoolean( (state & (1L << (i+8))) != 0 );
		}
}
Esempio n. 26
0
JBoolean
JSkipBlockAtLeft
	(
	const JCharacter*	sourceStart,
	JSize*				offset
	)
{
	return JConvertToBoolean(
			JSkipBlockAtLeft(sourceStart, offset, '(', ')') &&
			JSkipBlockAtLeft(sourceStart, offset, '[', ']'));
}
JBoolean
ParenthesizeArgForRender
	(
	const JFunction& f,
	const JFunction& arg
	)
{
	return JConvertToBoolean(
				kNeedParenForRender[ GetParenType(f) * kFunctionParenTypeCount +
									 GetParenType(arg)] );
}
Esempio n. 28
0
JBoolean
JXWidget::AcceptDrag
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JXKeyModifiers&	modifiers
	)
{
	return JConvertToBoolean(
			JXContainer::AcceptDrag(pt, button, modifiers) &&
			(!itsWantInputFlag || (GetWindow())->SwitchFocusToWidget(this)));
}
Esempio n. 29
0
JBoolean
TestWidget::HitSamePart
	(
	const JPoint& pt1,
	const JPoint& pt2
	)
	const
{
	return JConvertToBoolean(
			(its2Rect.Contains(pt1) && its2Rect.Contains(pt2)) ||
			(its3Rect.Contains(pt1) && its3Rect.Contains(pt2)));
}
Esempio n. 30
0
JBoolean
JXTable::HitSamePart
	(
	const JPoint& pt1,
	const JPoint& pt2
	)
	const
{
	JPoint cell1, cell2;
	return JConvertToBoolean( GetCell(pt1, &cell1) &&
							  GetCell(pt2, &cell2) &&
							  cell1 == cell2 );
}