void
JXDocumentMenu::JXDocumentMenuX()
{
	itsDocMgr = JXGetDocumentManager();

	ListenTo(this);
	ListenTo(itsDocMgr);

	SetUpdateAction(kDisableNone);
}
void
SCCircuitDocument::OpenSomething
	(
	const JCharacter* fileName
	)
{
	JString fullName;
	if (fileName != NULL && fileName[0] != '\0')
		{
		if (JFileExists(fileName))
			{
			fullName = fileName;
			}
		else
			{
			return;
			}
		}
	else if (!(JGetChooseSaveFile())->ChooseFile("File to open:", NULL, &fullName))
		{
		return;
		}

	std::ifstream input(fullName);
	const FileStatus status = CanReadFile(input);
	JXFileDocument* doc;
	if (status == kFileReadable &&
		!(JXGetDocumentManager())->FileDocumentIsOpen(fullName, &doc) &&
		OKToClose())
		{
		CloseAllWindows();
		FileChanged(fullName, kJTrue);
		ReadFile(input);
		}
	else if (status == kNeedNewerVersion)
		{
		(JGetUserNotification())->ReportError(
			"This notebook was created by a newer version of Symcir.  "
			"You need the newest version in order to open it.");
		}
	else if (status == kNotMyFile && OKToClose())
		{
		input.close();
		CloseAllWindows();
		ReadNetlist(fullName);
		}
}
示例#3
0
void
JXApplication::Abort
	(
	const JXDocumentManager::SafetySaveReason	reason,
	const JBoolean								dumpCore
	)
{
	if (!abortCalled)
		{
		abortCalled = kJTrue;

		JXDocumentManager* docMgr = NULL;
		if (JXGetDocumentManager(&docMgr))
			{
			docMgr->SafetySave(reason);
			}

		JXApplication* app;
		if (JXGetApplication(&app))
			{
			app->CleanUpBeforeSuddenDeath(reason);
			}
		}
	else
		{
		fprintf(stderr, "\nError inside XIO fatal error handler!\n\n");
		}

	if (dumpCore)
		{
		JThisProcess::Abort();
		}
	else
		{
		JThisProcess::Exit(1);
		}
}
CBExecOutputDocument::CBExecOutputDocument
	(
	const CBTextFileType	fileType,
	const JCharacter*		helpSectionName,
	const JBoolean			focusToCmd,
	const JBoolean			allowStop
	)
	:
	CBTextDocument(fileType, helpSectionName, kJFalse),
	itsFocusToCmdFlag(focusToCmd)
{
	itsProcess            = NULL;
	itsRecordLink         = NULL;
	itsDataLink           = NULL;
	itsCmdStream          = NULL;
	itsReceivedDataFlag   = kJFalse;
	itsProcessPausedFlag  = kJFalse;
	itsClearWhenStartFlag = kJTrue;
	itsUseCount           = 0;
	itsDontCloseMsg       = JGetString("WaitCloseMsg::CBExecOutputDocument");

	// buttons in upper right

	JXWindow* window = GetWindow();
	const JRect rect = window->GetBounds();

	JXMenuBar* menuBar = GetMenuBar();
	const JSize h      = menuBar->GetFrameHeight();

	const JCoordinate x = (allowStop ? 3 : 2) * kMenuButtonWidth;

	itsPauseButton =
		jnew JXTextButton(JGetString("PauseLabel::CBExecOutputDocument"), window,
						  JXWidget::kFixedRight, JXWidget::kFixedTop,
						  rect.right - x,0, kMenuButtonWidth,h);
	assert( itsPauseButton != NULL );
	ListenTo(itsPauseButton);
	itsPauseButton->SetShortcuts("^Z");
	itsPauseButton->SetHint(JGetString("PauseButtonHint::CBExecOutputDocument"));

	if (allowStop)
		{
		itsStopButton =
			jnew JXTextButton(JGetString("StopLabel::CBExecOutputDocument"), window,
							  JXWidget::kFixedRight, JXWidget::kFixedTop,
							  rect.right - 2*kMenuButtonWidth,0, kMenuButtonWidth,h);
		assert( itsStopButton != NULL );
		ListenTo(itsStopButton);
		itsStopButton->SetShortcuts("^C#.");
		itsStopButton->SetHint(JGetString("StopButtonHint::CBExecOutputDocument"));
		}
	else
		{
		itsStopButton = NULL;
		}

	itsKillButton =
		jnew JXTextButton(JGetString("KillLabel::CBExecOutputDocument"), window,
						  JXWidget::kFixedRight, JXWidget::kFixedTop,
						  rect.right - kMenuButtonWidth,0, kMenuButtonWidth,h);
	assert( itsKillButton != NULL );
	ListenTo(itsKillButton);

	if (!allowStop)
		{
		itsKillButton->SetShortcuts("^C#.");
		itsKillButton->SetHint(JGetString("StopButtonHint::CBExecOutputDocument"));
		}

	menuBar->AdjustSize(-x, 0);

	// command line input

	JXWidget::HSizingOption hSizing;
	JXWidget::VSizingOption vSizing;
	GetFileDisplayInfo(&hSizing, &vSizing);

	itsCmdPrompt =
		jnew JXStaticText(JGetString("CmdPrompt::CBExecOutputDocument"), window,
						  JXWidget::kFixedLeft, vSizing,
						  -1000, -1000, 0, 500);
	assert( itsCmdPrompt != NULL );
	itsCmdPrompt->SetToLabel();
	itsCmdPrompt->Hide();

	itsCmdInput =
		jnew CBCmdLineInput(this, window, hSizing, vSizing,
							-1000, -1000, 500, 500);
	assert( itsCmdInput != NULL );
	itsCmdInput->ShareEditMenu(GetTextEditor());
	itsCmdInput->Hide();

	itsEOFButton =
		jnew JXTextButton(JGetString("EOFButtonTitle::CBExecOutputDocument"), window,
						  JXWidget::kFixedRight, vSizing,
						  -1000, -1000, 500, 500);
	assert( itsEOFButton != NULL );
	itsEOFButton->SetShortcuts("^D");
	itsEOFButton->Hide();
	ListenTo(itsEOFButton);

	JXUrgentTask* task = jnew CBExecOutputPostFTCTask(this);
	assert( task != NULL );
	task->Go();

	GetTextEditor()->SetWritable(kJFalse);
	(JXGetDocumentManager())->DocumentMustStayOpen(this, kJTrue);

	window->SetWMClass(CBGetWMClassInstance(), CBGetExecOutputWindowClass());
}
示例#5
0
PlotDir::PlotDir
	(
	JXDirector*       supervisor,
	JXFileDocument*   notifySupervisor,
	const JCharacter* filename,
	const JBoolean    hideOnClose
	)
	:
	JXDocument(supervisor),
	itsFileName(filename)
{
	itsSupervisor       = notifySupervisor;
	itsHideOnClose      = hideOnClose;
	itsPlotIsClosing	= kJFalse;

	itsPrinter          = NULL;

	JCoordinate w 		= 500;
	JCoordinate h       = 400;
	JCoordinate minW	= 400;
	JCoordinate minH    = 300;

	JXWindow* window = jnew JXWindow(this, w,h, filename);
	assert( window != NULL );

	window->SetMinSize(minW,minH);
	if (hideOnClose)
		{
		window->SetCloseAction(JXWindow::kDeactivateDirector);
		}

	JXMenuBar* menuBar =
		jnew JXMenuBar(window,
			JXWidget::kHElastic, JXWidget::kFixedTop, 0,0, w, kJXDefaultMenuBarHeight);
	assert( menuBar != NULL );

	itsPlotMenu = menuBar->AppendTextMenu(kPlotMenuTitleStr);
	itsPlotMenu->SetMenuItems(kPlotMenuStr);
	itsPlotMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPlotMenu);

	itsAnalysisMenu = menuBar->AppendTextMenu(kAnalysisMenuTitleStr);
	itsAnalysisMenu->SetMenuItems(kAnalysisMenuStr);
	itsAnalysisMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsAnalysisMenu);

	itsFitParmsMenu = jnew JXTextMenu(itsAnalysisMenu, kFitParmsCmd, menuBar);
	assert( itsFitParmsMenu != NULL );
	itsFitParmsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsFitParmsMenu);
	itsAnalysisMenu->DisableItem(kFitParmsCmd);

	itsDiffMenu = jnew JXTextMenu(itsAnalysisMenu, kDiffPlotCmd, menuBar);
	assert( itsDiffMenu != NULL );
	itsDiffMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsDiffMenu);
	itsAnalysisMenu->DisableItem(kDiffPlotCmd);

	itsSessionDir =
		jnew GloveHistoryDir(JXGetApplication());
	assert(itsSessionDir != NULL);
	JXGetDocumentManager()->DocumentMustStayOpen(itsSessionDir, kJTrue);
	ListenTo(itsSessionDir);

	itsPlot =
		jnew GlovePlotter(itsSessionDir, menuBar, window,
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 30, w, h - kJXDefaultMenuBarHeight);
	assert( itsPlot != NULL );

	ListenTo(itsPlot);

	JXDocumentMenu* windowListMenu =
		jnew JXDocumentMenu(kWindowListMenuTitleStr, menuBar,
			JXWidget::kFixedLeft, JXWidget::kVElastic, 0,0, 10,10);
	assert( windowListMenu != NULL );
	menuBar->AppendMenu(windowListMenu);

	itsHelpMenu = menuBar->AppendTextMenu(kHelpMenuTitleStr);
	itsHelpMenu->SetMenuItems(kHelpMenuStr);
	itsHelpMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsHelpMenu);

	itsVarList	 = jnew GVarList();
	itsVarList->AddVariable("x",0);
	itsXVarIndex = 1;
	itsFunctionDialog = NULL;
	itsFitModuleDialog = NULL;

	itsFits = jnew JPtrArray<JFitBase>(JPtrArrayT::kForgetAll);
	assert( itsFits != NULL );
	ListenTo(itsFits);
	itsFitParmsDir = jnew FitParmsDir(this, itsFits);
	assert( itsFitParmsDir != NULL );
	itsCurveStats = jnew JArray<CurveStats>;
	assert( itsCurveStats != NULL );
	itsCurrentCurveType = kGDataCurve;

	itsDiffDirs = jnew JPtrArray<PlotDir>(JPtrArrayT::kForgetAll);
	assert( itsDiffDirs != NULL );
	ListenTo(itsDiffDirs);

	itsPrinter = jnew JXPSPrinter(GetDisplay());
	assert( itsPrinter != NULL );
	itsPrinter->SetOrientation(JPSPrinter::kLandscape);

	itsEPSPrinter	= jnew JX2DPlotEPSPrinter(GetDisplay());
	assert(itsEPSPrinter != NULL);
	itsPlot->SetEPSPrinter(itsEPSPrinter);

	ListenTo(itsPrinter);
}