void SyGFindFileDialog::UpdateButtons() { JXInputField* field = NULL; const JIndex action = itsActionRG->GetSelectedItem(); if (action == kFindFileAction) { field = itsFileInput; } else if (action == kFindExprAction) { field = itsExprInput; } assert( field != NULL ); if (field->IsEmpty()) { itsSearchButton->Deactivate(); } else { itsSearchButton->Activate(); } }
JBoolean CMArray2DTable::ExtractInputData ( const JPoint& cell ) { JXInputField* input = NULL; const JBoolean ok = GetXInputField(&input); assert( ok ); const JString& text = input->GetText(); if (!text.IsEmpty()) { if (text != itsOrigEditValue) { const JString name = itsArrayDir->GetExpression(cell); (CMGetLink())->SetValue(name, text); } return kJTrue; } else { return kJFalse; } }
JBoolean JXChooseFileDialog::OKToDeactivate() { if (!JXCSFDialogBase::OKToDeactivate()) { return kJFalse; } else if (Cancelled()) { return kJTrue; } JXPathInput* pathInput = GetPathInput(); if (pathInput->HasFocus()) { GoToItsPath(); return kJFalse; } JXInputField* filterInput = GetFilterInput(); if (filterInput->HasFocus()) { AdjustFilter(); return kJFalse; } JXDirTable* fileBrowser = GetFileBrowser(); if (fileBrowser->GoToSelectedDirectory()) { return kJFalse; } JPtrArray<JDirEntry> entryList(JPtrArrayT::kDeleteAll); if (fileBrowser->GetSelection(&entryList)) { const JSize count = entryList.GetElementCount(); for (JIndex i=1; i<=count; i++) { JDirEntry* entry = entryList.NthElement(i); entry->ForceUpdate(); // check that link hasn't been broken behind our back if (!entry->IsFile()) { (GetDirInfo())->ForceUpdate(); return kJFalse; } } return kJTrue; } else { return kJFalse; } }
void JXStyleTable::SetAllCellStyles ( const JFontStyle& style ) { itsStyleData->SetAllCellStyles(style); JXInputField* input = NULL; if (IsEditing() && GetXInputField(&input)) { input->SetFontStyle(style); } }
void JXStyleTable::SetFont ( const JCharacter* name, const JSize size ) { itsStyleData->SetFont(name, size); JXInputField* input = NULL; if (GetXInputField(&input)) { input->SetFontName(name); input->SetFontSize(size); } }
void JXStyleTable::SetCellStyle ( const JPoint& cell, const JFontStyle& style ) { itsStyleData->SetCellStyle(cell, style); JPoint editCell; JXInputField* input = NULL; if (GetEditedCell(&editCell) && editCell == cell && GetXInputField(&input)) { input->SetFontStyle(style); } }
JXInputField* CMArray2DTable::CreateXInputField ( const JPoint& cell, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) { JXInputField* input = JXStringTable::CreateXInputField(cell, x,y, w,h); input->SetIsRequired(); itsOrigEditValue = input->GetText(); return input; }
JXInputField* CBMacroSetTable::CreateStringTableInput ( const JPoint& cell, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) { SelectSingleCell(cell); JXInputField* input = JXStringTable::CreateStringTableInput( cell, enclosure, hSizing, vSizing, x,y, w,h); input->SetIsRequired(); return input; }
JBoolean JXSaveFileDialog::OKToDeactivate() { if (!JXCSFDialogBase::OKToDeactivate()) { return kJFalse; } else if (Cancelled()) { return kJTrue; } JXPathInput* pathInput = GetPathInput(); if (pathInput->HasFocus()) { GoToItsPath(); return kJFalse; } JXInputField* filterInput = GetFilterInput(); if (filterInput->HasFocus()) { AdjustFilter(); return kJFalse; } JXDirTable* fileBrowser = GetFileBrowser(); if (fileBrowser->HasFocus() && fileBrowser->GoToSelectedDirectory()) { return kJFalse; } const JString& fileName = itsFileNameInput->GetText(); if (fileName.IsEmpty()) { (JGetUserNotification())->ReportError("You need to enter a file name."); return kJFalse; } const JString& path = GetPath(); const JString fullName = path + fileName; const JBoolean fileExists = JFileExists(fullName); if (JDirectoryExists(fullName)) { (JGetUserNotification())->ReportError( "This name is already used for a directory."); return kJFalse; } else if (!JDirectoryWritable(path) && !fileExists) { (JGetUserNotification())->ReportError( "You are not allowed to write to this directory."); return kJFalse; } else if (!fileExists) { *itsFileName = fileName; return kJTrue; } else if (!JFileWritable(fullName)) { (JGetUserNotification())->ReportError( "You are not allowed to write to this file."); return kJFalse; } else if ((JGetUserNotification())->AskUserNo("That file already exists. Replace it?")) { *itsFileName = fileName; return kJTrue; } else { return kJFalse; } }
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); }