bool DoSystemConfigDialog(NCDialogParent *parent) { SysOptDialog dlg(parent); if (dlg.DoModal() == CMD_OK) { wcmConfig.systemAskOpenExec = dlg.askOpenExecButton.IsSet(); wcmConfig.systemEscPanel = dlg.escPanelButton.IsSet(); wcmConfig.systemBackSpaceUpDir = dlg.backUpDirButton.IsSet(); const char *s = wcmConfig.systemLang.ptr(); if (!s) s = "+"; bool langChanged = strcmp(dlg.curLangId.ptr(), s) != 0; wcmConfig.systemLang = new_char_str(dlg.curLangId.ptr()); if (langChanged) { NCMessageBox(parent, _LT("Note"), _LT("Language changed. \nFor effect you must save config and restart"), false); } return true; } return false; }
EditOptDialog::EditOptDialog(NCDialogParent *parent) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode( _LT("Editor") ).ptr(), bListOkCancel), iL(16, 2), saveFilePosButton(0, this, utf8_to_unicode( _LT("Save file position") ).ptr(), 0, wcmConfig.editSavePos), autoIdentButton(0, this, utf8_to_unicode( _LT("Auto indent") ).ptr(), 0, wcmConfig.editAutoIdent), shlButton(0, this, utf8_to_unicode( _LT("Syntax highlighting") ).ptr(), 0, wcmConfig.editShl), tabText(0, this, utf8_to_unicode( _LT("Tab size:") ).ptr()), tabEdit(0, this, 0, 0, 16) { char buf[0x100]; snprintf(buf, sizeof(buf)-1, "%i", wcmConfig.editTabSize); tabEdit.SetText(utf8_to_unicode(buf).ptr(), true); iL.AddWin(&saveFilePosButton, 0, 0, 0, 1); saveFilePosButton.Enable(); saveFilePosButton.Show(); iL.AddWin(&autoIdentButton, 1, 0, 1, 1); autoIdentButton.Enable(); autoIdentButton.Show(); iL.AddWin(&shlButton, 2, 0, 2, 1); shlButton.Enable(); shlButton.Show(); iL.AddWin(&tabText, 3, 0, 3, 0); tabText.Enable(); tabText.Show(); iL.AddWin(&tabEdit, 4, 1, 4, 1); tabEdit.Enable(); tabEdit.Show(); AddLayout(&iL); SetEnterCmd(CMD_OK); saveFilePosButton.SetFocus(); order.append(&saveFilePosButton); order.append(&autoIdentButton); order.append(&shlButton); order.append(&tabEdit); SetPosition(); }
bool OperCFThread::CopyLink( FS* srcFs, FSPath& srcPath, FSNode* srcNode, FS* destFs, FSPath& destPath, bool move ) { ASSERT( srcNode->st.IsLnk() ); if ( IsSameFile( srcFs, srcPath, &( srcNode->st ), destFs, destPath ) ) { RedMessage( _LT( "Can't copy link to itself:\n" ) , srcFs->Uri( srcPath ).GetUtf8() ); return false; } int ret_err; while ( destFs->Symlink( destPath, srcNode->st.link, &ret_err, Info() ) && !skipNonRegular ) switch ( RedMessage( _LT( "Can't create symbolic link:\n" ), destFs->Uri( destPath ).GetUtf8(), "to\n", srcNode->st.link.GetUtf8(), bSkipSkipallCancel, destFs->StrError( ret_err ).GetUtf8() ) ) { case CMD_CANCEL: return false; case CMD_SKIPALL: skipNonRegular = true; case CMD_SKIP: return true; } return !move || Unlink( srcFs, srcPath ); }
SearchFileParamDialog::SearchFileParamDialog(NCDialogParent *parent, SearchFileParams *params) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode(_LT("Search")).ptr(), bListOkCancel), iL(16, 3), maskText(0, this, utf8_to_unicode(_LT("File mask:")).ptr()), textText(0, this, utf8_to_unicode(_LT("Text:")).ptr()), maskEdit (0, this, 0, 0, 50), textEdit (0, this, 0, 0, 50), caseButton(0, this, utf8_to_unicode(_LT("Case sensitive")).ptr(), 0, params->sens) { if (params->mask.ptr()) maskEdit.SetText(params->mask.ptr(), true); if (params->txt.ptr()) textEdit.SetText(params->txt.ptr(), true); iL.AddWin(&maskText, 0, 0); maskText.Enable(); maskText.Show(); iL.AddWin(&textText, 1, 0); textText.Enable(); textText.Show(); iL.AddWin(&maskEdit, 0, 1); maskEdit.Enable(); maskEdit.Show(); maskEdit.SetFocus(); iL.AddWin(&textEdit, 1, 1); textEdit.Enable(); textEdit.Show(); iL.AddWin(&caseButton, 2, 1); caseButton.Enable(); caseButton.Show(); AddLayout(&iL); SetEnterCmd(CMD_OK); order.append(&maskEdit); order.append(&textEdit); order.append(&caseButton); SetPosition(); }
ReplaceEditParamDialog::ReplaceEditParamDialog(NCDialogParent *parent, ReplaceEditParams *params) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode(_LT("Replace")).ptr(), bListOkCancel), iL(16, 3), fromText(0, this, utf8_to_unicode(_LT("Search for:")).ptr()), toText(0, this, utf8_to_unicode(_LT("Replace with:")).ptr()), fromEdit (0, this, 0, 0, 50), toEdit (0, this, 0, 0, 50), caseButton(0, this, utf8_to_unicode(_LT("Case sensitive")).ptr(), 0, params->sens) { if (params->from.ptr()) fromEdit.SetText(params->from.ptr(), true); if (params->to.ptr()) toEdit.SetText(params->to.ptr(), true); iL.AddWin(&fromText, 0, 0); fromText.Enable(); fromText.Show(); iL.AddWin(&toText, 1, 0); toText.Enable(); toText.Show(); iL.AddWin(&fromEdit, 0, 1); fromEdit.Enable(); fromEdit.Show(); fromEdit.SetFocus(); iL.AddWin(&toEdit, 1, 1); toEdit.Enable(); toEdit.Show(); iL.AddWin(&caseButton, 2, 1); caseButton.Enable(); caseButton.Show(); AddLayout(&iL); SetEnterCmd(CMD_OK); order.append(&fromEdit); order.append(&toEdit); order.append(&caseButton); SetPosition(); }
bool OperCFThread::Copy(FS *srcFs, FSPath &__srcPath, FSList *list, FS *destFs, FSPath &__destPath, cstrhash<bool,unicode_t> &resList) { if (list->Count()<=0) return true; FSPath srcPath = __srcPath; int srcPos = srcPath.Count(); FSPath destPath = __destPath; int destPos = destPath.Count(); FSStat st; int ret_error; int res = destFs->Stat(__destPath, &st, &ret_error, Info()); if (res == -2) return false; if (res && !destFs->IsENOENT(ret_error)) { RedMessage( _LT("Can't copy to:\n"), destFs->Uri(destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } bool exist = (res == 0); if (list->Count()>1) { //если файлов >1 то копировать можно только в каталог if (!exist) { RedMessage( _LT("Can't copy files, destination is not found:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } if (!st.IsDir()) { RedMessage( _LT("Destination is not directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } for (FSNode *node = list->First(); node; node = node->next) { if (Info()->Stopped()) return false; srcPath.SetItemStr(srcPos, node->Name()); destPath.SetItemStr(destPos, node->Name()); if (!CopyNode(srcFs, srcPath, node, destFs, destPath, false)) return false; resList[node->Name().GetUnicode()] = true; } } else { // 1 element if (exist && st.IsDir()) destPath.SetItemStr(destPos, list->First()->Name()); srcPath.SetItemStr(srcPos, list->First()->Name()); if (!CopyNode(srcFs, srcPath, list->First(), destFs, destPath, false)) return false; resList[list->First()->Name().GetUnicode()] = true; }; return true; }
bool clFileAssociationsWin::Command( int id, int subId, Win* win, void* data ) { if ( id == CMD_OK ) { EndModal( CMD_OK ); return true; } if ( id == CMD_MINUS ) { const clNCFileAssociation* p = m_ListWin.GetCurrentData(); if ( !p ) { return true; } if ( NCMessageBox( ( NCDialogParent* )Parent(), _LT( "Delete item" ), carray_cat<char>( _LT( "Delete '" ), unicode_to_utf8( p->GetMask().data() ).data() , "' ?" ).data(), false, bListOkCancel ) == CMD_OK ) { m_ListWin.Del(); m_Saved = false; } return true; } if ( id == CMD_EDIT || ( id == CMD_ITEM_CLICK && win == &m_ListWin ) ) { const clNCFileAssociation* ValueToEdit = m_ListWin.GetCurrentData(); if ( !ValueToEdit ) { return true; } clEditFileAssociationsWin Dialog( ( NCDialogParent* )Parent(), ValueToEdit ); Dialog.SetEnterCmd( 0 ); if ( Dialog.DoModal( ) == CMD_OK ) { m_ListWin.Rename( Dialog.GetResult( ) ); m_Saved = false; } return true; } if ( id == CMD_PLUS ) { clEditFileAssociationsWin Dialog( ( NCDialogParent* )Parent(), NULL ); Dialog.SetEnterCmd( 0 ); if ( Dialog.DoModal( ) == CMD_OK ) { m_ListWin.Ins( Dialog.GetResult( ) ); m_Saved = false; } return true; } return NCDialog::Command( id, subId, win, data ); }
bool OperCFThread::Move(FS *srcFs, FSPath &__srcPath, FSList *list, FS *destFs, FSPath &__destPath) { if (list->Count()<=0) return true; FSPath srcPath = __srcPath; int srcPos = srcPath.Count(); FSPath destPath = __destPath; int destPos = destPath.Count(); FSStat st; int ret_error; int r = destFs->Stat(__destPath, &st, &ret_error, Info()); if (r == -2) return false; if (list->Count()>1) { //если файлов >1 то копировать можно только в каталог if (r) { RedMessage( _LT("Can't move files, bad destination directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } if (!st.IsDir()) { RedMessage( _LT("Destination is not directory:\n"), destFs->Uri(__destPath).GetUtf8(), bOk); return false; } for (FSNode *node = list->First(); node; node = node->next) { srcPath.SetItemStr(srcPos, node->Name()); destPath.SetItemStr(destPos, node->Name()); //printf("MOVE '%s'\n", srcPath.GetUtf8()); if (!MoveNode(srcFs, srcPath, node, destFs, destPath)) return false; } } else { // 1 element if (r && !destFs->IsENOENT(ret_error)) { RedMessage( _LT("Can't move to:\n"), destFs->Uri(destPath).GetUtf8(), bOk, destFs->StrError(ret_error).GetUtf8()); return false; } if (!r && st.IsDir()) destPath.SetItemStr(destPos, list->First()->Name()); FSNode *node = list->First(); srcPath.SetItemStr(srcPos, list->First()->Name()); if (!MoveNode(srcFs, srcPath, list->First(), destFs, destPath)) return false; } return true; }
int OperCFThread::MoveFile( FS* srcFs, FSPath& srcPath, FSNode* srcNode, FS* destFs, FSPath& destPath ) { if ( srcFs != destFs && !srcFs->Equal( destFs ) ) { return 1; } if ( IsSameFile( srcFs, srcPath, &( srcNode->st ), destFs, destPath ) ) { RedMessage( _LT( "Can't move file to itself:\n" ), srcFs->Uri( srcPath ).GetUtf8() ); return -1; } int ret_error; FSStat st; if ( !destFs->Stat( destPath, &st, &ret_error, Info() ) ) { if ( !commitAll ) { switch ( RedMessage( _LT( "Overwrite file?\n" ), destFs->Uri( destPath ).GetUtf8(), bOkAllNoCancel, destFs->StrError( ret_error ).GetUtf8() ) ) { case CMD_ALL: commitAll = true; //no break case CMD_OK: break; case CMD_NO: return 0; default: return -1; } } if ( destFs->Delete( destPath, &ret_error, Info() ) ) return RedMessage( _LT( "Can't delete the file:\n" ), destFs->Uri( destPath ).GetUtf8(), bSkipCancel, destFs->StrError( ret_error ).GetUtf8() ) == CMD_SKIP ? 0 : -1 ; } if ( srcFs->Rename( srcPath, destPath, &ret_error, Info() ) ) { if ( srcFs->IsEXDEV( ret_error ) ) { return 1; } return RedMessage( _LT( "Can't rename the file:\n" ), srcFs->Uri( srcPath ).GetUtf8(), "\nto\n", destFs->Uri( destPath ).GetUtf8(), bSkipCancel, srcFs->StrError( ret_error ).GetUtf8() ) == CMD_SKIP ? 0 : -1; } return 0; }
void CharsetDlg1::Del() { int n = list.GetCurrent(); if (n >=0 && n<csList.count() && csList.count() > 1 && NCMessageBox((NCDialogParent*)Parent(), _LT("Del"), carray_cat<char>(_LT("Delete element")," '", csList[n]->name ,"' ?").ptr(), false, bListOkCancel) == CMD_OK) { csList.del(n); list.SetList(csList.ptr(), csList.count()); SaveOperCharsets(); list.Invalidate(); } }
CharsetDlg1(NCDialogParent *parent, int curCharset) : NCDialog(createDialogAsChild, 0, parent, utf8_to_unicode( _LT("Charset") ).ptr(), bListOkCancel), layout(10,10), list(this, 7), otherButton(0, this, utf8_to_unicode( _LT("Other...") ).ptr(), CMD_OTHER), addButton(0, this, utf8_to_unicode( carray_cat<char>(_LT("Add..."), "(Ins)").ptr() ).ptr(), CMD_ADD), delButton(0, this, utf8_to_unicode( carray_cat<char>(_LT("Del..."), "(Del)").ptr() ).ptr(), CMD_DEL) { int i; InitOperCharsets(); list.SetList(::csList.ptr(), ::csList.count()); list.MoveFirst(0); for (int i = 0; i < ::csList.count(); i++) if (::csList[i]->id == curCharset) { list.MoveCurrent(i); break; } /* LO L LA LD */ layout.AddWin(&list,0,0,3,0); list.Enable(); list.Show(); list.SetFocus(); layout.AddWin(&otherButton,0,1); otherButton.Enable(); otherButton.Show(); layout.AddWin(&addButton,2,1); addButton.Enable(); addButton.Show(); layout.AddWin(&delButton,3,1); delButton.Enable(); delButton.Show(); int mx = 0, my = 0; LSize ls; otherButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; addButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; delButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; ls.x.minimal = ls.x.maximal = mx; ls.y.minimal = ls.y.maximal = my; otherButton.SetLSize(ls); addButton.SetLSize(ls); delButton.SetLSize(ls); layout.SetLineGrowth(1); AddLayout(&layout); SetEnterCmd(CMD_OK); SetPosition(); };
bool OperCFThread::RmDir( FS* fs, FSPath& path, bool* skipAll ) { int ret_err; while ( fs->RmDir( path, &ret_err, Info() ) ) { if ( skipAll && *skipAll ) { return true; } switch ( RedMessage( _LT( "Can`t delete directory:\n" ) , fs->Uri( path ).GetUtf8(), skipAll ? bRetrySkipSkipallCancel : bRetrySkipCancel, fs->StrError( ret_err ).GetUtf8() ) ) { case CMD_SKIPALL: if ( skipAll ) { *skipAll = true; } //no break case CMD_SKIP: return true; case CMD_RETRY: continue; default: return false; } } return true; }
bool OperCFThread::DeleteFile( FS* fs, FSPath& path ) //return true if not concelled { if ( Info()->Stopped() ) { return false; } if ( !commitAll ) { switch ( RedMessage( _LT( "Do you want to delete file?\n" ), fs->Uri( path ).GetUtf8(), bDeleteAllSkipCancel ) ) { case CMD_SKIP: return true; case CMD_ALL: commitAll = true; break; case CMD_OK: break; default: return false; } } return Unlink( fs, path ); //skip all??? }
bool OperCFThread::DeleteDir( FS* fs, FSPath& path ) { if ( Info()->Stopped() ) { return false; } FSList list; while ( true ) { int ret_err; int ret = fs->ReadDir( &list, path, &ret_err, Info() ); if ( ret == -2 ) { return false; } if ( !ret ) { break; } switch ( RedMessage( _LT( "Can`t open directory:\n" ), fs->Uri( path ).GetUtf8(), bRetrySkipCancel, fs->StrError( ret_err ).GetUtf8() ) ) { case CMD_SKIP: return true; case CMD_RETRY: continue; default: return false; } } return DeleteList( fs, path, list ); }
bool SelectOperCharset(NCDialogParent *parent, int *pCharsetId, int currentId) { int ret = CMD_CANCEL; { CharsetDlg1 dlg(parent, currentId); ret = dlg.DoModal(); if (ret == CMD_OK) { charset_struct * p = dlg.CurrentCharset(); if (!p) return false; if (pCharsetId) *pCharsetId = p->id; return true; } } if (ret == CMD_OTHER) { charset_struct *cslist[128]; int csCount = GetOtherCharsetList(cslist, 128); CharsetDialog dlg(parent, currentId, _LT("other charsets"), cslist, csCount); int ret = dlg.DoModal(); if (ret == CMD_OK) { charset_struct * p = dlg.CurrentCharset(); if (!p) return false; if (pCharsetId) *pCharsetId = p->id; return true; } } return false; }
SysOptDialog::SysOptDialog(NCDialogParent *parent) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode( _LT("System settings") ).ptr(), bListOkCancel), iL(16, 3) ,askOpenExecButton(0, this, utf8_to_unicode( _LT("Ask user if Exec/Open conflict") ).ptr(), 0, wcmConfig.systemAskOpenExec) ,escPanelButton(0, this, utf8_to_unicode( _LT("Enable ESC key to show/hide panels") ).ptr(), 0, wcmConfig.systemEscPanel) ,backUpDirButton(0, this, utf8_to_unicode( _LT("Enable BACKSPACE key to go up dir") ).ptr(), 0, wcmConfig.systemBackSpaceUpDir) // ,intLocale(this, utf8_to_unicode( _LT("Interface localisation (save config and restart)") ).ptr(), 0, wcmConfig.systemIntLocale) ,langStatic(0, this, utf8_to_unicode( _LT("Language:") ).ptr()) ,langVal(0, this, utf8_to_unicode( "______________________" ).ptr()) ,langButton(0, this, utf8_to_unicode( ">" ).ptr(), 1000) { #ifndef _WIN32 iL.AddWin(&askOpenExecButton, 0, 0, 0, 2); askOpenExecButton.Enable(); askOpenExecButton.Show(); #endif iL.AddWin(&escPanelButton, 1, 0, 1, 2); escPanelButton.Enable(); escPanelButton.Show(); iL.AddWin(&backUpDirButton,2, 0, 2, 2); backUpDirButton.Enable(); backUpDirButton.Show(); // iL.AddWin(&intLocale, 2, 0, 2, 2); intLocale.Enable(); intLocale.Show(); iL.AddWin(&langStatic, 3, 0); langStatic.Enable(); langStatic.Show(); iL.AddWin(&langVal, 3, 2); langVal.Enable(); langVal.Show(); iL.AddWin(&langButton, 3, 1); langButton.Enable(); langButton.Show(); iL.SetColGrowth(2); AddLayout(&iL); SetEnterCmd(CMD_OK); #ifndef _WIN32 askOpenExecButton.SetFocus(); order.append(&askOpenExecButton); #endif order.append(&escPanelButton); // order.append(&intLocale); order.append(&langButton); SetPosition(); #ifdef _WIN32 LangListLoad( carray_cat<sys_char_t>(GetAppPath().ptr(), utf8_to_sys("\\lang\\list").ptr()).ptr(), list); #else if (!LangListLoad(utf8_to_sys("install-files/share/wcm/lang/list").ptr(), list)) LangListLoad(utf8_to_sys(UNIX_CONFIG_DIR_PATH "/lang/list").ptr(), list); #endif SetCurLang(wcmConfig.systemLang.ptr() ? wcmConfig.systemLang.ptr() : "+"); }
bool OperCFThread::CopyDir(FS *srcFs, FSPath &__srcPath, FSNode *srcNode, FS *destFs, FSPath &__destPath, bool move) { if (Info()->Stopped()) return false; FSList list; int ret_error; while (true) { int ret = srcFs->ReadDir(&list, __srcPath, &ret_error, Info()); if (ret == -2) return false; if (!ret) break; switch ( RedMessage( _LT("Can`t open directory:\n") , srcFs->Uri(__srcPath).GetUtf8(), bRetrySkipCancel, srcFs->StrError(ret_error).GetUtf8()) ) { case CMD_SKIP: return true; case CMD_RETRY: continue; default: return false; } } while (destFs->MkDir(__destPath, MkDirMode, &ret_error, Info()) && !destFs->IsEEXIST(ret_error)) { switch (RedMessage( _LT("Can't create the directory:\n"), destFs->Uri(__destPath).GetUtf8(), bRetrySkipCancel, destFs->StrError(ret_error).GetUtf8())) { case CMD_CANCEL: return false; case CMD_SKIP: return true; } } FSPath srcPath = __srcPath; int srcPos = srcPath.Count(); FSPath destPath = __destPath; int destPos = destPath.Count(); for (FSNode *node = list.First(); node; node = node->next) { if (Info()->Stopped()) return false; srcPath.SetItemStr(srcPos, node->Name()); destPath.SetItemStr(destPos, node->Name()); if (!CopyNode(srcFs, srcPath, node, destFs, destPath, move)) return false; } destFs->SetFileTime(destPath, srcNode->st.mtime, srcNode->st.mtime, 0, Info()); return !move || RmDir(srcFs, __srcPath); }
void SysOptDialog::SetCurLang(const char *id) { curLangId = new_char_str(id); if (id[0] == '-') langVal.SetText( utf8_to_unicode( _LT("English") ).ptr() ); else if (id[0]=='+') langVal.SetText( utf8_to_unicode( _LT("Autodetect") ).ptr() ); else { for (int i = 0; i<list.count(); i++) { if (!strcmp(list[i].id.ptr(), id)) { langVal.SetText( utf8_to_unicode( list[i].name.ptr() ).ptr() ); return; } } langVal.SetText( utf8_to_unicode( id ).ptr() ); } }
bool clFileAssociationsWin::Key( cevent_key* pEvent ) { if ( pEvent->Type() == EV_KEYDOWN ) { if ( pEvent->Key() == VK_ESCAPE ) { if ( m_Saved || NCMessageBox( ( NCDialogParent* )Parent(), _LT( "Warning" ), _LT( "Quit without saving?" ), true, bListOkCancel ) == CMD_OK ) { return false; } return true; } if ( pEvent->Key() == VK_INSERT ) { Command( CMD_PLUS, 0, this, 0 ); return true; } if ( pEvent->Key() == VK_DELETE ) { Command( CMD_MINUS, 0, this, 0 ); return true; } if ( pEvent->Key() == VK_F4 ) { Command( CMD_EDIT, 0, this, 0 ); return true; } if ( pEvent->Key() == VK_RETURN && m_ListWin.InFocus() ) { Command( CMD_EDIT, 0, this, 0 ); return true; } // unicode_t c = UnicodeLC( pEvent->Char() ); } return false; }
clFileAssociationsWin( NCDialogParent* parent, std::vector<clNCFileAssociation>* Associations ) : NCDialog( ::createDialogAsChild, 0, parent, utf8_to_unicode( _LT( "File associations" ) ).data(), bListOkCancel ) , m_ListWin( this, Associations ) , m_Layout( 10, 10 ) , m_AddCurrentButton( 0, this, utf8_to_unicode( "+ (&Ins)" ).data(), CMD_PLUS ) , m_DelButton( 0, this, utf8_to_unicode( "- (&Del)" ).data(), CMD_MINUS ) , m_EditButton( 0, this, utf8_to_unicode( _LT( "&Edit" ) ).data(), CMD_EDIT ) , m_Saved( true ) { m_AddCurrentButton.Enable(); m_AddCurrentButton.Show(); m_DelButton.Enable(); m_DelButton.Show(); m_EditButton.Enable(); m_EditButton.Show(); LSize lsize = m_AddCurrentButton.GetLSize(); LSize lsize2 = m_DelButton.GetLSize(); LSize lsize3 = m_EditButton.GetLSize(); if ( lsize.x.minimal < lsize2.x.minimal ) { lsize.x.minimal = lsize2.x.minimal; } if ( lsize.x.minimal < lsize3.x.minimal ) { lsize.x.minimal = lsize3.x.minimal; } if ( lsize.x.maximal < lsize.x.minimal ) { lsize.x.maximal = lsize.x.minimal; } m_AddCurrentButton.SetLSize( lsize ); m_DelButton.SetLSize( lsize ); m_EditButton.SetLSize( lsize ); m_Layout.AddWinAndEnable( &m_ListWin, 0, 0, 9, 0 ); m_Layout.AddWin( &m_AddCurrentButton, 0, 1 ); m_Layout.AddWin( &m_DelButton, 1, 1 ); m_Layout.AddWin( &m_EditButton, 2, 1 ); m_Layout.SetLineGrowth( 9 ); this->AddLayout( &m_Layout ); SetPosition(); m_ListWin.SetFocus(); this->SetEnterCmd( CMD_OK ); }
void SimpleCFThreadWin::OperThreadStopped() { if (!threadData.errorString.IsEmpty()) { NCMessageBox((NCDialogParent*)Parent(), _LT("Create directory"), threadData.errorString.GetUtf8(), true); EndModal(0); return; } EndModal(100); }
PanelOptDialog::PanelOptDialog(NCDialogParent *parent) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode( _LT( "Panel settings") ).ptr(), bListOkCancel), iL(16, 3), showHiddenButton(0, this, utf8_to_unicode( _LT("Show hidden files") ).ptr(), 0, wcmConfig.panelShowHiddenFiles), showIconsButton(0, this, utf8_to_unicode( _LT("Show icons") ).ptr(), 0, wcmConfig.panelShowIcons), caseSensitive(0, this, utf8_to_unicode( _LT("Case sensitive sort") ).ptr(), 0, wcmConfig.panelCaseSensitive) { iL.AddWin(&showHiddenButton, 0, 0); showHiddenButton.Enable(); showHiddenButton.SetFocus(); showHiddenButton.Show(); iL.AddWin(&showIconsButton, 1, 0); showIconsButton.Enable(); showIconsButton.Show(); iL.AddWin(&caseSensitive, 2, 0); caseSensitive.Enable(); caseSensitive.Show(); AddLayout(&iL); SetEnterCmd(CMD_OK); showHiddenButton.SetFocus(); order.append(&showHiddenButton); order.append(&showIconsButton); order.append(&caseSensitive); SetPosition(); }
CopyDialog(NCDialogParent *parent, bool move = false) : SimpleCFThreadWin(parent, move ? _LT("Move") : _LT("Copy") ), _layout(7,2), _text1(0, this, utf8_to_unicode(move ? _LT("Moving the file") : _LT("Copying the file") ).ptr()), _text2(0, this, utf8_to_unicode( _LT("to") ).ptr()), _text3(0, this, utf8_to_unicode( _LT("Files processed") ).ptr()), _from(this), _to(this), _countWin(this), _progressWin(this) { _layout.AddWin(&_text1, 0, 0, 0, 1); _layout.AddWin(&_from, 1, 0, 1, 1); _layout.AddWin(&_text2, 2, 0, 2, 1); _layout.AddWin(&_to, 3, 0, 3, 1); _layout.AddWin(&_progressWin, 4,0,4,1); _layout.AddWin(&_text3, 5, 0); _layout.AddWin(&_countWin, 5, 1); _text1.Show(); _text1.Enable(); _text2.Show(); _text2.Enable(); _text3.Show(); _text3.Enable(); _from.Show(); _from.Enable(); _to.Show(); _to.Enable(); _countWin.Show(); _countWin.Enable(); _progressWin.Show(); _progressWin.Enable(); AddLayout(&_layout); SetPosition(); }
bool DirCalc( clPtr<FS> f, FSPath& path, clPtr<FSList> list, NCDialogParent* parent ) { bool doCurrentDir = list->Count() == 0; OperDirCalcData data(parent, f, path, list); DirCalcThreadWin dlg(parent, doCurrentDir ? _LT("Current folder metrics") : _LT("Selected folder(s) metrics"), &data, f->Uri(path).GetUnicode()); dlg.RunNewThread( "Folder calc", DirCalcThreadFunc, &data ); //может быть исключение dlg.Enable(); dlg.Show(); int cmd = dlg.DoModal(); dlg.StopThread(); if ( cmd != CMD_OK ) { return false; } return true; }
clCreateDirDialog( NCDialogParent* Parent, bool IsMultipleFolders, const unicode_t* Str ) : clInputStrDialogBase( Parent, utf8_to_unicode( _LT( "Create new directory" ) ).data() ) , m_Layout( 2, 9 ) , m_FieldEdit( EDIT_FIELD_MAKE_FOLDER, 0, (Win*)this, 0, 100, 7 ) , m_MultipleButton( 1, this, utf8_to_unicode( _LT( "Process multiple folders" ) ).data(), 0, IsMultipleFolders ) { m_Layout.AddWinAndEnable( &m_FieldEdit, 0, 0, 0, 2 ); order.append( &m_FieldEdit ); m_Layout.AddWinAndEnable( &m_MultipleButton, 1, 0, 1, 2 ); order.append( &m_MultipleButton ); AddLayout( &m_Layout ); if ( Str ) { m_FieldEdit.SetText( Str, true ); } m_FieldEdit.SetFocus(); SetPosition(); }
bool MkDir(FSPtr f, FSPath &p, NCDialogParent *parent) { SimpleCFThreadWin dlg(parent, _LT("Create directory") ); dlg.threadData.Clear(); dlg.threadData.srcFs = f; dlg.threadData.srcPath = p; dlg.RunNewThread("Create directory", MkDirThreadFunc, &dlg.threadData); //может быть исключение dlg.Enable(); dlg.Show(); dlg.DoModal(); dlg.StopThread(); return dlg.threadData.errorString.IsEmpty(); }
CfgLangDialog(NCDialogParent *parent, char *id, ccollect<LangListNode> *nl) : NCDialog(createDialogAsChild, 0, parent, utf8_to_unicode( _LT("Language") ).ptr(), bListOkCancel), _selected(0), _list(Win::WT_CHILD,Win::WH_TABFOCUS|WH_CLICKFOCUS, 0, this, VListWin::SINGLE_SELECT, VListWin::BORDER_3D, 0), nodeList(nl) { _list.Append( utf8_to_unicode( _LT("Autodetect") ).ptr()); //0 _list.Append( utf8_to_unicode( _LT("English") ).ptr()); //1 for (int i = 0; i<nl->count(); i++) _list.Append( utf8_to_unicode(nl->get(i).name.ptr()).ptr() ); int cur = 0; if (id[0] == '+') cur = 0; else if (id[0] == '-') cur = 1; else { for (int i = 0; i<nl->count(); i++) if (!strcmp(id, nl->get(i).id.ptr())) { cur = i+2; break; } } _list.MoveCurrent(cur); _list.Enable(); _list.Show(); _list.SetFocus(); LSRange h(10, 1000, 10); LSRange w(50, 1000, 30); _list.SetHeightRange(h); //in characters _list.SetWidthRange(w); //in characters AddWin(&_list); SetEnterCmd(CMD_OK); SetPosition(); };
bool DeleteList( clPtr<FS> f, FSPath& p, clPtr<FSList> list, NCDialogParent* parent ) { SimpleCFThreadWin dlg( parent, _LT( "Delete" ) ); dlg.threadData.Clear(); dlg.threadData.srcFs = f; dlg.threadData.srcPath = p; dlg.threadData.srcList = list; dlg.RunNewThread( "Delete", DeleteThreadFunc, &dlg.threadData ); //может быть исключение dlg.Enable(); dlg.Show(); dlg.DoModal(); dlg.StopThread(); return dlg.threadData.errorString.IsEmpty(); }
TerminalOptDialog::TerminalOptDialog(NCDialogParent *parent) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode( _LT("Terminal options") ).ptr(), bListOkCancel), iL(16, 3), backspaceKeyStatic(0, this, utf8_to_unicode( _LT("Backspace key:") ).ptr()), backspaceAsciiButton(0, this, utf8_to_unicode("ASCII DEL").ptr(), 1, wcmConfig.terminalBackspaceKey == 0), backspaceCtrlHButton(0, this, utf8_to_unicode("Ctrl H").ptr(), 1, wcmConfig.terminalBackspaceKey == 1) { iL.AddWin(&backspaceKeyStatic, 0, 0, 0, 1 ); backspaceKeyStatic.Enable(); backspaceKeyStatic.Show(); iL.AddWin(&backspaceAsciiButton, 1, 1); backspaceAsciiButton.Enable(); backspaceAsciiButton.Show(); iL.AddWin(&backspaceCtrlHButton, 2, 1); backspaceCtrlHButton.Enable(); backspaceCtrlHButton.Show(); iL.ColSet(0,10,10,10); iL.SetColGrowth(1); AddLayout(&iL); SetEnterCmd(CMD_OK); backspaceAsciiButton.SetFocus(); order.append(&backspaceAsciiButton); order.append(&backspaceCtrlHButton); SetPosition(); }
bool DoStyleConfigDialog(NCDialogParent *parent) { wcmConfig.ImpCurrentFonts(); ccollect<StyleOptDialog::Node> list; list.append(StyleOptDialog::Node( _LT("Panel") , false, panelFont.ptr(), &wcmConfig.panelFontUri)); list.append(StyleOptDialog::Node( _LT("Dialog"), false, dialogFont.ptr(), &wcmConfig.dialogFontUri)); list.append(StyleOptDialog::Node( _LT("Viewer"), true, viewerFont.ptr(), &wcmConfig.viewerFontUri)); list.append(StyleOptDialog::Node( _LT("Editor"), true, editorFont.ptr(), &wcmConfig.editorFontUri)); list.append(StyleOptDialog::Node( _LT("Terminal"), true, terminalFont.ptr(), &wcmConfig.terminalFontUri)); list.append(StyleOptDialog::Node( _LT("Help text"), false, helpTextFont.ptr(), &wcmConfig.helpTextFontUri)); list.append(StyleOptDialog::Node( _LT("Help bold text"), false, helpBoldFont.ptr(), &wcmConfig.helpBoldFontUri)); list.append(StyleOptDialog::Node( _LT("Help header text"), false, helpHeadFont.ptr(), &wcmConfig.helpHeadFontUri)); StyleOptDialog dlg(parent, &list); if (dlg.DoModal() == CMD_OK) { if (dlg.styleBlackButton.IsSet()) { wcmConfig.viewColorMode = wcmConfig.editColorMode = wcmConfig.panelColorMode = 1; // wcmConfig.whiteStyle = false; } else if (dlg.styleWhiteButton.IsSet()) { wcmConfig.viewColorMode = wcmConfig.editColorMode = wcmConfig.panelColorMode = 2; // wcmConfig.whiteStyle = true; } else { wcmConfig.viewColorMode = wcmConfig.editColorMode = wcmConfig.panelColorMode = 0; // wcmConfig.whiteStyle = false; } SetColorStyle(wcmConfig.panelColorMode); // SetEditorColorStyle(wcmConfig.editColorMode); // SetViewerColorStyle(wcmConfig.viewColorMode); wcmConfig.showToolBar = dlg.showToolbarButton.IsSet(); wcmConfig.showButtonBar = dlg.showButtonbarButton.IsSet(); for (int i = 0; i<list.count(); i++) if (list[i].newFont.ptr() && list[i].newFont->uri()[0] && list[i].pUri) { *(list[i].pUri) = new_char_str(list[i].newFont->uri()); } return true; } return false; }