本文整理汇总了C++中JArray::GetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ JArray::GetElement方法的具体用法?C++ JArray::GetElement怎么用?C++ JArray::GetElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArray
的用法示例。
在下文中一共展示了JArray::GetElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
JBoolean
GetEnclosure
(
const JArray<JRect>& rectList,
const JIndex rectIndex,
JIndex* enclIndex
)
{
const JRect theRect = rectList.GetElement(rectIndex);
JBoolean found = kJFalse;
*enclIndex = 0;
JSize minArea = 0;
const JSize count = rectList.GetElementCount();
for (JIndex i=1; i<=count; i++)
{
if (i != rectIndex)
{
const JRect r = rectList.GetElement(i);
const JSize a = r.area();
if (r.Contains(theRect) && (a < minArea || minArea == 0))
{
minArea = a;
found = kJTrue;
*enclIndex = i;
}
}
}
return found;
}
示例2: if
JVariableList::MatchResult
JVariableList::FindUniqueVarName
(
const JCharacter* prefix,
JIndex* index,
JString* maxPrefix
)
const
{
assert( !JStringEmpty(prefix) );
const JSize count = GetElementCount();
JArray<JIndex> matchList;
for (JIndex i=1; i<=count; i++)
{
const JString& name = GetVariableName(i);
if (name == prefix)
{
*index = i;
*maxPrefix = name;
return kSingleMatch;
}
else if (JStringBeginsWith(name, name.GetLength(), prefix))
{
matchList.AppendElement(i);
}
}
const JSize matchCount = matchList.GetElementCount();
if (matchCount == 0)
{
*index = 0;
maxPrefix->Clear();
return kNoMatch;
}
else if (matchCount == 1)
{
*index = matchList.GetElement(1);
*maxPrefix = GetVariableName(*index);
return kSingleMatch;
}
else
{
*maxPrefix = GetVariableName( matchList.GetElement(1) );
for (JIndex i=2; i<=matchCount; i++)
{
const JString& varName = GetVariableName( matchList.GetElement(i) );
const JSize matchLength = JCalcMatchLength(*maxPrefix, varName);
const JSize prefixLength = maxPrefix->GetLength();
if (matchLength < prefixLength)
{
maxPrefix->RemoveSubstring(matchLength+1, prefixLength);
}
}
*index = 0;
return kMultipleMatch;
}
}
示例3: GLUndoElementsChange
void
GLUndoElementsChange::Undo()
{
// we need to create this before we change the data, because
// it needs to read the old data first. We can't yet call NewUndo,
// though, because that will delete us.
GLUndoElementsChange* undo =
new GLUndoElementsChange(GetTable(), GetStartCell(), GetEndCell(), GetType());
assert(undo != NULL);
GRaggedFloatTableData* data = GetData();
JPoint start = GetStartCell();
JPoint end = GetEndCell();
GLUndoElementsBase::UndoType type = GetType();
if (type == GLUndoElementsBase::kRows)
{
}
else if (type == GLUndoElementsBase::kCols)
{
JSize cols = itsValues->GetElementCount();
for (JSize i = 1; i <= cols; i++)
{
JArray<JFloat>* col = itsValues->NthElement(i);
JSize rows = col->GetElementCount();
for (JSize j = 1; j <= rows; j++)
{
JFloat value = col->GetElement(j);
data->SetElement(j, i + start.x - 1, value);
}
}
}
else if (type == GLUndoElementsBase::kElements)
{
for (JSize i = start.x; i <= (JSize)end.x; i++)
{
JArray<JFloat>* col = itsValues->NthElement(i - start.x + 1);
JSize rows = col->GetElementCount();
for (JSize j = start.y; j <= start.y + rows -1; j++)
{
JFloat value = col->GetElement(j - start.y + 1);
data->SetElement(j, i, value);
}
}
}
NewUndo(undo);
}
示例4:
void
JInterPoly::AddPoints
(
const JArray<JFloat>& x,
const JArray<JFloat>& y
)
{
const JSize ptCount = x.GetElementCount();
assert( ptCount == y.GetElementCount() );
for (JIndex i=1; i<=ptCount; i++)
{
AddPoint(x.GetElement(i), y.GetElement(i));
}
}
示例5:
void
GRaggedFloatTableData::DuplicateRow
(
const JIndex index
)
{
const JSize colCount = itsCols->GetElementCount();
for (JIndex i=1; i<=colCount; i++)
{
JArray<JFloat>* colData = itsCols->NthElement(i);
const JSize rowCount = colData->GetElementCount();
if (index <= rowCount)
{
const JFloat element = colData->GetElement(index);
colData->InsertElementAtIndex(index, element);
}
}
RowsAdded(1);
if (itsBroadcast)
{
Broadcast(JTableData::RowDuplicated(index, index));
}
}
示例6: GetSubject
const JString&
GMessageHeader::GetBaseSubject()
{
if (itsHasBaseSubject)
{
return itsBaseSubject;
}
itsHasBaseSubject = kJTrue;
itsBaseSubject = GetSubject();
kFixSubjectRegex.SetCaseSensitive(kJFalse);
JArray<JIndexRange> subList;
while (kFixSubjectRegex.Match(itsBaseSubject, &subList))
{
itsBaseSubject = itsBaseSubject.GetSubstring(subList.GetElement(subList.GetElementCount()));
itsBaseSubject.TrimWhitespace();
subList.RemoveAll();
}
const JSize length = itsBaseSubject.GetLength();
JIndex findex = 1;
while (findex <= length &&
!isalnum(itsBaseSubject.GetCharacter(findex)))
{
findex++;
}
if (findex > 1 && findex <= length)
{
itsBaseSubject = itsBaseSubject.GetSubstring(findex, length);
}
return itsBaseSubject;
}
示例7:
JXPSPrintSetupDialog*
CBPSPrinter::CreatePrintSetupDialog
(
const Destination destination,
const JCharacter* printCmd,
const JCharacter* fileName,
const JBoolean collate,
const JBoolean bw
)
{
assert( itsCBPrintSetupDialog == NULL );
if (itsFontSize == kUnsetFontSize)
{
JString fontName;
CBGetPrefsManager()->GetDefaultFont(&fontName, &itsFontSize);
JArray<JIndexRange> matchList;
if (nxmRegex.Match(fontName, &matchList))
{
const JString hStr = fontName.GetSubstring(matchList.GetElement(2));
const JBoolean ok = hStr.ConvertToUInt(&itsFontSize);
assert( ok );
itsFontSize--;
}
}
itsCBPrintSetupDialog =
CBPSPrintSetupDialog::Create(destination, printCmd, fileName,
collate, bw, itsFontSize,
(CBGetPTTextPrinter())->WillPrintHeader());
return itsCBPrintSetupDialog;
}
示例8: if
JBoolean
CBCommandTable::WillAcceptDrop
(
const JArray<Atom>& typeList,
Atom* action,
const JPoint& pt,
const Time time,
const JXWidget* source
)
{
if (source == this)
{
return kJTrue;
}
else if (source == NULL)
{
return kJFalse;
}
const JSize typeCount = typeList.GetElementCount();
for (JIndex i=1; i<=typeCount; i++)
{
if (typeList.GetElement(i) == itsCommandXAtom)
{
return kJTrue;
}
}
return kJFalse;
}
示例9: WillAcceptDrop
JBoolean
JXPathInput::WillAcceptDrop
(
const JArray<Atom>& typeList,
Atom* action,
const JPoint& pt,
const Time time,
const JXWidget* source
)
{
itsExpectURLDropFlag = kJFalse;
const Atom urlXAtom = (GetSelectionManager())->GetURLXAtom();
JString dirName;
const JSize typeCount = typeList.GetElementCount();
for (JIndex i=1; i<=typeCount; i++)
{
if (typeList.GetElement(i) == urlXAtom &&
GetDroppedDirectory(time, kJFalse, &dirName))
{
*action = (GetDNDManager())->GetDNDActionPrivateXAtom();
itsExpectURLDropFlag = kJTrue;
return kJTrue;
}
}
return JXInputField::WillAcceptDrop(typeList, action, pt, time, source);
}
示例10: s
JBoolean
JParseURL
(
const JCharacter* url,
JString* protocol,
JString* host,
JIndex* port,
JString* path
)
{
*path = url;
JArray<JIndexRange> matchList;
if (urlPattern.Match(url, &matchList))
{
protocol->Set(url, matchList.GetElement(2));
host->Set(url, matchList.GetElement(3));
JIndexRange r = matchList.GetElement(4);
if (!r.IsEmpty())
{
const JString s(url, r);
if (!s.ConvertToUInt(port))
{
*port = 0;
}
}
else
{
*port = 0;
}
r = matchList.GetElement(5);
if (!r.IsEmpty())
{
path->Set(url, r);
}
else
{
*path = "/";
}
return kJTrue;
}
return kJFalse;
}
示例11: GetSelectionManager
JBoolean
JXExprEditor::EIPGetExternalClipboard
(
JString* text
)
{
text->Clear();
JBoolean gotData = kJFalse;
JXSelectionManager* selManager = GetSelectionManager();
JArray<Atom> typeList;
if (selManager->GetAvailableTypes(kJXClipboardName, CurrentTime, &typeList))
{
JBoolean canGetText = kJFalse;
Atom textType = None;
const JSize typeCount = typeList.GetElementCount();
for (JIndex i=1; i<=typeCount; i++)
{
Atom type = typeList.GetElement(i);
if (type == XA_STRING ||
(!canGetText && type == selManager->GetUtf8StringXAtom()))
{
canGetText = kJTrue;
textType = type;
break;
}
}
Atom returnType;
unsigned char* data = NULL;
JSize dataLength;
JXSelectionManager::DeleteMethod delMethod;
if (canGetText &&
selManager->GetData(kJXClipboardName, CurrentTime, textType,
&returnType, &data, &dataLength, &delMethod))
{
if (returnType == XA_STRING)
{
*text = JString(reinterpret_cast<JCharacter*>(data), dataLength);
gotData = kJTrue;
}
selManager->DeleteData(&data, delMethod);
}
else
{
(JGetUserNotification())->ReportError(
"Unable to paste the current contents of the X Clipboard.");
}
}
else
{
(JGetUserNotification())->ReportError("The X Clipboard is empty.");
}
return gotData;
}
示例12: GetFontManager
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++;
}
}
}
示例13: GetDisplay
void
TestWidget::PrintSelectionTargets
(
const Time time
)
{
JXDisplay* display = GetDisplay();
JXSelectionManager* selMgr = GetSelectionManager();
JXDNDManager* dndMgr = GetDNDManager();
JArray<Atom> typeList;
if (selMgr->GetAvailableTypes(kJXClipboardName, time, &typeList))
{
std::cout << std::endl;
std::cout << "Data types available from the clipboard:" << std::endl;
std::cout << std::endl;
const JSize typeCount = typeList.GetElementCount();
for (JIndex i=1; i<=typeCount; i++)
{
const Atom type = typeList.GetElement(i);
std::cout << XGetAtomName(*display, type) << std::endl;
}
for (JIndex i=1; i<=typeCount; i++)
{
const Atom type = typeList.GetElement(i);
if (type == XA_STRING ||
type == selMgr->GetUtf8StringXAtom() ||
type == selMgr->GetMimePlainTextXAtom())
{
std::cout << std::endl;
PrintSelectionText(kJXClipboardName, time, type);
}
}
}
else
{
std::cout << std::endl;
std::cout << "Unable to access the clipboard." << std::endl;
std::cout << std::endl;
}
}
示例14: lineIndexRegex
void
JExtractFileAndLine
(
const JCharacter* str,
JString* fileName,
JIndex* startLineIndex,
JIndex* endLineIndex
)
{
static JRegex lineIndexRegex(":([0-9]+)(-([0-9]+))?$");
*fileName = str;
JArray<JIndexRange> matchList;
if (lineIndexRegex.Match(*fileName, &matchList))
{
JString s = fileName->GetSubstring(matchList.GetElement(2));
JBoolean ok = s.ConvertToUInt(startLineIndex);
assert( ok );
const JIndexRange endRange = matchList.GetElement(4);
if (endLineIndex != NULL && !endRange.IsEmpty())
{
s = fileName->GetSubstring(endRange);
ok = s.ConvertToUInt(endLineIndex);
assert( ok );
}
else if (endLineIndex != NULL)
{
*endLineIndex = *startLineIndex;
}
fileName->RemoveSubstring(matchList.GetElement(1));
}
else
{
*startLineIndex = 0;
if (endLineIndex != NULL)
{
*endLineIndex = 0;
}
}
}
示例15:
static void
jCleanUserInfoMap()
{
const JSize count = theUserInfoMap.GetElementCount();
for (JIndex i=1; i<=count; i++)
{
jUIDInfo info = theUserInfoMap.GetElement(i);
info.Free();
}
}