From 74a8b1e097010c3589076353679b508a32c7456e Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 2 Dec 1997 13:12:09 +0000 Subject: [PATCH] ba0.cpp Aggiunto cambio studio e gestione CONVERTING ba0.url Aggiunat voce di menu per cmabio studio ba1600.cpp Migliorato riconoscimento dei drive rimuovibili git-svn-id: svn://10.65.10.50/trunk@5684 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0.cpp | 102 ++++++++++++++++++++++++++++++++++++++++---------- ba/ba0.url | 1 + ba/ba1600.cpp | 41 ++++++++++++++------ 3 files changed, 113 insertions(+), 31 deletions(-) diff --git a/ba/ba0.cpp b/ba/ba0.cpp index 4efdf2583..c45e69ce5 100755 --- a/ba/ba0.cpp +++ b/ba/ba0.cpp @@ -14,7 +14,9 @@ #include #include #include -#include +#include + +#include // CGetPrawinName #include @@ -198,13 +200,8 @@ void TColor_mask::update() void TColor_mask::save_colors() { TConfig colors(CONFIG_USER, "Colors"); - _color.restart(); - for (THash_object* h = _color.get_hashobj(); h; h = _color.get_hashobj()) - { - const TString& k = h->key(); - const TString& s = (const TString&)h->obj(); - colors.set(k, s); - } + FOR_EACH_ASSOC_STRING(_color, obj, key, str) + colors.set(key, str); } COLOR TColor_mask::get_color_entry(const char* name) const @@ -445,6 +442,9 @@ class TMenu : public TAssoc_array TAssoc_array _images; TAssoc_array _modules; + +public: // TObject + virtual bool ok() const { return _current != NULL; } public: bool read(const char* name); // First call @@ -672,7 +672,8 @@ void TSubmenu::read(TScanner& scanner) { bool disable = TRUE; TToken_string mod(line.mid(equal+1, -1), ','); - for (const char* cod = mod.get(0); cod; cod = mod.get()) +// for (const char* cod = mod.get(0); cod; cod = mod.get()) + FOR_EACH_TOKEN(mod, cod) { const int code = atoi(cod); if (code == 0 || main_app().has_module(code)) @@ -942,6 +943,7 @@ protected: bool choose_colors(); bool choose_editors(); + bool choose_study(); public: void reload_images() { _menu.reload_images(); } @@ -1121,11 +1123,12 @@ int TMenu_application::do_level() const int x = width / 2; int y = 1; - + + TString caption; for (int i = 0; i < curr.items(); i++, y++) { const TMenuitem& item = curr[i]; - TString80 caption = item.caption(); + caption = item.caption(); if (item.is_submenu() && caption.find("...") < 0) caption << "..."; @@ -1261,7 +1264,7 @@ bool TMenu_application::check_user() users.put("USERDESC", utente); users.put("PASSWORD", encode(pwd)); users.write(); - err = users.read(_isequal, _lock); + err = users.read(_isequal); } ok = utente.not_empty() && pwd.not_empty() && pwd == m.get(F_PASSWORD); @@ -1275,6 +1278,26 @@ bool TMenu_application::check_user() "Si desidera continuare ugualmente?", (const char*)utente); } + if (ok) + { + users.put("USERNAME", "PRASSI"); + users.read(_isequal); + if (users.get("AUTSTR") == "CONVERTING") + { + TString msg = "E' in corso una conversione archivi:\n"; + if (utente == "PRASSI") + { + msg << "Si desidera continuare ugualmente?"; + ok = yesno_box(msg); + } + else + { + msg << "Accesso negato."; + ok = error_box(msg); + } + } + } + if (ok) { user() = utente; @@ -1293,6 +1316,8 @@ bool TMenu_application::check_user() { if (ok) { + users.put("USERNAME", utente); + users.read(_isequal, _lock); users.put("CONNECTED", "X"); users.rewrite(); @@ -1301,14 +1326,12 @@ bool TMenu_application::check_user() customize_colors(); // Aggiorna set di colori xvt_dwin_invalidate_rect(TASK_WIN, NULL); // Ridisegna sfondo } - else - users.read(_isequal, _unlock); } } #if XVT_OS == XVT_OS_WIN if (ok && utente != "PRASSI") - WritePrivateProfileString("User", "Name", utente, "prassi.ini"); + WritePrivateProfileString("Main", "User", utente, CGetPrawinName()); #endif return ok; @@ -1326,10 +1349,13 @@ bool TMenu_application::create() TWait_cursor hourglass; - TFilename menu = (argc() < 2) ? "baprassi" : argv(1); - menu.ext("men"); - _menu.read(menu); - + if (!_menu.ok()) + { + TFilename menu = (argc() < 2) ? "baprassi" : argv(1); + menu.ext("men"); + _menu.read(menu); + } + dispatch_e_menu(MENU_ITEM(1)); return TRUE; } @@ -1485,6 +1511,41 @@ bool TMenu_application::choose_editors() return TRUE; } +HIDDEN bool study_handler(TMask_field& f, KEY k) +{ + bool ok = TRUE; + if (f.to_check(k)) + { + TFilename path(f.get()); + path.add("com"); + path.add("dir.gen"); + if (!fexist(path)) + ok = f.error_box("La directory %s non e' uno studio valido!", + (const char*)f.get()); + } + return ok; +} + +bool TMenu_application::choose_study() +{ + TMask m("Scelta studio", 1, 60, 6); + m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); + m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); + m.add_string(DLG_USER, 0, "Studio ", 1, 1, 50); + m.set_handler(DLG_USER, study_handler); + m.set(DLG_USER, prefix().get_studio()); + bool ok = m.run() == K_ENTER; + if (ok) + { + _mask->close_modal(); + do_events(); + destroy(); + prefix().set_studio(m.get(DLG_USER)); + create(); + } + return ok; +} + long TMenu_application::handler(WINDOW win, EVENT* ep) { long ret = TApplication::handler(win, ep); @@ -1504,6 +1565,7 @@ bool TMenu_application::menu(MENU_TAG mt) case MENU_ITEM(1): ok = main_loop(); break; case MENU_ITEM(2): choose_colors(); break; case MENU_ITEM(3): choose_editors(); break; + case MENU_ITEM(4): choose_study(); break; default: break; } return ok; @@ -1596,7 +1658,7 @@ int main(int argc, char** argv) if (user().blank()) { char u[16]; - GetPrivateProfileString("User", "Name", "PRASSI", u, sizeof(u), "prassi.ini"); + GetPrivateProfileString("Main", "User", "PRASSI", u, sizeof(u), CGetPrawinName()); user() = u; } diff --git a/ba/ba0.url b/ba/ba0.url index ab577004a..acc849137 100755 --- a/ba/ba0.url +++ b/ba/ba0.url @@ -8,3 +8,4 @@ MENU M_FONT ITEM M_FONT_SELECT "~Font" ITEM MENU_ITEM(2) "~Colori" ITEM MENU_ITEM(3) "~Editors" + ITEM MENU_ITEM(4) "~Studio" diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index f15b86880..527cf9edb 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -1,5 +1,6 @@ #include +#define XVT_INCL_NATIVE #include #include #include @@ -164,7 +165,7 @@ TAuto_token_string& TAuto_token_string::create(const char* ts) // Calcola il separatore for (const char* s = get_buffer(); *s; s++) { - if (strchr("|;,!^&+", *s) != NULL) + if (strchr("|;,!^&+\t\n", *s) != NULL) { separator(*s); break; @@ -536,7 +537,8 @@ TModule_mask::TModule_mask() class TFascicolator_mask : public TMask { -protected: +protected: + static bool sheet_notify(TSheet_field& f, int row, KEY k); static bool list_handler(TMask_field& f, KEY k); static bool save_handler(TMask_field& f, KEY k); static bool import_export_handler(TMask_field& f, KEY k); @@ -555,7 +557,15 @@ public: TFascicolator_mask(); virtual ~TFascicolator_mask() { } }; - + +bool TFascicolator_mask::sheet_notify(TSheet_field& f, int row, KEY k) +{ + bool ok = TRUE; + if (k == K_INS || k == K_DEL) + ok = FALSE; + return ok; +} + bool TFascicolator_mask::list_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -652,15 +662,22 @@ const TFilename& TFascicolator_mask::build_export_path(TFilename& path) const { CHECK(path.not_empty(), "Please, specify the module"); const TString module(path); + path.cut(0); - path << SLASH << 'u' << SLASH << user() << SLASH << "src" << SLASH << module; + path << SLASH << "src" << SLASH << module; if (!fexist(path)) { - path.cut(0); - path << SLASH << 'u' << SLASH << user() << SLASH << "p.due" << SLASH << module; - } - if (!fexist(path)) - path.tempdir(); + path.cut(0); + path << SLASH << 'u' << SLASH << user() << SLASH << "src" << SLASH << module; + if (!fexist(path)) + { + path.cut(0); + path << SLASH << 'u' << SLASH << user() << SLASH << "p.due" << SLASH << module; + if (!fexist(path)) + path.tempdir(); + } + } + path.lower(); return path; } @@ -783,7 +800,7 @@ bool TFascicolator_mask::move_file(const TFilename& file, const char* dir) const { TString msg(128); msg << "Lo spazio sull'unita' e' insufficiente"; - if (disk == 1 || disk == 2) + if (GetDriveType(disk-1) == DRIVE_REMOVABLE) { msg << ":\nInserire un nuovo disco e ritentare?"; if (!yesno_box(msg)) @@ -930,7 +947,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const return TRUE; const char drive = toupper(path[0]); - const bool floppy = (drive == 'A' || drive == 'B') && path[1] == ':'; + const bool floppy = (GetDriveType(drive - 'A') == DRIVE_REMOVABLE) && (path[1] == ':'); for (int d = 1; d <= disks && !aborted; d++) { @@ -964,6 +981,8 @@ TFascicolator_mask::TFascicolator_mask() : TMask("ba1600a") { TSheet_field& s = sfield(F_SHEET); + s.set_notify(sheet_notify); + TMask& m = s.sheet_mask(); m.set_handler(S_LIST, list_handler); m.set_handler(S_SAVE, save_handler);