/* ================ rvOpenFileDialog::HandleLookInChange Handles a selection change within the lookin control ================ */ void rvOpenFileDialog::HandleLookInChange(void) { char temp[256]; int sel; int i; idStr lookin; temp[0] = 0; sel = SendMessage(mWndLookin, CB_GETCURSEL, 0, 0); // If something other than base is selected then walk up the list // and build the new lookin path if (sel >= 1) { SendMessage(mWndLookin, CB_GETLBTEXT, 1, (LPARAM)temp); idStr::snPrintf(mLookin, sizeof(mLookin), "%s", temp); for (i = 2; i <= sel; i ++) { SendMessage(mWndLookin, CB_GETLBTEXT, i, (LPARAM)temp); idStr::snPrintf(mLookin, sizeof(mLookin), "%s/%s", mLookin, temp); } } else { mLookin[0] = 0; } // Update the controls with the new lookin path UpdateLookIn(); UpdateFileList(); }
void CFLTKEditor::New() { /* if (!CheckSave()) return; */ int iEditorID = NewEditor(); char pcName[20]; if (iEditorID < 0) return; SetCurEditor(iEditorID); GetFilename() = ""; sprintf(pcName, "Untitled %d", sm_iNewFileNo++); GetName() = pcName; GetPath() = "./"; GetTextBuffer()->select(0, GetTextBuffer()->length()); GetTextBuffer()->remove_selection(); IsFileChanged() = false; GetTextBuffer()->call_modify_callbacks(); SetTitle(); UpdateFileList(); }
void CCCITT4Client::OnFilesListItemClicked(QListWidgetItem *pItem) { QImage *pImage; QString sFilename; QDir oDir; QMessageBox msgBox; oDir.setCurrent(ui->lineEditPath->text()); sFilename = oDir.absoluteFilePath(pItem->text()); this->ui->graphicsView->Scene->clear(); pImage = new QImage(sFilename); if(pImage->isNull()) { msgBox.setText(QString("Can't' open the file: %1").arg(sFilename)); msgBox.exec(); /* Update the file list because it seems to be corrupt */ UpdateFileList(); return; } this->ui->graphicsView->Scene->addItem(new QGraphicsPixmapItem(QPixmap::fromImage(*pImage))); this->show(); /* Move the splitter to enhance the image viewer. */ setVerticalSpitter(0, 80); }
void AddTorrentWindow::OnMetadataComplete() { // // Pause the torrent to prevent files to be downloaded. // See [TorrentObject::LoadFromMagnet] for more info. // fTorrent->StopTransfer(); // // // fInfoHeaderView->Update(); // // // UpdateFileList(); }
/* ================ rvOpenFileDialog::HandleInitDialog Handles the init dialog message ================ */ void rvOpenFileDialog::HandleInitDialog ( void ) { // Cache the more used window handles mWndFileList = GetDlgItem ( mWnd, IDC_TOOLS_FILELIST ); mWndLookin = GetDlgItem ( mWnd, IDC_TOOLS_LOOKIN ); // Load the custom resources used by the controls mImageList = ImageList_LoadBitmap ( mInstance, MAKEINTRESOURCE(IDB_TOOLS_OPEN),16,1,RGB(255,255,255) ); mBackBitmap = (HBITMAP)LoadImage ( mInstance, MAKEINTRESOURCE(IDB_TOOLS_BACK), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS ); // Attach the image list to the file list and lookin controls ListView_SetImageList ( mWndFileList, mImageList, LVSIL_SMALL ); SendMessage( mWndLookin,CBEM_SETIMAGELIST,0,(LPARAM) mImageList ); // Back button is a bitmap button SendMessage( GetDlgItem ( mWnd, IDC_TOOLS_BACK ), BM_SETIMAGE, IMAGE_BITMAP, (LONG) mBackBitmap ); // Allow custom titles SetWindowText ( mWnd, mTitle ); // Custom ok button title if ( mOKTitle.Length ( ) ) { SetWindowText ( GetDlgItem ( mWnd, IDOK ), mOKTitle ); } // See if there is a filename in the lookin idStr temp; idStr filename = mLookin; filename.ExtractFileExtension ( temp ); if ( temp.Length ( ) ) { filename.ExtractFileName ( temp ); SetWindowText ( GetDlgItem ( mWnd, IDC_TOOLS_FILENAME ), temp ); filename.StripFilename ( ); idStr::snPrintf( mLookin, sizeof( mLookin ), "%s", filename.c_str() ); } // Update our controls UpdateLookIn ( ); UpdateFileList ( ); }
CCCITT4Client::CCCITT4Client(QWidget *parent, QString sStoragePath) : QMainWindow(parent), ui(new Ui::CCCITT4Client) { QString sTmp = sStoragePath; ui->setupUi(this); m_nCursorPos = 0; m_pSerialport = new CSerialport(); m_pPortSelectionDialog = new CPortSelectionDialog(); ui->BtSingleShot->setEnabled(false); ui->BtRepeat->setEnabled(false); if( (sStoragePath != "") && (QFile::exists(sStoragePath)) ) { this->ui->lineEditPath->setText(sStoragePath); } else { this->ui->lineEditPath->setText(QDir::currentPath()); } UpdateFileList(); m_oScreenRefreshTimer.start(100); connect(ui->BtConnect, SIGNAL(clicked()), this, SLOT(OnBtConnectClicked())); connect(ui->BtSingleShot, SIGNAL(clicked()), this, SLOT(OnBtSingleShotClicked())); connect(ui->BtRepeat, SIGNAL(clicked()), this, SLOT(OnBtRepeatClicked())); connect(ui->BtPath, SIGNAL(clicked()), this, SLOT(OnBtPathClicked())); connect(ui->lineEditPath, SIGNAL(textChanged(QString)), this, SLOT(OnLineEditPathChanged(QString))); connect(ui->listWidgetFiles, SIGNAL(itemSelectionChanged()), this, SLOT(OnFilesListSelectionChanged())); connect(&m_oScreenRefreshTimer, SIGNAL(timeout()), this, SLOT(OnScreenRefreshTimer())); connect(m_pSerialport, SIGNAL(showErrorMessage(QString, bool, bool)), this, SLOT(OnShowErrorMessage(QString, bool, bool))); connect(m_pSerialport, SIGNAL(frameCompleted(QString)), this, SLOT(OnFrameCompleted(QString))); }
void CFLTKEditor::SaveAs() { char *pcNewFile; char pcFilename[512]; string sNewFile; pcFilename[0] = 0; Fl_File_Chooser::sort = fl_casenumericsort; pcNewFile = fl_file_chooser(m_sFileChooserSaveTitle.c_str(), m_sFileChooserPattern.c_str(), pcFilename); if (pcNewFile != NULL) { sNewFile = pcNewFile; if (*fl_filename_ext(sNewFile.c_str()) == 0) { sNewFile = sNewFile + ".clu"; } // Check whether the name of current editor file is the same as // save as file, or whether new name is the same as that of a // file that is currently open. if (sNewFile != GetFilename()) { int i, iCount = m_mEditorData.Count(); for (i = 0; i < iCount; i++) { if (sNewFile == m_mEditorData[i].m_sFilename) { fl_alert("File with chosen name is already open in editor."); return; } } } SaveFile(sNewFile.c_str()); UpdateFileList(); } }
BOOL CPicapDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; if (!UpdateFileList(CString(lpszPathName))) { AfxMessageBox(UPDATE_FILE_LIST_FAILED_STR); return FALSE; } // TODO: Add your specialized creation code here if (!LoadImage(CString(lpszPathName))) { AfxMessageBox(LOAD_IMAGE_FAILED_STR); return FALSE; } COptionsDlg::GetInstance()->SetImageSize(GetImageWidth(), GetImageHeight()); return TRUE; }
void CFLTKEditor::Load() { /* if (!CheckSave()) return; */ char pcFilename[512]; pcFilename[0] = 0; Fl_File_Chooser::sort = fl_casenumericsort; char *pcNewFile = fl_file_chooser(m_sFileChooserLoadTitle.c_str(), m_sFileChooserPattern.c_str(), pcFilename); if (pcNewFile != NULL) { int i, iCount = m_mEditorData.Count(); // Check whether file has already been loaded for (i = 0; i < iCount; i++) { if (pcNewFile == m_mEditorData[i].m_sFilename) { // if file is found, select it SetCurEditor(i); break; } } // if file has not been loaded then do load it. if (i == iCount) { New(); LoadFile(pcNewFile); } UpdateFileList(); } }
void CFLTKEditor::Close() { if (!CheckSave()) return; if (m_iCurEditorID < 0 || m_iCurEditorID >= int(m_mEditorData.Count()) ) return; DeleteEditor(m_iCurEditorID); if (m_iCurEditorID > 0) { m_iCurEditorID--; SetCurEditor(m_iCurEditorID); } else if (m_iCurEditorID >= int(m_mEditorData.Count())) { char pcName[100]; NewEditor(); m_iCurEditorID = 0; SetCurEditor(m_iCurEditorID); GetFilename() = ""; sprintf(pcName, "Untitled %d", sm_iNewFileNo++); GetName() = pcName; GetPath() = "./"; GetTextBuffer()->select(0, GetTextBuffer()->length()); GetTextBuffer()->remove_selection(); IsFileChanged() = false; GetTextBuffer()->call_modify_callbacks(); SetTitle(); } UpdateFileList(); }
void C4FileSelDlg::SetPath(const char *szNewPath, bool fRefresh) { sPath.Copy(szNewPath); if (fRefresh && IsShown()) UpdateFileList(); }
bool CFileDialog::Activate() { char *buttons[] = { GetTranslation("Open directory"), GetTranslation("Select directory"), GetTranslation("Cancel") }; char label[] = "Dir: "; char curdir[1024]; ButtonBar.Push(); ButtonBar.AddButton("TAB", "Next button"); ButtonBar.AddButton("ENTER", "Activate button"); ButtonBar.AddButton("Arrows", "Navigate menu"); ButtonBar.AddButton("C", "Create directory"); ButtonBar.AddButton("A", "About"); ButtonBar.AddButton("ESC", "Cancel"); ButtonBar.Draw(); if (!getcwd(curdir, sizeof(curdir))) throwerror(true, "Could not read current directory"); if (chdir(m_szStartDir.c_str()) != 0) throwerror(true, "Could not open directory '%s'", m_szStartDir.c_str()); if (!ReadDir(m_szStartDir)) throwerror(true, "Could not read directory '%s'", m_szStartDir.c_str()); CCDKButtonBox ButtonBox(CDKScreen, CENTER, GetDefaultHeight(), 1, GetDefaultWidth(), 0, 1, 3, buttons, 3); ButtonBox.SetBgColor(5); if (!m_pCurDirWin && !m_pFileList) { m_pCurDirWin = new CCDKSWindow(CDKScreen, CENTER, getbegy(ButtonBox.GetBBox()->win)-2, 2, GetDefaultWidth()+1, NULL, 1); m_pCurDirWin->SetBgColor(5); if (!m_pFileList) { m_pFileList = new CCDKAlphaList(CDKScreen, CENTER, 2, getbegy(m_pCurDirWin->GetSWin()->win)-1, GetDefaultWidth()+1, const_cast<char*>(m_szTitle.c_str()), label, &m_DirItems[0], m_DirItems.size()); m_pFileList->SetBgColor(5); setCDKEntryPreProcess(m_pFileList->GetAList()->entryField, CreateDirCB, this); //m_pFileList->GetAList()->entryField->dispType = vVIEWONLY; // HACK: Disable backspace } setCDKAlphalistLLChar(m_pFileList->GetAList(), ACS_LTEE); setCDKAlphalistLRChar(m_pFileList->GetAList(), ACS_RTEE); setCDKLabelLLChar(m_pCurDirWin->GetSWin(), ACS_LTEE); setCDKLabelLRChar(m_pCurDirWin->GetSWin(), ACS_RTEE); setCDKButtonboxULChar(ButtonBox.GetBBox(), ACS_LTEE); setCDKButtonboxURChar(ButtonBox.GetBBox(), ACS_RTEE); } m_pFileList->Draw(); m_pCurDirWin->Draw(); ButtonBox.Draw(); m_pFileList->Bind(KEY_TAB, SwitchButtonK, ButtonBox.GetBBox()); // Pas TAB through ButtonBox m_szDestDir = m_szStartDir; UpdateCurDirText(); while(true) { // HACK: Give textbox content setCDKEntryValue(m_pFileList->GetAList()->entryField, chtype2Char(m_pFileList->GetAList()->scrollField->item[m_pFileList->GetAList()->scrollField->currentItem])); char *selection = m_pFileList->Activate(); if ((m_pFileList->ExitType() != vNORMAL) || (ButtonBox.GetCurrent() == 2)) break; if (!selection || !selection[0]) continue; if (ButtonBox.GetCurrent() == 1) { if (m_bAskWAccess && !WriteAccess(m_szDestDir)) { char *dbuttons[2] = { GetTranslation("Continue as root"), GetTranslation("Choose another directory") }; CCDKDialog Diag(CDKScreen, CENTER, CENTER, GetTranslation("You don't have write permissions for this directory.\n" "The files can be extracted as the root user,\n" "but you'll need to enter the root password for this later."), dbuttons, 2); Diag.SetBgColor(26); int sel = Diag.Activate(); Diag.Destroy(); refreshCDKScreen(CDKScreen); if (sel) continue; } break; } if (!FileExists(selection)) { if (YesNoBox(GetTranslation("Directory does not exist\nDo you want to create it?"))) { if (mkdir(selection, (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH)) != 0) { WarningBox("%s\n%.75s\n%.75s", GetTranslation("Could not create directory"), selection, strerror(errno)); continue; } } else continue; } UpdateFileList(selection); } bool success = ((m_pFileList->ExitType() != vESCAPE_HIT) && (ButtonBox.GetCurrent() == 1)); ButtonBar.Pop(); if (m_bRestoreDir) chdir(curdir); // Return back to original directory return success; }
void C4FileSelDlg::OnShown() { BaseClass::OnShown(); // load files UpdateFileList(); }
AddTorrentWindow::AddTorrentWindow(TorrentObject* torrent) : BWindow(BRect(), "Add torrent", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_PULSE_NEEDED ), fTorrent(torrent), fCancelAdd(true) { SetPulseRate(1000000); SetLayout(new BGroupLayout(B_VERTICAL)); float spacing = be_control_look->DefaultItemSpacing(); // // // fInfoHeaderView = new InfoHeaderView(fTorrent); fFileList = new BColumnListView("FileList", 0, B_PLAIN_BORDER, true); fStartCheckBox = new BCheckBox("", "Start when added", NULL); fCancelButton = new BButton("Cancel", new BMessage(B_QUIT_REQUESTED)); fAddButton = new BButton("Add", new BMessage(MSG_BUTTON_ADD)); fLoadingView = new BStatusBar("", "Downloading Metadata"); fLoadingView->SetBarHeight(12); fLoadingView->SetMaxValue(1.0); if( !fTorrent->IsMagnet() ) fLoadingView->Hide(); fStartCheckBox->SetValue(B_CONTROL_ON); // // // fFileList->SetColumnFlags(B_ALLOW_COLUMN_RESIZE); fFileList->SetSortingEnabled(false); fFileList->SetExplicitMinSize(BSize(550, FILE_COLUMN_HEIGHT * 5)); fFileList->AddColumn(new FileColumn("Name", 400, 400, 500), COLUMN_FILE_NAME); fFileList->AddColumn(new CheckBoxColumn("DL", 40, 40, 40), COLUMN_FILE_DOWNLOAD); // // We're a magnet or a complete torrent file? // if( fTorrent->IsMagnet() ) { fTorrent->SetMetadataCallbackHandler(this); //const_cast<TorrentObject*>(fTorrent)->StartTransfer(); } else UpdateFileList(); AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fInfoHeaderView) .AddGlue() .Add(fFileList) .Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .SetInsets(spacing, spacing, spacing, spacing) .Add(fStartCheckBox) .AddGlue() .Add(fCancelButton) .Add(fAddButton) .Add(fLoadingView) ) .SetInsets(spacing, spacing, spacing, spacing) ); CenterOnScreen(); Run(); }
/* ================ rvOpenFileDialog::HandleCommandOK Handles the pressing of the OK button but either opening a selected folder or closing the dialog with the resulting filename ================ */ void rvOpenFileDialog::HandleCommandOK(void) { char temp[256]; LVITEM item; // If nothing is selected then there is nothing to open int sel = ListView_GetNextItem(mWndFileList, -1, LVNI_SELECTED); if (sel == -1) { GetWindowText(GetDlgItem(mWnd, IDC_TOOLS_FILENAME), temp, sizeof(temp)-1); if (!temp[0]) { return; } item.iImage = 2; } else { // Get the currently selected item item.mask = LVIF_IMAGE|LVIF_TEXT; item.iImage = sel; item.iSubItem = 0; item.pszText = temp; item.cchTextMax = 256; item.iItem = sel; ListView_GetItem(mWndFileList, &item); } // If the item is a folder then just open that folder if (item.iImage == 0) { if (strlen(mLookin)) { idStr::snPrintf(mLookin, sizeof(mLookin), "%s/%s", mLookin, temp); } else { idStr::Copynz(mLookin, temp, sizeof(mLookin)); } UpdateLookIn(); UpdateFileList(); } // If the item is a file then build the filename and end the dialog else if (item.iImage == 2) { mFilename = mLookin; if (mFilename.Length()) { mFilename.Append("/"); } mFilename.Append(temp); // Make sure the file exists if (mFlags & OFD_MUSTEXIST) { idFile *file; file = fileSystem->OpenFileRead(mFilename); if (!file) { MessageBox(mWnd, va("%s\nFile not found.\nPlease verify the correct file name was given", mFilename.c_str()), "Open", MB_ICONERROR|MB_OK); return; } fileSystem->CloseFile(file); } EndDialog(mWnd, 1); } return; }
bool CFLTKEditor::HighlightLinePos(const char *pcFilename, int iInputPos) { if (iInputPos < 0) return false; int iTextPos, iLineStart, iLineEnd; char pcSearchName[300], *pcPoint; string sName; strncpy(pcSearchName, pcFilename, 299); if ((pcPoint = strstr(pcSearchName, ".clu"))) { *pcPoint = 0; } // if (GetFilename().size() == 0) sName = GetPath() + GetName(); // else // sName = GetFilename(); if (pcSearchName != sName) { int i, iCount = m_mEditorData.Count(); for (i = 0; i < iCount; i++) { //sName = m_mEditorData[i].m_sFilename; //if (sName.size() == 0) //{ sName = m_mEditorData[i].m_sPath + m_mEditorData[i].m_sName; //} if (sName == pcSearchName) { SetCurEditor(i); m_pFileChoice->value(i); break; } } // File not opened yet if (i == iCount) { sName = pcSearchName; sName = sName + ".clu"; CFLTKEditor::New(); CFLTKEditor::LoadFile(sName.c_str()); UpdateFileList(); } } //iTextPos = GetTextBuffer()->skip_lines(0, iLine-1); iTextPos = iInputPos + 1; if (iTextPos >= GetTextBuffer()->length()) iTextPos = GetTextBuffer()->length()-2; iLineStart = GetTextBuffer()->line_start(iTextPos); iLineEnd = GetTextBuffer()->line_end(iTextPos); GetTextBuffer()->select(iLineStart, iLineEnd); GetEditor()->insert_position(iTextPos); GetEditor()->show_insert_position(); GetTextBuffer()->call_modify_callbacks(); return true; }
bool CFLTKEditor::Create(int iPosX, int iPosY, int iWidth, int iHeight, const char* pcFilename, void *pvIcon) { if (m_bIsOK) return true; icon(pvIcon); size(iWidth, iHeight); if (iPosX >= 0 && iPosY >= 0) position(iPosX, iPosY); m_pReplaceDlg = new Fl_Window(300, 105, "Replace"); m_pReplaceDlg->begin(); m_pReplaceFind = new Fl_Input(80, 10, 210, 25, "Find:"); m_pReplaceFind->align(FL_ALIGN_LEFT); m_pReplaceWith = new Fl_Input(80, 40, 210, 25, "Replace:"); m_pReplaceWith->align(FL_ALIGN_LEFT); m_pReplaceAll = new Fl_Button(10, 70, 90, 25, "Replace All"); m_pReplaceAll->callback((Fl_Callback *) CB_ReplaceAll, this); m_pReplaceNext = new Fl_Return_Button(105, 70, 120, 25, "Replace Next"); m_pReplaceNext->callback((Fl_Callback *) CB_Replace2, this); m_pReplaceCancel = new Fl_Button(230, 70, 60, 25, "Cancel"); m_pReplaceCancel->callback((Fl_Callback *) CB_ReplaceCan, this); m_pReplaceDlg->end(); m_pReplaceDlg->set_non_modal(); color(FL_LIGHT2); begin(); InitMenu(); m_pMenuBar = new Fl_Menu_Bar(0, 0, iWidth, 20); m_pMenuBar->copy(&m_vecMenuItem[0], this); m_pMenuBar->textsize(11); m_pMenuBar->box(FL_FLAT_BOX); m_pMenuBar->down_box(FL_FLAT_BOX); m_pMenuBar->color(FL_LIGHT2); m_pToolBar = new Fl_Pack(0, 23, iWidth-10, 20); m_pToolBar->type(FL_HORIZONTAL); m_pToolBar->spacing(5); m_pToolBar->color(FL_LIGHT2); //m_pToolBar->box(FL_BORDER_FRAME); m_pToolBar->begin(); m_pHSpaceBox = new Fl_Box(FL_NO_BOX, 0, 0, 3, 20, ""); m_pFileChoice = new Fl_Choice(0, 0, 200, 20); m_pFileChoice->box(FL_FLAT_BOX); m_pFileChoice->textsize(11); m_pFileChoice->callback((Fl_Callback *) CFLTKEditor::CB_SetFile, this); m_pToolBar->end(); m_pContextMenu = new Fl_Menu_Button(0, 46, iWidth, iHeight - 46); m_pContextMenu->copy(&m_vecCMenuItem[0], this); m_pContextMenu->textsize(11); m_pContextMenu->box(FL_FLAT_BOX); m_pContextMenu->down_box(FL_FLAT_BOX); m_pContextMenu->color(FL_LIGHT2); m_pContextMenu->type(Fl_Menu_Button::POPUP3); InitStyleTable(); end(); callback((Fl_Callback *) CFLTKEditor::CB_Quit, this); New(); if (pcFilename) { LoadFile(pcFilename); } else { SetTitle(); } UpdateFileList(); m_bIsOK = true; return true; }