Example #1
0
JBoolean
CBApp::Close()
{
	// --man with no args must leave window open

	if ((CBGetViewManPageDialog())->IsActive())
		{
		return kJFalse;
		}

	CBGetPrefsManager()->SaveProgramState();

	// close these first so they remember all open text documents

	if (!(CBGetDocumentManager())->CloseProjectDocuments())
		{
		return kJFalse;
		}

	// close everything else

	const JBoolean success = JXApplication::Close();	// deletes us if successful
	if (!success)
		{
		CBGetPrefsManager()->ForgetProgramState();
		}

	return success;
}
CBSymbolDirector::CBSymbolDirector
	(
	istream&			projInput,
	const JFileVersion	projVers,
	istream*			setInput,
	const JFileVersion	setVers,
	istream*			symInput,
	const JFileVersion	symVers,
	CBProjectDocument*	supervisor,
	const JBoolean		subProject
	)
	:
	JXWindowDirector(supervisor),
	JPrefObject(CBGetPrefsManager(), kCBSymbolDirectorID)
{
	CBSymbolDirectorX(supervisor);

	const JBoolean useProjData = JI2B( setInput == NULL || setVers < 71 );
	if (!useProjData)
		{
		(GetWindow())->ReadGeometry(*setInput);

		// put SR windows on top of main window

		JBoolean active;
		*setInput >> active;
		if (active && !subProject)
			{
			Activate();
			}

		// read and create CBSymbolSRDirectors here
		}
Example #3
0
JBoolean
CBFileNode::ParseFiles
	(
	CBFileListTable*			parser,
	const JPtrArray<JString>&	allSuffixList,
	CBSymbolList*				symbolList,
	CBCTree*					cTree,
	CBJavaTree*					javaTree,
	CBPHPTree*					phpTree,
	JProgressDisplay&			pg
	)
	const
{
	JString fullName, trueName;
	if (GetFullName(&fullName) && JGetTrueName(fullName, &trueName))
		{
		if (!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}

		const CBTextFileType type = (CBGetPrefsManager())->GetFileType(trueName);
		if ((CBGetDocumentManager())->GetComplementFile(trueName, type, &fullName,
														GetProjectDoc(), kJFalse) &&
			JGetTrueName(fullName, &trueName) &&
			!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}
		}
	return CBFileNodeBase::ParseFiles(parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg);
}
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;
}
Example #5
0
void
CBFileNode::OpenComplementFile()
	const
{
	JString fullName;
	if (GetFullName(&fullName))
		{
		const CBTextFileType type = (CBGetPrefsManager())->GetFileType(fullName);
		if (type == kCBHTMLFT || type == kCBXMLFT)
			{
			(JXGetWebBrowser())->ShowFileContent(fullName);
			}
		else
			{
			(CBGetDocumentManager())->OpenComplementFile(fullName, type);
			}
		}
	else
		{
		JString msg = "Unable to find complement of \"";
		msg += GetFileName();
		msg.AppendCharacter('"');
		(JGetUserNotification())->ReportError(msg);
		}
}
void
CBFileListTable::ParseFile
	(
	const JString&				fullName,
	const JPtrArray<JString>&	allSuffixList,
	const time_t				modTime,
	CBSymbolList*				symbolList,
	CBCTree*					cTree,
	CBJavaTree*					javaTree
	)
{
	if (CBPrefsManager::FileMatchesSuffix(fullName, allSuffixList))
		{
		const CBTextFileType fileType = (CBGetPrefsManager())->GetFileType(fullName);
		JFAID_t id;
		if (AddFile(fullName, fileType, modTime, &id))
			{
			itsChangedDuringParseFlag = kJTrue;

			symbolList->FileChanged(fullName, fileType, id);
			cTree->FileChanged(fullName, fileType, id);
			javaTree->FileChanged(fullName, fileType, id);
			}
		}
}
Example #7
0
CBApp::CBApp
	(
	int*			argc,
	char*			argv[],
	const JBoolean	useMDI,
	JBoolean*		displayAbout,
	JString*		prevVersStr
	)
	:
	JXApplication(argc, argv, kAppSignature, kCBDefaultStringData),
	JPrefObject(NULL, kCBAppID)
{
	itsWarnBeforeQuitFlag = kJFalse;

	itsSystemIncludeDirs = jnew JPtrArray<JString>(JPtrArrayT::kDeleteAll);
	assert( itsSystemIncludeDirs != NULL );

	*displayAbout = CBCreateGlobals(this, useMDI);
	SetPrefInfo(CBGetPrefsManager(), kCBAppID);
	JPrefObject::ReadPrefs();

	if (!*displayAbout)
		{
		*prevVersStr = CBGetPrefsManager()->GetJCCVersionStr();
		if (*prevVersStr == CBGetVersionNumberStr())
			{
			prevVersStr->Clear();
			}
		else
			{
			*displayAbout = kJTrue;
			}
		}
	else
		{
		prevVersStr->Clear();
		}

	GetSystemIncludeDirectories();

	// Write shared prefs, if they don't exist.
	// (must be done after everything created)

	CBMWriteSharedPrefs(kJFalse);
}
CBPTPrinter::CBPTPrinter()
	:
	JXPTPrinter(),
	JPrefObject(CBGetPrefsManager(), kCBPrintPlainTextID)
{
	itsPrintHeaderFlag    = kJTrue;
	itsCBPrintSetupDialog = NULL;

	JPrefObject::ReadPrefs();
}
CBSymbolDirector::CBSymbolDirector
	(
	CBProjectDocument* supervisor
	)
	:
	JXWindowDirector(supervisor),
	JPrefObject(CBGetPrefsManager(), kCBSymbolDirectorID)
{
	CBSymbolDirectorX(supervisor);
}
CBSearchTextDialog::CBSearchTextDialog()
	:
	JXSearchTextDialog(kCBSearchTextHelpName),
	JPrefObject(CBGetPrefsManager(), kCBSearchTextID),
	itsFileSetName("Untitled")
{
	itsCSF = jnew CBListCSF(kReplaceFileListStr, kAppendToFileListStr);
	assert( itsCSF != NULL );

	itsOnlyListFilesFlag         = kJFalse;
	itsListFilesWithoutMatchFlag = kJFalse;
}
CBPSPrinter::CBPSPrinter
	(
	JXDisplay* display
	)
	:
	JXPSPrinter(display),
	JPrefObject(CBGetPrefsManager(), kCBPrintStyledTextID)
{
	itsFontSize           = kUnsetFontSize;
	itsTE                 = NULL;
	itsCBPrintSetupDialog = NULL;

	JPrefObject::ReadPrefs();
}
CBEditSearchPathsDialog::CBEditSearchPathsDialog
	(
	JXDirector*			supervisor,
	const CBDirList&	dirList,
	CBRelPathCSF*		csf
	)
	:
	JXDialogDirector(supervisor, kJTrue),
	JPrefObject(CBGetPrefsManager(), kCBEditSearchPathsDialogID)
{
	BuildWindow(dirList, csf);
	JPrefObject::ReadPrefs();
	ListenTo(this);
}
CBEditTextPrefsDialog::CBEditTextPrefsDialog
	(
	CBTextDocument* doc
	)
	:
	JXDialogDirector(CBGetApplication(), kJTrue)
{
	itsDoc               = doc;
	itsChooseColorDialog = NULL;

	itsOrigEmulatorIndex =
		itsEmulatorIndex = kEmulatorToMenuIndex[
			CBGetPrefsManager()->GetEmulator() ];

	BuildWindow(doc);
	ListenTo(this);
}
Example #14
0
void
CBApp::CleanUpBeforeSuddenDeath
	(
	const JXDocumentManager::SafetySaveReason reason
	)
{
	JXApplication::CleanUpBeforeSuddenDeath(reason);

	if (reason != JXDocumentManager::kAssertFired)
		{
		JPrefObject::WritePrefs();
		CBGetPrefsManager()->SaveProgramState();
//		(CBGetDocumentManager())->Save
		}

	CBCleanUpBeforeSuddenDeath(reason);		// must be last call
}
Example #15
0
CBRunCommandDialog::CBRunCommandDialog
	(
	CBProjectDocument*	projDoc,
	CBTextDocument*		textDoc
	)
	:
	JXDialogDirector(JXGetApplication(), kJTrue),
	JPrefObject(CBGetPrefsManager(), kCBRunCommandDialogID),
	itsProjDoc(projDoc),
	itsTextDoc(textDoc),
	itsFullNameList(NULL),
	itsLineIndexList(NULL)
{
	assert( itsTextDoc != NULL );

	BuildWindow();
	JPrefObject::ReadPrefs();
	ListenTo(this);
}
Example #16
0
CBRunCommandDialog::CBRunCommandDialog
	(
	CBProjectDocument*			projDoc,
	const JPtrArray<JString>&	fullNameList,
	const JArray<JIndex>&		lineIndexList
	)
	:
	JXDialogDirector(JXGetApplication(), kJTrue),
	JPrefObject(CBGetPrefsManager(), kCBRunCommandDialogID),
	itsProjDoc(projDoc),
	itsTextDoc(NULL)
{
	itsFullNameList = new JDCCPtrArray<JString>(fullNameList, JPtrArrayT::kDeleteAll);
	assert( itsFullNameList != NULL );

	itsLineIndexList = new JArray<JIndex>(lineIndexList);
	assert( itsLineIndexList != NULL );

	BuildWindow();
	JPrefObject::ReadPrefs();
	ListenTo(this);
}
void
CBFileListTable::ScanAll
	(
	CBProjectTree*		fileTree,
	const CBDirList&	dirList,
	CBSymbolList*		symbolList,
	CBCTree*			cTree,
	CBJavaTree*			javaTree,
	JProgressDisplay&	pg
	)
{
	const JSize dirCount = dirList.GetElementCount();
	if (dirCount > 0 || (fileTree->GetProjectRoot())->HasChildren())
		{
		pg.VariableLengthProcessBeginning(JGetString(kParsingFilesID), kJFalse, kJTrue);

		JPtrArray<JString> allSuffixList(JPtrArrayT::kDeleteAll);
		(CBGetPrefsManager())->GetAllFileSuffixes(&allSuffixList);

		JString fullPath;
		JBoolean recurse;
		for (JIndex i=1; i<=dirCount; i++)
			{
			if (dirList.GetFullPath(i, &fullPath, &recurse))
				{
				ScanDirectory(fullPath, recurse,
							  allSuffixList, symbolList,
							  cTree, javaTree,
							  pg);
				}
			}

		fileTree->ParseFiles(this, allSuffixList, symbolList, cTree, javaTree, pg);

		pg.ProcessFinished();
		}
}
void
CBEditTextPrefsDialog::UpdateSettings()
{
	CBTextEditor* te = itsDoc->GetTextEditor();

	JString fontName;
	JSize fontSize;
	itsFontMenu->GetFont(&fontName, &fontSize);
	const JBoolean fontChanged = JI2B(
		fontName != te->GetDefaultFont().GetName() ||
		fontSize != te->GetDefaultFont().GetSize() );

	JFloat vScrollScale = 1.0;
	if (fontChanged)
		{
		const JFontManager* fontMgr = te->GetFontManager();
		const JFloat h1 = te->GetDefaultFont().GetLineHeight();
		const JFloat h2 = fontMgr->GetFont(fontName, fontSize).GetLineHeight();
		vScrollScale    = h2 / h1;
		}

	JInteger tabCharCount;
	JBoolean ok = itsTabCharCountInput->GetValue(&tabCharCount);
	assert( ok );

	JInteger crmLineWidth;
	ok = itsCRMLineWidthInput->GetValue(&crmLineWidth);
	assert( ok );

	JInteger undoDepth;
	ok = itsUndoDepthInput->GetValue(&undoDepth);
	assert( ok );

	JInteger rightMargin;
	ok = itsRightMarginInput->GetValue(&rightMargin);
	assert( ok );

	CBPrefsManager* prefsMgr = CBGetPrefsManager();
	const JBoolean textColorChanged = JNegate(
		itsColor[ CBPrefsManager::kTextColorIndex-1 ] ==
		prefsMgr->GetColor(CBPrefsManager::kTextColorIndex));

	// set colors before RecalcStyles() so stylers update themselves

	prefsMgr->SetDefaultFont(fontName, fontSize);
	for (JIndex j=1; j<=CBPrefsManager::kColorCount; j++)
		{
		prefsMgr->SetColor(j, itsColor[j-1]);
		}

	JPtrArray<CBTextDocument>* docList = (CBGetDocumentManager())->GetTextDocList();
	const JSize docCount = docList->GetElementCount();

	JProgressDisplay* pg = JNewPG();
	pg->FixedLengthProcessBeginning(docCount, "Updating preferences...", kJFalse, kJFalse);

	for (JIndex i=1; i<=docCount; i++)
		{
		CBTextDocument* doc = docList->NthElement(i);

		doc->ShouldMakeBackupFile(itsCreateBackupCB->IsChecked());
		doc->ShouldMakeNewBackupEveryOpen(!itsOnlyBackupIfNoneCB->IsChecked());
		doc->ShouldAllocateTitleSpace(itsExtraSpaceWindTitleCB->IsChecked());
		doc->ShouldOpenComplFileOnTop(itsOpenComplFileOnTopCB->IsChecked());

		te = doc->GetTextEditor();

		if (itsEmulatorIndex != itsOrigEmulatorIndex)
			{
			JTEKeyHandler* handler;
			CBInstallEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ], te, &handler);
			}

		te->ShouldAutoIndent(itsAutoIndentCB->IsChecked());
		te->CBShouldAllowDragAndDrop(itsUseDNDCB->IsChecked());
		te->ShouldMoveToFrontOfText(itsLeftToFrontOfTextCB->IsChecked());

		te->ShouldBalanceWhileTyping(itsBalanceWhileTypingCB->IsChecked());
		te->ShouldScrollToBalance(itsScrollToBalanceCB->IsChecked());
		te->ShouldBeepWhenTypeUnbalanced(itsBeepWhenTypeUnbalancedCB->IsChecked());

		te->TabShouldBeSmart(itsSmartTabCB->IsChecked());
		te->TabShouldInsertSpaces(itsTabToSpacesCB->IsChecked());

		if (fontChanged)
			{
			JXScrollbar *hScrollbar, *vScrollbar;
			const JBoolean ok = te->GetScrollbars(&hScrollbar, &vScrollbar);
			assert( ok );
			vScrollbar->PrepareForScaledMaxValue(vScrollScale);

			te->SetFont(fontName, fontSize, tabCharCount);
			}
		else
			{
			te->SetTabCharCount(tabCharCount);
			}

		te->SetCRMLineWidth(crmLineWidth);
		te->SetUndoDepth(undoDepth);
		te->SetRightMarginWidth(itsRightMarginCB->IsChecked(), rightMargin);

		te->SetDefaultFontStyle(itsColor [ CBPrefsManager::kTextColorIndex-1 ]);
		te->SetBackColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]);
		te->SetFocusColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]);
		te->SetCaretColor(itsColor [ CBPrefsManager::kCaretColorIndex-1 ]);
		te->SetSelectionColor(itsColor [ CBPrefsManager::kSelColorIndex-1 ]);
		te->SetSelectionOutlineColor(itsColor [ CBPrefsManager::kSelLineColorIndex-1 ]);
		te->SetRightMarginColor(itsColor [ CBPrefsManager::kRightMarginColorIndex-1 ]);

		if (textColorChanged)
			{
			te->RecalcStyles();
			}

		// force update of insertion font

		JIndex caretIndex;
		if (te->GetCaretLocation(&caretIndex))
			{
			te->SetCaretLocation(caretIndex);
			}

		pg->IncrementProgress();
		}

	CBFnMenuUpdater* updater = CBGetFnMenuUpdater();
	updater->ShouldSortFnNames(itsSortFnMenuCB->IsChecked());
	updater->ShouldIncludeNamespace(itsNSInFnMenuCB->IsChecked());
	updater->ShouldPackFnNames(itsPackFnMenuCB->IsChecked());

	JXTEBase::SetPartialWordModifier(
		(JXTEBase::PartialWordModifier) itsPWModRG->GetSelectedItem());

	JXTEBase::ShouldUseWindowsHomeEnd(itsHomeEndCB->IsChecked());
	CBTextEditor::CaretShouldFollowScroll(itsScrollCaretCB->IsChecked());
	JTextEditor::ShouldCopyWhenSelect(itsCopyWhenSelectCB->IsChecked());
	JXTEBase::MiddleButtonShouldPaste(itsMiddleButtonPasteCB->IsChecked());

	CBSearchTextDialog* dlog = CBGetSearchTextDialog();
	dlog->SetFont(fontName, fontSize);

	itsDoc->JPrefObject::WritePrefs();

	if (itsEmulatorIndex != itsOrigEmulatorIndex)
		{
		prefsMgr->SetEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ]);
		}

	CBMWriteSharedPrefs(kJTrue);

	pg->ProcessFinished();
	jdelete pg;
}
CBCommandTable::CBCommandTable
	(
	const CBCommandManager::CmdList& cmdList,

	JXTextButton*		addCmdButton,
	JXTextButton*		removeCmdButton,
	JXTextButton*		duplicateCmdButton,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h)
{
	itsTextInput   = NULL;
	itsDNDRowIndex = 0;

	itsCommandXAtom =
		(GetDisplay())->RegisterXAtom(CBCommandSelection::GetCommandXAtomName());

	// font

	(CBGetPrefsManager())->GetDefaultFont(&itsFontName, &itsFontSize);

	const JSize rowHeight = 2*kVMarginWidth + JMax(
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()),
		(GetFontManager())->GetLineHeight(itsFontName, itsFontSize, JFontStyle()));
	SetDefaultRowHeight(rowHeight);

	// buttons

	itsAddCmdButton       = addCmdButton;
	itsRemoveCmdButton    = removeCmdButton;
	itsDuplicateCmdButton = duplicateCmdButton;

	ListenTo(itsAddCmdButton);
	ListenTo(itsRemoveCmdButton);
	ListenTo(itsDuplicateCmdButton);

	// type menu

	itsOptionsMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10);
	assert( itsOptionsMenu != NULL );
	itsOptionsMenu->SetToHiddenPopupMenu();
	itsOptionsMenu->SetMenuItems(kOptionsMenuStr);
	itsOptionsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsOptionsMenu);

	// base path

	CBProjectDocument* doc = NULL;
	if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc))
		{
		itsBasePath = doc->GetFilePath();
		}

	// data

	itsCmdList = new CBCommandManager::CmdList(cmdList);
	assert( itsCmdList != NULL );
	FinishCmdListCopy(itsCmdList);

	for (JIndex i=1; i<=kColCount; i++)
		{
		AppendCols(1, kInitColWidth[i-1]);
		}

	AppendRows(itsCmdList->GetElementCount());

	UpdateButtons();
	ListenTo(&(GetTableSelection()));
}
Example #20
0
CBTextEditor::CBTextEditor
	(
	CBTextDocument*		document,
	const JCharacter*	fileName,
	JXMenuBar*			menuBar,
	CBTELineIndexInput*	lineInput,
	CBTEColIndexInput*	colInput,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXTEBase(kFullEditor, kJTrue, kJFalse, scrollbarSet,
			 enclosure, hSizing, vSizing, x,y, w,h),
	itsLastModifiers(GetDisplay())
{
	itsDoc = document;
	ListenTo(itsDoc);

	UpdateWritable(fileName);

	itsLineInput = lineInput;
	itsLineInput->SetTE(this, colInput);

	itsColInput = colInput;
	itsColInput->SetTE(this);

	itsTokenStartList = JTEStyler::NewTokenStartList();

	itsBalanceWhileTypingFlag     = kJTrue;
	itsScrollToBalanceFlag        = kJTrue;
	itsBeepWhenTypeUnbalancedFlag = kJTrue;

	itsSmartTabFlag = kJTrue;

	// create edit menu

	JXTextMenu* editMenu = AppendEditMenu(menuBar, kJTrue, kJTrue, kJTrue, kJTrue, kJTrue, kJTrue, kJFalse, kJFalse);
	const JSize editCount = editMenu->GetItemCount();
	editMenu->ShowSeparatorAfter(editCount);

	itsExecScriptCmdIndex = editCount + 1;
	editMenu->AppendItem(kExecScriptStr, JXMenu::kPlainType, NULL,
						 kExecScriptNMShortcutStr, kExecScriptAction);
	editMenu->SetItemImage(itsExecScriptCmdIndex, jx_run_script);

	editMenu->AppendItem(kExecScriptSubmenuStr);
	CreateScriptMenu(editMenu, editCount + 2);

	// create search menu

	JXTextMenu* searchMenu = AppendSearchReplaceMenu(menuBar);
	itsFirstSearchMenuItem = searchMenu->GetItemCount() + 1;
	searchMenu->ShowSeparatorAfter(itsFirstSearchMenuItem-1);
	searchMenu->AppendMenuItems(kSearchMenuStr, "CBTextEditor");
	ListenTo(searchMenu);

	searchMenu->SetItemImage(itsFirstSearchMenuItem + kBalanceCmd,     jcc_balance_braces);
	searchMenu->SetItemImage(itsFirstSearchMenuItem + kViewManPageCmd, jcc_view_man_page);

	// create menus when needed

	itsFnMenu         = NULL;
	itsCompletionMenu = NULL;
	itsContextMenu    = NULL;

	// font

	CBPrefsManager* prefsMgr = CBGetPrefsManager();

	JString fontName;
	JSize fontSize;
	prefsMgr->GetDefaultFont(&fontName, &fontSize);
	SetFont(fontName, fontSize, kDefTabCharCount);

	// colors

	SetDefaultFontStyle(prefsMgr->GetColor(CBPrefsManager::kTextColorIndex));

	SetBackColor(prefsMgr->GetColor(CBPrefsManager::kBackColorIndex));
	SetFocusColor(GetBackColor());

	SetCaretColor(prefsMgr->GetColor(CBPrefsManager::kCaretColorIndex));
	SetSelectionColor(prefsMgr->GetColor(CBPrefsManager::kSelColorIndex));
	SetSelectionOutlineColor(prefsMgr->GetColor(CBPrefsManager::kSelLineColorIndex));

	// right margin

	itsDrawRightMarginFlag = kJFalse;
	itsRightMarginWidth    = 80;
	itsRightMarginColor    = prefsMgr->GetColor(CBPrefsManager::kRightMarginColorIndex);
	SetWhitespaceColor(itsRightMarginColor);

	// misc setup

	ShouldBroadcastCaretLocationChanged(kJTrue);
	UpdateTabHandling();
	ListenTo(this);

	(scrollbarSet->GetVScrollbar())->SetScrollDelay(0);

	UseMultipleUndo();
	SetLastSaveLocation();
	ShouldAutoIndent(kJTrue);
	CBShouldAllowDragAndDrop(kJTrue);	// new users expect it
	ShouldMoveToFrontOfText(kJTrue);

	itsLineInput->ShareEditMenu(this);
	itsColInput->ShareEditMenu(this);

	SetCharacterInWordFunction(CBMIsCharacterInWord);

	JTEKeyHandler* handler;
	CBInstallEmulator((CBGetPrefsManager())->GetEmulator(), this, &handler);
}
void
CBEditTextPrefsDialog::BuildWindow
	(
	CBTextDocument* doc
	)
{
// begin JXLayout

	JXWindow* window = jnew JXWindow(this, 640,530, "");
	assert( window != NULL );

	itsTabCharCountInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,130, 40,20);
	assert( itsTabCharCountInput != NULL );

	itsCRMLineWidthInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,150, 40,20);
	assert( itsCRMLineWidthInput != NULL );

	itsUndoDepthInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,170, 40,20);
	assert( itsUndoDepthInput != NULL );

	JXTextButton* cancelButton =
		jnew JXTextButton(JGetString("cancelButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 40,490, 60,20);
	assert( cancelButton != NULL );

	JXTextButton* okButton =
		jnew JXTextButton(JGetString("okButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 220,490, 60,20);
	assert( okButton != NULL );
	okButton->SetShortcuts(JGetString("okButton::CBEditTextPrefsDialog::shortcuts::JXLayout"));

	itsCreateBackupCB =
		jnew JXTextCheckbox(JGetString("itsCreateBackupCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,230, 300,20);
	assert( itsCreateBackupCB != NULL );

	itsAutoIndentCB =
		jnew JXTextCheckbox(JGetString("itsAutoIndentCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,160, 280,20);
	assert( itsAutoIndentCB != NULL );

	JXStaticText* spacesPerTabLabel =
		jnew JXStaticText(JGetString("spacesPerTabLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,130, 210,20);
	assert( spacesPerTabLabel != NULL );
	spacesPerTabLabel->SetToLabel();

	itsExtraSpaceWindTitleCB =
		jnew JXTextCheckbox(JGetString("itsExtraSpaceWindTitleCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,310, 300,20);
	assert( itsExtraSpaceWindTitleCB != NULL );

	itsOpenComplFileOnTopCB =
		jnew JXTextCheckbox(JGetString("itsOpenComplFileOnTopCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,280, 300,20);
	assert( itsOpenComplFileOnTopCB != NULL );

	itsFontMenu =
		jnew JXChooseMonoFont(window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 280,60);
	assert( itsFontMenu != NULL );

	itsEmulatorMenu =
		jnew JXTextMenu(JGetString("itsEmulatorMenu::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,90, 280,25);
	assert( itsEmulatorMenu != NULL );

	JXStaticText* undoDepthLabel =
		jnew JXStaticText(JGetString("undoDepthLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,170, 210,20);
	assert( undoDepthLabel != NULL );
	undoDepthLabel->SetToLabel();

	itsUseDNDCB =
		jnew JXTextCheckbox(JGetString("itsUseDNDCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,130, 280,20);
	assert( itsUseDNDCB != NULL );

	itsOnlyBackupIfNoneCB =
		jnew JXTextCheckbox(JGetString("itsOnlyBackupIfNoneCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,250, 300,20);
	assert( itsOnlyBackupIfNoneCB != NULL );

	itsLeftToFrontOfTextCB =
		jnew JXTextCheckbox(JGetString("itsLeftToFrontOfTextCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,450, 300,20);
	assert( itsLeftToFrontOfTextCB != NULL );

	itsHelpButton =
		jnew JXTextButton(JGetString("itsHelpButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 130,490, 60,20);
	assert( itsHelpButton != NULL );
	itsHelpButton->SetShortcuts(JGetString("itsHelpButton::CBEditTextPrefsDialog::shortcuts::JXLayout"));

	itsBalanceWhileTypingCB =
		jnew JXTextCheckbox(JGetString("itsBalanceWhileTypingCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,310, 280,20);
	assert( itsBalanceWhileTypingCB != NULL );

	itsScrollToBalanceCB =
		jnew JXTextCheckbox(JGetString("itsScrollToBalanceCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,330, 280,20);
	assert( itsScrollToBalanceCB != NULL );

	itsBeepWhenTypeUnbalancedCB =
		jnew JXTextCheckbox(JGetString("itsBeepWhenTypeUnbalancedCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,350, 280,20);
	assert( itsBeepWhenTypeUnbalancedCB != NULL );

	JXStaticText* cpmLabel =
		jnew JXStaticText(JGetString("cpmLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,150, 210,20);
	assert( cpmLabel != NULL );
	cpmLabel->SetToLabel();

	itsSmartTabCB =
		jnew JXTextCheckbox(JGetString("itsSmartTabCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,220, 280,20);
	assert( itsSmartTabCB != NULL );

	itsPWModRG =
		jnew JXRadioGroup(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 460,350, 160,80);
	assert( itsPWModRG != NULL );

	JXTextRadioButton* ctrlMetaLabel =
		jnew JXTextRadioButton(JXTEBase::kCtrlMetaPWMod, JGetString("ctrlMetaLabel::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,10, 90,20);
	assert( ctrlMetaLabel != NULL );

	JXTextRadioButton* mod2Label =
		jnew JXTextRadioButton(JXTEBase::kMod2PWMod, JGetString("mod2Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,30, 70,20);
	assert( mod2Label != NULL );

	JXTextRadioButton* mod3Label =
		jnew JXTextRadioButton(JXTEBase::kMod3PWMod, JGetString("mod3Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,50, 70,20);
	assert( mod3Label != NULL );

	JXTextRadioButton* mod4Label =
		jnew JXTextRadioButton(JXTEBase::kMod4PWMod, JGetString("mod4Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 90,30, 60,20);
	assert( mod4Label != NULL );

	JXTextRadioButton* mod5Label =
		jnew JXTextRadioButton(JXTEBase::kMod5PWMod, JGetString("mod5Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 90,50, 60,20);
	assert( mod5Label != NULL );

	JXStaticText* partialWordTitle =
		jnew JXStaticText(JGetString("partialWordTitle::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,360, 120,60);
	assert( partialWordTitle != NULL );

	itsCopyWhenSelectCB =
		jnew JXTextCheckbox(JGetString("itsCopyWhenSelectCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,250, 280,20);
	assert( itsCopyWhenSelectCB != NULL );

	itsColorButton[CBPrefsManager::kTextColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kTextColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,50, 40,20);
	assert( itsColorButton[CBPrefsManager::kTextColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kBackColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kBackColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 440,50, 80,20);
	assert( itsColorButton[CBPrefsManager::kBackColorIndex-1] != NULL );

	JXStaticText* changeColorLabel =
		jnew JXStaticText(JGetString("changeColorLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 310,50, 90,20);
	assert( changeColorLabel != NULL );
	changeColorLabel->SetToLabel();

	itsColorButton[CBPrefsManager::kSelColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kSelColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 560,50, 60,20);
	assert( itsColorButton[CBPrefsManager::kSelColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kSelLineColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kSelLineColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,70, 50,20);
	assert( itsColorButton[CBPrefsManager::kSelLineColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kCaretColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kCaretColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 520,50, 40,20);
	assert( itsColorButton[CBPrefsManager::kCaretColorIndex-1] != NULL );

	itsDefColorsButton =
		jnew JXTextButton(JGetString("itsDefColorsButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,95, 100,20);
	assert( itsDefColorsButton != NULL );

	itsInvColorsButton =
		jnew JXTextButton(JGetString("itsInvColorsButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 500,95, 100,20);
	assert( itsInvColorsButton != NULL );

	JXStaticText* colorSetsLabel =
		jnew JXStaticText(JGetString("colorSetsLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 310,95, 90,20);
	assert( colorSetsLabel != NULL );
	colorSetsLabel->SetToLabel();

	itsTabToSpacesCB =
		jnew JXTextCheckbox(JGetString("itsTabToSpacesCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,190, 280,20);
	assert( itsTabToSpacesCB != NULL );

	itsHomeEndCB =
		jnew JXTextCheckbox(JGetString("itsHomeEndCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 330,470, 300,20);
	assert( itsHomeEndCB != NULL );

	itsScrollCaretCB =
		jnew JXTextCheckbox(JGetString("itsScrollCaretCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 330,490, 300,20);
	assert( itsScrollCaretCB != NULL );

	itsSortFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsSortFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,390, 280,20);
	assert( itsSortFnMenuCB != NULL );

	itsPackFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsPackFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,430, 280,20);
	assert( itsPackFnMenuCB != NULL );

	itsColorButton[CBPrefsManager::kRightMarginColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kRightMarginColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 450,70, 160,20);
	assert( itsColorButton[CBPrefsManager::kRightMarginColorIndex-1] != NULL );

	itsRightMarginCB =
		jnew JXTextCheckbox(JGetString("itsRightMarginCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,190, 210,20);
	assert( itsRightMarginCB != NULL );

	itsRightMarginInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,190, 40,20);
	assert( itsRightMarginInput != NULL );

	itsSampleText =
		jnew CBSampleText(window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 310,20, 310,25);
	assert( itsSampleText != NULL );

	itsNSInFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsNSInFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,410, 280,20);
	assert( itsNSInFnMenuCB != NULL );

	JXStaticText* wordWrapHint =
		jnew JXStaticText(JGetString("wordWrapHint::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 40,460, 250,20);
	assert( wordWrapHint != NULL );
	wordWrapHint->SetFontSize(JGetDefaultFontSize()-2);
	wordWrapHint->SetToLabel();

	itsMiddleButtonPasteCB =
		jnew JXTextCheckbox(JGetString("itsMiddleButtonPasteCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,270, 280,20);
	assert( itsMiddleButtonPasteCB != NULL );

// end JXLayout

	window->SetTitle("Text Editor Preferences");
	SetButtons(okButton, cancelButton);

	ListenTo(itsHelpButton);

	itsEmulatorMenu->SetMenuItems(kEmulatorMenuStr);
	itsEmulatorMenu->SetUpdateAction(JXMenu::kDisableNone);
	itsEmulatorMenu->SetToPopupChoice(kJTrue, itsEmulatorIndex);
	ListenTo(itsEmulatorMenu);

	itsCreateBackupCB->SetState(doc->WillMakeBackupFile());
	itsOnlyBackupIfNoneCB->SetState(!doc->WillMakeNewBackupEveryOpen());
	itsExtraSpaceWindTitleCB->SetState(doc->WillAllocateTitleSpace());
	itsOpenComplFileOnTopCB->SetState(doc->WillOpenComplFileOnTop());

	CBTextEditor* te = doc->GetTextEditor();

	itsAutoIndentCB->SetState(te->WillAutoIndent());
	itsUseDNDCB->SetState(te->CBAllowsDragAndDrop());
	itsLeftToFrontOfTextCB->SetState(te->WillMoveToFrontOfText());

	itsBalanceWhileTypingCB->SetState(te->WillBalanceWhileTyping());
	itsScrollToBalanceCB->SetState(te->WillScrollToBalance());
	itsBeepWhenTypeUnbalancedCB->SetState(te->WillBeepWhenTypeUnbalanced());

	CBFnMenuUpdater* updater = CBGetFnMenuUpdater();
	itsSortFnMenuCB->SetState(updater->WillSortFnNames());
	itsNSInFnMenuCB->SetState(updater->WillIncludeNamespace());
	itsPackFnMenuCB->SetState(updater->WillPackFnNames());

	itsSmartTabCB->SetState(te->TabIsSmart());
	itsTabToSpacesCB->SetState(te->TabInsertsSpaces());
	itsCopyWhenSelectCB->SetState(te->WillCopyWhenSelect());
	itsMiddleButtonPasteCB->SetState(te->MiddleButtonWillPaste());

	const JFont& font = te->GetDefaultFont();
	itsFontMenu->SetFont(font.GetName(), font.GetSize());

	itsTabCharCountInput->SetValue(te->GetTabCharCount());
	itsTabCharCountInput->SetLowerLimit(1);

	itsCRMLineWidthInput->SetValue(te->GetCRMLineWidth());
	itsCRMLineWidthInput->SetLowerLimit(1);

	itsUndoDepthInput->SetValue(te->GetUndoDepth());
	itsUndoDepthInput->SetLowerLimit(1);

	JSize margin;
	itsRightMarginCB->SetState(te->GetRightMarginWidth(&margin));
	itsRightMarginInput->SetValue(margin);
	itsRightMarginInput->SetLowerLimit(1);

	itsPWModRG->SelectItem(te->GetPartialWordModifier());
	itsHomeEndCB->SetState(JXTEBase::WillUseWindowsHomeEnd());
	itsScrollCaretCB->SetState(CBTextEditor::CaretWillFollowScroll());

	ListenTo(itsCreateBackupCB);
	ListenTo(itsBalanceWhileTypingCB);
	UpdateDisplay();

	// must do this after SetWindow()

	CBPrefsManager* prefsMgr = CBGetPrefsManager();
	JXColormap* colormap     = GetColormap();
	for (JIndex i=0; i<CBPrefsManager::kColorCount; i++)
		{
		itsColor[i] = prefsMgr->GetColor(i+1);
		ListenTo(itsColorButton[i]);
		}

	ListenTo(itsDefColorsButton);
	ListenTo(itsInvColorsButton);
	ListenTo(itsFontMenu);
	ListenTo(itsRightMarginCB);

	UpdateSampleText();
}
void
CBSearchTextDialog::BuildWindow()
{
// begin JXLayout

	JXWindow* window = jnew JXWindow(this, 450,470, "");
	assert( window != NULL );

	JXStaticText* replaceLabel =
		jnew JXStaticText(JGetString("replaceLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 20,101, 220,20);
	assert( replaceLabel != NULL );
	replaceLabel->SetToLabel();

	JXStaticText* searchLabel =
		jnew JXStaticText(JGetString("searchLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 20,31, 220,20);
	assert( searchLabel != NULL );
	searchLabel->SetToLabel();

	JXInputField* searchInput =
		jnew JXInputField(kJTrue, kJFalse, window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 20,50, 220,40);
	assert( searchInput != NULL );

	JXInputField* replaceInput =
		jnew JXInputField(kJTrue, kJFalse, window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 20,120, 220,40);
	assert( replaceInput != NULL );

	JXTextButton* closeButton =
		jnew JXTextButton(JGetString("closeButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedBottom, 320,440, 80,20);
	assert( closeButton != NULL );

	JXTextCheckbox* ignoreCaseCB =
		jnew JXTextCheckbox(JGetString("ignoreCaseCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,180, 130,20);
	assert( ignoreCaseCB != NULL );

	JXTextCheckbox* wrapSearchCB =
		jnew JXTextCheckbox(JGetString("wrapSearchCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,240, 130,20);
	assert( wrapSearchCB != NULL );

	JXTextButton* replaceButton =
		jnew JXTextButton(JGetString("replaceButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 300,50, 140,20);
	assert( replaceButton != NULL );

	JXTextCheckbox* entireWordCB =
		jnew JXTextCheckbox(JGetString("entireWordCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,210, 130,20);
	assert( entireWordCB != NULL );

	JXStringHistoryMenu* prevReplaceMenu =
		jnew JXStringHistoryMenu(kHistoryLength, "", window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 250,130, 30,20);
	assert( prevReplaceMenu != NULL );

	JXStringHistoryMenu* prevSearchMenu =
		jnew JXStringHistoryMenu(kHistoryLength, "", window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 250,60, 30,20);
	assert( prevSearchMenu != NULL );

	JXTextButton* helpButton =
		jnew JXTextButton(JGetString("helpButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedBottom, 60,440, 80,20);
	assert( helpButton != NULL );
	helpButton->SetShortcuts(JGetString("helpButton::CBSearchTextDialog::shortcuts::JXLayout"));

	JXTextCheckbox* searchIsRegexCB =
		jnew JXTextCheckbox(JGetString("searchIsRegexCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 160,180, 150,20);
	assert( searchIsRegexCB != NULL );

	JXTextCheckbox* replaceIsRegexCB =
		jnew JXTextCheckbox(JGetString("replaceIsRegexCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 320,180, 110,20);
	assert( replaceIsRegexCB != NULL );

	JXTextCheckbox* singleLineCB =
		jnew JXTextCheckbox(JGetString("singleLineCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 160,210, 150,20);
	assert( singleLineCB != NULL );

	JXTextCheckbox* preserveCaseCB =
		jnew JXTextCheckbox(JGetString("preserveCaseCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 320,210, 110,20);
	assert( preserveCaseCB != NULL );

	JXTextButton* qRefButton =
		jnew JXTextButton(JGetString("qRefButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedBottom, 190,440, 80,20);
	assert( qRefButton != NULL );

	itsMultifileCB =
		jnew JXTextCheckbox(JGetString("itsMultifileCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,360, 100,20);
	assert( itsMultifileCB != NULL );
	itsMultifileCB->SetShortcuts(JGetString("itsMultifileCB::CBSearchTextDialog::shortcuts::JXLayout"));

	JXScrollbarSet* scrollbarSet =
		jnew JXScrollbarSet(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 140,360, 300,60);
	assert( scrollbarSet != NULL );

	JXStaticText* findLabel =
		jnew JXStaticText(JGetString("findLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 320,20, 100,20);
	assert( findLabel != NULL );
	findLabel->SetToLabel(kJTrue);

	JXSearchTextButton* findBackButton =
		jnew JXSearchTextButton(kJFalse, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 300,20, 20,20);
	assert( findBackButton != NULL );

	JXSearchTextButton* findFwdButton =
		jnew JXSearchTextButton(kJTrue, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 420,20, 20,20);
	assert( findFwdButton != NULL );

	JXStaticText* replaceFindLabel =
		jnew JXStaticText(JGetString("replaceFindLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 320,80, 100,20);
	assert( replaceFindLabel != NULL );
	replaceFindLabel->SetToLabel(kJTrue);

	JXSearchTextButton* replaceFindBackButton =
		jnew JXSearchTextButton(kJFalse, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 300,80, 20,20);
	assert( replaceFindBackButton != NULL );

	JXSearchTextButton* replaceFindFwdButton =
		jnew JXSearchTextButton(kJTrue, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 420,80, 20,20);
	assert( replaceFindFwdButton != NULL );

	JXStaticText* replaceAllLabel =
		jnew JXStaticText(JGetString("replaceAllLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 320,110, 100,20);
	assert( replaceAllLabel != NULL );
	replaceAllLabel->SetToLabel(kJTrue);

	JXSearchTextButton* replaceAllBackButton =
		jnew JXSearchTextButton(kJFalse, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 300,110, 20,20);
	assert( replaceAllBackButton != NULL );

	JXSearchTextButton* replaceAllFwdButton =
		jnew JXSearchTextButton(kJTrue, window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 420,110, 20,20);
	assert( replaceAllFwdButton != NULL );

	JXTextButton* replaceAllInSelButton =
		jnew JXTextButton(JGetString("replaceAllInSelButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 300,140, 140,20);
	assert( replaceAllInSelButton != NULL );

	JXTextCheckbox* stayOpenCB =
		jnew JXTextCheckbox(JGetString("stayOpenCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 160,240, 150,20);
	assert( stayOpenCB != NULL );

	JXTextCheckbox* retainFocusCB =
		jnew JXTextCheckbox(JGetString("retainFocusCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 320,240, 110,20);
	assert( retainFocusCB != NULL );

	itsFileListMenu =
		jnew JXTextMenu(JGetString("itsFileListMenu::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 30,390, 90,30);
	assert( itsFileListMenu != NULL );

	itsSearchDirCB =
		jnew JXTextCheckbox(JGetString("itsSearchDirCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,270, 130,20);
	assert( itsSearchDirCB != NULL );
	itsSearchDirCB->SetShortcuts(JGetString("itsSearchDirCB::CBSearchTextDialog::shortcuts::JXLayout"));

	itsDirInput =
		jnew JXPathInput(window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 150,270, 190,20);
	assert( itsDirInput != NULL );

	JXStaticText* filterLabel =
		jnew JXStaticText(JGetString("filterLabel::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 50,300, 100,20);
	assert( filterLabel != NULL );
	filterLabel->SetToLabel();

	itsDirHistory =
		jnew CBSearchPathHistoryMenu(kHistoryLength, "", window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 340,270, 30,20);
	assert( itsDirHistory != NULL );

	itsFileFilterInput =
		jnew JXInputField(window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 150,300, 190,20);
	assert( itsFileFilterInput != NULL );

	itsFileFilterHistory =
		jnew CBSearchFilterHistoryMenu(kHistoryLength, "", window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 340,300, 30,20);
	assert( itsFileFilterHistory != NULL );

	itsRecurseDirCB =
		jnew JXTextCheckbox(JGetString("itsRecurseDirCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,330, 215,20);
	assert( itsRecurseDirCB != NULL );

	itsChooseDirButton =
		jnew JXTextButton(JGetString("itsChooseDirButton::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 380,270, 60,20);
	assert( itsChooseDirButton != NULL );

	itsInvertFileFilterCB =
		jnew JXTextCheckbox(JGetString("itsInvertFileFilterCB::CBSearchTextDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 380,300, 60,20);
	assert( itsInvertFileFilterCB != NULL );

	itsPathFilterInput =
		jnew JXInputField(window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 255,330, 155,20);
	assert( itsPathFilterInput != NULL );

	itsPathFilterHistory =
		jnew CBSearchFilterHistoryMenu(kHistoryLength, "", window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 410,330, 30,20);
	assert( itsPathFilterHistory != NULL );

// end JXLayout

	SetObjects(searchInput, prevSearchMenu,
			   ignoreCaseCB, entireWordCB, wrapSearchCB,
			   searchIsRegexCB, singleLineCB,
			   replaceInput, prevReplaceMenu,
			   replaceIsRegexCB, preserveCaseCB,
			   stayOpenCB, retainFocusCB,
			   findFwdButton, findBackButton,
			   replaceButton,
			   replaceFindFwdButton, replaceFindBackButton,
			   replaceAllFwdButton, replaceAllBackButton,
			   replaceAllInSelButton,
			   closeButton, helpButton, qRefButton);

	ListenTo(itsSearchDirCB);
	ListenTo(itsDirInput);
	ListenTo(itsMultifileCB);

	itsFileList =
		jnew JXFileListTable(scrollbarSet, scrollbarSet->GetScrollEnclosure(),
							JXWidget::kHElastic, JXWidget::kVElastic,
							0,0, 10,10);
	assert( itsFileList != NULL );
	itsFileList->FitToEnclosure();
	itsFileList->ShouldAcceptFileDrop();
	itsFileList->BackspaceShouldRemoveSelectedFiles();
	ListenTo(itsFileList);

	itsFileListMenu->SetMenuItems(kFileListMenuStr, "CBSearchTextDialog");
	ListenTo(itsFileListMenu);

	ListenTo(itsChooseDirButton);
	ListenTo(itsDirHistory);
	ListenTo(itsFileFilterHistory);
	ListenTo(itsPathFilterHistory);

	const JFont& font = window->GetFontManager()->GetDefaultMonospaceFont();

	itsDirInput->ShouldAllowInvalidPath();
	itsDirHistory->SetDefaultFont(font, kJTrue);
	itsFileFilterInput->SetDefaultFont(font);
	itsFileFilterHistory->SetDefaultFont(font, kJTrue);
	itsPathFilterInput->SetDefaultFont(font);
	itsPathFilterHistory->SetDefaultFont(font, kJTrue);
	itsRecurseDirCB->SetState(kJTrue);

	UpdateBasePath();
	ListenTo(CBGetDocumentManager());

	CBPrefsManager* prefsMgr = CBGetPrefsManager();
	JPrefObject::ReadPrefs();

	JString fontName;
	JSize fontSize;
	prefsMgr->GetDefaultFont(&fontName, &fontSize);
	SetFont(fontName, fontSize);

	searchInput->SetCharacterInWordFunction(CBMIsCharacterInWord);
	replaceInput->SetCharacterInWordFunction(CBMIsCharacterInWord);

	// create hidden JXDocument so Meta-# shortcuts work

	JXDocumentMenu* fileListMenu =
		jnew JXDocumentMenu("", window,
						   JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,-20, 10,10);
	assert( fileListMenu != NULL );

	// decor

	const JRect wFrame  = window->GetFrame();
	const JRect cbFrame = itsSearchDirCB->GetFrame();

	JXDownRect* line =
		jnew JXDownRect(window, JXWidget::kFixedLeft, JXWidget::kFixedTop,
					   cbFrame.left, cbFrame.top-6,
					   wFrame.right-10-cbFrame.left, 2);
	assert( line != NULL );
	line->SetBorderWidth(1);
}