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; }
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; }
void GRaggedFloatTableData::InsertElement ( const JIndex row, const JIndex col, const JFloat value ) { JArray<JFloat>* dataCol = itsCols->NthElement(col); dataCol->InsertElementAtIndex(row, value); const JSize rowCount = dataCol->GetElementCount(); if (itsBroadcast) { Broadcast(GRaggedFloatTableData::ElementInserted(row, col)); } if (rowCount == GetRowCount()) { RowsAdded(1); if (itsBroadcast) { Broadcast(JTableData::RowsInserted(rowCount+1, 1)); } } }
void GRaggedFloatTableData::RemoveElement ( const JIndex row, const JIndex col ) { JArray<JFloat>* dataCol = itsCols->NthElement(col); const JSize rowCount = dataCol->GetElementCount(); if (row <= rowCount) { dataCol->RemoveElement(row); } if (itsBroadcast) { Broadcast(GRaggedFloatTableData::ElementRemoved(row, col)); } if (GetMaxRowCount() == GetRowCount() - 2) { if (itsBroadcast) { Broadcast(JTableData::RowsRemoved(GetRowCount(), 1)); } RowsDeleted(1); } }
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)); } }
void GRaggedFloatTableData::InsertCol ( const JIndex index, const JOrderedSet<JFloat>* initData ) { JIndex trueIndex = index; const JIndex maxIndex = itsCols->GetElementCount()+1; if (trueIndex > maxIndex) { trueIndex = maxIndex; } JArray<JFloat>* colData = jnew JArray<JFloat>; assert( colData != NULL ); itsCols->InsertAtIndex(trueIndex, colData); if (initData != NULL) { const JSize rowCount = initData->GetElementCount(); for (JIndex i=1; i<=rowCount; i++) { colData->InsertElementAtIndex(i, initData->GetElement(i)); } } ColsAdded(1); if (itsBroadcast) { Broadcast(JTableData::ColsInserted(trueIndex, 1)); } }
JArray JLEDObj::getProperties() { JArray properties = JModuleObj::getProperties(); properties.append(JIntegerProperty("value", value, -limit-1, limit)); properties.append(JColorProperty("color", color)); properties.append(JColorProperty("bkgnd", bkgnd)); return properties; }
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; }
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; }
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); }
JArray JTNG4Obj::getProperties() { JArray properties = JTNG3Obj::getProperties(); properties.append(JIntegerProperty("oseparator0", oseparators[0], 0, 255)); properties.append(JIntegerProperty("oseparator1", oseparators[1], 0, 255)); properties.append(JIntegerListProperty("exclusive", exclusive, JIntegerListProperty::booleanTag)); properties.append(JIntegerProperty("extraInputCount", extraInputCount, 0, 32-IN_LAST)); return properties; }
JArray JDelaySustainObj::getProperties() { JArray properties = JAddObj::getProperties(); properties.append(JIntegerProperty("delay", delay, 0, 65535)); properties.append(JIntegerProperty("sustain", sustain, 0, 65535)); return properties; }
JArray J1DMObj::getProperties() { JArray properties = JModuleObj::getProperties(); properties.append(JIntegerProperty("vx", v[0], 0, mask)); properties.append(JIntegerProperty("vy", v[1], 0, mask)); properties.append(JColorProperty("color", color)); properties.append(JColorProperty("bkgnd", bkgnd)); return properties; }
JArray<T> expand_to_rank(int rank, const JArray<T>& array) { assert(rank >= array.get_rank()); Dimensions old_dims(array.get_dims()); shared_ptr<vector<int> > new_dims_vector(new vector<int>(rank, 1)); copy(old_dims.begin(), old_dims.end(), new_dims_vector->begin() + (rank - array.get_rank())); return JArray<T>(new_dims_vector, array.get_content()); }
JArray JRealComplexObj::getProperties() { JArray properties = JLabelObj::getProperties(); properties.append(JRealProperty("real", cval.r, w, f)); properties.append(JRealProperty("imag", cval.i, w, f)); properties.append(JIntegerProperty("width", w, 3, 20)); properties.append(JIntegerProperty("float", f, 1, w-2)); return properties; }
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; }
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++; } } }
JArray<JTEStyler::TokenData>* JTEStyler::NewTokenStartList() { JArray<TokenData>* list = new JArray<TokenData>(kListBlockSize); assert( list != NULL ); list->SetSortOrder(JOrderedSetT::kSortAscending); list->SetCompareFunction(CompareTokenStarts); return list; }
GLUndoElementsChange::GLUndoElementsChange ( GXRaggedFloatTable* table, const JPoint& start, const JPoint& end, const GLUndoElementsBase::UndoType type ) : GLUndoElementsBase(table, start, end, type) { itsValues = new JPtrArray<JArray<JFloat> >(JPtrArrayT::kDeleteAll); assert(itsValues != NULL); GRaggedFloatTableData* data = GetData(); JIndex colstart; JIndex colend; if (type == GLUndoElementsBase::kRows) { colstart = 1; colend = data->GetDataColCount(); } else { colstart = start.x; colend = end.x; } for (JSize i = colstart; i <= colend; i++) { JArray<JFloat>* col = new JArray<JFloat>; assert(col != NULL); itsValues->Append(col); JIndex rowstart; JIndex rowend; if (type == GLUndoElementsBase::kCols) { rowstart = 1; rowend = data->GetDataRowCount(i); } else { rowstart = start.y; rowend = JMin((JSize)end.y, data->GetDataRowCount(i)); } for (JSize j = rowstart; j <= rowend; j++) { JFloat value; if (data->GetElement(j, i, &value)) { col->AppendElement(value); } } } }
JFontStyle CBHTMLStyler::GetTagStyle ( const JIndexRange& tokenRange, const JIndex typeIndex ) { const JString& text = GetText(); JFontStyle style; JArray<JIndexRange> matchList; if (tagNamePattern.MatchWithin(text, tokenRange, &matchList)) { itsLatestTagName = text.GetSubstring(matchList.GetElement(2)); itsLatestTagName.ToLower(); JString openTag; if (itsLatestTagName.GetFirstCharacter() == '/' && itsLatestTagName.GetLength() > 1) { openTag = itsLatestTagName.GetSubstring(2, itsLatestTagName.GetLength()); } JBoolean found = GetWordStyle(itsLatestTagName, &style); if (!found && !openTag.IsEmpty()) { found = GetWordStyle(openTag, &style); } if (!found) { found = GetXMLStyle(itsLatestTagName, &style); } if (!found && !openTag.IsEmpty()) { found = GetXMLStyle(openTag, &style); } if (!found) { style = GetTypeStyle(typeIndex); } } else if (text.GetCharacter(tokenRange.first) == '<') { itsLatestTagName.Clear(); style = GetTypeStyle(typeIndex); } else { style = GetStyle(typeIndex, itsLatestTagName); } return style; }
static void jCleanUserInfoMap() { const JSize count = theUserInfoMap.GetElementCount(); for (JIndex i=1; i<=count; i++) { jUIDInfo info = theUserInfoMap.GetElement(i); info.Free(); } }
JArray JTNGObj::getProperties() { JArray properties = JANDObj::getProperties(); properties.append(JIntegerProperty("factor", factor, 1, 256)); properties.append(JIntegerProperty("channelCount", channelCount, 4, 32)); for (int i=0; i<channelCount; i++) properties.append(JIntegerListProperty( JString("inv-")+JInteger::toJString(i+1), inv[i], JIntegerListProperty::booleanTag)); return properties; }
JBoolean TestWidget::WillAcceptDrop ( const JArray<Atom>& typeList, Atom* action, const Time time, const JXWidget* source ) { JXDNDManager* dndMgr = GetDNDManager(); if (typeList.GetFirstElement() == (GetSelectionManager())->GetURLXAtom()) { cout << endl; cout << "Accepting the drop of type text/uri-list" << endl; cout << endl; *action = dndMgr->GetDNDActionPrivateXAtom(); return kJTrue; } else if (*action == dndMgr->GetDNDActionCopyXAtom()) { cout << endl; cout << "Accepting the drop" << endl; cout << endl; PrintSelectionText(dndMgr->GetDNDSelectionName(), time, (GetSelectionManager())->GetMimePlainTextXAtom()); return kJTrue; } else { JXDisplay* display = GetDisplay(); cout << endl; cout << "Not accepting the drop because the action isn't copy" << endl; cout << "Action: " << XGetAtomName(*display, *action) << endl; cout << endl; cout << "Data types available from DND source:" << endl; cout << endl; const JSize typeCount = typeList.GetElementCount(); for (JIndex i=1; i<=typeCount; i++) { const Atom type = typeList.GetElement(i); cout << XGetAtomName(*display, type) << endl; } cout << endl; PrintSelectionText(dndMgr->GetDNDSelectionName(), time, (GetSelectionManager())->GetMimePlainTextXAtom()); return kJFalse; } }
void GDBPlot2DCommand::HandleSuccess ( const JString& data ) { JArray<JFloat>* x = GetX(); JArray<JFloat>* y = GetY(); if ((GetLastResult()).BeginsWith("error,msg=\"No symbol")) { x->RemoveAll(); y->RemoveAll(); return; } const JIndex count = x->GetElementCount(); JIndex i; JIndexRange r; JArray<JIndexRange> matchRange1, matchRange2; JString v1, v2; for (i=1; i<=count; i++) { if (!prefixPattern.MatchAfter(data, r, &matchRange1)) { break; } r = matchRange1.GetElement(1); if (!prefixPattern.MatchAfter(data, r, &matchRange2)) { break; } r = matchRange2.GetElement(1); v1 = data.GetSubstring(matchRange1.GetElement(2)); v1.TrimWhitespace(); v2 = data.GetSubstring(matchRange2.GetElement(2)); v2.TrimWhitespace(); JFloat x1, y1; if (!v1.ConvertToFloat(&x1) || !v2.ConvertToFloat(&y1)) { break; } x->SetElement(i, x1); y->SetElement(i, y1); } if (i <= count) { const JSize delta = count - (i-1); x->RemoveNextElements(count - delta + 1, delta); y->RemoveNextElements(count - delta + 1, delta); } }
JArray JListBox::getSelectedItems() { JArray Selected; int size = content.size(); for (int i=0; i<size; i++) { JAssociation &obj = *(JAssociation*)content[i]; if ((int)*(JInteger*)obj.value() == 1) { Selected.append(*obj.key()); } } return Selected; }
JBoolean SVNTabBase::ExecuteDiff ( const JCharacter* origCmd, const JCharacter* rev, const JBoolean isPrev ) { JPtrArray<JString> fileList(JPtrArrayT::kDeleteAll); JArray<JIndex> revList; GetSelectedFilesForDiff(&fileList, &revList); if (fileList.IsEmpty()) { return kJFalse; } (JXGetApplication())->DisplayBusyCursor(); JSubstitute subst; subst.DefineVariable("rev_option", rev); const JBoolean customPrev = JI2B( isPrev && !revList.IsEmpty() ); const JSize count = fileList.GetElementCount(); JString cmd, fullName, r; for (JIndex i=1; i<=count; i++) { cmd = origCmd; fullName = JPrepArgForExec(*(fileList.NthElement(i))); if (customPrev) { const JIndex j = revList.GetElement(i); r = JString(j-1, JString::kBase10); r += ":"; r += JString(j, JString::kBase10); subst.DefineVariable("rev_option", r); } subst.DefineVariable("file_name", fullName); subst.Substitute(&cmd); if (itsDirector->HasPath()) { JSimpleProcess::Create(itsDirector->GetPath(), cmd, kJTrue); } else { JSimpleProcess::Create(cmd, kJTrue); } } return kJTrue; }
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 DoGetProperties(const JObject* obj, void** arg) { JArray properties = ((JViewObj*)obj)->getProperties(); JArray &collection = *(JArray*)arg[0]; JDictionary &dict = *(JDictionary*)arg[1]; int sz = properties.size(); for (int i=0; i<sz; i++) { JProperty &prop = *(JProperty*)properties[i]; if (!dict[prop.getName()]) { dict.add(prop.getName(), prop); collection.append(prop); } } }
void JColormap::SetDynamicColors ( const JArray<JDynamicColorInfo>& colorList ) { const JSize count = colorList.GetElementCount(); for (JIndex i=1; i<=count; i++) { const JDynamicColorInfo info = colorList.GetElement(i); SetDynamicColor(info.index, info.color); } }
void JPlotFitQuad::JPlotFitQuadX ( J2DPlotWidget* plot, JPlotDataBase* fitData ) { JArray<JIndex> powers; powers.AppendElement(0); powers.AppendElement(1); powers.AppendElement(2); InitializePolynomial(powers); }