void JXFSBindingManager::BuildCommand ( JString* cmd, const JCharacter* q, const JCharacter* u, const JCharacter* qf, const JCharacter* uf ) { if (cmd->Contains("$")) { const JCharacter* map[] = { "q", q, "u", u, "qf", qf, "uf", uf }; (JGetStringManager())->Replace(cmd, map, sizeof(map)); } else { *cmd += " "; *cmd += qf; } }
JBoolean GFGLink::StartCTags() { assert( itsCTagsProcess == NULL ); JString cmd = kCTagsCmd; int toFD, fromFD; const JError err = JProcess::Create(&itsCTagsProcess, cmd, kJCreatePipe, &toFD, kJCreatePipe, &fromFD, kJAttachToFromFD, NULL); if (err.OK()) { itsOutputLink = jnew JOutPipeStream(toFD, kJTrue); assert( itsOutputLink != NULL ); itsInputFD = fromFD; assert( itsInputFD != ACE_INVALID_HANDLE ); ListenTo(itsCTagsProcess); return kJTrue; } else { (JGetStringManager())->ReportError(kUnableToStartCTagsID, err); return kJFalse; } }
void JWebBrowser::ShowFileLocation ( const JCharacter* fileName ) { if (!JStringEmpty(itsShowFileLocationCmd)) { JString fullName = fileName; JStripTrailingDirSeparator(&fullName); JString path, name; JSplitPathAndName(fullName, &path, &name); const JCharacter* map[] = { kFileVarName, fullName, kPathVarName, path }; JString s = itsShowFileLocationCmd; if (!s.Contains("$")) { s += " '$"; s += kFileVarName; s += "'"; } (JGetStringManager())->Replace(&s, map, sizeof(map)); JSimpleProcess::Create(s, kJTrue); } }
JString CMLink::Build1DArrayExpressionForCFamilyLanguage ( const JCharacter* origExpr, const JInteger index ) { JString expr = origExpr; const JString indexStr(index, 0); // must use floating point conversion if (expr.Contains("$i")) { const JCharacter* map[] = { "i", indexStr.GetCString() }; (JGetStringManager())->Replace(&expr, map, sizeof(map)); } else { if (expr.GetFirstCharacter() != '(' || expr.GetLastCharacter() != ')') { expr.PrependCharacter('('); expr.AppendCharacter(')'); } expr.AppendCharacter('['); expr += indexStr; expr.AppendCharacter(']'); } return expr; }
JString CMLink::Build2DArrayExpressionForCFamilyLanguage ( const JCharacter* origExpr, const JInteger rowIndex, const JInteger colIndex ) { JString expr = origExpr; const JBoolean usesI = expr.Contains("$i"); // row const JBoolean usesJ = expr.Contains("$j"); // col const JString iStr(rowIndex, 0); // must use floating point conversion const JString jStr(colIndex, 0); // must use floating point conversion // We have to do both at the same time because otherwise we lose a $. if (usesI || usesJ) { const JCharacter* map[] = { "i", iStr.GetCString(), "j", jStr.GetCString() }; (JGetStringManager())->Replace(&expr, map, sizeof(map)); } if (!usesI || !usesJ) { if (expr.GetFirstCharacter() != '(' || expr.GetLastCharacter() != ')') { expr.PrependCharacter('('); expr.AppendCharacter(')'); } if (!usesI) { expr.AppendCharacter('['); expr += iStr; expr.AppendCharacter(']'); } if (!usesJ) { expr.AppendCharacter('['); expr += jStr; expr.AppendCharacter(']'); } } return expr; }
JBoolean SyGGetTrashDirectory ( JString* path, const JBoolean reportErrors ) { if (!theTrashDir.IsEmpty()) { *path = theTrashDir; return kJTrue; } if (!JGetPrefsDirectory(path)) { if (reportErrors) { (JGetUserNotification())->ReportError(JGetString(kNoPrefsDirID)); } return kJFalse; } *path = JCombinePathAndName(*path, kTrashDirName); JError err = JNoError(); if (!JDirectoryExists(*path)) { err = JCreateDirectory(*path, kTrashCanPerms); } else { err = JSetPermissions(*path, kTrashCanPerms); } if (err.OK()) { theTrashDir = *path; const JBoolean ok = JDirInfo::Create(theTrashDir, &theTrashDirInfo); assert( ok ); return kJTrue; } else { path->Clear(); if (reportErrors) { (JGetStringManager())->ReportError(kCreateTrashErrorID, err); } return kJFalse; } }
JBoolean SyGGetRecentFileDirectory ( JString* path, const JBoolean reportErrors ) { if (!theRecentFileDir.IsEmpty()) { *path = theRecentFileDir; return kJTrue; } if (!JGetPrefsDirectory(path)) { if (reportErrors) { (JGetUserNotification())->ReportError(JGetString(kNoPrefsDirID)); } return kJFalse; } *path = JCombinePathAndName(*path, kRecentFileDirName); JError err = JNoError(); if (!JDirectoryExists(*path)) { err = JCreateDirectory(*path, kRecentFileDirPerms); } else { err = JSetPermissions(*path, kRecentFileDirPerms); } if (err.OK()) { theRecentFileDir = *path; return kJTrue; } else { path->Clear(); if (reportErrors) { (JGetStringManager())->ReportError(kCreateRecentFileDirErrorID, err); } return kJFalse; } }
void JWebBrowser::Exec ( const JCharacter* cmd, const JCharacter* varName, const JCharacter* value ) const { if (!JStringEmpty(cmd)) { const JCharacter* map[] = { varName, value }; JString s = cmd; (JGetStringManager())->Replace(&s, map, sizeof(map)); JSimpleProcess::Create(s, kJTrue); } }
JString XDLink::Build1DArrayExpression ( const JCharacter* origExpr, const JInteger index ) { JString expr = origExpr; const JString indexStr(index, 0); // must use floating point conversion if (expr.Contains("$i")) { // double literal $'s for (JIndex i=expr.GetLength()-1; i>=1; i--) { if (expr.GetCharacter(i) == '$' && expr.GetCharacter(i+1) != 'i') { expr.InsertCharacter('$', i); } } const JCharacter* map[] = { "i", indexStr.GetCString() }; (JGetStringManager())->Replace(&expr, map, sizeof(map)); } else { expr.AppendCharacter('['); expr += indexStr; expr.AppendCharacter(']'); } return expr; }
void CBAboutDialog::BuildWindow ( const JCharacter* prevVersStr ) { // begin JXLayout JXWindow* window = new JXWindow(this, 430,180, ""); assert( window != NULL ); JXImageWidget* jccIcon = new JXImageWidget(window, JXWidget::kFixedLeft, JXWidget::kFixedTop, 25,20, 40,40); assert( jccIcon != NULL ); JXStaticText* textWidget = new JXStaticText(JGetString("textWidget::CBAboutDialog::JXLayout"), window, JXWidget::kHElastic, JXWidget::kVElastic, 90,20, 330,110); assert( textWidget != NULL ); JXTextButton* okButton = new JXTextButton(JGetString("okButton::CBAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 320,150, 60,20); assert( okButton != NULL ); okButton->SetShortcuts(JGetString("okButton::CBAboutDialog::shortcuts::JXLayout")); itsHelpButton = new JXTextButton(JGetString("itsHelpButton::CBAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 185,150, 60,20); assert( itsHelpButton != NULL ); itsHelpButton->SetShortcuts(JGetString("itsHelpButton::CBAboutDialog::shortcuts::JXLayout")); itsCreditsButton = new JXTextButton(JGetString("itsCreditsButton::CBAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 50,150, 60,20); assert( itsCreditsButton != NULL ); JXImageWidget* npsIcon = new JXImageWidget(window, JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,75, 65,65); assert( npsIcon != NULL ); // end JXLayout window->SetTitle("About"); SetButtons(okButton, NULL); ListenTo(itsHelpButton); ListenTo(itsCreditsButton); // text JString text = CBGetVersionStr(); if (!JStringEmpty(prevVersStr)) { const JCharacter* map[] = { "vers", prevVersStr }; text += JGetString("UpgradeNotice::CBAboutDialog"); (JGetStringManager())->Replace(&text, map, sizeof(map)); itsHelpButton->SetLabel(JGetString("ChangeButtonLabel::CBAboutDialog")); itsIsUpgradeFlag = kJTrue; } textWidget->SetText(text); // Code Crusader icon itsAnimTask = new CBAboutDialogIconTask(jccIcon); assert( itsAnimTask != NULL ); itsAnimTask->Start(); // NPS icon JXImage* image = new JXImage(GetDisplay(), new_planet_software); assert( image != NULL ); npsIcon->SetImage(image, kJTrue); // adjust window to fit text const JSize bdh = textWidget->GetBoundsHeight(); const JSize aph = textWidget->GetApertureHeight(); if (bdh > aph) { window->AdjustSize(0, bdh - aph); // safe to calculate once bdh > aph } }
void MDApp::InitStrings() { (JGetStringManager())->Register(kAppSignature, kMDDefaultStringData); }
void CMLineIndexTable::OpenLineMenu ( const JIndex lineIndex, const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers, const JBoolean onlyBreakpoints, const JIndex firstBPIndex ) { if (itsLineMenu == NULL) { itsLineMenu = jnew JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsLineMenu != NULL ); itsLineMenu->SetToHiddenPopupMenu(kJTrue); itsLineMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsLineMenu); } itsLineMenuLineIndex = lineIndex; itsIsFullLineMenuFlag = !onlyBreakpoints; itsLineMenu->RemoveAllItems(); if (itsIsFullLineMenuFlag) { itsLineMenu->AppendMenuItems(kLineMenuStr); } itsLineMenu->AppendMenuItems(kAllBreakpointsMenuStr); JIndex bpIndex = firstBPIndex; if (bpIndex == 0 && !GetFirstBreakpointOnLine(lineIndex, &bpIndex)) { bpIndex == 0; } itsLineMenuBPRange.SetToNothing(); if (itsBPList->IndexValid(bpIndex)) { itsLineMenuBPRange.first = bpIndex; } while (itsBPList->IndexValid(bpIndex)) { itsLineMenuBPRange.last = bpIndex; const CMBreakpoint* bp = itsBPList->NthElement(bpIndex); const JString bpIndexStr(bp->GetDebuggerIndex(), 0); const JString ignoreCountStr(bp->GetIgnoreCount(), 0); const JCharacter* map[] = { "index", bpIndexStr.GetCString(), "ignore_count", ignoreCountStr.GetCString() }; JString s = kBreakpointMenuStr; (JGetStringManager())->Replace(&s, map, sizeof(map)); itsLineMenu->AppendMenuItems(s); if (!HasMultipleBreakpointsOnLine(bpIndex)) { break; } bpIndex++; } JTableSelection& s = GetTableSelection(); s.ClearSelection(); s.SelectRow(lineIndex); if (itsDeselectTask == NULL) { itsDeselectTask = jnew CMDeselectLineTask(this); assert( itsDeselectTask != NULL ); itsDeselectTask->Start(); } itsLineMenu->PopUp(this, pt, buttonStates, modifiers); }
void MDAboutDialog::BuildWindow ( const JCharacter* prevVersStr ) { // begin JXLayout JXWindow* window = new JXWindow(this, 370,120, ""); assert( window != NULL ); JXStaticText* textWidget = new JXStaticText(JGetString("textWidget::MDAboutDialog::JXLayout"), window, JXWidget::kHElastic, JXWidget::kVElastic, 70,20, 280,50); assert( textWidget != NULL ); JXTextButton* okButton = new JXTextButton(JGetString("okButton::MDAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 260,90, 60,20); assert( okButton != NULL ); okButton->SetShortcuts(JGetString("okButton::MDAboutDialog::shortcuts::JXLayout")); itsHelpButton = new JXTextButton(JGetString("itsHelpButton::MDAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 155,90, 60,20); assert( itsHelpButton != NULL ); itsHelpButton->SetShortcuts(JGetString("itsHelpButton::MDAboutDialog::shortcuts::JXLayout")); JXImageWidget* imageWidget = new JXImageWidget(window, JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 40,40); assert( imageWidget != NULL ); itsCreditsButton = new JXTextButton(JGetString("itsCreditsButton::MDAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 50,90, 60,20); assert( itsCreditsButton != NULL ); // end JXLayout window->SetTitle(JGetString("WindowTitle::MDAboutDialog")); SetButtons(okButton, NULL); ListenTo(itsHelpButton); ListenTo(itsCreditsButton); JXImage* image = new JXImage(GetDisplay(), md_about_icon); assert( image != NULL ); imageWidget->SetImage(image, kJTrue); JString text = MDGetVersionStr(); if (!JStringEmpty(prevVersStr)) { const JCharacter* map[] = { "vers", prevVersStr }; text += JGetString(kUpgradeNoticeID); (JGetStringManager())->Replace(&text, map, sizeof(map)); itsHelpButton->SetLabel(JGetString(kChangeButtonLabelID)); itsIsUpgradeFlag = kJTrue; } textWidget->SetText(text); const JSize bdh = textWidget->GetBoundsHeight(); const JSize aph = textWidget->GetApertureHeight(); if (bdh > aph) { window->AdjustSize(0, bdh - aph); // safe to calculate once bdh > aph } }
void GLAboutDialog::BuildWindow ( const JCharacter* prevVersStr ) { // begin JXLayout JXWindow* window = jnew JXWindow(this, 430,180, ""); assert( window != NULL ); JXImageWidget* gloveIcon = jnew JXImageWidget(window, JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,15, 50,50); assert( gloveIcon != NULL ); JXStaticText* textWidget = jnew JXStaticText(JGetString("textWidget::GLAboutDialog::JXLayout"), window, JXWidget::kHElastic, JXWidget::kVElastic, 90,20, 330,110); assert( textWidget != NULL ); JXImageWidget* npsIcon = jnew JXImageWidget(window, JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,75, 65,65); assert( npsIcon != NULL ); JXTextButton* okButton = jnew JXTextButton(JGetString("okButton::GLAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 320,150, 60,20); assert( okButton != NULL ); okButton->SetShortcuts(JGetString("okButton::GLAboutDialog::shortcuts::JXLayout")); itsHelpButton = jnew JXTextButton(JGetString("itsHelpButton::GLAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 185,150, 60,20); assert( itsHelpButton != NULL ); itsCreditsButton = jnew JXTextButton(JGetString("itsCreditsButton::GLAboutDialog::JXLayout"), window, JXWidget::kFixedLeft, JXWidget::kFixedBottom, 50,150, 60,20); assert( itsCreditsButton != NULL ); // end JXLayout window->SetTitle("About"); SetButtons(okButton, NULL); ListenTo(itsHelpButton); ListenTo(itsCreditsButton); const JCharacter* map1[] = { "version", JGetString("VERSION"), "copyright", JGetString("COPYRIGHT") }; JString text = JGetString(kDescriptionID, map1, sizeof(map1)); if (!JStringEmpty(prevVersStr)) { const JCharacter* map[] = { "vers", prevVersStr }; text += JGetString(kUpgradeNoticeID); (JGetStringManager())->Replace(&text, map, sizeof(map)); itsHelpButton->SetLabel(JGetString(kChangeButtonLabelID)); itsIsUpgradeFlag = kJTrue; } textWidget->SetText(text); JXImage* image = jnew JXImage(GetDisplay(), JXPM(glove_icon)); assert(image != NULL); gloveIcon->SetImage(image, kJTrue); // NPS icon image = jnew JXImage(GetDisplay(), nps); assert( image != NULL ); npsIcon->SetImage(image, kJTrue); const JSize bdh = textWidget->GetBoundsHeight(); const JSize aph = textWidget->GetApertureHeight(); if (bdh > aph) { window->AdjustSize(0, bdh - aph); // safe to calculate once bdh > aph } }
void JInitCore ( JAssertBase* ah, const JCharacter* appSignature, const JCharacter** defaultStringData, JUserNotification* un, JChooseSaveFile* csf, JCreateProgressDisplay* cpg, JGetCurrentFontManager* gcfm, JGetCurrentColormap* gcc, const JCharacter* defaultFontName, const JCharacter* greekFontName, const JCharacter* monospaceFontName ) { // assert handler if (ah != NULL) { theAssertHandler = ah; } // NULL is valid in this case -- see JGetAssertHandler() // socket library (mainly Windows) ACE_OS::socket_init(); // signal handler JThisProcess::Initialize(); // initialize write-once/read-many static data for thread safety JString s; JGetTempDirectory(&s); // string manager JStringManager* stringMgr = JGetStringManager(); // create it if (defaultStringData != NULL) { stringMgr->Register(appSignature, defaultStringData); } // user notification if (un != NULL) { theUserNotification = un; } else { theUserNotification = new JTextUserNotification; assert( theUserNotification != NULL ); } // choose/save file if (csf != NULL) { theChooseSaveFile = csf; } else { theChooseSaveFile = new JTextChooseSaveFile; assert( theChooseSaveFile != NULL ); } // progress display factory if (cpg != NULL) { theCreatePG = cpg; } else { theCreatePG = new JCreateTextPG; assert( theCreatePG != NULL ); } // font manager if (gcfm != NULL) { theGetCurrFontMgr = gcfm; } // colormap if (gcc != NULL) { theGetCurrColormap = gcc; } // default font name if (!JStringEmpty(defaultFontName)) { theDefaultFontName = new JString(defaultFontName); assert( theDefaultFontName != NULL ); } // greek font name if (!JStringEmpty(greekFontName)) { theGreekFontName = new JString(greekFontName); assert( theGreekFontName != NULL ); } // monospace font name if (!JStringEmpty(monospaceFontName)) { theMonospaceFontName = new JString(monospaceFontName); assert( theMonospaceFontName != NULL ); } // remember to clean up atexit(JDeleteGlobals); }
JString XDLink::Build2DArrayExpression ( const JCharacter* origExpr, const JInteger rowIndex, const JInteger colIndex ) { JString expr = origExpr; const JBoolean usesI = expr.Contains("$i"); // row const JBoolean usesJ = expr.Contains("$j"); // col const JString iStr(rowIndex, 0); // must use floating point conversion const JString jStr(colIndex, 0); // must use floating point conversion // We have to do both at the same time because otherwise we lose a $. if (usesI || usesJ) { // double literal $'s for (JIndex i=expr.GetLength()-1; i>=1; i--) { if (expr.GetCharacter(i) == '$' && expr.GetCharacter(i+1) != 'i' && expr.GetCharacter(i+1) != 'j') { expr.InsertCharacter('$', i); } } const JCharacter* map[] = { "i", iStr.GetCString(), "j", jStr.GetCString() }; (JGetStringManager())->Replace(&expr, map, sizeof(map)); } if (!usesI || !usesJ) { if (expr.GetFirstCharacter() != '(' || expr.GetLastCharacter() != ')') { expr.PrependCharacter('('); expr.AppendCharacter(')'); } if (!usesI) { expr.AppendCharacter('['); expr += iStr; expr.AppendCharacter(']'); } if (!usesJ) { expr.AppendCharacter('['); expr += jStr; expr.AppendCharacter(']'); } } return expr; }
void JXTextMenuData::InsertMenuItems ( const JIndex startIndex, const JCharacter* menuStr, const JCharacter* idNamespace ) { JStringManager* strMgr = JGetStringManager(); JSize currIndex = startIndex; JString str = menuStr; JBoolean done = kJFalse; JString itemText, shortcuts, nmShortcut, id, strID, id1; while (!done) { JIndex sepIndex; const JBoolean found = str.LocateSubstring("|", &sepIndex); if (found) { assert( sepIndex > 1 ); itemText = str.GetSubstring(1, sepIndex-1); str.RemoveSubstring(1, sepIndex); } else { itemText = str; done = kJTrue; } JBoolean isActive, hasSeparator, isCheckbox, isRadio; ParseMenuItemStr(&itemText, &isActive, &hasSeparator, &isCheckbox, &isRadio, &shortcuts, &nmShortcut, &id); if (!JStringEmpty(idNamespace) && !id.IsEmpty()) { strID = id; strID += "::"; strID += idNamespace; JString* itemText1; if (strMgr->GetElement(strID, &itemText1) && itemText1 != NULL) { itemText = *itemText1; JBoolean isActive1, hasSeparator1, isCheckbox1, isRadio1; ParseMenuItemStr(&itemText, &isActive1, &hasSeparator1, &isCheckbox1, &isRadio1, &shortcuts, &nmShortcut, &id1); } } InsertItem(currIndex, itemText, isCheckbox, isRadio, shortcuts, nmShortcut, id); if (!isActive) { DisableItem(currIndex); } if (hasSeparator) { ShowSeparatorAfter(currIndex); } currIndex++; } }