void PlayInfoBox::setparm(int xpos, int ypos, int width) { /*int i; for (i=0; i<width-5; i++) { strncat (message[0], " ", 1); } //jrml*/ memset(message[0],' ',width-1); memset(message[1],' ',width-1); *(message[0]+width-1) = '\0'; *(message[1]+width-1) = '\0'; infobox = newCDKLabel ( cdkscreen, xpos, ypos, (char **)message, 2, TRUE, FALSE ); setCDKLabelLLChar (infobox, ACS_LTEE); setCDKLabelLRChar (infobox, ACS_RTEE); }
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; }